package jnpf.qualifications.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.entity.qualifications.QualificationsFieldCategory;
import jnpf.qualifications.service.QualificationsFieldCategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 标准字段分类管理
 *
 * @author Flynn Chan
 * @create 2024-03-04
 */
@Tag(name = "标准字段分类管理")
@RestController
@RequestMapping("/qualifications_field_category")
public class QualificationsFieldCategoryController {

    @Resource
    private QualificationsFieldCategoryService qualificationsFieldCategoryService;

    /**
     * 标准字段分类创建
     * @param qualificationsFieldCategory
     * @return
     */
    @PostMapping("/create")
    public ActionResult<String> create(@RequestBody QualificationsFieldCategory qualificationsFieldCategory){
        qualificationsFieldCategoryService.create(qualificationsFieldCategory);
        return ActionResult.success("添加成功");
    }

    /**
     * id查询分类
     * @param id
     * @return
     */
    @GetMapping("/getCategoryById")
    public ActionResult<QualificationsFieldCategory> getCategoryById(String id){
        return ActionResult.success(qualificationsFieldCategoryService.getCategoryById(id));
    }

    /**
     * 分类id删除
     * @param id
     * @return
     */
    @DeleteMapping("/deleteCategoryById")
    public ActionResult<Long> deleteCategoryById(String id){
        return ActionResult.success(qualificationsFieldCategoryService.deleteCategoryById(id));
    }

    /**
     * 修改分类
     * @param qualificationsFieldCategory
     * @return
     */
    @PostMapping("/updateCategoryById")
    public ActionResult<Boolean> updateCategoryById(@RequestBody QualificationsFieldCategory qualificationsFieldCategory){
        qualificationsFieldCategory.setCreatorTime(new Date());
        return ActionResult.success(qualificationsFieldCategoryService.updateById(qualificationsFieldCategory));
    }

    /**
     * @Description:
     * @params:
     * @return: 分类列表
     * @Author: vinson
     * @Date 2024/3/6 17:32
     */
    @GetMapping("/getCategoryList")
    public ActionResult<List<QualificationsFieldCategory>> getCategoryList(){
        return ActionResult.success(qualificationsFieldCategoryService.getCategoryList());
    }
}
