feat(system): 添加编码规则管理功能基础CRUD

- 创建编码规则实体类SysCodeRule,定义规则编码、名称、前缀等字段
- 实现编码规则的增删改查功能,包括列表查询、详情查看、新增修改等操作
- 添加编码规则的启用状态、重置周期等配置选项
- 创建数据库映射文件和对应的SQL语句
- 实现编码规则的导出功能
- 添加权限控制和数据验证机制
main
yangk 2 weeks ago
parent d508a056ac
commit c57944a8c6

@ -0,0 +1,140 @@
package com.ruoyi.web.controller.system;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysCodeRule;
import com.ruoyi.system.service.ISysCodeRuleService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* Controller
*
* @author Yangk
* @date 2026-06-08
*/
@Controller
@RequestMapping("/system/rule")
public class SysCodeRuleController extends BaseController
{
private String prefix = "system/rule";
@Autowired
private ISysCodeRuleService sysCodeRuleService;
@RequiresPermissions("system:rule:view")
@GetMapping()
public String rule()
{
return prefix + "/rule";
}
/**
*
*/
@RequiresPermissions("system:rule:list")
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(SysCodeRule sysCodeRule)
{
startPage();
List<SysCodeRule> list = sysCodeRuleService.selectSysCodeRuleList(sysCodeRule);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("system:rule:export")
@Log(title = "编码规则", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ResponseBody
public AjaxResult export(SysCodeRule sysCodeRule)
{
List<SysCodeRule> list = sysCodeRuleService.selectSysCodeRuleList(sysCodeRule);
ExcelUtil<SysCodeRule> util = new ExcelUtil<SysCodeRule>(SysCodeRule.class);
return util.exportExcel(list, "编码规则数据");
}
/**
*
*/
@RequiresPermissions("system:rule:view")
@GetMapping("/view/{ruleId}")
public String view(@PathVariable("ruleId") Long ruleId, ModelMap mmap)
{
SysCodeRule sysCodeRule = sysCodeRuleService.selectSysCodeRuleByRuleId(ruleId);
mmap.put("sysCodeRule", sysCodeRule);
return prefix + "/view";
}
/**
*
*/
@RequiresPermissions("system:rule:add")
@GetMapping("/add")
public String add()
{
return prefix + "/add";
}
/**
*
*/
@RequiresPermissions("system:rule:add")
@Log(title = "编码规则", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(SysCodeRule sysCodeRule)
{
return toAjax(sysCodeRuleService.insertSysCodeRule(sysCodeRule));
}
/**
*
*/
@RequiresPermissions("system:rule:edit")
@GetMapping("/edit/{ruleId}")
public String edit(@PathVariable("ruleId") Long ruleId, ModelMap mmap)
{
SysCodeRule sysCodeRule = sysCodeRuleService.selectSysCodeRuleByRuleId(ruleId);
mmap.put("sysCodeRule", sysCodeRule);
return prefix + "/edit";
}
/**
*
*/
@RequiresPermissions("system:rule:edit")
@Log(title = "编码规则", businessType = BusinessType.UPDATE)
@PostMapping("/edit")
@ResponseBody
public AjaxResult editSave(SysCodeRule sysCodeRule)
{
return toAjax(sysCodeRuleService.updateSysCodeRule(sysCodeRule));
}
/**
*
*/
@RequiresPermissions("system:rule:remove")
@Log(title = "编码规则", businessType = BusinessType.DELETE)
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(sysCodeRuleService.deleteSysCodeRuleByRuleIds(ids));
}
}

@ -0,0 +1,118 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增编码规则')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-rule-add">
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">规则编码:</label>
<div class="col-sm-8">
<input name="ruleCode" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">规则名称:</label>
<div class="col-sm-8">
<input name="ruleName" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">编码前缀:</label>
<div class="col-sm-8">
<input name="codePrefix" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">日期格式:</label>
<div class="col-sm-8">
<input name="dateFormat" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">流水号长度:</label>
<div class="col-sm-8">
<input name="serialLength" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">当前流水号:</label>
<div class="col-sm-8">
<input name="currentSerial" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">重置周期DAY、MONTH、YEAR、NONE</label>
<div class="col-sm-8">
<select name="resetCycle" class="form-control" th:with="type=${@dict.getType('ams_code_reset_cycle')}" required>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">上次流水键例如20260526</label>
<div class="col-sm-8">
<input name="lastSerialKey" class="form-control" type="text">
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">启用状态Y启用N停用</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('ams_enabled_status')}">
<input type="radio" th:id="${'enabled_' + dict.dictCode}" name="enabled" th:value="${dict.dictValue}" th:checked="${dict.default}" required>
<label th:for="${'enabled_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">备注:</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control"></textarea>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">删除标志0存在1删除</label>
<div class="col-sm-8">
<input name="delFlag" class="form-control" type="text">
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "system/rule"
$("#form-rule-add").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-rule-add').serialize());
}
}
</script>
</body>
</html>

@ -0,0 +1,111 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('修改编码规则')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-rule-edit" th:object="${sysCodeRule}">
<input name="ruleId" th:field="*{ruleId}" type="hidden">
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">规则编码:</label>
<div class="col-sm-8">
<input name="ruleCode" th:field="*{ruleCode}" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">规则名称:</label>
<div class="col-sm-8">
<input name="ruleName" th:field="*{ruleName}" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">编码前缀:</label>
<div class="col-sm-8">
<input name="codePrefix" th:field="*{codePrefix}" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">日期格式:</label>
<div class="col-sm-8">
<input name="dateFormat" th:field="*{dateFormat}" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">流水号长度:</label>
<div class="col-sm-8">
<input name="serialLength" th:field="*{serialLength}" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">当前流水号:</label>
<div class="col-sm-8">
<input name="currentSerial" th:field="*{currentSerial}" class="form-control" type="text" required>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">重置周期DAY、MONTH、YEAR、NONE</label>
<div class="col-sm-8">
<select name="resetCycle" class="form-control" th:with="type=${@dict.getType('ams_code_reset_cycle')}" required>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{resetCycle}"></option>
</select>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">上次流水键例如20260526</label>
<div class="col-sm-8">
<input name="lastSerialKey" th:field="*{lastSerialKey}" class="form-control" type="text">
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label is-required">启用状态Y启用N停用</label>
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('ams_enabled_status')}">
<input type="radio" th:id="${'enabled_' + dict.dictCode}" name="enabled" th:value="${dict.dictValue}" th:field="*{enabled}" required>
<label th:for="${'enabled_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="col-sm-4 control-label">备注:</label>
<div class="col-sm-8">
<textarea name="remark" class="form-control">[[*{remark}]]</textarea>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = ctx + "system/rule";
$("#form-rule-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-rule-edit').serialize());
}
}
</script>
</body>
</html>

@ -0,0 +1,170 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('编码规则列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="formId">
<div class="select-list">
<ul>
<li>
<label>规则编码:</label>
<input type="text" name="ruleCode"/>
</li>
<li>
<label>规则名称:</label>
<input type="text" name="ruleName"/>
</li>
<li>
<label>编码前缀:</label>
<input type="text" name="codePrefix"/>
</li>
<li>
<label>日期格式:</label>
<input type="text" name="dateFormat"/>
</li>
<li>
<label>流水号长度:</label>
<input type="text" name="serialLength"/>
</li>
<li>
<label>当前流水号:</label>
<input type="text" name="currentSerial"/>
</li>
<li>
<label>重置周期DAY、MONTH、YEAR、NONE</label>
<select name="resetCycle" th:with="type=${@dict.getType('ams_code_reset_cycle')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<label>上次流水键例如20260526</label>
<input type="text" name="lastSerialKey"/>
</li>
<li>
<label>启用状态Y启用N停用</label>
<select name="enabled" th:with="type=${@dict.getType('ams_enabled_status')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
</li>
</ul>
</div>
</form>
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:rule:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:rule:edit">
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:rule:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:rule:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('system:rule:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:rule:remove')}]];
var resetCycleDatas = [[${@dict.getType('ams_code_reset_cycle')}]];
var enabledDatas = [[${@dict.getType('ams_enabled_status')}]];
var prefix = ctx + "system/rule";
$(function() {
var options = {
url: prefix + "/list",
viewUrl: prefix + "/view/{id}",
createUrl: prefix + "/add",
updateUrl: prefix + "/edit/{id}",
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
modalName: "编码规则",
columns: [{
checkbox: true
},
{
field: 'ruleId',
title: '规则ID',
visible: false
},
{
field: 'ruleCode',
title: '规则编码'
},
{
field: 'ruleName',
title: '规则名称'
},
{
field: 'codePrefix',
title: '编码前缀'
},
{
field: 'dateFormat',
title: '日期格式'
},
{
field: 'serialLength',
title: '流水号长度'
},
{
field: 'currentSerial',
title: '当前流水号'
},
{
field: 'resetCycle',
title: '重置周期DAY、MONTH、YEAR、NONE',
formatter: function(value, row, index) {
return $.table.selectDictLabel(resetCycleDatas, value);
}
},
{
field: 'lastSerialKey',
title: '上次流水键例如20260526'
},
{
field: 'enabled',
title: '启用状态Y启用N停用',
formatter: function(value, row, index) {
return $.table.selectDictLabel(enabledDatas, value);
}
},
{
field: 'remark',
title: '备注'
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="$.operate.view(\'' + row.ruleId + '\')"><i class="fa fa-eye"></i>查看</a> ');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.ruleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.ruleId + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
});
</script>
</body>
</html>

@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('编码规则详细')" />
</head>
<body>
<div class="main-content">
<form class="form-horizontal" th:object="${sysCodeRule}">
<h4 class="form-header h4">基本信息</h4>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">规则编码:</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{ruleCode}"></p>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">规则名称:</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{ruleName}"></p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">编码前缀:</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{codePrefix}"></p>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">日期格式:</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{dateFormat}"></p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">流水号长度:</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{serialLength}"></p>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">当前流水号:</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{currentSerial}"></p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">重置周期DAY、MONTH、YEAR、NONE</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{@dict.getLabel('ams_code_reset_cycle', resetCycle)}"></p>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">上次流水键例如20260526</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{lastSerialKey}"></p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">启用状态Y启用N停用</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{@dict.getLabel('ams_enabled_status', enabled)}"></p>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">备注:</label>
<div class="col-sm-8">
<p class="form-control-plaintext" th:text="*{remark}"></p>
</div>
</div>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
</body>
</html>

@ -0,0 +1,191 @@
package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* sys_code_rule
*
* @author Yangk
* @date 2026-06-08
*/
public class SysCodeRule extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 规则ID */
private Long ruleId;
/** 规则编码 */
@Excel(name = "规则编码")
private String ruleCode;
/** 规则名称 */
@Excel(name = "规则名称")
private String ruleName;
/** 编码前缀 */
@Excel(name = "编码前缀")
private String codePrefix;
/** 日期格式 */
@Excel(name = "日期格式")
private String dateFormat;
/** 流水号长度 */
@Excel(name = "流水号长度")
private Long serialLength;
/** 当前流水号 */
@Excel(name = "当前流水号")
private Long currentSerial;
/** 重置周期DAY、MONTH、YEAR、NONE */
@Excel(name = "重置周期DAY、MONTH、YEAR、NONE")
private String resetCycle;
/** 上次流水键例如20260526 */
@Excel(name = "上次流水键例如20260526")
private String lastSerialKey;
/** 启用状态Y启用N停用 */
@Excel(name = "启用状态Y启用N停用")
private String enabled;
/** 删除标志0存在1删除 */
private String delFlag;
public void setRuleId(Long ruleId)
{
this.ruleId = ruleId;
}
public Long getRuleId()
{
return ruleId;
}
public void setRuleCode(String ruleCode)
{
this.ruleCode = ruleCode;
}
public String getRuleCode()
{
return ruleCode;
}
public void setRuleName(String ruleName)
{
this.ruleName = ruleName;
}
public String getRuleName()
{
return ruleName;
}
public void setCodePrefix(String codePrefix)
{
this.codePrefix = codePrefix;
}
public String getCodePrefix()
{
return codePrefix;
}
public void setDateFormat(String dateFormat)
{
this.dateFormat = dateFormat;
}
public String getDateFormat()
{
return dateFormat;
}
public void setSerialLength(Long serialLength)
{
this.serialLength = serialLength;
}
public Long getSerialLength()
{
return serialLength;
}
public void setCurrentSerial(Long currentSerial)
{
this.currentSerial = currentSerial;
}
public Long getCurrentSerial()
{
return currentSerial;
}
public void setResetCycle(String resetCycle)
{
this.resetCycle = resetCycle;
}
public String getResetCycle()
{
return resetCycle;
}
public void setLastSerialKey(String lastSerialKey)
{
this.lastSerialKey = lastSerialKey;
}
public String getLastSerialKey()
{
return lastSerialKey;
}
public void setEnabled(String enabled)
{
this.enabled = enabled;
}
public String getEnabled()
{
return enabled;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getDelFlag()
{
return delFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("ruleId", getRuleId())
.append("ruleCode", getRuleCode())
.append("ruleName", getRuleName())
.append("codePrefix", getCodePrefix())
.append("dateFormat", getDateFormat())
.append("serialLength", getSerialLength())
.append("currentSerial", getCurrentSerial())
.append("resetCycle", getResetCycle())
.append("lastSerialKey", getLastSerialKey())
.append("enabled", getEnabled())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("delFlag", getDelFlag())
.toString();
}
}

@ -0,0 +1,61 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.SysCodeRule;
/**
* Mapper
*
* @author Yangk
* @date 2026-06-08
*/
public interface SysCodeRuleMapper
{
/**
*
*
* @param ruleId
* @return
*/
public SysCodeRule selectSysCodeRuleByRuleId(Long ruleId);
/**
*
*
* @param sysCodeRule
* @return
*/
public List<SysCodeRule> selectSysCodeRuleList(SysCodeRule sysCodeRule);
/**
*
*
* @param sysCodeRule
* @return
*/
public int insertSysCodeRule(SysCodeRule sysCodeRule);
/**
*
*
* @param sysCodeRule
* @return
*/
public int updateSysCodeRule(SysCodeRule sysCodeRule);
/**
*
*
* @param ruleId
* @return
*/
public int deleteSysCodeRuleByRuleId(Long ruleId);
/**
*
*
* @param ruleIds
* @return
*/
public int deleteSysCodeRuleByRuleIds(String[] ruleIds);
}

@ -0,0 +1,61 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.SysCodeRule;
/**
* Service
*
* @author Yangk
* @date 2026-06-08
*/
public interface ISysCodeRuleService
{
/**
*
*
* @param ruleId
* @return
*/
public SysCodeRule selectSysCodeRuleByRuleId(Long ruleId);
/**
*
*
* @param sysCodeRule
* @return
*/
public List<SysCodeRule> selectSysCodeRuleList(SysCodeRule sysCodeRule);
/**
*
*
* @param sysCodeRule
* @return
*/
public int insertSysCodeRule(SysCodeRule sysCodeRule);
/**
*
*
* @param sysCodeRule
* @return
*/
public int updateSysCodeRule(SysCodeRule sysCodeRule);
/**
*
*
* @param ruleIds
* @return
*/
public int deleteSysCodeRuleByRuleIds(String ruleIds);
/**
*
*
* @param ruleId
* @return
*/
public int deleteSysCodeRuleByRuleId(Long ruleId);
}

@ -0,0 +1,97 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysCodeRuleMapper;
import com.ruoyi.system.domain.SysCodeRule;
import com.ruoyi.system.service.ISysCodeRuleService;
import com.ruoyi.common.core.text.Convert;
/**
* Service
*
* @author Yangk
* @date 2026-06-08
*/
@Service
public class SysCodeRuleServiceImpl implements ISysCodeRuleService
{
@Autowired
private SysCodeRuleMapper sysCodeRuleMapper;
/**
*
*
* @param ruleId
* @return
*/
@Override
public SysCodeRule selectSysCodeRuleByRuleId(Long ruleId)
{
return sysCodeRuleMapper.selectSysCodeRuleByRuleId(ruleId);
}
/**
*
*
* @param sysCodeRule
* @return
*/
@Override
public List<SysCodeRule> selectSysCodeRuleList(SysCodeRule sysCodeRule)
{
return sysCodeRuleMapper.selectSysCodeRuleList(sysCodeRule);
}
/**
*
*
* @param sysCodeRule
* @return
*/
@Override
public int insertSysCodeRule(SysCodeRule sysCodeRule)
{
sysCodeRule.setCreateTime(DateUtils.getNowDate());
return sysCodeRuleMapper.insertSysCodeRule(sysCodeRule);
}
/**
*
*
* @param sysCodeRule
* @return
*/
@Override
public int updateSysCodeRule(SysCodeRule sysCodeRule)
{
sysCodeRule.setUpdateTime(DateUtils.getNowDate());
return sysCodeRuleMapper.updateSysCodeRule(sysCodeRule);
}
/**
*
*
* @param ruleIds
* @return
*/
@Override
public int deleteSysCodeRuleByRuleIds(String ruleIds)
{
return sysCodeRuleMapper.deleteSysCodeRuleByRuleIds(Convert.toStrArray(ruleIds));
}
/**
*
*
* @param ruleId
* @return
*/
@Override
public int deleteSysCodeRuleByRuleId(Long ruleId)
{
return sysCodeRuleMapper.deleteSysCodeRuleByRuleId(ruleId);
}
}

@ -0,0 +1,121 @@
<?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.system.mapper.SysCodeRuleMapper">
<resultMap type="SysCodeRule" id="SysCodeRuleResult">
<result property="ruleId" column="rule_id" />
<result property="ruleCode" column="rule_code" />
<result property="ruleName" column="rule_name" />
<result property="codePrefix" column="code_prefix" />
<result property="dateFormat" column="date_format" />
<result property="serialLength" column="serial_length" />
<result property="currentSerial" column="current_serial" />
<result property="resetCycle" column="reset_cycle" />
<result property="lastSerialKey" column="last_serial_key" />
<result property="enabled" column="enabled" />
<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="delFlag" column="del_flag" />
</resultMap>
<sql id="selectSysCodeRuleVo">
select rule_id, rule_code, rule_name, code_prefix, date_format, serial_length, current_serial, reset_cycle, last_serial_key, enabled, create_by, create_time, update_by, update_time, remark, del_flag from sys_code_rule
</sql>
<select id="selectSysCodeRuleList" parameterType="SysCodeRule" resultMap="SysCodeRuleResult">
<include refid="selectSysCodeRuleVo"/>
<where>
<if test="ruleCode != null and ruleCode != ''"> and rule_code = #{ruleCode}</if>
<if test="ruleName != null and ruleName != ''"> and rule_name like concat('%', #{ruleName}, '%')</if>
<if test="codePrefix != null and codePrefix != ''"> and code_prefix = #{codePrefix}</if>
<if test="dateFormat != null and dateFormat != ''"> and date_format = #{dateFormat}</if>
<if test="serialLength != null "> and serial_length = #{serialLength}</if>
<if test="currentSerial != null "> and current_serial = #{currentSerial}</if>
<if test="resetCycle != null and resetCycle != ''"> and reset_cycle = #{resetCycle}</if>
<if test="lastSerialKey != null and lastSerialKey != ''"> and last_serial_key = #{lastSerialKey}</if>
<if test="enabled != null and enabled != ''"> and enabled = #{enabled}</if>
</where>
</select>
<select id="selectSysCodeRuleByRuleId" parameterType="Long" resultMap="SysCodeRuleResult">
<include refid="selectSysCodeRuleVo"/>
where rule_id = #{ruleId}
</select>
<insert id="insertSysCodeRule" parameterType="SysCodeRule" useGeneratedKeys="true" keyProperty="ruleId">
insert into sys_code_rule
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ruleCode != null and ruleCode != ''">rule_code,</if>
<if test="ruleName != null and ruleName != ''">rule_name,</if>
<if test="codePrefix != null and codePrefix != ''">code_prefix,</if>
<if test="dateFormat != null and dateFormat != ''">date_format,</if>
<if test="serialLength != null">serial_length,</if>
<if test="currentSerial != null">current_serial,</if>
<if test="resetCycle != null and resetCycle != ''">reset_cycle,</if>
<if test="lastSerialKey != null">last_serial_key,</if>
<if test="enabled != null and enabled != ''">enabled,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
<if test="delFlag != null">del_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ruleCode != null and ruleCode != ''">#{ruleCode},</if>
<if test="ruleName != null and ruleName != ''">#{ruleName},</if>
<if test="codePrefix != null and codePrefix != ''">#{codePrefix},</if>
<if test="dateFormat != null and dateFormat != ''">#{dateFormat},</if>
<if test="serialLength != null">#{serialLength},</if>
<if test="currentSerial != null">#{currentSerial},</if>
<if test="resetCycle != null and resetCycle != ''">#{resetCycle},</if>
<if test="lastSerialKey != null">#{lastSerialKey},</if>
<if test="enabled != null and enabled != ''">#{enabled},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="delFlag != null">#{delFlag},</if>
</trim>
</insert>
<update id="updateSysCodeRule" parameterType="SysCodeRule">
update sys_code_rule
<trim prefix="SET" suffixOverrides=",">
<if test="ruleCode != null and ruleCode != ''">rule_code = #{ruleCode},</if>
<if test="ruleName != null and ruleName != ''">rule_name = #{ruleName},</if>
<if test="codePrefix != null and codePrefix != ''">code_prefix = #{codePrefix},</if>
<if test="dateFormat != null and dateFormat != ''">date_format = #{dateFormat},</if>
<if test="serialLength != null">serial_length = #{serialLength},</if>
<if test="currentSerial != null">current_serial = #{currentSerial},</if>
<if test="resetCycle != null and resetCycle != ''">reset_cycle = #{resetCycle},</if>
<if test="lastSerialKey != null">last_serial_key = #{lastSerialKey},</if>
<if test="enabled != null and enabled != ''">enabled = #{enabled},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
</trim>
where rule_id = #{ruleId}
</update>
<delete id="deleteSysCodeRuleByRuleId" parameterType="Long">
delete from sys_code_rule where rule_id = #{ruleId}
</delete>
<delete id="deleteSysCodeRuleByRuleIds" parameterType="String">
delete from sys_code_rule where rule_id in
<foreach item="ruleId" collection="array" open="(" separator="," close=")">
#{ruleId}
</foreach>
</delete>
</mapper>
Loading…
Cancel
Save