package com.zfire.mall.manager.controller.record;

import com.zfire.mall.manager.annotation.ApiNotAuth;
import com.zfire.mall.manager.bean.record.ImgCarouselManageBean;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.record.CompanyRecordLogic;
import com.zfire.mall.manager.plus.entity.CompanyRecordManage;
import com.zfire.mall.manager.plus.entity.ImgCarouselManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api(value = "公司备案轮播图API", tags ={"公司备案轮播图API"} )
@RequestMapping(value = "/record", produces = "application/json; charset=utf-8")
public class CompanyRecordController {

    @Autowired
    CompanyRecordLogic companyRecordLogic;

    @PostMapping("/company/add")
    @ApiOperation("新增公司备案信息")
    public ResponseHelper addRecordCompany(@RequestBody CompanyRecordManage companyRecordManage){
        companyRecordLogic.addRecordCompany(companyRecordManage);
        return ResponseHelper.success();
    }

    @PostMapping("/company/update")
    @ApiOperation("修改")
    public ResponseHelper editRecordCompany(@RequestBody CompanyRecordManage companyRecordManage){
        companyRecordLogic.editRecordCompany(companyRecordManage);
        return ResponseHelper.success();
    }

    @ApiNotAuth
    @GetMapping("/company/list")
    @ApiOperation("公司列表")
    public ResponseHelper<List<CompanyRecordManage>> companyRecordList(){
        List<CompanyRecordManage> companyRecordManage  = companyRecordLogic.companyRecordList();
        return ResponseHelper.success(companyRecordManage);
    }

    @ApiNotAuth
    @GetMapping("/company/detail")
    @ApiOperation("查询")
    public ResponseHelper<CompanyRecordManage> getCompany(@RequestParam String id){
        CompanyRecordManage imgCarouselManage  = companyRecordLogic.getCompany(id);
        return ResponseHelper.success(imgCarouselManage);
    }


    @PostMapping("/carousel/add")
    @ApiOperation("新增轮播图信息")
    public ResponseHelper addImgCarousel(@RequestBody ImgCarouselManage imgCarouselManage){
        companyRecordLogic.addImgCarousel(imgCarouselManage);
        return ResponseHelper.success();
    }

    @ApiNotAuth
    @GetMapping("/list")
    @ApiOperation(value = "轮播图列表")
    public ResponseHelper<List<ImgCarouselManage>> list()  {
        List<ImgCarouselManage> adminRoleIPage = companyRecordLogic.list();
        return ResponseHelper.success(adminRoleIPage);
    }

    @PostMapping("/delete")
    @ApiOperation("批量删除轮播图")
    public ResponseHelper delete(@RequestParam List<String> ids){
        companyRecordLogic.delete(ids);
        return ResponseHelper.success();
    }

    @ApiNotAuth
    @GetMapping("/detail")
    @ApiOperation("查询")
    public ResponseHelper<ImgCarouselManage> get(@RequestParam String id){
        ImgCarouselManage imgCarouselManage  = companyRecordLogic.detail(id);
        return ResponseHelper.success(imgCarouselManage);
    }


    @PostMapping("/update")
    @ApiOperation("修改")
    public ResponseHelper update(@RequestBody ImgCarouselManageBean imgCarouselManage){
        companyRecordLogic.update(imgCarouselManage);
        return ResponseHelper.success();
    }


    @PostMapping("/updateImgStatus")
    @ApiOperation("轮播图显示与隐藏")
    public ResponseHelper weatherShow(@RequestParam String id){
        companyRecordLogic.updateStatus(id);
        return ResponseHelper.success();
    }



}
