package com.ruoyi.web.project.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DictUtils;
import com.yanzhu.jh.project.domain.SurProjectChecking;
import com.yanzhu.jh.project.service.ISurProjectCheckingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version : V1.0
 * @ClassName: ProjectCheckingController
 * @Description: 项目举牌验收
 * @Auther: JiangYuQi
 * @Date: 2020/7/7 18:03
 */
@RestController
@RequestMapping("/wechat/projectchecking")
public class ProjectCheckingController extends BaseController {

    @Autowired
    private ISurProjectCheckingService surProjectCheckingService;

    /**
     * 查询当前用户举牌验收项目列表
     * @param surProjectChecking
     * @return
     */
    @GetMapping("/list")
    public AjaxResult list(SurProjectChecking surProjectChecking){
        if(surProjectChecking.getDeptId()==0){
            surProjectChecking.setDeptId(null);
        }
        return success(surProjectCheckingService.selectSurProjectCheckingList(surProjectChecking));
    }

    /**
     *  统计举牌验收
     * @param surProjectChecking
     * @return
     */
    @GetMapping("/findGroupCountByApprove")
    public AjaxResult findGroupCountByApprove(SurProjectChecking surProjectChecking){
        if(surProjectChecking.getDeptId()==0){
            surProjectChecking.setDeptId(null);
        }
        return success(surProjectCheckingService.findGroupCountByApprove(surProjectChecking));
    }

    /**
     * 查询举牌验收详情
     * @param id
     * @return
     */
    @GetMapping("/info")
    public AjaxResult info(Long id){
        return success(surProjectCheckingService.selectSurProjectCheckingById(id));
    }

    /**
     * 新增举牌验收
     * @param surProjectChecking
     * @return
     */
    @PostMapping("/add")
    @Log(title = "举牌验收", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody SurProjectChecking surProjectChecking){
        return success(surProjectCheckingService.insertSurProjectChecking(surProjectChecking));
    }

    /**
     * 修改举牌验收
     * @param surProjectChecking
     * @return
     */
    @PostMapping("/edit")
    @Log(title = "举牌验收", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@RequestBody SurProjectChecking surProjectChecking){
        return success(surProjectCheckingService.updateSurProjectChecking(surProjectChecking));
    }

    /**
     * 删除举牌验收
     */
    @Log(title = "举牌验收", businessType = BusinessType.DELETE)
    @GetMapping("/remove")
    public AjaxResult remove(@RequestParam Long id)
    {
        return toAjax(surProjectCheckingService.deleteSurProjectCheckingById(id));
    }

    /**
     * 根据项目统计举牌验收
     * @param projectId
     * @return
     */
    @GetMapping("/findStatisticsByProjectId")
    public AjaxResult findStatisticsByProjectId(Long projectId){
        return success(surProjectCheckingService.findStatisticsByProjectId(projectId));
    }

    /**
     * 查询字段类型数据
     * @return
     */
    @GetMapping("/queryDictType")
    public AjaxResult queryDictType(String type){
        return success(DictUtils.getDictCache(type));
    }
}
