kim.sesame.framework.serial.dao.SerialNumberRuleDao Maven / Gradle / Ivy
package kim.sesame.framework.serial.dao;
import kim.sesame.framework.serial.entity.SerialNumberRuleEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 序列号Dao
**/
@Component
public class SerialNumberRuleDao {
@Autowired
private JdbcTemplate jdbcTemplate;
/* 检查表 如果不存在就创建 */
public void check_notExistsCreate() {
String sql = " CREATE TABLE IF NOT EXISTS `sys_serial_number_rule` ( " +
" `code` VARCHAR(50) NOT NULL COMMENT '编码', " +
" `name` VARCHAR(400) NOT NULL COMMENT '名称', " +
" `cur_time` DATETIME NOT NULL COMMENT '当前时间', " +
" `cur_num` DECIMAL(18,0) NOT NULL COMMENT '当前序号', " +
" PRIMARY KEY (`code`) " +
" ) DEFAULT CHARSET=utf8 COMMENT='序列号表'";
jdbcTemplate.execute(sql);
}
/* 根据code查询序号实体并添加悲观锁 */
public SerialNumberRuleEntity querySerialNumberRuleForUpdate(String code) {
SerialNumberRuleEntity entity = null;
try {
String sql = "SELECT code code,name name,cur_time curTime,cur_num curNum " +
" FROM sys_serial_number_rule " +
" WHERE CODE = '" + code + "' for update ";
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy