package com.cpop.system.business.controller.backstage;

import com.cpop.core.base.entity.R;
import com.cpop.core.utils.bean.BeanUtils;
import com.cpop.system.business.bo.BrandBo;
import com.cpop.system.business.vo.BrandPageVo;
import com.mybatisflex.core.paginate.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import com.cpop.system.business.entity.Brand;
import com.cpop.system.business.service.BrandService;
import org.springframework.web.bind.annotation.RestController;

/**
 * 系统-品牌表 控制层。
 *
 * @author DB
 * @since 2023-10-25
 */
@RestController
@Tag(name = "品牌接口")
@RequestMapping("/backstage/brand")
public class BackstageBrandController {

    @Autowired
    private BrandService brandService;

    /**
     * 新增品牌
     * @author DB
     * @since 2023/10/25 16:53
     * @param bo 品牌参数
     * @return com.cpop.core.base.entity.R<java.lang.Void>
     */
    @PostMapping("/insertSysBrand")
    @Operation(summary = "新增品牌")
    @Deprecated(since = "1.1.0")
    public R<Void> insertSysBrand(@RequestBody @Parameter(description = "品牌") @Validated BrandBo bo) {
        return R.fail("新增品牌接口已废弃");
    }

    /**
     * 修改品牌
     *
     * @param bo 品牌参数
     * @return com.cpop.core.base.entity.R<java.lang.Void>
     * @author DB
     * @since 2023/11/10 9:21
     */
    @Operation(summary = "修改品牌")
    @PutMapping("/updateSysBrand")
    public R<Void> updateSysBrand(@RequestBody @Parameter(description = "品牌") @Validated BrandBo bo) {
        Brand entity = BeanUtils.mapToClass(bo, Brand.class);
        brandService.updateById(entity);
        return R.ok();
    }

    /**
     * 导入果酱品牌
     * @author DB
     * @since 2023/10/25 15:53
     * @param brandId 果酱品牌信息
     */
    @PostMapping("/importJamboxBrand/{brandId}")
    @Operation(summary = "导入果酱品牌")
    @Deprecated(since = "1.1.0")
    public R<Void> importJamboxBrand(@PathVariable String brandId) {
        return R.fail("导入果酱品牌接口已废弃");
    }

    /**
     * 查询品牌分页列表
     * @author DB
     * @since 2023/09/13 17:55
     * @param brandName 请求参数
     * @return com.cpop.core.base.entity.R<com.mybatisflex.core.paginate.Page<com.cpop.system.business.vo.BrandPageVo>>
     */
    @Operation(summary = "查询品牌分页列表")
    @GetMapping("/getBrandPage")
    public R<Page<BrandPageVo>> getBrandPageList(String brandName) {
        Page<BrandPageVo> pageVo = brandService.getBrandPage(brandName);
        return R.ok(pageVo);
    }

    /**
     * 根据品牌id删除品牌
     * @author DB
     * @since 2023/11/09 10:31
     * @param id 主键
     * @return com.cpop.core.base.entity.R<java.lang.Void>
     */
    @Operation(summary = "根据品牌id删除品牌")
    @DeleteMapping("/removeBrandById/{id}")
    @Deprecated(since = "1.1.0")
    public R<Void> removeBrandById(@PathVariable String id) {
        return R.fail("根据品牌id删除品牌接口已废弃");
    }

}
