package cn.ezhizao.project.business.taskType.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
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 cn.ezhizao.framework.aspectj.lang.annotation.Log;
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
import cn.ezhizao.project.business.taskType.domain.BizTaskType;
import cn.ezhizao.project.business.taskType.service.IBizTaskTypeService;
import cn.ezhizao.framework.web.controller.BaseController;
import cn.ezhizao.framework.web.domain.AjaxResult;
import cn.ezhizao.common.utils.poi.ExcelUtil;
import cn.ezhizao.framework.web.page.TableDataInfo;

/**
 * 任务项目 记账报税/社保申报/公积金申报 等Controller
 *
 * @author ruoyi
 * @date 2023-11-07
 */
@RestController
@RequestMapping("/business/taskType")
public class BizTaskTypeController extends BaseController
{
    @Resource
    private IBizTaskTypeService bizTaskTypeService;

    /**
     * 查询任务项目 记账报税/社保申报/公积金申报 等列表
     */
    @PreAuthorize("@ss.hasPermi('business:taskType:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizTaskType bizTaskType) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaskType);
        startPage();
        List<BizTaskType> list = bizTaskTypeService.getList(bizTaskType);
        return getDataTable(list);
    }

    /**
     * 导出任务项目 记账报税/社保申报/公积金申报 等列表
     */
    @PreAuthorize("@ss.hasPermi('business:taskType:export')")
    @Log(title = "任务项目 记账报税/社保申报/公积金申报 等", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizTaskType bizTaskType) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaskType);
        List<BizTaskType> list = bizTaskTypeService.getList(bizTaskType);
        ExcelUtil<BizTaskType> util = new ExcelUtil<BizTaskType>(BizTaskType.class);
        util.exportExcel(response, list, "任务项目 记账报税/社保申报/公积金申报 等数据");
    }

    /**
     * 获取任务项目 记账报税/社保申报/公积金申报 等详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:taskType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizTaskTypeService.getById(id));
    }

    /**
     * 新增任务项目 记账报税/社保申报/公积金申报 等
     */
    @PreAuthorize("@ss.hasPermi('business:taskType:add')")
    @Log(title = "任务项目 记账报税/社保申报/公积金申报 等", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTaskType bizTaskType) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaskType);
        return toAjax(bizTaskTypeService.save(bizTaskType));
    }

    /**
     * 修改任务项目 记账报税/社保申报/公积金申报 等
     */
    @PreAuthorize("@ss.hasPermi('business:taskType:edit')")
    @Log(title = "任务项目 记账报税/社保申报/公积金申报 等", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTaskType bizTaskType) throws NoSuchFieldException, IllegalAccessException
    {
        setTenantId(bizTaskType);
        return toAjax(bizTaskTypeService.updateById(bizTaskType));
    }

    /**
     * 删除任务项目 记账报税/社保申报/公积金申报 等
     */
    @PreAuthorize("@ss.hasPermi('business:taskType:remove')")
    @Log(title = "任务项目 记账报税/社保申报/公积金申报 等", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(bizTaskTypeService.removeBatchByIds(ids));
    }
}
