From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java | 207 ++++++++++++++++++++++++++------------------------- 1 files changed, 106 insertions(+), 101 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java index 4c46e78..3c03493 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackConfigServiceImpl.java @@ -1,101 +1,106 @@ -package com.yeshi.fanli.service.impl.redpack; - -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; - -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import com.yeshi.fanli.dao.mybatis.redpack.RedPackConfigMapper; -import com.yeshi.fanli.entity.redpack.RedPackConfig; -import com.yeshi.fanli.exception.redpack.RedPackConfigException; -import com.yeshi.fanli.service.inter.redpack.RedPackConfigService; -import com.yeshi.fanli.util.StringUtil; - -@Service -public class RedPackConfigServiceImpl implements RedPackConfigService { - - @Resource - private RedPackConfigMapper redPackConfigMapper; - - @Override - public RedPackConfig getByKey(String key) { - return redPackConfigMapper.getByKey(key, new Date()); - } - - @Override - @Cacheable(value = "redpackCache", key = "'getValueByKey-' + #key") - public String getValueByKey(String key) { - RedPackConfig config = redPackConfigMapper.getByKey(key, new Date()); - if (config != null) { - return config.getValue(); - } - return null; - } - - @Override - public RedPackConfig getByKey(String key, Date date) { - if (date == null) - return getByKey(key); - return redPackConfigMapper.getByKey(key, date); - } - - @Override - public String getValueByKey(String key, Date date) { - if (date == null) - return getValueByKey(key); - RedPackConfig config = redPackConfigMapper.getByKey(key, date); - if (config != null) { - return config.getValue(); - } - return null; - } - - @Override - public List<RedPackConfig> query(int page, int pageSize, String key) { - return redPackConfigMapper.query((page - 1) * pageSize, pageSize, key); - } - - @Override - public long count(String key) { - return redPackConfigMapper.count(key); - } - - - @Override - public void save(RedPackConfig record) throws RedPackConfigException { - String name = record.getName(); - if (StringUtil.isNullOrEmpty(name)) - throw new RedPackConfigException(1, "鍚嶇О涓嶈兘涓虹┖"); - - if (StringUtil.isNullOrEmpty(record.getValue())) - throw new RedPackConfigException(1, "鍊间笉鑳戒负绌�"); - - if (StringUtil.isNullOrEmpty(record.getKey())) - throw new RedPackConfigException(1, "鏍囪瘑涓嶈兘涓虹┖"); - - record.setUpdateTime(new Date()); - if (record.getId() == null) { - record.setCreateTime(new Date()); - redPackConfigMapper.insert(record); - } else { - RedPackConfig resultObj = redPackConfigMapper.selectByPrimaryKey(record.getId()); - if (resultObj == null) - throw new RedPackConfigException(1, "淇敼鍐呭宸蹭笉瀛樺湪"); - record.setCreateTime(resultObj.getCreateTime()); - redPackConfigMapper.updateByPrimaryKey(record); - } - } - - - @Override - public void delete(List<Long> idsList) { - if (idsList != null) - for (Long id : idsList) - redPackConfigMapper.deleteByPrimaryKey(id); - - } - -} +package com.yeshi.fanli.service.impl.redpack; + +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; + +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + +import com.yeshi.fanli.dao.mybatis.redpack.RedPackConfigMapper; +import com.yeshi.fanli.entity.redpack.RedPackConfig; +import com.yeshi.fanli.exception.redpack.RedPackConfigException; +import com.yeshi.fanli.service.inter.redpack.RedPackConfigService; +import com.yeshi.fanli.util.StringUtil; + +@Service +public class RedPackConfigServiceImpl implements RedPackConfigService { + + @Resource + private RedPackConfigMapper redPackConfigMapper; + + @Override + public RedPackConfig getByKey(String key) { + return redPackConfigMapper.getByKey(key, new Date()); + } + + @Override + @Cacheable(value = "redpackCache", key = "'getValueByKey-' + #key") + public String getValueByKey(String key) { + RedPackConfig config = redPackConfigMapper.getByKey(key, new Date()); + if (config != null) { + return config.getValue(); + } + return null; + } + + @Override + public RedPackConfig getByKey(String key, Date date) { + if (date == null) + return getByKey(key); + return redPackConfigMapper.getByKey(key, date); + } + + @Override + public String getValueByKey(String key, Date date) { + if (date == null) + return getValueByKey(key); + RedPackConfig config = redPackConfigMapper.getByKey(key, date); + if (config != null) { + return config.getValue(); + } + return null; + } + + @Override + public List<RedPackConfig> query(int page, int pageSize, String key) { + return redPackConfigMapper.query((page - 1) * pageSize, pageSize, key); + } + + @Override + public long count(String key) { + return redPackConfigMapper.count(key); + } + + + @Override + public void save(RedPackConfig record) throws RedPackConfigException { + String name = record.getName(); + if (StringUtil.isNullOrEmpty(name)) + throw new RedPackConfigException(1, "鍚嶇О涓嶈兘涓虹┖"); + + if (StringUtil.isNullOrEmpty(record.getValue())) + throw new RedPackConfigException(1, "鍊间笉鑳戒负绌�"); + + if (StringUtil.isNullOrEmpty(record.getKey())) + throw new RedPackConfigException(1, "鏍囪瘑涓嶈兘涓虹┖"); + + String remark = record.getRemark(); + if ("null".equalsIgnoreCase(remark)) { + record.setRemark(""); + } + + record.setUpdateTime(new Date()); + if (record.getId() == null) { + record.setCreateTime(new Date()); + redPackConfigMapper.insert(record); + } else { + RedPackConfig resultObj = redPackConfigMapper.selectByPrimaryKey(record.getId()); + if (resultObj == null) + throw new RedPackConfigException(1, "淇敼鍐呭宸蹭笉瀛樺湪"); + record.setCreateTime(resultObj.getCreateTime()); + redPackConfigMapper.updateByPrimaryKey(record); + } + } + + + @Override + public void delete(List<Long> idsList) { + if (idsList != null) + for (Long id : idsList) + redPackConfigMapper.deleteByPrimaryKey(id); + + } + +} -- Gitblit v1.8.0