Pārlūkot izejas kodu

feat(physical): 新增服务标签管理功能

- 新增服务标签实体类 PhysicalTag 及其对应的数据表映射
- 实现服务标签业务对象 PhysicalTagBo 和视图对象 PhysicalTagVo
- 提供服务标签的增删改查接口,支持分页和导出功能
- 配置 MyBatis Plus Mapper 接口及 XML 映射文件
- 实现服务标签唯一性校验和基础数据验证逻辑
- 添加权限控制注解,确保接口访问安全
- 支持通过 Excel 导出服务标签列表数据
fugui001 3 nedēļas atpakaļ
vecāks
revīzija
a50bebf923

+ 105 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/controller/PhysicalTagController.java

@@ -0,0 +1,105 @@
+package org.dromara.physical.controller;
+
+import java.util.List;
+
+import lombok.RequiredArgsConstructor;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.constraints.*;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.dromara.physical.domain.bo.PhysicalTagBo;
+import org.dromara.physical.domain.vo.PhysicalTagVo;
+import org.dromara.physical.service.IPhysicalTagService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.dromara.common.idempotent.annotation.RepeatSubmit;
+import org.dromara.common.log.annotation.Log;
+import org.dromara.common.web.core.BaseController;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import org.dromara.common.log.enums.BusinessType;
+import org.dromara.common.excel.utils.ExcelUtil;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+
+/**
+ * 服务标签
+ *
+ * @author Lion Li
+ * @date 2025-12-02
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/physical/tag")
+public class PhysicalTagController extends BaseController {
+
+    private final IPhysicalTagService physicalTagService;
+
+    /**
+     * 查询服务标签列表
+     */
+    @SaCheckPermission("physical:tag:list")
+    @GetMapping("/list")
+    public TableDataInfo<PhysicalTagVo> list(PhysicalTagBo bo, PageQuery pageQuery) {
+        return physicalTagService.queryPageList(bo, pageQuery);
+    }
+
+    /**
+     * 导出服务标签列表
+     */
+    @SaCheckPermission("physical:tag:export")
+    @Log(title = "服务标签", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(PhysicalTagBo bo, HttpServletResponse response) {
+        List<PhysicalTagVo> list = physicalTagService.queryList(bo);
+        ExcelUtil.exportExcel(list, "服务标签", PhysicalTagVo.class, response);
+    }
+
+    /**
+     * 获取服务标签详细信息
+     *
+     * @param id 主键
+     */
+    @SaCheckPermission("physical:tag:query")
+    @GetMapping("/{id}")
+    public R<PhysicalTagVo> getInfo(@NotNull(message = "主键不能为空")
+                                     @PathVariable Long id) {
+        return R.ok(physicalTagService.queryById(id));
+    }
+
+    /**
+     * 新增服务标签
+     */
+    @SaCheckPermission("physical:tag:add")
+    @Log(title = "服务标签", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping()
+    public R<Void> add(@Validated(AddGroup.class) @RequestBody PhysicalTagBo bo) {
+        return toAjax(physicalTagService.insertByBo(bo));
+    }
+
+    /**
+     * 修改服务标签
+     */
+    @SaCheckPermission("physical:tag:edit")
+    @Log(title = "服务标签", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
+    @PutMapping()
+    public R<Void> edit(@Validated(EditGroup.class) @RequestBody PhysicalTagBo bo) {
+        return toAjax(physicalTagService.updateByBo(bo));
+    }
+
+    /**
+     * 删除服务标签
+     *
+     * @param ids 主键串
+     */
+    @SaCheckPermission("physical:tag:remove")
+    @Log(title = "服务标签", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public R<Void> remove(@NotEmpty(message = "主键不能为空")
+                          @PathVariable Long[] ids) {
+        return toAjax(physicalTagService.deleteWithValidByIds(List.of(ids), true));
+    }
+}

+ 82 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/domain/PhysicalTag.java

@@ -0,0 +1,82 @@
+package org.dromara.physical.domain;
+
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.util.Date;
+
+import java.io.Serial;
+
+/**
+ * 服务标签对象 physical_tag
+ *
+ * @author Lion Li
+ * @date 2025-12-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("physical_tag")
+public class PhysicalTag extends BaseEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @TableId(value = "id")
+    private Long id;
+
+    /**
+     * 标签名称,如“美食”、“特产”
+     */
+    private String name;
+
+    /**
+     * 图标URL,如 /icons/food.png
+     */
+    private String iconUrl;
+
+    /**
+     * 背景色或文字色,如 #FF6B35
+     */
+    private String colorCode;
+
+    /**
+     * 是否启用(true=显示)
+     */
+    private Long isEnabled;
+
+    /**
+     * 排序权重,越小越靠前
+     */
+    private Long sortOrder;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     *
+     */
+    private Date createdAt;
+
+    /**
+     *
+     */
+    private Date updatedAt;
+
+    /**
+     *
+     */
+    private Long createdBy;
+
+    /**
+     *
+     */
+    private Long updatedBy;
+
+
+}

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

@@ -0,0 +1,83 @@
+package org.dromara.physical.domain.bo;
+
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import jakarta.validation.constraints.*;
+import org.dromara.physical.domain.PhysicalTag;
+
+import java.util.Date;
+
+/**
+ * 服务标签业务对象 physical_tag
+ *
+ * @author Lion Li
+ * @date 2025-12-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = PhysicalTag.class, reverseConvertGenerate = false)
+public class PhysicalTagBo extends BaseEntity {
+
+    /**
+     * 主键ID
+     */
+    @NotNull(message = "主键ID不能为空", groups = { EditGroup.class })
+    private Long id;
+
+    /**
+     * 标签名称,如“美食”、“特产”
+     */
+    @NotBlank(message = "标签名称,如“美食”、“特产”不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String name;
+
+    /**
+     * 图标URL,如 /icons/food.png
+     */
+    private String iconUrl;
+
+    /**
+     * 背景色或文字色,如 #FF6B35
+     */
+    private String colorCode;
+
+    /**
+     * 是否启用(true=显示)
+     */
+    private Long isEnabled;
+
+    /**
+     * 排序权重,越小越靠前
+     */
+    private Long sortOrder;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     *
+     */
+    private Date createdAt;
+
+    /**
+     *
+     */
+    private Date updatedAt;
+
+    /**
+     *
+     */
+    private Long createdBy;
+
+    /**
+     *
+     */
+    private Long updatedBy;
+
+
+}

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

@@ -0,0 +1,99 @@
+package org.dromara.physical.domain.vo;
+
+import java.util.Date;
+import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
+import cn.idev.excel.annotation.ExcelProperty;
+import org.dromara.common.excel.annotation.ExcelDictFormat;
+import org.dromara.common.excel.convert.ExcelDictConvert;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import org.dromara.physical.domain.PhysicalTag;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+
+
+/**
+ * 服务标签视图对象 physical_tag
+ *
+ * @author Lion Li
+ * @date 2025-12-02
+ */
+@Data
+@ExcelIgnoreUnannotated
+@AutoMapper(target = PhysicalTag.class)
+public class PhysicalTagVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @ExcelProperty(value = "主键ID")
+    private Long id;
+
+    /**
+     * 标签名称,如“美食”、“特产”
+     */
+    @ExcelProperty(value = "标签名称,如“美食”、“特产”")
+    private String name;
+
+    /**
+     * 图标URL,如 /icons/food.png
+     */
+    @ExcelProperty(value = "图标URL,如 /icons/food.png")
+    private String iconUrl;
+
+    /**
+     * 背景色或文字色,如 #FF6B35
+     */
+    @ExcelProperty(value = "背景色或文字色,如 #FF6B35")
+    private String colorCode;
+
+    /**
+     * 是否启用(true=显示)
+     */
+    @ExcelProperty(value = "是否启用", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(readConverterExp = "t=rue=显示")
+    private Long isEnabled;
+
+    /**
+     * 排序权重,越小越靠前
+     */
+    @ExcelProperty(value = "排序权重,越小越靠前")
+    private Long sortOrder;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注")
+    private String remark;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Date createdAt;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Date updatedAt;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Long createdBy;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Long updatedBy;
+
+
+}

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

@@ -0,0 +1,45 @@
+package org.dromara.physical.mapper;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+import org.dromara.physical.domain.PhysicalTag;
+import org.dromara.physical.domain.vo.PhysicalTagVo;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 服务标签Mapper接口
+ *
+ * @author Lion Li
+ * @date 2025-12-02
+ */
+@DS("mysql2")
+public interface PhysicalTagMapper extends BaseMapperPlus<PhysicalTag, PhysicalTagVo> {
+
+    @InterceptorIgnore(tenantLine = "true")
+    Page<PhysicalTagVo> selectAllPhysicalTagsPage(@Param("page") Page<PhysicalTag> page, @Param("ew") Wrapper<PhysicalTag> wrapper);
+
+    @InterceptorIgnore(tenantLine = "true")
+    PhysicalTagVo selectAllPhysicalTagsById(Long id);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int updatePhysicalTag(PhysicalTag update);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int insertPhysicalTag(PhysicalTag insert);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int deletePhysicalTag(@Param("ids") Collection<Long> ids);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<PhysicalTagVo> selectAllPhysicalTagsList(@Param("ew") Wrapper<PhysicalTag> wrapper);
+
+    @InterceptorIgnore(tenantLine = "true")
+    PhysicalTagVo selectAllPhysicalTagsByName(String name,Long id);
+
+}

+ 68 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/physical/service/IPhysicalTagService.java

@@ -0,0 +1,68 @@
+package org.dromara.physical.service;
+
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.physical.domain.bo.PhysicalTagBo;
+import org.dromara.physical.domain.vo.PhysicalTagVo;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 服务标签Service接口
+ *
+ * @author Lion Li
+ * @date 2025-12-02
+ */
+public interface IPhysicalTagService {
+
+    /**
+     * 查询服务标签
+     *
+     * @param id 主键
+     * @return 服务标签
+     */
+    PhysicalTagVo queryById(Long id);
+
+    /**
+     * 分页查询服务标签列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 服务标签分页列表
+     */
+    TableDataInfo<PhysicalTagVo> queryPageList(PhysicalTagBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询符合条件的服务标签列表
+     *
+     * @param bo 查询条件
+     * @return 服务标签列表
+     */
+    List<PhysicalTagVo> queryList(PhysicalTagBo bo);
+
+    /**
+     * 新增服务标签
+     *
+     * @param bo 服务标签
+     * @return 是否新增成功
+     */
+    Boolean insertByBo(PhysicalTagBo bo);
+
+    /**
+     * 修改服务标签
+     *
+     * @param bo 服务标签
+     * @return 是否修改成功
+     */
+    Boolean updateByBo(PhysicalTagBo bo);
+
+    /**
+     * 校验并批量删除服务标签信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+}

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

@@ -0,0 +1,150 @@
+package org.dromara.physical.service.impl;
+
+import org.dromara.common.core.exception.ServiceException;
+import org.dromara.common.core.utils.MapstructUtils;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.dromara.physical.domain.PhysicalTag;
+import org.dromara.physical.domain.bo.PhysicalTagBo;
+import org.dromara.physical.domain.vo.PhysicalTagVo;
+import org.dromara.physical.mapper.PhysicalTagMapper;
+import org.dromara.physical.service.IPhysicalTagService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * 服务标签Service业务层处理
+ *
+ * @author Lion Li
+ * @date 2025-12-02
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service
+public class PhysicalTagServiceImpl implements IPhysicalTagService {
+
+    private final PhysicalTagMapper baseMapper;
+
+    /**
+     * 查询服务标签
+     *
+     * @param id 主键
+     * @return 服务标签
+     */
+    @Override
+    public PhysicalTagVo queryById(Long id){
+        return baseMapper.selectAllPhysicalTagsById(id);
+    }
+
+    /**
+     * 分页查询服务标签列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 服务标签分页列表
+     */
+    @Override
+    public TableDataInfo<PhysicalTagVo> queryPageList(PhysicalTagBo bo, PageQuery pageQuery) {
+        LambdaQueryWrapper<PhysicalTag> lqw = buildQueryWrapper(bo);
+        Page<PhysicalTagVo> result = baseMapper.selectAllPhysicalTagsPage(pageQuery.build(), lqw);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 查询符合条件的服务标签列表
+     *
+     * @param bo 查询条件
+     * @return 服务标签列表
+     */
+    @Override
+    public List<PhysicalTagVo> queryList(PhysicalTagBo bo) {
+        LambdaQueryWrapper<PhysicalTag> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectAllPhysicalTagsList(lqw);
+    }
+
+    private LambdaQueryWrapper<PhysicalTag> buildQueryWrapper(PhysicalTagBo bo) {
+        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.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());
+        lqw.eq(bo.getSortOrder() != null, PhysicalTag::getSortOrder, bo.getSortOrder());
+        lqw.eq(bo.getCreatedAt() != null, PhysicalTag::getCreatedAt, bo.getCreatedAt());
+        lqw.eq(bo.getUpdatedAt() != null, PhysicalTag::getUpdatedAt, bo.getUpdatedAt());
+        lqw.eq(bo.getCreatedBy() != null, PhysicalTag::getCreatedBy, bo.getCreatedBy());
+        lqw.eq(bo.getUpdatedBy() != null, PhysicalTag::getUpdatedBy, bo.getUpdatedBy());
+        return lqw;
+    }
+
+    /**
+     * 新增服务标签
+     *
+     * @param bo 服务标签
+     * @return 是否新增成功
+     */
+    @Override
+    public Boolean insertByBo(PhysicalTagBo bo) {
+        PhysicalTag add = MapstructUtils.convert(bo, PhysicalTag.class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insertPhysicalTag(add) > 0;
+        if (flag) {
+            bo.setId(add.getId());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改服务标签
+     *
+     * @param bo 服务标签
+     * @return 是否修改成功
+     */
+    @Override
+    public Boolean updateByBo(PhysicalTagBo bo) {
+        PhysicalTag update = MapstructUtils.convert(bo, PhysicalTag.class);
+        validEntityBeforeSave(update);
+        return baseMapper.updatePhysicalTag(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(PhysicalTag entity){
+        //TODO 做一些数据校验,如唯一约束
+        Long id = entity.getId();
+        String name = entity.getName();
+        if (StringUtils.isBlank(name)) {
+            throw new ServiceException("标签名称不能为空");
+        }
+        PhysicalTagVo physicalTagVo = baseMapper.selectAllPhysicalTagsByName(name,id);
+        if(physicalTagVo!=null){
+            throw new ServiceException("标签名称 '" + name + "' 已存在");
+        }
+    }
+
+    /**
+     * 校验并批量删除服务标签信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deletePhysicalTag(ids) > 0;
+    }
+}

+ 103 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/physical/PhysicalTagMapper.xml

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.dromara.physical.mapper.PhysicalTagMapper">
+
+
+    <select id="selectAllPhysicalTagsPage" resultType="org.dromara.physical.domain.vo.PhysicalTagVo">
+        SELECT id, name, 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  ${ew.customSqlSegment}
+    </select>
+
+
+  <select id="selectAllPhysicalTagsList" resultType="org.dromara.physical.domain.vo.PhysicalTagVo">
+        SELECT id, name, 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  ${ew.customSqlSegment}
+    </select>
+
+
+    <select id="selectAllPhysicalTagsById" resultType="org.dromara.physical.domain.vo.PhysicalTagVo">
+        SELECT id, name, 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 id=#{id}
+    </select>
+
+    <select id="selectAllPhysicalTagsByName" resultType="org.dromara.physical.domain.vo.PhysicalTagVo">
+        SELECT id, name, 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}
+        <if test="id != null">
+            and id!=#{id}
+        </if>
+    </select>
+
+
+    <insert id="insertPhysicalTag"  useGeneratedKeys="true" keyProperty="id">
+        INSERT INTO physical_tag (
+            <trim suffixOverrides=",">
+                <if test="name != null and name.trim() != ''">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>
+                <if test="sortOrder != null">sort_order,</if>
+                <if test="remark != null">remark,</if>
+                <if test="createdBy != null">created_by,</if>
+                <if test="updatedBy != null">updated_by,</if>
+                created_at,
+                updated_at
+            </trim>
+        ) VALUES (
+            <trim suffixOverrides=",">
+                <if test="name != null and name.trim() != ''">#{name},</if>
+                <if test="iconUrl != null and iconUrl != ''">#{iconUrl},</if>
+                <if test="colorCode != null and colorCode != ''">#{colorCode},</if>
+                <if test="isEnabled != null">#{isEnabled},</if>
+                <if test="sortOrder != null">#{sortOrder},</if>
+                <if test="remark != null">#{remark},</if>
+                <if test="createdBy != null">#{createdBy},</if>
+                <if test="updatedBy != null">#{updatedBy},</if>
+                NOW(),
+                NOW()
+            </trim>
+        )
+    </insert>
+
+    <update id="updatePhysicalTag">
+        UPDATE physical_tag
+        <set>
+            <if test="name != null and name.trim() != ''">name = #{name},</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>
+            <if test="sortOrder != null">sort_order = #{sortOrder},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
+            updated_at = NOW()
+        </set>
+        WHERE id = #{id} AND id IS NOT NULL
+    </update>
+
+    <delete id="deletePhysicalTag">
+        DELETE FROM physical_tag
+        <where>
+            id IN
+            <foreach item="id" collection="ids" open="(" separator="," close=")">
+                <if test="id > 0">
+                    #{id}
+                </if>
+            </foreach>
+        </where>
+    </delete>
+
+</mapper>