|
@@ -0,0 +1,50 @@
|
|
|
|
|
+package com.etotem.cfc.controller.admin;
|
|
|
|
|
+
|
|
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
|
|
+import com.etotem.cfc.entity.InnatePortraitConfig;
|
|
|
|
|
+import com.etotem.cfc.mapper.InnatePortraitConfigMapper;
|
|
|
|
|
+import com.etotem.cfc.service.FamilyMemberAttributeService;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/api/admin/innate-portrait-config")
|
|
|
|
|
+public class InnatePortraitConfigController {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private InnatePortraitConfigMapper innatePortraitConfigMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private FamilyMemberAttributeService familyMemberAttributeService;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/list")
|
|
|
|
|
+ public Result<List<InnatePortraitConfig>> list() {
|
|
|
|
|
+ return Result.success(innatePortraitConfigMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<InnatePortraitConfig>().orderByAsc(InnatePortraitConfig::getSortOrder)));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/update")
|
|
|
|
|
+ public Result<Void> update(@RequestBody InnatePortraitConfig config) {
|
|
|
|
|
+ if (config.getId() == null) {
|
|
|
|
|
+ return Result.error("缺少id");
|
|
|
|
|
+ }
|
|
|
|
|
+ innatePortraitConfigMapper.update(null, new LambdaUpdateWrapper<InnatePortraitConfig>()
|
|
|
|
|
+ .eq(InnatePortraitConfig::getId, config.getId())
|
|
|
|
|
+ .set(InnatePortraitConfig::getWeight, config.getWeight())
|
|
|
|
|
+ .set(InnatePortraitConfig::getEnabled, config.getEnabled())
|
|
|
|
|
+ .set(InnatePortraitConfig::getAiEnabled, config.getAiEnabled()));
|
|
|
|
|
+ return Result.success(null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/invalidate")
|
|
|
|
|
+ public Result<Void> invalidate() {
|
|
|
|
|
+ familyMemberAttributeService.invalidateAllInnateScores();
|
|
|
|
|
+ return Result.success(null);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|