package com.dk.mdm.controller.core;

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.core.Post;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.core.PostQuery;
import com.dk.mdm.model.response.core.PostResponse;
import com.dk.mdm.model.vo.core.PostVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.dk.mdm.service.core.PostService;

@Api(tags = "职务API接口")
@RestController
@RequestMapping("/core/post")
public class PostController{

    public BaseService<Post> getService() {
        return postService;
    }

    @Autowired
    private PostService postService;

    /**
     * @desc   : 条件查询
     * @author : 夏常明
     * @date   : 2023/1/4 9:39
     */
    @ApiOperation( value = "分页、关联、条件查询", notes = "分页、关联、条件查询" )
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<PostResponse>> selectByCond(@RequestBody PostQuery postQuery) {
        return postService.selectByCond(postQuery);
    }

    /**
     * @desc : 通过ID查询
     * @author : 夏常明
     * @date : 2023/1/4 9:39
     */
    @PostMapping({"{id}"})
    public ResponseResultVO selectById(@PathVariable String id) {
        return postService.selectById(id);
    }

    /**
     * @desc : 新建职务
     * @author : 夏常明
     * @date : 2023/1/4 9:39
     */
    @ApiOperation( value = "新建职务", notes = "新建职务" )
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody PostVO postVO) {
        return postService.insert(postVO);
    }

    /**
     * @desc : 编辑职务
     * @author : 夏常明
     * @date : 2023/1/4 9:39
     */
    @ApiOperation( value = "编辑职务", notes = "编辑职务" )
    @PostMapping({"update"})
    public ResponseResultVO<Boolean> update(@RequestBody PostVO postVO) {
        return postService.update(postVO);
    }

    /**
     * @desc : 停用
     * @author : 夏常明
     * @date :  2023/1/4 9:39
     */
    @ApiOperation(value = "停用", notes = "停用")
    @PostMapping("disable/{id}")
    public ResponseResultVO<Boolean> disable(@PathVariable String id) {
        return this.getService().disable(id);
    }

    /**
     * @desc : 启用
     * @author : 夏常明
     * @date :  2023/1/4 9:39
     */
    @ApiOperation(value = "启用", notes = "启用")
    @PostMapping("enable/{id}")
    public ResponseResultVO<Boolean> enable(@PathVariable String id) {
        return this.getService().enable(id);
    }
}
