package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.manager.service.TbJcglAbfcService;
import com.mosty.base.manager.service.TbJcglDsfService;
import com.mosty.base.model.dto.jcgl.TbJcglAbfcDto;
import com.mosty.base.model.dto.jcgl.TbJcglDsfDto;
import com.mosty.base.model.dto.jcgl.TbJcglDsfJudgeDto;
import com.mosty.base.model.entity.jcgl.TbJcglAbfc;
import com.mosty.base.model.entity.jcgl.TbJcglDsf;
import com.mosty.base.model.query.jcgl.TbJcglAbfcQuery;
import com.mosty.base.model.query.jcgl.TbJcglDsfQuery;
import com.mosty.base.model.vo.jcgl.TbJcglDsfVo;
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 javax.annotation.Resource;
import java.util.List;

/**
 * @author dw
 * @since 2022/9/28
 **/
@Api(tags = "第三方相关接口")
@RestController
@AllArgsConstructor
@RequestMapping("/dsf")
public class TbJcglDsfController {

    private final TbJcglDsfService tbJcglDsfService;

    @ApiOperation("添加第三方数据")
    @JwtSysUser
    @PostMapping
    @Log(title = "添加第三方数据", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> addEntity(@RequestBody TbJcglDsfDto dto) {
        return ResponseResult.success(this.tbJcglDsfService.addEntity(dto));
    }

    @ApiOperation("修改第三方数据")
    @JwtSysUser
    @PutMapping
    @Log(title = "修改第三方数据", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> editEntity(@RequestBody TbJcglDsfDto dto) {
        return ResponseResult.success(this.tbJcglDsfService.editEntity(dto));
    }

    @ApiOperation("批量删除第三方")
    @JwtSysUser
    @DeleteMapping
    @Log(title = "批量删除第三方", businessType = BusinessType.DELETE)
    public ResponseResult<Void> deleteEntity(@RequestParam List<String> ids) {
        this.tbJcglDsfService.deleteEntity(ids);
        return ResponseResult.success();
    }

    @ApiOperation("查询第三方列表")
    @JwtSysUser
    @GetMapping
    public ResponseResult<IPage<TbJcglDsf>> getPageList(TbJcglDsfQuery dto) {
        return ResponseResult.success(this.tbJcglDsfService.getPageList(dto));
    }

    @ApiOperation("查询第三方详情")
    @JwtSysUser
    @GetMapping("{id}")
    public ResponseResult<TbJcglDsf> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbJcglDsfService.getInfo(id));
    }

    @ApiOperation("修改第三方状态")
    @JwtSysUser
    @PostMapping("judge")
    @Log(title = "修改第三方状态", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> judge(@RequestBody TbJcglDsfJudgeDto dto) {
        return ResponseResult.success(this.tbJcglDsfService.judge(dto));
    }
    @ApiOperation("根据code查询第三方详情")
    @JwtSysUser
    @GetMapping("/getDsfInfo/{code}")
    public ResponseResult<TbJcglDsfVo> getDsfInfo(@PathVariable("code") String code){
        return ResponseResult.success(this.tbJcglDsfService.getDsfInfo(code));
    }
}
