package org.dromara.mp.controller;

import org.dromara.common.core.domain.R;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.log.enums.OperatorType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.mp.domain.MerTaskEnroll;
import org.dromara.mp.domain.vo.MerTaskEnrollVo;
import org.dromara.mp.domain.vo.MyTaskVo;
import org.dromara.mp.domain.vo.TaskVo;
import org.dromara.mp.domain.vo.UserWorkerBus;
import org.dromara.mp.service.IMyTaskService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * @author sunzexing
 * @version 1.0
 * @title MyTaskController
 * @description
 * @create 2024-05-08 18:46
 */
@RestController
@RequestMapping("/task")
public class MyTaskController extends BaseController {

    @Resource
    public IMyTaskService taskService;


    /***
     * 任务广场
     * @param name
     * @param pageQuery
     * @return
     */
    @GetMapping("/taskList")
    @Log(title = "任务广场", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public TableDataInfo<MyTaskVo> selTastList(String name, PageQuery pageQuery){
        return taskService.selTastList(name,pageQuery);
    }



    /***
     * 任务广场
     * @param name
     * @param pageQuery
     * @return
     */
    @GetMapping("/myTaskList")
    @Log(title = "我的任务", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public TableDataInfo<MyTaskVo> selMyTastList(String name, PageQuery pageQuery){
        return taskService.selMyTastList(name,pageQuery);
    }


    /****
     * 任务广场-任务详情
     * @param id
     * @return
     */
    @GetMapping("/taskListDetail")
    @Log(title = "任务详情", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public R<TaskVo> selTaskListDetail(Long id){
        return R.ok(taskService.selTaskListDetail(id));
    }


    /***
     * 请求任务
     * @param id 项目ID
     * @param no 项目编码
     * @return
     */
    @PostMapping("/accept")
    @Log(title = "接收任务", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public R<Boolean>  acceptTask(Long id,String no){
        return R.ok(taskService.acceptTask(id,no));
    }



    /***
     * 签到-项目列表
     * @return
     */
    @PostMapping("/selMyCheckPro")
    @Log(title = "签到项目列表", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public R<List<MyTaskVo>>  selMyCheckPro(){
        return R.ok(taskService.selMyCheckPro());
    }




    /***
     * 我的任务-任务详情
     * @return
     */
    @GetMapping("/myTaskDetail")
    @Log(title = "我的任务-任务详情", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public R<TaskVo> selMyTaskDetail(Long id){
        return R.ok(taskService.selMyTaskDetail(id));
    }




    /***
     * 我的任务-提交完工报告
     * @return
     */
    @PostMapping("/updOverReport")
    @Log(title = "我的任务-提交完工报告", businessType = BusinessType.UPDATE,operatorType= OperatorType.MOBILE)
    public R<Integer> updOverReport(MerTaskEnroll enroll){
        return R.ok(taskService.updOverReport(enroll));
    }


    /***
     * 我的任务-查询完工报告
     * @return
     */
    @GetMapping("/getOverReport")
    @Log(title = "我的任务-查看完工报告", businessType = BusinessType.UPDATE,operatorType= OperatorType.MOBILE)
    public R<MerTaskEnrollVo> selOverReport(Long id) {
        return R.ok(taskService.selOverReport(id));
    }



    /***
     * 我的合同列表
     * @param name
     * @param pageQuery
     * @return
     */
    @GetMapping("/getMyHts")
    @Log(title = "我的合同列表", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public TableDataInfo<UserWorkerBus> getMyHts(String name, PageQuery pageQuery){
        return taskService.selMyHtList(name,pageQuery);
    }



    /***
     *
     * 我的项目确认单
     * @param name
     * @param pageQuery
     * @return
     *
     */
    @GetMapping("/proSureDoc")
    @Log(title = "我的项目确认单", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public TableDataInfo<MerTaskEnrollVo>  selProSureDoc(String name, PageQuery pageQuery){
        return taskService.selProSureDoc(name,pageQuery);
    }


    /***
     * 获取签约信息
     * @param id
     * @param domain
     * @return
     * @throws Exception
     */
//    @GetMapping("/getSignUrl")
    @Log(title = "获取签约信息", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public  R<String>  getSignUrl(Long id,String domain)throws Exception{
        return R.ok("",this.taskService.signPro(id,domain));
    }



    /***
     * 获取签约信息
     * @param id
     * @param domain
     * @return
     * @throws Exception
     */
//    @GetMapping("/getSureSigUrl")
    @Log(title = "获取确认单签约信息", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public  R<String>  signSurePro(Long id,String domain)throws Exception{
        return R.ok("",this.taskService.signSurePro(id,domain));
    }

    /***
     * 获取签约信息
     * @param id
     * @param domain
     * @return
     * @throws Exception
     */
//    @GetMapping("/getJzqSignUrl")
    @GetMapping("/getSignUrl")
    @Log(title = "获取签约信息", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public  R<String>  getJzqSignUrl(Long id,String domain)throws Exception{
        return R.ok("",this.taskService.signProJzq(id,domain));
    }



    /***
     * 获取签约信息
     * @param id
     * @param domain
     * @return
     * @throws Exception
     */
//    @GetMapping("/getJzqSureSigUrl")
    @GetMapping("/getSureSigUrl")
    @Log(title = "获取确认单签约信息", businessType = BusinessType.SELECT,operatorType= OperatorType.MOBILE)
    public  R<String>  JzqsignSurePro(Long id,String domain)throws Exception{
        return R.ok("",this.taskService.signSureProJzq(id,domain));
    }





}
