package com.securitycontrol.background.controller;

import com.securitycontrol.background.service.ISignProService;
import com.securitycontrol.common.core.web.controller.BaseController;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.core.web.page.TableDataInfo;
import com.securitycontrol.common.log.annotation.Log;
import com.securitycontrol.common.log.enums.OperationType;
import com.securitycontrol.entity.background.dto.ParamDto;
import com.securitycontrol.entity.background.vo.ProjectVo;
import com.securitycontrol.entity.background.vo.SignProVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author：cwchen
 * @date：2024-04-01-19:23
 * @version：1.0
 * @description：项目工程/单项工程-web层
 */
@RequestMapping(value = "/back/signPro/")
@RestController
public class SignProController extends BaseController {

    @Resource(name = "ISignProService")
    private ISignProService service;

    @ApiOperation(value = "获取项目列表")
    @GetMapping("getProLists")
    @Log(title = "工程管理", menu = "工程管理->项目管理", grade = OperationType.QUERY_BUSINESS, details = "查询项目列表", type = "业务日志")
    public TableDataInfo getProLists(ParamDto dto) {
        startPage();
        List<ProjectVo> list = new ArrayList<>();
        list = service.getProLists(dto);
        return getDataTable(list);
    }

    @ApiOperation(value = "新增项目")
    @PostMapping("addProject")
    @Log(title = "工程管理", menu = "工程管理->项目管理", grade = OperationType.ADD_BUSINESS, details = "新增项目", type = "业务日志")
    public AjaxResult addProject(@RequestBody ProjectVo vo) {
        return service.addOrUpdateProject(vo);
    }

    @ApiOperation(value = "修改项目")
    @PostMapping("updateProject")
    @Log(title = "工程管理", menu = "工程管理->项目管理", grade = OperationType.ADD_BUSINESS, details = "修改项目", type = "业务日志")
    public AjaxResult updateProject(@RequestBody ProjectVo vo) {
        return service.addOrUpdateProject(vo);
    }

    @ApiOperation(value = "项目详情")
    @GetMapping(value="getProjectById")
    public AjaxResult getProjectById(ParamDto dto){
        return service.getProjectById(dto);
    }

    @ApiOperation(value = "删除项目")
    @PostMapping(value="delProjectById")
    @Log(title = "工程管理", menu = "工程管理->项目管理", grade = OperationType.DELETE_BUSINESS, details = "删除项目", type = "业务日志")
    public AjaxResult delProjectById(@RequestBody ParamDto dto){
        return service.delProjectById(dto);
    }

    @ApiOperation(value = "获取单项工程列表")
    @GetMapping("getSignProLists")
    @Log(title = "工程管理", menu = "工程管理->单项工程管理", grade = OperationType.QUERY_BUSINESS, details = "查询单项工程列表", type = "业务日志")
    public TableDataInfo getSignProLists(ParamDto dto) {
        startPage();
        List<SignProVo> list = new ArrayList<>();
        list = service.getSignProLists(dto);
        return getDataTable(list);
    }

    @ApiOperation(value = "新增单项工程")
    @PostMapping("addSignProject")
    @Log(title = "工程管理", menu = "工程管理->单项工程管理", grade = OperationType.ADD_BUSINESS, details = "新增单项工程", type = "业务日志")
    public AjaxResult addSignProject(@RequestBody SignProVo vo) {
        return service.addOrUpdateSignProject(vo);
    }

    @ApiOperation(value = "修改单项工程")
    @PostMapping("updateSignProject")
    @Log(title = "工程管理", menu = "工程管理->单项工程管理", grade = OperationType.ADD_BUSINESS, details = "修改单项工程", type = "业务日志")
    public AjaxResult updateSignProject(@RequestBody SignProVo vo) {
        return service.addOrUpdateSignProject(vo);
    }

    @ApiOperation(value = "单项工程详情")
    @GetMapping(value="getSignProById")
    public AjaxResult getSignProById(ParamDto dto){
        return service.getSignProById(dto);
    }

    @ApiOperation(value = "删除单项工程")
    @PostMapping(value="delSignProById")
    @Log(title = "工程管理", menu = "工程管理->项目管理", grade = OperationType.DELETE_BUSINESS, details = "删除单项工程", type = "业务日志")
    public AjaxResult delSignProById(@RequestBody ParamDto dto){
        return service.delSignProById(dto);
    }
}
