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

/**
 * @version : V1.0
 * @ClassName: ProjectScheduleController
 * @Description: 项目形象进度
 * @Auther: JiangYuQi
 * @Date: 2020/7/7 18:03
 */
@RestController
@RequestMapping("/wechat/projectSchedule")
public class ProjectScheduleController extends BaseController {

    @Autowired
    private ISurProjectScheduleService isurProjectScheduleService;

    /**
     *  查询项目形象进度列表
     * @param surProjectSchedule
     * @return
     */
    @GetMapping("/list")
    public AjaxResult list(SurProjectSchedule surProjectSchedule){
        return success(isurProjectScheduleService.selectSurProjectScheduleList(surProjectSchedule));
    }

    /**
     * 查询项目最后一个形象进度
     * @param projectId
     * @return
     */
    @GetMapping("/lastInfo")
    public AjaxResult lastInfo(Long projectId){
        return success(isurProjectScheduleService.getProjectConstructionProgress(projectId));
    }

    /**
     * 查询形象进度详情
     * @param id
     * @return
     */
    @GetMapping("/info")
    public AjaxResult info(Long id){
        return success(isurProjectScheduleService.selectSurProjectScheduleById(id));
    }

    /**
     * 新增问题整改
     * @param surProjectSchedule
     * @return
     */
    @PostMapping("/add")
    @Log(title = "形象进度", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody SurProjectSchedule surProjectSchedule){
        return success(isurProjectScheduleService.insertSurProjectSchedule(surProjectSchedule));
    }

    /**
     * 删除形象进度
     */
    @Log(title = "形象进度", businessType = BusinessType.DELETE)
    @GetMapping("/remove")
    public AjaxResult remove(@RequestParam Long id)
    {
        return toAjax(isurProjectScheduleService.deleteSurProjectScheduleById(id));
    }

}
