This commit is contained in:
雷欧(林平凡)
2025-08-18 17:55:16 +08:00
parent 3d9d43f1eb
commit 691ac6798e
13 changed files with 878 additions and 2 deletions

View File

@@ -0,0 +1,114 @@
package com.ruoyi.jarvis.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 商品错误提示对象 prd_error_tip
*
* @author ruoyi
* @date 2024-01-01
*/
public class PrdErrorTip extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键ID */
private Long id;
/** 错误代码 */
@Excel(name = "错误代码")
private String errCode;
/** 错误子代码 */
@Excel(name = "错误子代码")
private String errSubCode;
/** 错误消息 */
@Excel(name = "错误消息")
private String errMsg;
/** 错误内容 */
@Excel(name = "错误内容")
private String content;
/** 状态 */
@Excel(name = "状态", readConverterExp = "0=禁用,1=启用")
private Integer status;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setErrCode(String errCode)
{
this.errCode = errCode;
}
public String getErrCode()
{
return errCode;
}
public void setErrSubCode(String errSubCode)
{
this.errSubCode = errSubCode;
}
public String getErrSubCode()
{
return errSubCode;
}
public void setErrMsg(String errMsg)
{
this.errMsg = errMsg;
}
public String getErrMsg()
{
return errMsg;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getStatus()
{
return status;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("errCode", getErrCode())
.append("errSubCode", getErrSubCode())
.append("errMsg", getErrMsg())
.append("content", getContent())
.append("status", getStatus())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.toString();
}
}

View File

@@ -0,0 +1,70 @@
package com.ruoyi.jarvis.mapper;
import java.util.List;
import com.ruoyi.jarvis.domain.PrdErrorTip;
/**
* 商品错误提示Mapper接口
*
* @author ruoyi
* @date 2024-01-01
*/
public interface PrdErrorTipMapper
{
/**
* 查询商品错误提示
*
* @param id 商品错误提示主键
* @return 商品错误提示
*/
public PrdErrorTip selectPrdErrorTipById(Long id);
/**
* 查询商品错误提示列表
*
* @param prdErrorTip 商品错误提示
* @return 商品错误提示集合
*/
public List<PrdErrorTip> selectPrdErrorTipList(PrdErrorTip prdErrorTip);
/**
* 新增商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
public int insertPrdErrorTip(PrdErrorTip prdErrorTip);
/**
* 修改商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
public int updatePrdErrorTip(PrdErrorTip prdErrorTip);
/**
* 删除商品错误提示
*
* @param id 商品错误提示主键
* @return 结果
*/
public int deletePrdErrorTipById(Long id);
/**
* 批量删除商品错误提示
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deletePrdErrorTipByIds(Long[] ids);
/**
* 根据错误代码和子代码查询错误提示
*
* @param errCode 错误代码
* @param errSubCode 错误子代码
* @return 商品错误提示
*/
public PrdErrorTip selectPrdErrorTipByCode(String errCode, String errSubCode);
}

View File

@@ -0,0 +1,43 @@
package com.ruoyi.jarvis.service;
/**
* 商家编码自动生成服务接口
*
* @author ruoyi
* @date 2024-01-01
*/
public interface IOuterIdGeneratorService
{
/**
* 根据SKUID生成商家编码
*
* @param skuid SKUID
* @return 生成的商家编码
*/
public String generateOuterId(String skuid);
/**
* 根据SKUID和自定义前缀生成商家编码
*
* @param skuid SKUID
* @param prefix 自定义前缀
* @return 生成的商家编码
*/
public String generateOuterId(String skuid, String prefix);
/**
* 重置SKUID的计数器
*
* @param skuid SKUID
* @return 是否成功
*/
public boolean resetCounter(String skuid);
/**
* 获取SKUID的当前计数器值
*
* @param skuid SKUID
* @return 当前计数器值
*/
public Long getCurrentCounter(String skuid);
}

View File

@@ -0,0 +1,70 @@
package com.ruoyi.jarvis.service;
import java.util.List;
import com.ruoyi.jarvis.domain.PrdErrorTip;
/**
* 商品错误提示Service接口
*
* @author ruoyi
* @date 2024-01-01
*/
public interface IPrdErrorTipService
{
/**
* 查询商品错误提示
*
* @param id 商品错误提示主键
* @return 商品错误提示
*/
public PrdErrorTip selectPrdErrorTipById(Long id);
/**
* 查询商品错误提示列表
*
* @param prdErrorTip 商品错误提示
* @return 商品错误提示集合
*/
public List<PrdErrorTip> selectPrdErrorTipList(PrdErrorTip prdErrorTip);
/**
* 新增商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
public int insertPrdErrorTip(PrdErrorTip prdErrorTip);
/**
* 修改商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
public int updatePrdErrorTip(PrdErrorTip prdErrorTip);
/**
* 批量删除商品错误提示
*
* @param ids 需要删除的商品错误提示主键集合
* @return 结果
*/
public int deletePrdErrorTipByIds(Long[] ids);
/**
* 删除商品错误提示信息
*
* @param id 商品错误提示主键
* @return 结果
*/
public int deletePrdErrorTipById(Long id);
/**
* 根据错误代码和子代码查询错误提示
*
* @param errCode 错误代码
* @param errSubCode 错误子代码
* @return 商品错误提示
*/
public PrdErrorTip selectPrdErrorTipByCode(String errCode, String errSubCode);
}

View File

@@ -0,0 +1,141 @@
package com.ruoyi.jarvis.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import com.ruoyi.jarvis.service.IOuterIdGeneratorService;
import com.ruoyi.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 商家编码自动生成服务实现类
*
* @author ruoyi
* @date 2024-01-01
*/
@Service
public class OuterIdGeneratorServiceImpl implements IOuterIdGeneratorService
{
private static final Logger log = LoggerFactory.getLogger(OuterIdGeneratorServiceImpl.class);
@Autowired
private RedisTemplate<String, Object> redisTemplate;
// Redis key前缀
private static final String REDIS_KEY_PREFIX = "outer_id_counter:";
// 默认编号长度
private static final int DEFAULT_NUMBER_LENGTH = 3;
// 默认编号格式
private static final String DEFAULT_NUMBER_FORMAT = "%03d";
/**
* 根据SKUID生成商家编码
*
* @param skuid SKUID
* @return 生成的商家编码
*/
@Override
public String generateOuterId(String skuid) {
if (StringUtils.isEmpty(skuid)) {
log.warn("SKUID为空无法生成商家编码");
return null;
}
return generateOuterId(skuid, skuid);
}
/**
* 根据SKUID和自定义前缀生成商家编码
*
* @param skuid SKUID
* @param prefix 自定义前缀
* @return 生成的商家编码
*/
@Override
public String generateOuterId(String skuid, String prefix) {
if (StringUtils.isEmpty(skuid) || StringUtils.isEmpty(prefix)) {
log.warn("SKUID或前缀为空无法生成商家编码");
return null;
}
try {
// 生成Redis key
String redisKey = REDIS_KEY_PREFIX + skuid;
// 递增计数器
Long counter = redisTemplate.opsForValue().increment(redisKey);
// 格式化编号
String formattedNumber = String.format(DEFAULT_NUMBER_FORMAT, counter);
// 生成商家编码
String outerId = prefix + formattedNumber;
log.info("成功生成商家编码: skuid={}, counter={}, outerId={}", skuid, counter, outerId);
return outerId;
} catch (Exception e) {
log.error("生成商家编码失败: skuid={}, prefix={}", skuid, prefix, e);
return null;
}
}
/**
* 重置SKUID的计数器
*
* @param skuid SKUID
* @return 是否成功
*/
@Override
public boolean resetCounter(String skuid) {
if (StringUtils.isEmpty(skuid)) {
log.warn("SKUID为空无法重置计数器");
return false;
}
try {
String redisKey = REDIS_KEY_PREFIX + skuid;
redisTemplate.delete(redisKey);
log.info("成功重置计数器: skuid={}", skuid);
return true;
} catch (Exception e) {
log.error("重置计数器失败: skuid={}", skuid, e);
return false;
}
}
/**
* 获取SKUID的当前计数器值
*
* @param skuid SKUID
* @return 当前计数器值
*/
@Override
public Long getCurrentCounter(String skuid) {
if (StringUtils.isEmpty(skuid)) {
log.warn("SKUID为空无法获取计数器值");
return 0L;
}
try {
String redisKey = REDIS_KEY_PREFIX + skuid;
Object value = redisTemplate.opsForValue().get(redisKey);
if (value == null) {
return 0L;
}
if (value instanceof Number) {
return ((Number) value).longValue();
}
return Long.valueOf(value.toString());
} catch (Exception e) {
log.error("获取计数器值失败: skuid={}", skuid, e);
return 0L;
}
}
}

View File

@@ -0,0 +1,106 @@
package com.ruoyi.jarvis.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.jarvis.mapper.PrdErrorTipMapper;
import com.ruoyi.jarvis.domain.PrdErrorTip;
import com.ruoyi.jarvis.service.IPrdErrorTipService;
/**
* 商品错误提示Service业务层处理
*
* @author ruoyi
* @date 2024-01-01
*/
@Service
public class PrdErrorTipServiceImpl implements IPrdErrorTipService
{
@Autowired
private PrdErrorTipMapper prdErrorTipMapper;
/**
* 查询商品错误提示
*
* @param id 商品错误提示主键
* @return 商品错误提示
*/
@Override
public PrdErrorTip selectPrdErrorTipById(Long id)
{
return prdErrorTipMapper.selectPrdErrorTipById(id);
}
/**
* 查询商品错误提示列表
*
* @param prdErrorTip 商品错误提示
* @return 商品错误提示
*/
@Override
public List<PrdErrorTip> selectPrdErrorTipList(PrdErrorTip prdErrorTip)
{
return prdErrorTipMapper.selectPrdErrorTipList(prdErrorTip);
}
/**
* 新增商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
@Override
public int insertPrdErrorTip(PrdErrorTip prdErrorTip)
{
return prdErrorTipMapper.insertPrdErrorTip(prdErrorTip);
}
/**
* 修改商品错误提示
*
* @param prdErrorTip 商品错误提示
* @return 结果
*/
@Override
public int updatePrdErrorTip(PrdErrorTip prdErrorTip)
{
return prdErrorTipMapper.updatePrdErrorTip(prdErrorTip);
}
/**
* 批量删除商品错误提示
*
* @param ids 需要删除的商品错误提示主键
* @return 结果
*/
@Override
public int deletePrdErrorTipByIds(Long[] ids)
{
return prdErrorTipMapper.deletePrdErrorTipByIds(ids);
}
/**
* 删除商品错误提示信息
*
* @param id 商品错误提示主键
* @return 结果
*/
@Override
public int deletePrdErrorTipById(Long id)
{
return prdErrorTipMapper.deletePrdErrorTipById(id);
}
/**
* 根据错误代码和子代码查询错误提示
*
* @param errCode 错误代码
* @param errSubCode 错误子代码
* @return 商品错误提示
*/
@Override
public PrdErrorTip selectPrdErrorTipByCode(String errCode, String errSubCode)
{
return prdErrorTipMapper.selectPrdErrorTipByCode(errCode, errSubCode);
}
}

View File

@@ -0,0 +1,89 @@
<?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.jarvis.mapper.PrdErrorTipMapper">
<resultMap type="PrdErrorTip" id="PrdErrorTipResult">
<result property="id" column="id" />
<result property="errCode" column="err_code" />
<result property="errSubCode" column="err_sub_code" />
<result property="errMsg" column="err_msg" />
<result property="content" column="content" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectPrdErrorTipVo">
select id, err_code, err_sub_code, err_msg, content, status, create_time, update_time
from prd_error_tip
</sql>
<select id="selectPrdErrorTipList" parameterType="PrdErrorTip" resultMap="PrdErrorTipResult">
<include refid="selectPrdErrorTipVo"/>
<where>
<if test="errCode != null and errCode != ''"> and err_code = #{errCode}</if>
<if test="errSubCode != null and errSubCode != ''"> and err_sub_code = #{errSubCode}</if>
<if test="errMsg != null and errMsg != ''"> and err_msg like concat('%', #{errMsg}, '%')</if>
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
<if test="status != null "> and status = #{status}</if>
</where>
order by create_time desc
</select>
<select id="selectPrdErrorTipById" parameterType="Long" resultMap="PrdErrorTipResult">
<include refid="selectPrdErrorTipVo"/>
where id = #{id}
</select>
<select id="selectPrdErrorTipByCode" resultMap="PrdErrorTipResult">
<include refid="selectPrdErrorTipVo"/>
where err_code = #{errCode} and err_sub_code = #{errSubCode} and status = 1
</select>
<insert id="insertPrdErrorTip" parameterType="PrdErrorTip" useGeneratedKeys="true" keyProperty="id">
insert into prd_error_tip
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="errCode != null and errCode != ''">err_code,</if>
<if test="errSubCode != null and errSubCode != ''">err_sub_code,</if>
<if test="errMsg != null and errMsg != ''">err_msg,</if>
<if test="content != null and content != ''">content,</if>
<if test="status != null">status,</if>
create_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="errCode != null and errCode != ''">#{errCode},</if>
<if test="errSubCode != null and errSubCode != ''">#{errSubCode},</if>
<if test="errMsg != null and errMsg != ''">#{errMsg},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="status != null">#{status},</if>
sysdate(),
</trim>
</insert>
<update id="updatePrdErrorTip" parameterType="PrdErrorTip">
update prd_error_tip
<trim prefix="SET" suffixOverrides=",">
<if test="errCode != null and errCode != ''">err_code = #{errCode},</if>
<if test="errSubCode != null and errSubCode != ''">err_sub_code = #{errSubCode},</if>
<if test="errMsg != null and errMsg != ''">err_msg = #{errMsg},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="status != null">status = #{status},</if>
update_time = sysdate(),
</trim>
where id = #{id}
</update>
<delete id="deletePrdErrorTipById" parameterType="Long">
delete from prd_error_tip where id = #{id}
</delete>
<delete id="deletePrdErrorTipByIds" parameterType="String">
delete from prd_error_tip where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>