package com.mosty.yjzl.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.yjzl.TbZdyFgrwDkDto;
import com.mosty.base.model.dto.yjzl.TbZdyFgrwDto;
import com.mosty.base.model.query.yjzl.TbZdyFgrwQuery;
import com.mosty.base.model.query.yjzl.TbZdyFgrwlqQuery;
import com.mosty.base.model.vo.yjzl.TbZdyFgrwVO;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.token.JwtSysUser;
import com.mosty.yjzl.service.TbZdyFgrwService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api(tags = {"方格任务-自定义任务"})
@RestController
@AllArgsConstructor
@RequestMapping("/tbZdyrw")
public class TbZdyFgrwController {

    private final TbZdyFgrwService tbZdyFgrwService;

    @ApiOperation(value = "添加自定义任务")
    @PostMapping ("/addTbZdyrw")
    @JwtSysUser
    public ResponseResult<Boolean> addTbZdyrw(@RequestBody TbZdyFgrwDto dto) {
        return ResponseResult.success(tbZdyFgrwService.addTbZdyrw(dto));
    }

    @ApiOperation(value = "修改自定义任务")
    @PostMapping ("/editTbZdyrw")
    @JwtSysUser
    public ResponseResult<Boolean> editTbZdyrw(@RequestBody TbZdyFgrwDto dto) {
        return ResponseResult.success(tbZdyFgrwService.editTbZdyrw(dto));
    }

    @ApiOperation(value = "删除自定义任务")
    @PostMapping ("/delTbZdyrw")
    @JwtSysUser
    public ResponseResult<Boolean> delTbZdyrw(@RequestBody TbZdyFgrwDto dto) {
        return ResponseResult.success(tbZdyFgrwService.delTbZdyrw(dto));
    }

    @ApiOperation(value = "查询列表")
    @GetMapping("/selectList")
    @JwtSysUser
    public ResponseResult<IPage<TbZdyFgrwVO>> selectList(TbZdyFgrwQuery query) {
        return ResponseResult.success(tbZdyFgrwService.selectList(query));
    }

    @ApiOperation(value = "app查询列表")
    @GetMapping("/selectListApp")
    @JwtSysUser
    public ResponseResult<IPage<TbZdyFgrwVO>> selectListApp(TbZdyFgrwQuery query) {
        return ResponseResult.success(tbZdyFgrwService.selectListApp(query));
    }

    @ApiOperation(value = "任务详情")
    @GetMapping("/getFgrwXq")
    @JwtSysUser
    public ResponseResult<TbZdyFgrwVO> getFgrwXq(TbZdyFgrwQuery query) {
        return ResponseResult.success(tbZdyFgrwService.getFgrwXq(query));
    }

    @ApiOperation(value = "领取任务")
    @GetMapping("/getLqrw")
    @JwtSysUser
    public ResponseResult<Boolean> getLqrw(TbZdyFgrwlqQuery query) {
        return ResponseResult.success(tbZdyFgrwService.getLqrw(query));
    }

    @ApiOperation(value = "任务打卡详情")
    @GetMapping("/getFgrwDkXq")
    @JwtSysUser
    public ResponseResult<Map<String,Object>> getFgrwDkXq(TbZdyFgrwQuery query) {
        return ResponseResult.success(tbZdyFgrwService.getFgrwDkXq(query));
    }

    @ApiOperation(value = "自定义任务打卡")
    @PostMapping ("/zdyRwdk")
    @JwtSysUser
    public ResponseResult<Boolean> zdyRwdk(@RequestBody TbZdyFgrwDkDto dto) {
        return ResponseResult.success(tbZdyFgrwService.zdyRwdk(dto));
    }
}
