package jnpf.qualifications.controller;

import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;

import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.model.qualifications.dto.QualificationsDto;
import jnpf.model.qualifications.vo.QualificationsCategoryVo;
import jnpf.model.qualifications.vo.QualificationsItemsVo;
import jnpf.permission.model.user.MiniUserVo;
import jnpf.qualifications.service.QualificationsFieldService;
import jnpf.qualifications.service.QualificationsService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

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

/**
 * 标准字段配置管理
 *
 * @author Flynn Chan
 * @create 2024-03-04
 */
@Tag(name = "标准字段配置管理")
@RestController
@RequestMapping("/qualifications_field")
public class QualificationsFieldController {

    @Resource
    private QualificationsFieldService qualificationsFieldService;

  /**
   * @Description:标准字段创建
   * @params:
   * @return:
   * @Author: vinson
   * @Date 2024/3/5 16:55
   */
    @PostMapping("/create")
    public ActionResult<Boolean> create(@RequestBody QualificationsDto qualificationsDto){
        return ActionResult.success(qualificationsFieldService.create(qualificationsDto));
    }

   /**
    * @Description:标准字段修改
    * @params: QualificationsDto
    * @return: Boolean
    * @Author: vinson
    * @Date 2024/3/5 16:53
    */
    @PostMapping("/updateById")
    public ActionResult<Boolean> updateById(@RequestBody QualificationsDto QualificationsDto){
        return ActionResult.success(qualificationsFieldService.updateById(QualificationsDto));
    }

    /**
     * @Description:标准字段配置分页查询
     * @params:
     * @return:
     * @Author: vinson
     * @Date 2024/3/5 16:54
     */
    @GetMapping("/getQualificationsFieldPages")
    public ActionResult<PageInfo<QualificationsCategoryVo>> getQualificationsFieldPages(@RequestParam(value = "keyword",required = false) String keyword,
                                                                          @RequestParam(value = "categoryId",required = false) String categoryId,
                                                                          @RequestParam(value = "currentPage") Integer currentPage,
                                                                          @RequestParam(value = "pageSize") Integer pageSize){
        return ActionResult.success(qualificationsFieldService.getQualificationsFieldPages(keyword, categoryId,currentPage,pageSize));
    }

    /**
     * @Description:注释项详情页
     * @params:
     * @return:
     * @Author: vinson
     * @Date 2024/3/7 15:10
     */
    @GetMapping("/getQualificationsFieldItem")
    public ActionResult<QualificationsItemsVo> getQualificationsFieldItem(
            @RequestParam(value = "fieldId") String fieldId){
        return ActionResult.success(qualificationsFieldService.getQualificationsFieldItem(fieldId));
    }

    /**
     * @Description:标准字段删除
     * @params:
     * @return:
     * @Author: vinson
     * @Date 2024/3/7 16:15
     */
    @PostMapping("/deleteFieldById")
    public ActionResult<Boolean> deleteFieldById(
            @RequestParam(value = "fieldId") String fieldId){
        return ActionResult.success(qualificationsFieldService.deleteFieldById(fieldId));
    }

    /**
     * @Description:
     * @params:
     * @return:
     * @Author: vinson
     * @Date 2024/3/11 15:38
     */
    @Operation(summary = "获取分类下字段信息")
    @GetMapping("getCategoryFieldList")
    public ActionResult getCategoryFieldList(String categoryId){
        return ActionResult.success(qualificationsFieldService.getCategoryFieldList(categoryId));
    }

}

