package com.zcloud.modules.custormerInfo.controller;

import com.zcloud.common.annotation.SysLog;
import com.zcloud.common.utils.PageUtils;
import com.zcloud.common.utils.R;
import com.zcloud.modules.custormerInfo.entity.BusAlifacoryCustomerEntity;
import com.zcloud.modules.custormerInfo.service.BusAlifacoryCustomerService;
import com.zcloud.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.Map;

/**
 * @Author zhangyue
 * @Desc 客户-阿里云转码模板关联表(BusAlifacoryCustomer)表控制层
 * @Date 2024-05-06 10:47:31
 */
@Api(tags = "客户-阿里云转码模板关联表")
@RestController
@RequestMapping("busAlifacoryCustomer")
public class BusAlifacoryCustomerController extends AbstractController {

    @Autowired
    private BusAlifacoryCustomerService busAlifacoryCustomerService;

    @ApiOperation("客户-阿里云转码模板关联表-新增数据")
    @SysLog("客户-阿里云转码模板关联表-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody BusAlifacoryCustomerEntity param) {
        param.setCreator(getUserId());
        param.setOperator(getUserId());
        busAlifacoryCustomerService.save(param);

        return R.ok();
    }

    @ApiOperation("客户-阿里云转码模板关联表-编辑数据")
    @SysLog("客户-阿里云转码模板关联表-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody BusAlifacoryCustomerEntity param) {
        param.setOperator(getUserId());
        busAlifacoryCustomerService.updateById(param);

        return R.ok();
    }


    @ApiOperation("客户-阿里云转码模板关联表-删除数据")
    @SysLog("客户-阿里云转码模板关联表-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusAlifacoryCustomerEntity param) {
        busAlifacoryCustomerService.delete(param.getAlifacoryCustomerId(), getUserId());
        return R.ok();
    }

    @ApiOperation("客户-阿里云转码模板关联表-分页查询")
    @SysLog("客户-阿里云转码模板关联表-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = busAlifacoryCustomerService.listPage(params);

        return R.ok().put("page", page);
    }


    @ApiOperation("客户-阿里云转码模板关联表-根据ID查详情")
    @SysLog("客户-阿里云转码模板关联表-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusAlifacoryCustomerEntity param) {
        BusAlifacoryCustomerEntity busAlifacoryCustomer = busAlifacoryCustomerService.getById(param.getAlifacoryCustomerId());
        return R.ok().put("busAlifacoryCustomer", busAlifacoryCustomer);
    }

}
