package com.pusong.business.controller;

import java.util.List;

import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.pusong.common.idempotent.annotation.RepeatSubmit;
import com.pusong.common.log.annotation.Log;
import com.pusong.common.web.core.BaseController;
import com.pusong.common.mybatis.core.page.PageQuery;
import com.pusong.common.core.domain.R;
import com.pusong.common.core.validate.AddGroup;
import com.pusong.common.core.validate.EditGroup;
import com.pusong.common.log.enums.BusinessType;
import com.pusong.common.excel.utils.ExcelUtil;
import com.pusong.business.domain.vo.PsTaskWorkRecordVo;
import com.pusong.business.domain.bo.PsTaskWorkRecordBo;
import com.pusong.business.service.IPsTaskWorkRecordService;
import com.pusong.common.mybatis.core.page.TableDataInfo;

/**
 * 外勤任务记录
 *
 * @author wls
 * @date 2024-08-09
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/taskWorkRecord")
@SaIgnore
public class PsTaskWorkRecordController extends BaseController {

    private final IPsTaskWorkRecordService psTaskWorkRecordService;

    /**
     * 根据任务委派id查询工作进度列表
     */
    @Log(title = "根据任务委派id查询工作进度列表")
    @SaCheckPermission("business:taskWorkRecord:list")
    @GetMapping("/list")
    public R<List<PsTaskWorkRecordVo>> list(@NotNull  Long id) {
        return R.ok(psTaskWorkRecordService.queryListByAppointId(id));
    }

    /**
     * 根据主任务id查询工作进度列表
     */
    @Log(title = "根据主任务id查询工作进度列表")
    @SaCheckPermission("business:taskWorkRecord:listByTaskId")
    @GetMapping("/listByTaskId")
    public R<List<PsTaskWorkRecordVo>> listByTaskId(@NotNull  Long id) {
        return R.ok(psTaskWorkRecordService.queryListByTaskId(id));
    }

    /**
     * 新增外勤任务记录
     */
    @SaCheckPermission("business:taskWorkRecord:add")
    @Log(title = "外勤任务记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody PsTaskWorkRecordBo bo) {
        return toAjax(psTaskWorkRecordService.insertByBo(bo));
    }

//    /**
//     * 导出外勤任务记录列表
//     */
//    @SaCheckPermission("business:taskWorkRecord:export")
//    @Log(title = "外勤任务记录", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(PsTaskWorkRecordBo bo, HttpServletResponse response) {
//        List<PsTaskWorkRecordVo> list = psTaskWorkRecordService.queryList(bo);
//        ExcelUtil.exportExcel(list, "外勤任务记录", PsTaskWorkRecordVo.class, response);
//    }
//
//    /**
//     * 获取外勤任务记录详细信息
//     *
//     * @param id 主键
//     */
//    @SaCheckPermission("business:taskWorkRecord:query")
//    @GetMapping("/{id}")
//    public R<PsTaskWorkRecordVo> getInfo(@NotNull(message = "主键不能为空")
//                                     @PathVariable Long id) {
//        return R.ok(psTaskWorkRecordService.queryById(id));
//    }
//
//    /**
//     * 新增外勤任务记录
//     */
//    @SaCheckPermission("business:taskWorkRecord:add")
//    @Log(title = "外勤任务记录", businessType = BusinessType.INSERT)
//    @RepeatSubmit()
//    @PostMapping()
//    public R<Void> add(@Validated(AddGroup.class) @RequestBody PsTaskWorkRecordBo bo) {
//        return toAjax(psTaskWorkRecordService.insertByBo(bo));
//    }
//
//    /**
//     * 修改外勤任务记录
//     */
//    @SaCheckPermission("business:taskWorkRecord:edit")
//    @Log(title = "外勤任务记录", businessType = BusinessType.UPDATE)
//    @RepeatSubmit()
//    @PutMapping()
//    public R<Void> edit(@Validated(EditGroup.class) @RequestBody PsTaskWorkRecordBo bo) {
//        return toAjax(psTaskWorkRecordService.updateByBo(bo));
//    }
//
//    /**
//     * 删除外勤任务记录
//     *
//     * @param ids 主键串
//     */
//    @SaCheckPermission("business:taskWorkRecord:remove")
//    @Log(title = "外勤任务记录", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public R<Void> remove(@NotEmpty(message = "主键不能为空")
//                          @PathVariable Long[] ids) {
//        return toAjax(psTaskWorkRecordService.deleteWithValidByIds(List.of(ids), true));
//    }
}
