package jnpf.personnels.controller.web.black;


import jnpf.base.ActionResult;
import jnpf.model.personnels.dto.black.FtbPersonnelsBlacklistTypeAddDTO;
import jnpf.model.personnels.dto.black.FtbPersonnelsBlacklistTypeUpdateDTO;
import jnpf.model.personnels.vo.black.FtbPersonnelsBlacklistTypeListVO;
import jnpf.personnels.service.FtbPersonnelsBlacklistTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * web人事黑名单类型模块
 *
 * @author wcx
 * @since 2024-05-08
 */
@RestController
@RequestMapping("/ftb-personnels-blacklist-type")
public class FtbPersonnelsBlacklistTypeController {


    @Autowired
    private FtbPersonnelsBlacklistTypeService ftbPersonnelsBlacklistTypeService;

    /**
     * 新增黑名单类型
     *
     * @param ftbPersonnelsBlacklistTypeAddDTO
     * @return {@link ActionResult }
     */
    @PostMapping(value = "/add")
    public ActionResult add(@Validated @RequestBody FtbPersonnelsBlacklistTypeAddDTO ftbPersonnelsBlacklistTypeAddDTO) {
        ftbPersonnelsBlacklistTypeService.add(ftbPersonnelsBlacklistTypeAddDTO);
        return ActionResult.success();
    }

    /**
     * 删除黑名单类型
     *
     * @param id 主键id(必填)
     * @return {@link ActionResult }
     */
    @DeleteMapping(value = "/delete/{id}")
    public ActionResult delete(@PathVariable("id") String id) {
        ftbPersonnelsBlacklistTypeService.delete(id);
        return ActionResult.success();
    }

    /**
     * 编辑黑名单类型
     *
     * @return {@link ActionResult }
     */
    @PostMapping(value = "/update")
    public ActionResult updateData(@Validated @RequestBody FtbPersonnelsBlacklistTypeUpdateDTO ftbPersonnelsBlacklistTypeUpdateDTO) {
        ftbPersonnelsBlacklistTypeService.updateData(ftbPersonnelsBlacklistTypeUpdateDTO);
        return ActionResult.success();
    }

    /**
     * 黑名单类型列表
     *
     * @return {@link ActionResult }
     */
    @GetMapping(value = "/list")
    public ActionResult<List<FtbPersonnelsBlacklistTypeListVO>> listData() {
        List<FtbPersonnelsBlacklistTypeListVO> result = ftbPersonnelsBlacklistTypeService.listData();
        return ActionResult.success(result);
    }

    /**
     * 办理离职时黑名单类型下拉查询
     *
     * @return {@link ActionResult }
     */
    @GetMapping(value = "/list-dropDown")
    public ActionResult<List<FtbPersonnelsBlacklistTypeListVO>> listDropDown() {
        List<FtbPersonnelsBlacklistTypeListVO> result = ftbPersonnelsBlacklistTypeService.listData();
        return ActionResult.success(result);
    }

}
