package com.mosty.base.manager.controller;

import com.mosty.base.manager.service.TbJcglXljlService;
import com.mosty.base.model.dto.jcgl.TbJcglAbfcDto;
import com.mosty.base.model.dto.jcgl.TbJcglXljlDto;
import com.mosty.base.model.entity.jcgl.TbJcglAbfc;
import com.mosty.base.model.entity.jcgl.TbJcglXljl;
import com.mosty.base.model.query.jcgl.TbJcglAbfcQuery;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "训练记录")
@RestController
@AllArgsConstructor
@RequestMapping("/xljl")
public class TbJcglXljlController {

    private final TbJcglXljlService tbJcglXljlService;

    @ApiOperation("添加训练记录")
    @JwtSysUser
    @PostMapping
    @Log(title = "添加训练记录", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> addEntity(@RequestBody TbJcglXljlDto dto) {
        return ResponseResult.success(this.tbJcglXljlService.addEntity(dto));
    }

    @ApiOperation("修改训练记录")
    @JwtSysUser
    @PutMapping
    @Log(title = "修改训练记录", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> editEntity(@RequestBody TbJcglXljlDto dto) {
        return ResponseResult.success(this.tbJcglXljlService.editEntity(dto));
    }

    @ApiOperation("批量删除训练记录")
    @JwtSysUser
    @DeleteMapping
    @Log(title = "批量删除训练记录", businessType = BusinessType.DELETE)
    public ResponseResult<Void> deleteEntity(@RequestBody List<String> ids) {
        this.tbJcglXljlService.deleteEntity(ids);
        return ResponseResult.success();
    }


    @ApiOperation("查询训练记录详情")
    @JwtSysUser
    @GetMapping("{id}")
    public ResponseResult<TbJcglXljl> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbJcglXljlService.getInfo(id));
    }

    @ApiOperation("根据巡防人员ID获取人员训练列表")
    @JwtSysUser
    @GetMapping("/getListByXfid")
    public ResponseResult<List<TbJcglXljl>> getListByXfid(String xfid) {
        return ResponseResult.success(this.tbJcglXljlService.getListByXfid(xfid));
    }

}
