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.BusAlifacoryEntity;
import com.zcloud.modules.custormerInfo.service.BusAlifacoryService;
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 阿里云转码模板(BusAlifacory)表控制层
 * @Date 2024-05-09 17:09:46
 */
@Api(tags = "阿里云转码模板")
@RestController
@RequestMapping("busAlifacory")
public class BusAlifacoryController extends AbstractController {

    @Autowired
    private BusAlifacoryService busAlifacoryService;

    @ApiOperation("阿里云转码模板-新增数据")
    @SysLog("阿里云转码模板-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody BusAlifacoryEntity param) {
        param.setCreator(getUserId());
        param.setOperator(getUserId());
        busAlifacoryService.save(param);

        return R.ok();
    }

    @ApiOperation("阿里云转码模板-编辑数据")
    @SysLog("阿里云转码模板-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody BusAlifacoryEntity param) {
        param.setOperator(getUserId());
        busAlifacoryService.updateById(param);

        return R.ok();
    }


    @ApiOperation("阿里云转码模板-删除数据")
    @SysLog("阿里云转码模板-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusAlifacoryEntity param) {
        busAlifacoryService.delete(param.getAlifacoryId(), getUserId());
        return R.ok();
    }

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

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


    @ApiOperation("阿里云转码模板-根据ID查详情")
    @SysLog("阿里云转码模板-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusAlifacoryEntity param) {
        BusAlifacoryEntity busAlifacory = busAlifacoryService.getById(param.getAlifacoryId());
        return R.ok().put("busAlifacory", busAlifacory);
    }

}
