ソースを参照

feat(physical): 更新标签实体字段并调整相关查询逻辑

- 将标签名称字段 name 更改为 serviceName 和 serviceCode
- 更新数据库映射文件中的字段选择和条件查询
- 修改服务层校验逻辑以适应新字段
- 调整插入和更新操作的字段映射
- 更新 PhysicalTagMapper 接口方法参数及 SQL 查询语句
- 修改 BO 和 VO 类中对应的属性名以匹配新的字段定义
fugui001 2 週間 前
コミット
02cb5d5f0c

+ 3 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/domain/PhysicalTag.java

@@ -31,7 +31,9 @@ public class PhysicalTag extends BaseEntity {
     /**
      * 标签名称,如“美食”、“特产”
      */
-    private String name;
+    private String serviceName;
+
+    private String serviceCode;
 
     /**
      * 图标URL,如 /icons/food.png

+ 3 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/domain/bo/PhysicalTagBo.java

@@ -32,7 +32,9 @@ public class PhysicalTagBo extends BaseEntity {
      * 标签名称,如“美食”、“特产”
      */
     @NotBlank(message = "标签名称,如“美食”、“特产”不能为空", groups = { AddGroup.class, EditGroup.class })
-    private String name;
+    private String serviceName;
+
+    private String serviceCode;
 
     /**
      * 图标URL,如 /icons/food.png

+ 3 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/domain/vo/PhysicalTagVo.java

@@ -38,7 +38,9 @@ public class PhysicalTagVo implements Serializable {
      * 标签名称,如“美食”、“特产”
      */
     @ExcelProperty(value = "标签名称,如“美食”、“特产”")
-    private String name;
+    private String serviceName;
+
+    private String serviceCode;
 
     /**
      * 图标URL,如 /icons/food.png

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/mapper/PhysicalTagMapper.java

@@ -40,6 +40,6 @@ public interface PhysicalTagMapper extends BaseMapperPlus<PhysicalTag, PhysicalT
     List<PhysicalTagVo> selectAllPhysicalTagsList(@Param("ew") Wrapper<PhysicalTag> wrapper);
 
     @InterceptorIgnore(tenantLine = "true")
-    PhysicalTagVo selectAllPhysicalTagsByName(String name,Long id);
+    PhysicalTagVo selectAllPhysicalTagsByName(@Param("serviceName") String serviceName,Long id);
 
 }

+ 5 - 4
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/service/impl/PhysicalTagServiceImpl.java

@@ -75,7 +75,8 @@ public class PhysicalTagServiceImpl implements IPhysicalTagService {
         Map<String, Object> params = bo.getParams();
         LambdaQueryWrapper<PhysicalTag> lqw = Wrappers.lambdaQuery();
         lqw.orderByAsc(PhysicalTag::getId);
-        lqw.like(StringUtils.isNotBlank(bo.getName()), PhysicalTag::getName, bo.getName());
+        lqw.like(StringUtils.isNotBlank(bo.getServiceCode()), PhysicalTag::getServiceCode, bo.getServiceCode());
+        lqw.like(StringUtils.isNotBlank(bo.getServiceName()), PhysicalTag::getServiceName, bo.getServiceName());
         lqw.eq(StringUtils.isNotBlank(bo.getIconUrl()), PhysicalTag::getIconUrl, bo.getIconUrl());
         lqw.eq(StringUtils.isNotBlank(bo.getColorCode()), PhysicalTag::getColorCode, bo.getColorCode());
         lqw.eq(bo.getIsEnabled() != null, PhysicalTag::getIsEnabled, bo.getIsEnabled());
@@ -123,13 +124,13 @@ public class PhysicalTagServiceImpl implements IPhysicalTagService {
     private void validEntityBeforeSave(PhysicalTag entity){
         //TODO 做一些数据校验,如唯一约束
         Long id = entity.getId();
-        String name = entity.getName();
+        String name = entity.getServiceName();
         if (StringUtils.isBlank(name)) {
-            throw new ServiceException("标签名称不能为空");
+            throw new ServiceException("名称不能为空");
         }
         PhysicalTagVo physicalTagVo = baseMapper.selectAllPhysicalTagsByName(name,id);
         if(physicalTagVo!=null){
-            throw new ServiceException("标签名称 '" + name + "' 已存在");
+            throw new ServiceException("名称 '" + name + "' 已存在");
         }
     }
 

+ 9 - 8
ruoyi-modules/ruoyi-system/src/main/resources/mapper/physical/PhysicalTagMapper.xml

@@ -6,7 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectAllPhysicalTagsPage" resultType="org.dromara.physical.domain.vo.PhysicalTagVo">
-        SELECT id, name, icon_url as iconUrl, color_code as colorCode,
+        SELECT id, service_name,service_code, icon_url as iconUrl, color_code as colorCode,
                is_enabled as isEnabled, sort_order as sortOrder,
                remark, created_at as createdAt, updated_at as updatedAt,
                created_by as createdBy, updated_by as updatedBy
@@ -15,7 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
   <select id="selectAllPhysicalTagsList" resultType="org.dromara.physical.domain.vo.PhysicalTagVo">
-        SELECT id, name, icon_url as iconUrl, color_code as colorCode,
+        SELECT id, service_name,service_code, icon_url as iconUrl, color_code as colorCode,
                is_enabled as isEnabled, sort_order as sortOrder,
                remark, created_at as createdAt, updated_at as updatedAt,
                created_by as createdBy, updated_by as updatedBy
@@ -24,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectAllPhysicalTagsById" resultType="org.dromara.physical.domain.vo.PhysicalTagVo">
-        SELECT id, name, icon_url as iconUrl, color_code as colorCode,
+        SELECT id, service_name,service_code, icon_url as iconUrl, color_code as colorCode,
                is_enabled as isEnabled, sort_order as sortOrder,
                remark, created_at as createdAt, updated_at as updatedAt,
                created_by as createdBy, updated_by as updatedBy
@@ -32,11 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectAllPhysicalTagsByName" resultType="org.dromara.physical.domain.vo.PhysicalTagVo">
-        SELECT id, name, icon_url as iconUrl, color_code as colorCode,
+        SELECT id, service_name,service_code, icon_url as iconUrl, color_code as colorCode,
                is_enabled as isEnabled, sort_order as sortOrder,
                remark, created_at as createdAt, updated_at as updatedAt,
                created_by as createdBy, updated_by as updatedBy
-        FROM physical_tag  where name=#{name}
+        FROM physical_tag  where service_name=#{serviceName}
         <if test="id != null">
             and id!=#{id}
         </if>
@@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertPhysicalTag"  useGeneratedKeys="true" keyProperty="id">
         INSERT INTO physical_tag (
             <trim suffixOverrides=",">
-                <if test="name != null and name.trim() != ''">name,</if>
+                <if test="serviceName != null and serviceName.trim() != ''">service_name,</if>
                 <if test="iconUrl != null and iconUrl != ''">icon_url,</if>
                 <if test="colorCode != null and colorCode != ''">color_code,</if>
                 <if test="isEnabled != null">is_enabled,</if>
@@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </trim>
         ) VALUES (
             <trim suffixOverrides=",">
-                <if test="name != null and name.trim() != ''">#{name},</if>
+                <if test="serviceName != null and serviceName.trim() != ''">#{serviceName},</if>
                 <if test="iconUrl != null and iconUrl != ''">#{iconUrl},</if>
                 <if test="colorCode != null and colorCode != ''">#{colorCode},</if>
                 <if test="isEnabled != null">#{isEnabled},</if>
@@ -76,7 +76,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updatePhysicalTag">
         UPDATE physical_tag
         <set>
-            <if test="name != null and name.trim() != ''">name = #{name},</if>
+            <if test="serviceName != null and serviceName.trim() != ''">service_name = #{serviceName},</if>
+            <if test="serviceCode != null and serviceCode.trim() != ''">service_code = #{serviceCode},</if>
             <if test="iconUrl != null and iconUrl != ''">icon_url = #{iconUrl},</if>
             <if test="colorCode != null and colorCode != ''">color_code = #{colorCode},</if>
             <if test="isEnabled != null">is_enabled = #{isEnabled},</if>