feat(sip): 实现代码生成功能
- 新增 CodeGenTable 实体类,用于存储代码生成规则 - 添加 CodeGenTableMapper 接口和 XML 文件,实现代码生成规则的持久化 - 实现 CodeGenTableServiceImpl 服务类,提供代码生成逻辑 - 在 OrderDeliveryServiceImpl 中集成代码生成功能,用于生成发货记录代码- 在生产配置中添加 demoEnabled 属性,控制是否启用演示模式master
parent
41445b32cd
commit
3623c5564f
|
@ -1,4 +1,5 @@
|
||||||
ruoyi:
|
ruoyi:
|
||||||
|
demoEnabled: false
|
||||||
excelTemplate: /home/application/excelTemplate
|
excelTemplate: /home/application/excelTemplate
|
||||||
server:
|
server:
|
||||||
# 服务器的HTTP端口,默认为80
|
# 服务器的HTTP端口,默认为80
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
package com.ruoyi.sip.domain;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代码生成业务表(CodeGenTable)实体类
|
||||||
|
*
|
||||||
|
* @author ch
|
||||||
|
* @since 2025-05-21 14:39:07
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CodeGenTable {
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 表名称
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String tableName;
|
||||||
|
/**
|
||||||
|
* 表描述
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String tableComment;
|
||||||
|
/**
|
||||||
|
* code前缀
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String prefix;
|
||||||
|
/**
|
||||||
|
* 流水号
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Integer number;
|
||||||
|
/**
|
||||||
|
* code生成日期
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Date genDate;
|
||||||
|
private String dateFormat;
|
||||||
|
/**
|
||||||
|
* 流水号长度
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Integer numberLength;
|
||||||
|
/**
|
||||||
|
* 创建者
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String createBy;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新者
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String updateBy;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
private Long version;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public enum TableNameEnum{
|
||||||
|
ORDER_DELIVERY("order_delivery", "发货记录"),
|
||||||
|
;
|
||||||
|
private final String name;
|
||||||
|
private final String desc;
|
||||||
|
TableNameEnum(String type, String desc) {
|
||||||
|
this.name = type;
|
||||||
|
this.desc = desc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.ruoyi.sip.mapper;
|
||||||
|
|
||||||
|
import com.ruoyi.sip.domain.CodeGenTable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ch
|
||||||
|
* @Desc 代码生成业务表(CodeGenTable)表数据库访问层
|
||||||
|
* @Date 2025-05-21 14:39:07
|
||||||
|
*/
|
||||||
|
public interface CodeGenTableMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过实体作为筛选条件查询
|
||||||
|
*
|
||||||
|
* @param codeGenTable 实例对象
|
||||||
|
* @return 对象列表
|
||||||
|
*/
|
||||||
|
List<CodeGenTable> queryAll(CodeGenTable codeGenTable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查详情
|
||||||
|
*/
|
||||||
|
CodeGenTable queryById(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*/
|
||||||
|
int insert(CodeGenTable codeGenTable);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改数据
|
||||||
|
*/
|
||||||
|
int update(CodeGenTable codeGenTable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键删除数据
|
||||||
|
*/
|
||||||
|
int deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id批量删除代码生成业务表
|
||||||
|
*/
|
||||||
|
int batchRemove(Long[] ids);
|
||||||
|
|
||||||
|
CodeGenTable selectByTableName(String tableName);
|
||||||
|
|
||||||
|
int updateNumber(CodeGenTable codeGeneratorConfig);
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.ruoyi.sip.service;
|
||||||
|
|
||||||
|
import com.ruoyi.sip.domain.CodeGenTable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ch
|
||||||
|
* @Desc 代码生成业务表(CodeGenTable)表服务接口
|
||||||
|
* @Date 2025-05-21 14:39:07
|
||||||
|
*/
|
||||||
|
public interface ICodeGenTableService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过实体作为筛选条件查询
|
||||||
|
*/
|
||||||
|
List<CodeGenTable> queryAll(CodeGenTable codeGenTable);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查详情
|
||||||
|
*/
|
||||||
|
CodeGenTable queryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增数据
|
||||||
|
*/
|
||||||
|
int insert(CodeGenTable codeGenTable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改数据
|
||||||
|
*/
|
||||||
|
int update(CodeGenTable codeGenTable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过主键删除数据
|
||||||
|
*/
|
||||||
|
int deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id批量删除代码生成业务表
|
||||||
|
*/
|
||||||
|
int batchRemove(Long[] ids);
|
||||||
|
|
||||||
|
String generateCode(String tableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
package com.ruoyi.sip.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.sip.domain.CodeGenTable;
|
||||||
|
import com.ruoyi.sip.mapper.CodeGenTableMapper;
|
||||||
|
import com.ruoyi.sip.service.ICodeGenTableService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author ch
|
||||||
|
* @Desc 代码生成业务表(CodeGenTable)表服务实现类
|
||||||
|
* @Date 2025-05-21 14:39:08
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CodeGenTableServiceImpl implements ICodeGenTableService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CodeGenTableMapper codeGenTableMapper;
|
||||||
|
public static final String DELIMIT = "-";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询列表数据
|
||||||
|
*
|
||||||
|
* @param codeGenTable 实例对象
|
||||||
|
* @return 对象列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<CodeGenTable> queryAll(CodeGenTable codeGenTable) {
|
||||||
|
List<CodeGenTable> dataList = codeGenTableMapper.queryAll(codeGenTable);
|
||||||
|
return dataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodeGenTable queryById(Long id) {
|
||||||
|
return codeGenTableMapper.queryById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insert(CodeGenTable codeGenTable) {
|
||||||
|
return codeGenTableMapper.insert(codeGenTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(CodeGenTable codeGenTable) {
|
||||||
|
return codeGenTableMapper.update(codeGenTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteById(Long id) {
|
||||||
|
return codeGenTableMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过id批量删除代码生成业务表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int batchRemove(Long[] ids) {
|
||||||
|
return codeGenTableMapper.batchRemove(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generateCode(String tableName) {
|
||||||
|
CodeGenTable codeGeneratorConfig = codeGenTableMapper.selectByTableName(tableName);
|
||||||
|
|
||||||
|
if (codeGeneratorConfig == null) {
|
||||||
|
throw new ServiceException(StringUtils.format("未找到[{}]对应编码生成规则", tableName));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据表字段动态获取生成规则
|
||||||
|
String prefix = codeGeneratorConfig.getPrefix();
|
||||||
|
int numberLength = codeGeneratorConfig.getNumberLength();
|
||||||
|
|
||||||
|
|
||||||
|
CodeGenTable updateDto = new CodeGenTable();
|
||||||
|
updateDto.setTableName(tableName);
|
||||||
|
updateDto.setVersion(codeGeneratorConfig.getVersion());
|
||||||
|
|
||||||
|
if (!DateUtils.isSameDay(codeGeneratorConfig.getGenDate(), DateUtils.getNowDate())) {
|
||||||
|
updateDto.setNumber(0);
|
||||||
|
updateDto.setGenDate(DateUtils.getNowDate());
|
||||||
|
} else {
|
||||||
|
updateDto.setNumber(codeGeneratorConfig.getNumber());
|
||||||
|
}
|
||||||
|
String datePart = DateUtils.parseDateToStr(codeGeneratorConfig.getDateFormat(), DateUtils.getNowDate());
|
||||||
|
// 使用乐观锁机制更新 number
|
||||||
|
int currentSequence = updateDto.getNumber();
|
||||||
|
String sequenceStr = String.format("%0" + numberLength + "d", currentSequence);
|
||||||
|
|
||||||
|
// 构造唯一 code
|
||||||
|
String generatedCode = prefix + DELIMIT + datePart + DELIMIT + sequenceStr;
|
||||||
|
|
||||||
|
// 更新数据库中的 number 字段,确保并发安全性
|
||||||
|
int updatedRows = codeGenTableMapper.updateNumber(updateDto);
|
||||||
|
if (updatedRows == 0) {
|
||||||
|
throw new ServiceException("系统繁忙,请重试");
|
||||||
|
}
|
||||||
|
|
||||||
|
return generatedCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ package com.ruoyi.sip.service.impl;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.sip.domain.CodeGenTable;
|
||||||
|
import com.ruoyi.sip.service.ICodeGenTableService;
|
||||||
import com.ruoyi.sip.utils.CodeGeneratorUtil;
|
import com.ruoyi.sip.utils.CodeGeneratorUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -23,6 +25,8 @@ public class OrderDeliveryServiceImpl implements IOrderDeliveryService
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderDeliveryMapper orderDeliveryMapper;
|
private OrderDeliveryMapper orderDeliveryMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ICodeGenTableService codeGenTableService;
|
||||||
/**
|
/**
|
||||||
* 查询发货记录
|
* 查询发货记录
|
||||||
*
|
*
|
||||||
|
@ -56,9 +60,8 @@ public class OrderDeliveryServiceImpl implements IOrderDeliveryService
|
||||||
@Override
|
@Override
|
||||||
public int insertOrderDelivery(OrderDelivery orderDelivery)
|
public int insertOrderDelivery(OrderDelivery orderDelivery)
|
||||||
{
|
{
|
||||||
OrderDelivery queryCountParam = new OrderDelivery();
|
|
||||||
queryCountParam.setCreatedAt(DateUtils.getNowDate());
|
String deliveryCode =codeGenTableService.generateCode(CodeGenTable.TableNameEnum.ORDER_DELIVERY.getName());
|
||||||
String deliveryCode = CodeGeneratorUtil.generateUniqueCode("OD", () -> orderDeliveryMapper.count(queryCountParam));
|
|
||||||
orderDelivery.setDeliveryCode(deliveryCode);
|
orderDelivery.setDeliveryCode(deliveryCode);
|
||||||
return orderDeliveryMapper.insertOrderDelivery(orderDelivery);
|
return orderDeliveryMapper.insertOrderDelivery(orderDelivery);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,245 @@
|
||||||
|
<?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="com.ruoyi.sip.mapper.CodeGenTableMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.ruoyi.sip.domain.CodeGenTable" id="CodeGenTableMap">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="tableName" column="table_name"/>
|
||||||
|
<result property="tableComment" column="table_comment"/>
|
||||||
|
<result property="prefix" column="prefix"/>
|
||||||
|
<result property="number" column="number"/>
|
||||||
|
<result property="genDate" column="gen_date"/>
|
||||||
|
<result property="numberLength" column="number_length"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="remark" column="remark"/>
|
||||||
|
<result property="version" column="version"/>
|
||||||
|
<result property="dateFormat" column="date_format"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 基本字段 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, table_name, table_comment, prefix, number, gen_date, number_length, create_by, create_time, update_by, update_time, remark,version,date_format
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!--通过实体作为筛选条件查询-->
|
||||||
|
<select id="queryAll" resultMap="CodeGenTableMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from code_gen_table
|
||||||
|
<where>
|
||||||
|
<if test="id != null">
|
||||||
|
and id = #{id}
|
||||||
|
</if>
|
||||||
|
<if test="tableName != null and tableName != ''">
|
||||||
|
and table_name = #{tableName}
|
||||||
|
</if>
|
||||||
|
<if test="tableComment != null and tableComment != ''">
|
||||||
|
and table_comment = #{tableComment}
|
||||||
|
</if>
|
||||||
|
<if test="prefix != null and prefix != ''">
|
||||||
|
and prefix = #{prefix}
|
||||||
|
</if>
|
||||||
|
<if test="number != null">
|
||||||
|
and number = #{number}
|
||||||
|
</if>
|
||||||
|
<if test="genDate != null">
|
||||||
|
and gen_date = #{genDate}
|
||||||
|
</if>
|
||||||
|
<if test="numberLength != null">
|
||||||
|
and number_length = #{numberLength}
|
||||||
|
</if>
|
||||||
|
<if test="createBy != null and createBy != ''">
|
||||||
|
and create_by = #{createBy}
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
and create_time = #{createTime}
|
||||||
|
</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">
|
||||||
|
and update_by = #{updateBy}
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
and update_time = #{updateTime}
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
and remark = #{remark}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!--根据ID查详情-->
|
||||||
|
<select id="queryById" parameterType="Integer" resultMap="CodeGenTableMap">
|
||||||
|
SELECT id,
|
||||||
|
table_name,
|
||||||
|
table_comment,
|
||||||
|
prefix,
|
||||||
|
number,
|
||||||
|
gen_date,
|
||||||
|
number_length,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
remark,
|
||||||
|
version,
|
||||||
|
date_format
|
||||||
|
FROM code_gen_table
|
||||||
|
WHERE id = #{id}
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
<select id="selectByTableName" resultType="com.ruoyi.sip.domain.CodeGenTable">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from code_gen_table where table_name=#{tableName}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<!--新增所有列-->
|
||||||
|
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
INSERT INTO code_gen_table
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="tableName != null and tableName != ''">
|
||||||
|
table_name,
|
||||||
|
</if>
|
||||||
|
<if test="tableComment != null and tableComment != ''">
|
||||||
|
table_comment,
|
||||||
|
</if>
|
||||||
|
<if test="prefix != null and prefix != ''">
|
||||||
|
prefix,
|
||||||
|
</if>
|
||||||
|
<if test="number != null">
|
||||||
|
number,
|
||||||
|
</if>
|
||||||
|
<if test="genDate != null">
|
||||||
|
gen_date,
|
||||||
|
</if>
|
||||||
|
<if test="numberLength != null">
|
||||||
|
number_length,
|
||||||
|
</if>
|
||||||
|
<if test="createBy != null and createBy != ''">
|
||||||
|
create_by,
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time,
|
||||||
|
</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">
|
||||||
|
update_by,
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time,
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
remark,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="tableName != null and tableName != ''">
|
||||||
|
#{tableName},
|
||||||
|
</if>
|
||||||
|
<if test="tableComment != null and tableComment != ''">
|
||||||
|
#{tableComment},
|
||||||
|
</if>
|
||||||
|
<if test="prefix != null and prefix != ''">
|
||||||
|
#{prefix},
|
||||||
|
</if>
|
||||||
|
<if test="number != null">
|
||||||
|
#{number},
|
||||||
|
</if>
|
||||||
|
<if test="genDate != null">
|
||||||
|
#{genDate},
|
||||||
|
</if>
|
||||||
|
<if test="numberLength != null">
|
||||||
|
#{numberLength},
|
||||||
|
</if>
|
||||||
|
<if test="createBy != null and createBy != ''">
|
||||||
|
#{createBy},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
#{createTime},
|
||||||
|
</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">
|
||||||
|
#{updateBy},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
#{updateTime},
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
#{remark},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!--通过主键修改数据-->
|
||||||
|
<update id="update">
|
||||||
|
UPDATE code_gen_table
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
version=version+1
|
||||||
|
<if test="tableName != null and tableName != ''">
|
||||||
|
table_name = #{tableName},
|
||||||
|
</if>
|
||||||
|
<if test="tableComment != null and tableComment != ''">
|
||||||
|
table_comment = #{tableComment},
|
||||||
|
</if>
|
||||||
|
<if test="prefix != null and prefix != ''">
|
||||||
|
prefix = #{prefix},
|
||||||
|
</if>
|
||||||
|
<if test="number != null">
|
||||||
|
number = #{number},
|
||||||
|
</if>
|
||||||
|
<if test="genDate != null">
|
||||||
|
gen_date = #{genDate},
|
||||||
|
</if>
|
||||||
|
<if test="numberLength != null">
|
||||||
|
number_length = #{numberLength},
|
||||||
|
</if>
|
||||||
|
<if test="createBy != null and createBy != ''">
|
||||||
|
create_by = #{createBy},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time = #{createTime},
|
||||||
|
</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">
|
||||||
|
update_by = #{updateBy},
|
||||||
|
</if>
|
||||||
|
<if test="updateTime != null">
|
||||||
|
update_time = #{updateTime},
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
remark = #{remark},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
WHERE id = #{id} and version=#{version}
|
||||||
|
</update>
|
||||||
|
<update id="updateNumber">
|
||||||
|
update code_gen_table
|
||||||
|
set number=#{number} + 1,
|
||||||
|
version=version + 1
|
||||||
|
<if test="genDate != null">
|
||||||
|
,gen_date = #{genDate}
|
||||||
|
</if>
|
||||||
|
where table_name = #{tableName}
|
||||||
|
and version = #{version}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!--通过主键删除-->
|
||||||
|
<delete id="deleteById">
|
||||||
|
DELETE
|
||||||
|
FROM code_gen_table
|
||||||
|
WHERE id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<!--通过id批量删除-->
|
||||||
|
<delete id="batchRemove">
|
||||||
|
delete from code_gen_table where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue