package com.srs.web.controller.comprehensive;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.srs.common.annotation.Log;
import com.srs.common.core.controller.BaseController;
import com.srs.common.core.domain.AjaxResult;
import com.srs.common.enums.BusinessType;
import com.srs.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.*;
import com.srs.comprehensive.domain.CphOwnGoodType;
import com.srs.comprehensive.service.ICphOwnGoodTypeService;

/**
 * 个人评优评先类别Controller
 *
 * @author srs
 * @date 2023-09-11
 */
@RestController
@RequestMapping(value = "/comprehensive/OwnGoodtype")
@Api(value = "个人评优评先类别管理", tags = "个人评优评先类别管理")
public class CphOwnGoodTypeController extends BaseController {
    @Autowired
    private ICphOwnGoodTypeService cphOwnGoodTypeService;

    /**
     * 查询个人评优评先类别列表
     */
    //@RequiresPermissions("comprehensive:type:list")
    @GetMapping("/list")
    @ApiOperation("查询个人评优评先类别列表")
    public AjaxResult list(CphOwnGoodType cphOwnGoodType)
    {
        List<CphOwnGoodType> list = cphOwnGoodTypeService.selectCphOwnGoodTypeList(cphOwnGoodType);
        return success(list);
    }
//
//    /**
//     * 导出个人评优评先类别列表
//     */
//    //@RequiresPermissions("comprehensive:type:export")
    @Log(title = "个人评优评先类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出个人评优评先类别列表")
    public void export(HttpServletResponse response, CphOwnGoodType cphOwnGoodType)
    {
        List<CphOwnGoodType> list = cphOwnGoodTypeService.selectCphOwnGoodTypeList(cphOwnGoodType);
        ExcelUtil<CphOwnGoodType> util = new ExcelUtil<CphOwnGoodType>(CphOwnGoodType.class);
        util.exportExcel(response, list, "个人评优评先类别数据");
    }
//
//    /**
//     * 获取个人评优评先类别详细信息
//     */
//    //@RequiresPermissions("comprehensive:type:query")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取个人评优评先类别详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cphOwnGoodTypeService.selectCphOwnGoodTypeById(id));
    }
//
//    /**
//     * 新增个人评优评先类别
//     */
//    //@RequiresPermissions("comprehensive:type:add")
    @Log(title = "个人评优评先类别", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增个人评优评先类别")
    public AjaxResult add(@RequestBody CphOwnGoodType cphOwnGoodType)
    {
        return toAjax(cphOwnGoodTypeService.insertCphOwnGoodType(cphOwnGoodType));
    }
//
//    /**
//     * 修改个人评优评先类别
//     */
//    //@RequiresPermissions("comprehensive:type:edit")
    @Log(title = "个人评优评先类别", businessType = BusinessType.UPDATE)
    @PostMapping("/update")
    @ApiOperation("修改个人评优评先类别")
    public AjaxResult edit(@RequestBody CphOwnGoodType cphOwnGoodType)
    {
        return toAjax(cphOwnGoodTypeService.updateCphOwnGoodType(cphOwnGoodType));
    }
//
//    /**
//     * 删除个人评优评先类别
//     */
//    //@RequiresPermissions("comprehensive:type:remove")
    @Log(title = "个人评优评先类别", businessType = BusinessType.DELETE)
	@PostMapping("/delete/{ids}")
    @ApiOperation("删除个人评优评先类别")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        System.out.println(Arrays.toString(ids));
        return toAjax(cphOwnGoodTypeService.deleteCphOwnGoodTypeByIds(ids));
    }
}
