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.SurProjectStandard;
import com.yanzhu.jh.project.service.ISurProjectStandardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version : V1.0
 * @ClassName: ProjectStandardController
 * @Description: 项目标准管理
 * @Auther: JiangYuQi
 * @Date: 2020/7/7 18:03
 */
@RestController
@RequestMapping("/wechat/projectStandard")
public class WcProjectStandardController extends BaseController {

    @Autowired
    private ISurProjectStandardService surProjectStandardService;

    /**
     *  查询项目标准列表
     * @param surProjectStandard
     * @return
     */
    @GetMapping("/list")
    public AjaxResult list(SurProjectStandard surProjectStandard){
        if(surProjectStandard.getDeptId()==0){
            surProjectStandard.setDeptId(null);
        }
        return success(surProjectStandardService.selectSurProjectStandardList(surProjectStandard));
    }

    /**
     *  查询项目标准列表
     * @param surProjectStandard
     * @return
     */
    @GetMapping("/findCountByType")
    public AjaxResult findCountByType(SurProjectStandard surProjectStandard){
        if(surProjectStandard.getDeptId()==0){
            surProjectStandard.setDeptId(null);
        }
        return success(surProjectStandardService.selectSurProjectStandardGroupByType(surProjectStandard));
    }

    /**
     * 查询项目标准详情
     * @param id
     * @return
     */
    @GetMapping("/info")
    public AjaxResult info(Long id){
        return success(surProjectStandardService.selectSurProjectStandardById(id));
    }

    /**
     * 新增项目标准管理
     * @param surProjectStandard
     * @return
     */
    @PostMapping("/add")
    @Log(title = "项目标准管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody SurProjectStandard surProjectStandard){
        return success(surProjectStandardService.insertSurProjectStandard(surProjectStandard));
    }

    /**
     * 删除项目标准管理
     */
    @Log(title = "项目标准管理", businessType = BusinessType.DELETE)
    @GetMapping("/remove")
    public AjaxResult remove(@RequestParam Long id)
    {
        return toAjax(surProjectStandardService.deleteSurProjectStandardById(id));
    }

    /**
     * 查询项目标准类型
     * @return
     */
    @GetMapping("/queryStandardType")
    public AjaxResult queryStandardType(){
        return success(DictUtils.getDictCache("prj_standard_type"));
    }

}
