|
@@ -0,0 +1,208 @@
|
|
|
|
|
+package cn.com.yusys.ai.plus.market.controller;
|
|
|
|
|
+
|
|
|
|
|
+import cn.com.yusys.ai.plus.market.MarketCons;
|
|
|
|
|
+import cn.com.yusys.ai.plus.market.dto.SkillCreateDTO;
|
|
|
|
|
+import cn.com.yusys.ai.plus.market.dto.SkillQueryDTO;
|
|
|
|
|
+import cn.com.yusys.ai.plus.market.dto.SkillUpdateDTO;
|
|
|
|
|
+import cn.com.yusys.ai.plus.market.entity.YusysAiSkill;
|
|
|
|
|
+import cn.com.yusys.ai.plus.market.service.YusysAiSkillService;
|
|
|
|
|
+import cn.com.yusys.ai.common.BizException;
|
|
|
|
|
+import cn.com.yusys.ai.common.ResultDto;
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * AI技能 Controller
|
|
|
|
|
+ */
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/api/market/skill")
|
|
|
|
|
+public class YusysAiSkillController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private YusysAiSkillService skillService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分页查询技能列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/page")
|
|
|
|
|
+ public ResultDto<Page<YusysAiSkill>> pageQuery(@RequestBody SkillQueryDTO queryDTO) {
|
|
|
|
|
+ Page<YusysAiSkill> page = skillService.pageQuery(
|
|
|
|
|
+ queryDTO.getPageNum(),
|
|
|
|
|
+ queryDTO.getPageSize(),
|
|
|
|
|
+ queryDTO.getSkillName(),
|
|
|
|
|
+ queryDTO.getSkillGroup(),
|
|
|
|
|
+ queryDTO.getSkillStatus()
|
|
|
|
|
+ );
|
|
|
|
|
+ return ResultDto.success(page).total(page.getTotal());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据ID查询技能详情
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/getById")
|
|
|
|
|
+ public ResultDto<YusysAiSkill> getById(@RequestBody String id) {
|
|
|
|
|
+ YusysAiSkill skill = skillService.getById(id);
|
|
|
|
|
+ if (skill == null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultDto.success(skill);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据技能名称查询
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/getByName")
|
|
|
|
|
+ public ResultDto<YusysAiSkill> getByName(@RequestBody String skillName) {
|
|
|
|
|
+ YusysAiSkill skill = skillService.getBySkillName(skillName);
|
|
|
|
|
+ if (skill == null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultDto.success(skill);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据分组查询技能列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/listByGroup")
|
|
|
|
|
+ public ResultDto<List<YusysAiSkill>> listByGroup(@RequestBody String skillGroup) {
|
|
|
|
|
+ List<YusysAiSkill> list = skillService.listByGroup(skillGroup);
|
|
|
|
|
+ return ResultDto.success(list).total(list.size());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询已发布的技能列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/listPublic")
|
|
|
|
|
+ public ResultDto<List<YusysAiSkill>> listPublic() {
|
|
|
|
|
+ List<YusysAiSkill> list = skillService.listPublic();
|
|
|
|
|
+ return ResultDto.success(list).total(list.size());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 创建技能
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping
|
|
|
|
|
+ public ResultDto<YusysAiSkill> create(@RequestBody SkillCreateDTO createDTO) {
|
|
|
|
|
+ // 检查技能名称是否已存在
|
|
|
|
|
+ YusysAiSkill existSkill = skillService.getBySkillName(createDTO.getSkillName());
|
|
|
|
|
+ if (existSkill != null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NAME_EXISTS);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ YusysAiSkill skill = new YusysAiSkill();
|
|
|
|
|
+ BeanUtil.copyProperties(createDTO, skill);
|
|
|
|
|
+ skill.setCreatedAt(LocalDateTime.now());
|
|
|
|
|
+ skill.setUpdatedAt(LocalDateTime.now());
|
|
|
|
|
+
|
|
|
|
|
+ skillService.save(skill);
|
|
|
|
|
+ return new ResultDto<YusysAiSkill>().code("0").message("创建成功").data(skill);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 更新技能
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/update")
|
|
|
|
|
+ public ResultDto<YusysAiSkill> update(@RequestBody SkillUpdateDTO updateDTO) {
|
|
|
|
|
+ if (updateDTO.getPkId() == null || updateDTO.getPkId().isEmpty()) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_ID_EMPTY);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ YusysAiSkill skill = skillService.getById(updateDTO.getPkId());
|
|
|
|
|
+ if (skill == null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果修改了技能名称,检查新名称是否已被占用
|
|
|
|
|
+ if (updateDTO.getSkillName() != null && !updateDTO.getSkillName().equals(skill.getSkillName())) {
|
|
|
|
|
+ YusysAiSkill existSkill = skillService.getBySkillName(updateDTO.getSkillName());
|
|
|
|
|
+ if (existSkill != null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NAME_EXISTS);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ BeanUtil.copyProperties(updateDTO, skill, "pkId", "createdAt", "createBy");
|
|
|
|
|
+ skill.setUpdatedAt(LocalDateTime.now());
|
|
|
|
|
+
|
|
|
|
|
+ skillService.updateById(skill);
|
|
|
|
|
+ return new ResultDto<YusysAiSkill>().code("0").message("更新成功").data(skill);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除技能
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/delete")
|
|
|
|
|
+ public ResultDto<Void> delete(@RequestBody String id) {
|
|
|
|
|
+ YusysAiSkill skill = skillService.getById(id);
|
|
|
|
|
+ if (skill == null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ skillService.removeById(id);
|
|
|
|
|
+ return ResultDto.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量删除技能
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/deleteBatch")
|
|
|
|
|
+ public ResultDto<Void> deleteBatch(@RequestBody List<String> ids) {
|
|
|
|
|
+ skillService.removeByIds(ids);
|
|
|
|
|
+ return ResultDto.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发布技能
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/publish")
|
|
|
|
|
+ public ResultDto<Void> publish(@RequestBody String id) {
|
|
|
|
|
+ YusysAiSkill skill = skillService.getById(id);
|
|
|
|
|
+ if (skill == null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ skillService.publish(id);
|
|
|
|
|
+ return ResultDto.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 取消发布技能
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/unpublish")
|
|
|
|
|
+ public ResultDto<Void> unpublish(@RequestBody String id) {
|
|
|
|
|
+ YusysAiSkill skill = skillService.getById(id);
|
|
|
|
|
+ if (skill == null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ skillService.unpublish(id);
|
|
|
|
|
+ return ResultDto.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 启用技能
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/enable")
|
|
|
|
|
+ public ResultDto<Void> enable(@RequestBody String id) {
|
|
|
|
|
+ YusysAiSkill skill = skillService.getById(id);
|
|
|
|
|
+ if (skill == null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ skillService.enable(id);
|
|
|
|
|
+ return ResultDto.success();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 禁用技能
|
|
|
|
|
+ */
|
|
|
|
|
+ @PostMapping("/disable")
|
|
|
|
|
+ public ResultDto<Void> disable(@RequestBody String id) {
|
|
|
|
|
+ YusysAiSkill skill = skillService.getById(id);
|
|
|
|
|
+ if (skill == null) {
|
|
|
|
|
+ throw BizException.of(MarketCons.ERROR_SKILL_NOT_FOUND);
|
|
|
|
|
+ }
|
|
|
|
|
+ skillService.disable(id);
|
|
|
|
|
+ return ResultDto.success();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|