Explorar o código

chore: remove scope-creep DimensionWeight files

These files were accidentally created by subagents and are not part of the tongue diagnosis feature.
Sisyphus hai 2 meses
pai
achega
3b769771e6

+ 0 - 64
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/DimensionWeightController.java

@@ -1,64 +0,0 @@
-package com.etotem.cfc.controller.admin;
-
-import com.etotem.cfc.common.Result;
-import com.etotem.cfc.entity.DimensionWeight;
-import com.etotem.cfc.service.DimensionWeightService;
-import org.springframework.web.bind.annotation.*;
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-@RestController
-@RequestMapping("/api/admin/dimension-weight")
-public class DimensionWeightController {
-
-    @Resource
-    private DimensionWeightService dimensionWeightService;
-
-    /**
-     * 批量保存维度权重(全量替换)
-     * POST /api/admin/dimension-weight/save
-     * Body: { targetType, targetId, weights: [{dimension, weight, enabled}] }
-     */
-    @PostMapping("/save")
-    public Result<String> save(@RequestBody Map<String, Object> body) {
-        String targetType = (String) body.get("targetType");
-        Long targetId = Long.valueOf(body.get("targetId").toString());
-
-        List<DimensionWeight> weights = null;
-        Object wObj = body.get("weights");
-        if (wObj instanceof List) {
-            @SuppressWarnings("unchecked")
-            List<Map<String, Object>> rawList = (List<Map<String, Object>>) wObj;
-            weights = rawList.stream()
-                .filter(m -> {
-                    Boolean enabled = (Boolean) m.get("enabled");
-                    return enabled != null && enabled;
-                })
-                .map(m -> {
-                    DimensionWeight dw = new DimensionWeight();
-                    dw.setDimension((String) m.get("dimension"));
-                    Object weightObj = m.get("weight");
-                    dw.setWeight(weightObj != null ? Integer.valueOf(weightObj.toString()) : 0);
-                    return dw;
-                })
-                .collect(Collectors.toList());
-        }
-
-        dimensionWeightService.saveWeights(targetType, targetId, weights);
-        return Result.success("保存成功");
-    }
-
-    /**
-     * 读取维度权重列表
-     * POST /api/admin/dimension-weight/list
-     * Body: { targetType, targetId }
-     */
-    @PostMapping("/list")
-    public Result<List<DimensionWeight>> list(@RequestBody Map<String, Object> body) {
-        String targetType = (String) body.get("targetType");
-        Long targetId = Long.valueOf(body.get("targetId").toString());
-        return Result.success(dimensionWeightService.getByTarget(targetType, targetId));
-    }
-}

+ 0 - 32
cfc-backend/src/main/java/com/etotem/cfc/entity/DimensionWeight.java

@@ -1,32 +0,0 @@
-package com.etotem.cfc.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.Data;
-import java.io.Serializable;
-import java.util.Date;
-
-@Data
-@TableName("dimension_weights")
-public class DimensionWeight implements Serializable {
-
-    @TableId(type = IdType.AUTO)
-    private Long id;
-
-    /** article / activity / product */
-    private String targetType;
-
-    /** 关联实体ID */
-    private Long targetId;
-
-    /** body / mind / wisdom / action / wealth */
-    private String dimension;
-
-    /** 百分比权重,0-100 */
-    private Integer weight;
-
-    private Date createdAt;
-
-    private Date updatedAt;
-}

+ 0 - 9
cfc-backend/src/main/java/com/etotem/cfc/mapper/DimensionWeightMapper.java

@@ -1,9 +0,0 @@
-package com.etotem.cfc.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.etotem.cfc.entity.DimensionWeight;
-import org.apache.ibatis.annotations.Mapper;
-
-@Mapper
-public interface DimensionWeightMapper extends BaseMapper<DimensionWeight> {
-}

+ 0 - 68
cfc-backend/src/main/java/com/etotem/cfc/service/DimensionWeightService.java

@@ -1,68 +0,0 @@
-package com.etotem.cfc.service;
-
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.etotem.cfc.entity.DimensionWeight;
-import com.etotem.cfc.mapper.DimensionWeightMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
-
-@Slf4j
-@Service
-public class DimensionWeightService {
-
-    @Resource
-    private DimensionWeightMapper dimensionWeightMapper;
-
-    /**
-     * 批量保存维度权重(全量替换:先删后插)
-     * @param targetType article / activity / product
-     * @param targetId 关联实体ID
-     * @param weights 权重列表(只保存 enabled=true 的)
-     */
-    @Transactional
-    public void saveWeights(String targetType, Long targetId, List<DimensionWeight> weights) {
-        // 先删除该目标的所有权重
-        LambdaQueryWrapper<DimensionWeight> delWrapper = Wrappers.lambdaQuery();
-        delWrapper.eq(DimensionWeight::getTargetType, targetType)
-                   .eq(DimensionWeight::getTargetId, targetId);
-        dimensionWeightMapper.delete(delWrapper);
-
-        // 插入新权重
-        if (weights != null && !weights.isEmpty()) {
-            for (DimensionWeight w : weights) {
-                w.setTargetType(targetType);
-                w.setTargetId(targetId);
-                w.setCreatedAt(new Date());
-                w.setUpdatedAt(new Date());
-                dimensionWeightMapper.insert(w);
-            }
-        }
-    }
-
-    /**
-     * 读取某个实体的所有维度权重
-     */
-    public List<DimensionWeight> getByTarget(String targetType, Long targetId) {
-        LambdaQueryWrapper<DimensionWeight> wrapper = Wrappers.lambdaQuery();
-        wrapper.eq(DimensionWeight::getTargetType, targetType)
-               .eq(DimensionWeight::getTargetId, targetId)
-               .orderByAsc(DimensionWeight::getDimension);
-        return dimensionWeightMapper.selectList(wrapper);
-    }
-
-    /**
-     * 删除某个实体的所有维度权重
-     */
-    @Transactional
-    public void deleteByTarget(String targetType, Long targetId) {
-        LambdaQueryWrapper<DimensionWeight> wrapper = Wrappers.lambdaQuery();
-        wrapper.eq(DimensionWeight::getTargetType, targetType)
-               .eq(DimensionWeight::getTargetId, targetId);
-        dimensionWeightMapper.delete(wrapper);
-    }
-}

+ 0 - 9
cfc-web/src/api/dimension-weight.js

@@ -1,9 +0,0 @@
-import request from '@/utils/request'
-
-export function saveDimensionWeights(data) {
-  return request({ url: '/api/admin/dimension-weight/save', method: 'post', data })
-}
-
-export function getDimensionWeights(data) {
-  return request({ url: '/api/admin/dimension-weight/list', method: 'post', data })
-}

+ 0 - 303
cfc-web/src/components/DimensionWeightPicker.vue

@@ -1,303 +0,0 @@
-<template>
-  <div class="dimension-weight-picker">
-    <div class="dimension-rows">
-      <div
-        v-for="dim in dimensions"
-        :key="dim.value"
-        class="dimension-row"
-        :class="{ 'is-enabled': rowEnabled[dim.value] }"
-      >
-        <el-checkbox
-          v-model="rowEnabled[dim.value]"
-          @change="onToggle(dim.value)"
-          class="dim-check"
-        >
-          <span class="dim-label" :style="{ color: dim.color }">{{ dim.label }}</span>
-        </el-checkbox>
-
-        <div class="dim-slider" :class="{ 'is-locked': !rowEnabled[dim.value] }">
-          <el-slider
-            v-model="rowValues[dim.value]"
-            :disabled="!rowEnabled[dim.value]"
-            :min="0"
-            :max="100"
-            :step="5"
-            :show-tooltip="true"
-            @change="onSliderChange(dim.value)"
-          />
-        </div>
-
-        <el-input-number
-          v-model="rowValues[dim.value]"
-          :disabled="!rowEnabled[dim.value]"
-          :min="0"
-          :max="100"
-          :step="5"
-          size="small"
-          class="dim-num"
-          controls-position="right"
-          @change="onSliderChange(dim.value)"
-        />
-        <span class="dim-unit">%</span>
-      </div>
-    </div>
-
-    <div class="sum-bar">
-      <span class="sum-label">已分配:</span>
-      <div class="sum-track">
-        <div class="sum-fill" :class="sumClass" :style="{ width: totalSum + '%' }"></div>
-      </div>
-      <span class="sum-value" :class="sumClass">{{ totalSum }}%</span>
-      <span v-if="totalSum !== 100 && totalSum !== 0" class="sum-tip">(启用项合计应等于100%)</span>
-      <span v-if="totalSum === 100" class="sum-tip sum-ok">✓ 分配合理</span>
-    </div>
-
-    <div v-if="showPresets" class="preset-btns">
-      <el-button size="mini" @click="applyPreset('single', 'body')">100%身</el-button>
-      <el-button size="mini" @click="applyPreset('single', 'mind')">100%智</el-button>
-      <el-button size="mini" @click="applyPreset('single', 'action')">100%行</el-button>
-      <el-button size="mini" @click="applyPreset('single', 'wealth')">100%富</el-button>
-      <el-button size="mini" @click="applyPreset('single', 'heart')">100%心</el-button>
-      <el-button size="mini" @click="applyPreset('equal')">均分100%</el-button>
-      <el-button size="mini" type="text" style="margin-left:4px;" @click="clearAll">清空</el-button>
-    </div>
-  </div>
-</template>
-
-<script>
-export default {
-  name: 'DimensionWeightPicker',
-  props: {
-    // v-model: Array of { dimension: 'body', weight: 40, enabled: true }
-    value: {
-      type: Array,
-      default: function() {
-        return []
-      }
-    },
-    // 是否显示快捷预设按钮
-    showPresets: {
-      type: Boolean,
-      default: false
-    }
-  },
-  data() {
-    return {
-      rowEnabled: {
-        body: false,
-        mind: false,
-        action: false,
-        wealth: false,
-        heart: false
-      },
-      rowValues: {
-        body: 0,
-        mind: 0,
-        action: 0,
-        wealth: 0,
-        heart: 0
-      },
-      dimensions: [
-        { value: 'body',  label: '身·土', color: '#FF8C42' },
-        { value: 'mind',  label: '智·金', color: '#6366F1' },
-        { value: 'action', label: '行·木', color: '#10B981' },
-        { value: 'wealth', label: '富·水', color: '#F59E0B' },
-        { value: 'heart', label: '心·火', color: '#FF6B9D' }
-      ]
-    }
-  },
-  computed: {
-    totalSum() {
-      let sum = 0
-      for (var key in this.rowEnabled) {
-        if (this.rowEnabled[key]) {
-          sum += this.rowValues[key] || 0
-        }
-      }
-      return sum
-    },
-    sumClass() {
-      if (this.totalSum === 0) return 'sum-zero'
-      return this.totalSum === 100 ? 'sum-ok' : 'sum-error'
-    },
-    // 用于 v-model 输出的格式
-    outputValue() {
-      const result = []
-      for (var key in this.rowEnabled) {
-        if (this.rowEnabled[key]) {
-          result.push({
-            dimension: key,
-            weight: this.rowValues[key] || 0,
-            enabled: true
-          })
-        }
-      }
-      return result
-    }
-  },
-  watch: {
-    value: {
-      handler(val) {
-        this.loadFromValue(val || [])
-      },
-      immediate: true,
-      deep: true
-    }
-  },
-  methods: {
-    loadFromValue(val) {
-      // 重置
-      for (var key in this.rowEnabled) {
-        this.rowEnabled[key] = false
-        this.rowValues[key] = 0
-      }
-      // 加载外部值
-      if (Array.isArray(val)) {
-        for (var i = 0; i < val.length; i++) {
-          var item = val[i]
-          if (item.dimension && this.rowEnabled.hasOwnProperty(item.dimension)) {
-            this.rowEnabled[item.dimension] = true
-            this.rowValues[item.dimension] = item.weight || 0
-          }
-        }
-      }
-    },
-    onToggle(dim) {
-      // 如果启用但值为0,默认给一个值
-      if (this.rowEnabled[dim] && this.rowValues[dim] === 0) {
-        this.rowValues[dim] = 100
-      }
-      this.emitInput()
-    },
-    onSliderChange() {
-      this.emitInput()
-    },
-    emitInput() {
-      this.$emit('input', this.outputValue)
-    },
-    applyPreset(type, dim) {
-      // 先清空
-      for (var key in this.rowEnabled) {
-        this.rowEnabled[key] = false
-        this.rowValues[key] = 0
-      }
-      if (type === 'single' && dim) {
-        this.rowEnabled[dim] = true
-        this.rowValues[dim] = 100
-      } else if (type === 'equal') {
-        // 均分给所有5个
-        var each = Math.floor(100 / 5)
-        var remainder = 100 - each * 5
-        for (var i = 0; i < this.dimensions.length; i++) {
-          var d = this.dimensions[i]
-          this.rowEnabled[d.value] = true
-          this.rowValues[d.value] = each + (i < remainder ? 1 : 0)
-        }
-      }
-      this.emitInput()
-    },
-    clearAll() {
-      for (var key in this.rowEnabled) {
-        this.rowEnabled[key] = false
-        this.rowValues[key] = 0
-      }
-      this.emitInput()
-    }
-  }
-}
-</script>
-
-<style scoped>
-.dimension-weight-picker {
-  font-size: 14px;
-}
-.dimension-rows {
-  border: 1px solid #dcdfe6;
-  border-radius: 4px;
-  padding: 8px 12px;
-  background: #fafafa;
-}
-.dimension-row {
-  display: flex;
-  align-items: center;
-  padding: 6px 0;
-  border-bottom: 1px solid #f0f0f0;
-}
-.dimension-row:last-child {
-  border-bottom: none;
-}
-.dim-check {
-  width: 90px;
-  min-width: 90px;
-}
-.dim-label {
-  font-weight: 600;
-  font-size: 13px;
-}
-.dim-slider {
-  flex: 1;
-  margin: 0 12px;
-  opacity: 0.4;
-  pointer-events: none;
-  transition: opacity 0.2s;
-}
-.dim-slider.is-locked {
-  opacity: 1;
-  pointer-events: auto;
-}
-.dim-num {
-  width: 80px;
-}
-.dim-unit {
-  color: #999;
-  margin-left: 4px;
-  font-size: 12px;
-}
-.sum-bar {
-  display: flex;
-  align-items: center;
-  margin-top: 10px;
-  gap: 8px;
-}
-.sum-label {
-  color: #666;
-  font-size: 13px;
-  min-width: 56px;
-}
-.sum-track {
-  flex: 1;
-  height: 8px;
-  background: #e4e7ed;
-  border-radius: 4px;
-  overflow: hidden;
-}
-.sum-fill {
-  height: 100%;
-  border-radius: 4px;
-  transition: width 0.3s, background 0.3s;
-}
-.sum-zero .sum-fill { background: #e4e7ed; }
-.sum-ok .sum-fill { background: #67c23a; }
-.sum-error .sum-fill { background: #f56c6c; }
-.sum-value {
-  min-width: 40px;
-  font-size: 13px;
-  font-weight: 600;
-}
-.sum-zero .sum-value { color: #999; }
-.sum-ok .sum-value { color: #67c23a; }
-.sum-error .sum-value { color: #f56c6c; }
-.sum-tip {
-  font-size: 12px;
-  color: #f56c6c;
-}
-.sum-ok .sum-tip {
-  color: #67c23a;
-}
-.preset-btns {
-  margin-top: 8px;
-  display: flex;
-  flex-wrap: wrap;
-  gap: 4px;
-}
-</style>