diff --git a/README.md b/README.md index c2afc268..bdeb4541 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,8 @@ litemall = Spring Boot后端 + Vue管理员前端 + 微信小程序用户前端 * 商品管理 * 推广管理 * 系统管理 +* 配置管理 +* 统计报表 ## 云演示 diff --git a/litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminConfigController.java b/litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminConfigController.java new file mode 100644 index 00000000..22a7ce4f --- /dev/null +++ b/litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminConfigController.java @@ -0,0 +1,96 @@ +package org.linlinjava.litemall.admin.web; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.linlinjava.litemall.admin.annotation.RequiresPermissionsDesc; +import org.linlinjava.litemall.core.system.SystemConfig; +import org.linlinjava.litemall.core.util.JacksonUtil; +import org.linlinjava.litemall.core.util.ResponseUtil; +import org.linlinjava.litemall.db.service.LitemallSystemConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +@RestController +@RequestMapping("/admin/config") +@Validated +public class AdminConfigController { + private final Log logger = LogFactory.getLog(AdminConfigController.class); + + @Autowired + private LitemallSystemConfigService systemConfigService; + + @RequiresPermissions("admin:config:mall:list") + @RequiresPermissionsDesc(menu={"配置管理" , "商场配置"}, button="详情") + @GetMapping("/mall") + public Object listMall() { + Map data = systemConfigService.listMail(); + return ResponseUtil.ok(data); + } + + @RequiresPermissions("admin:config:mall:updateConfigs") + @RequiresPermissionsDesc(menu={"配置管理" , "商场配置"}, button="编辑") + @PostMapping("/mall") + public Object updateMall(@RequestBody String body ) { + Map data = JacksonUtil.toMap(body); + systemConfigService.updateConfig(data); + SystemConfig.updateConfigs(data); + return ResponseUtil.ok(); + } + + @RequiresPermissions("admin:config:express:list") + @RequiresPermissionsDesc(menu={"配置管理" , "运费配置"}, button="详情") + @GetMapping("/express") + public Object listExpress() { + Map data = systemConfigService.listExpress(); + return ResponseUtil.ok(data); + } + + @RequiresPermissions("admin:config:express:updateConfigs") + @RequiresPermissionsDesc(menu={"配置管理" , "运费配置"}, button="编辑") + @PostMapping("/express") + public Object updateExpress(@RequestBody String body) { + Map data = JacksonUtil.toMap(body); + systemConfigService.updateConfig(data); + SystemConfig.updateConfigs(data); + return ResponseUtil.ok(); + } + + @RequiresPermissions("admin:config:order:list") + @RequiresPermissionsDesc(menu={"配置管理" , "订单配置"}, button="详情") + @GetMapping("/order") + public Object lisOrder() { + Map data = systemConfigService.listOrder(); + return ResponseUtil.ok(data); + } + + @RequiresPermissions("admin:config:order:updateConfigs") + @RequiresPermissionsDesc(menu={"配置管理" , "订单配置"}, button="编辑") + @PostMapping("/order") + public Object updateOrder(@RequestBody String body) { + Map data = JacksonUtil.toMap(body); + systemConfigService.updateConfig(data); + return ResponseUtil.ok(); + } + + @RequiresPermissions("admin:config:wx:list") + @RequiresPermissionsDesc(menu={"配置管理" , "小程序配置"}, button="详情") + @GetMapping("/wx") + public Object listWx() { + Map data = systemConfigService.listWx(); + return ResponseUtil.ok(data); + } + + @RequiresPermissions("admin:config:wx:updateConfigs") + @RequiresPermissionsDesc(menu={"配置管理" , "小程序配置"}, button="编辑") + @PostMapping("/wx") + public Object updateWx(@RequestBody String body) { + Map data = JacksonUtil.toMap(body); + systemConfigService.updateConfig(data); + SystemConfig.updateConfigs(data); + return ResponseUtil.ok(); + } +} diff --git a/litemall-admin/src/api/config.js b/litemall-admin/src/api/config.js new file mode 100644 index 00000000..2b129b84 --- /dev/null +++ b/litemall-admin/src/api/config.js @@ -0,0 +1,61 @@ +import request from '@/utils/request' + +export function listMall() { + return request({ + url: '/config/mall', + method: 'get' + }) +} + +export function updateMall(data) { + return request({ + url: '/config/mall', + method: 'post', + data + }) +} + +export function listExpress() { + return request({ + url: '/config/express', + method: 'get' + }) +} + +export function updateExpress(data) { + return request({ + url: '/config/express', + method: 'post', + data + }) +} + +export function listOrder() { + return request({ + url: '/config/order', + method: 'get' + }) +} + +export function updateOrder(data) { + return request({ + url: '/config/order', + method: 'post', + data + }) +} + +export function listWx() { + return request({ + url: '/config/wx', + method: 'get' + }) +} + +export function updateWx(data) { + return request({ + url: '/config/wx', + method: 'post', + data + }) +} diff --git a/litemall-admin/src/router/index.js b/litemall-admin/src/router/index.js index e206e5e2..bbc054bd 100644 --- a/litemall-admin/src/router/index.js +++ b/litemall-admin/src/router/index.js @@ -403,7 +403,7 @@ export const asyncRouterMap = [ component: Layout, redirect: 'noredirect', alwaysShow: true, - name: 'sysManage', + name: 'configManage', meta: { title: '配置管理', icon: 'chart' @@ -459,7 +459,7 @@ export const asyncRouterMap = [ alwaysShow: true, name: 'statManage', meta: { - title: '统计', + title: '统计报表', icon: 'chart' }, children: [ diff --git a/litemall-admin/src/views/config/express.vue b/litemall-admin/src/views/config/express.vue new file mode 100644 index 00000000..6fc85237 --- /dev/null +++ b/litemall-admin/src/views/config/express.vue @@ -0,0 +1,70 @@ + + + diff --git a/litemall-admin/src/views/config/mall.vue b/litemall-admin/src/views/config/mall.vue new file mode 100644 index 00000000..f6c4fc52 --- /dev/null +++ b/litemall-admin/src/views/config/mall.vue @@ -0,0 +1,68 @@ + + + diff --git a/litemall-admin/src/views/config/order.vue b/litemall-admin/src/views/config/order.vue new file mode 100644 index 00000000..07b5c2f2 --- /dev/null +++ b/litemall-admin/src/views/config/order.vue @@ -0,0 +1,66 @@ + + + diff --git a/litemall-admin/src/views/config/wx.vue b/litemall-admin/src/views/config/wx.vue new file mode 100644 index 00000000..70099e3a --- /dev/null +++ b/litemall-admin/src/views/config/wx.vue @@ -0,0 +1,86 @@ + + + diff --git a/litemall-core/src/main/java/org/linlinjava/litemall/core/system/BaseConfig.java b/litemall-core/src/main/java/org/linlinjava/litemall/core/system/BaseConfig.java deleted file mode 100644 index 7f6784ca..00000000 --- a/litemall-core/src/main/java/org/linlinjava/litemall/core/system/BaseConfig.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.linlinjava.litemall.core.system; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -/** - * 配置基类,该类实际持有所有的配置,子类只是提供代理访问方法 - */ -abstract class BaseConfig { - - //所有的配置均保存在该 HashMap 中 - protected static Map configs = new HashMap<>(); - - /** - * 添加配置到公共Map中 - * - * @param key - * @param value - */ - public static void addConfig(String key, String value) { - configs.put(key, value); - } - - /** - * 重载配置,传入子类的prefix - */ - public static void reloadConfig(String prefix) { - //先遍历删除该 prefix 所有配置 - for (Iterator> it = configs.entrySet().iterator(); it.hasNext(); ) { - Map.Entry item = it.next(); - if (item.getKey().startsWith(prefix)) - it.remove(); - } - - ConfigService.getSystemConfigService().reloadConfig(prefix); - } - - /** - * 按String类型获取配置值 - * - * @param keyName - * @return - */ - protected static String getConfig(String keyName) { - return configs.get(keyName); - } - - /** - * 以Integer类型获取配置值 - * - * @param keyName - * @return - */ - protected static Integer getConfigInt(String keyName) { - return Integer.parseInt(configs.get(keyName)); - } - - /** - * 以BigDecimal类型获取配置值 - * - * @param keyName - * @return - */ - protected static BigDecimal getConfigBigDec(String keyName) { - return new BigDecimal(configs.get(keyName)); - } - - /** - * 子类实现该方法,并告知父类配置前缀,该前缀用来索引配置组用于简化访问和按组重读配置 - * - * @return - */ - abstract String getPrefix(); -} diff --git a/litemall-core/src/main/java/org/linlinjava/litemall/core/system/ConfigService.java b/litemall-core/src/main/java/org/linlinjava/litemall/core/system/ConfigService.java deleted file mode 100644 index d1448272..00000000 --- a/litemall-core/src/main/java/org/linlinjava/litemall/core/system/ConfigService.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.linlinjava.litemall.core.system; - -import org.linlinjava.litemall.db.domain.LitemallSystem; -import org.linlinjava.litemall.db.service.LitemallSystemConfigService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.util.List; - -/** - * 该类用于自动初始化数据库配置到BaseConfig中,以便BaseConfig的子类调用 - */ -@Component -class ConfigService { - private static ConfigService systemConfigService; - @Autowired - private LitemallSystemConfigService litemallSystemConfigService; - - //不允许实例化 - private ConfigService() { - - } - - static ConfigService getSystemConfigService() { - return systemConfigService; - } - - @PostConstruct - public void inist() { - systemConfigService = this; - systemConfigService.inistConfigs(); - } - - /** - * 根据 prefix 重置该 prefix 下所有设置 - * - * @param prefix - */ - public void reloadConfig(String prefix) { - List list = litemallSystemConfigService.queryAll(); - for (LitemallSystem item : list) { - //符合条件,添加 - if (item.getKeyName().startsWith(prefix)) - BaseConfig.addConfig(item.getKeyName(), item.getKeyValue()); - } - } - - /** - * 读取全部配置 - */ - private void inistConfigs() { - List list = litemallSystemConfigService.queryAll(); - for (LitemallSystem item : list) { - BaseConfig.addConfig(item.getKeyName(), item.getKeyValue()); - } - } -} \ No newline at end of file diff --git a/litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemConfig.java b/litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemConfig.java index 0a94135f..3536fdab 100644 --- a/litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemConfig.java +++ b/litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemConfig.java @@ -1,72 +1,119 @@ package org.linlinjava.litemall.core.system; +import org.linlinjava.litemall.db.domain.LitemallSystem; +import org.linlinjava.litemall.db.service.LitemallSystemConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** - * 系统设置,其他配置请参考该类的实现 + * 系统设置 */ -public class SystemConfig extends BaseConfig { - public static final String PRE_FIX = "litemall.system."; +public class SystemConfig { + // 小程序相关配置 + public final static String LITEMALL_WX_INDEX_NEW = "litemall_wx_index_new"; + public final static String LITEMALL_WX_INDEX_HOT = "litemall_wx_index_hot"; + public final static String LITEMALL_WX_INDEX_BRAND = "litemall_wx_index_brand"; + public final static String LITEMALL_WX_INDEX_TOPIC = "litemall_wx_index_topic"; + public final static String LITEMALL_WX_INDEX_CATLOG_LIST = "litemall_wx_catlog_list"; + public final static String LITEMALL_WX_INDEX_CATLOG_GOODS = "litemall_wx_catlog_goods"; + public final static String LITEMALL_WX_SHARE = "litemall_wx_share"; + // 运费相关配置 + public final static String LITEMALL_EXPRESS_FREIGHT_VALUE = "litemall_express_freight_value"; + public final static String LITEMALL_EXPRESS_FREIGHT_MIN = "litemall_express_freight_min"; + // 订单相关配置 + public final static String LITEMALL_ORDER_UNPAID = "litemall_order_unpaid"; + public final static String LITEMALL_ORDER_UNCONFIRM = "litemall_order_unconfirm"; + public final static String LITEMALL_ORDER_COMMENT = "litemall_order_comment"; + // 商场相关配置 + public final static String LITEMALL_MALL_NAME = "litemall_mall_name"; + public final static String LITEMALL_MALL_ADDRESS = "litemall_mall_address"; + public final static String LITEMALL_MALL_PHONE = "litemall_mall_phone"; + public final static String LITEMALL_MALL_QQ = "litemall_mall_qq"; + + //所有的配置均保存在该 HashMap 中 + private static Map SYSTEM_CONFIGS = new HashMap<>(); + + private static String getConfig(String keyName) { + return SYSTEM_CONFIGS.get(keyName); + } + + private static Integer getConfigInt(String keyName) { + return Integer.parseInt(SYSTEM_CONFIGS.get(keyName)); + } + + private static Boolean getConfigBoolean(String keyName) { + return Boolean.valueOf(SYSTEM_CONFIGS.get(keyName)); + } + + private static BigDecimal getConfigBigDec(String keyName) { + return new BigDecimal(SYSTEM_CONFIGS.get(keyName)); + } public static Integer getNewLimit() { - return getConfigInt(PRE_FIX + "indexlimit.new"); + return getConfigInt(LITEMALL_WX_INDEX_NEW); } public static Integer getHotLimit() { - return getConfigInt(PRE_FIX + "indexlimit.hot"); + return getConfigInt(LITEMALL_WX_INDEX_HOT); } public static Integer getBrandLimit() { - return getConfigInt(PRE_FIX + "indexlimit.brand"); + return getConfigInt(LITEMALL_WX_INDEX_BRAND); } public static Integer getTopicLimit() { - return getConfigInt(PRE_FIX + "indexlimit.topic"); + return getConfigInt(LITEMALL_WX_INDEX_TOPIC); } public static Integer getCatlogListLimit() { - return getConfigInt(PRE_FIX + "indexlimit.catloglist"); + return getConfigInt(LITEMALL_WX_INDEX_CATLOG_LIST); } public static Integer getCatlogMoreLimit() { - return getConfigInt(PRE_FIX + "indexlimit.catloggood"); - } - - public static String getHotBannerTitle() { - return getConfig(PRE_FIX + "banner.hot.title"); - } - - public static String getNewBannerTitle() { - return getConfig(PRE_FIX + "banner.new.title"); - } - - public static String getHotImageUrl() { - return getConfig(PRE_FIX + "banner.hot.imageurl"); - } - - public static String getNewImageUrl() { - return getConfig(PRE_FIX + "banner.new.imageurl"); - } - - public static BigDecimal getFreight() { - return getConfigBigDec(PRE_FIX + "freight.value"); - } - - public static BigDecimal getFreightLimit() { - return getConfigBigDec(PRE_FIX + "freight.limit"); - } - - public static String getMallName() { - return getConfig(PRE_FIX + "mallname"); + return getConfigInt(LITEMALL_WX_INDEX_CATLOG_GOODS); } public static boolean isAutoCreateShareImage() { - int autoCreate = getConfigInt(PRE_FIX + "shareimage.autocreate"); - return autoCreate == 0 ? false : true; + return getConfigBoolean(LITEMALL_WX_SHARE); } - @Override - public String getPrefix() { - return PRE_FIX; + public static BigDecimal getFreight() { + return getConfigBigDec(LITEMALL_EXPRESS_FREIGHT_VALUE); + } + + public static BigDecimal getFreightLimit() { + return getConfigBigDec(LITEMALL_EXPRESS_FREIGHT_MIN); + } + + public static String getMallName() { + return getConfig(LITEMALL_MALL_NAME); + } + + public static String getMallAddress() { + return getConfig(LITEMALL_MALL_ADDRESS); + } + + public static String getMallPhone() { + return getConfig(LITEMALL_MALL_PHONE); + } + + public static String getMallQQ() { + return getConfig(LITEMALL_MALL_QQ); + } + + public static void setConfigs(Map configs) { + SYSTEM_CONFIGS = configs; + } + + public static void updateConfigs(Map data) { + for (Map.Entry entry : data.entrySet()) { + SYSTEM_CONFIGS.put(entry.getKey(), entry.getValue()); + } } } \ No newline at end of file diff --git a/litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemInistService.java b/litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemInistService.java index 8bb41af0..e68c5004 100644 --- a/litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemInistService.java +++ b/litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemInistService.java @@ -1,34 +1,77 @@ package org.linlinjava.litemall.core.system; import org.linlinjava.litemall.core.util.SystemInfoPrinter; +import org.linlinjava.litemall.db.service.LitemallSystemConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; /** - * 系统启动服务,用于检查系统状态及打印系统信息 + * 系统启动服务,用于设置系统配置信息、检查系统状态及打印系统信息 */ @Component class SystemInistService { private SystemInistService systemInistService; - @Autowired - private ConfigService configService; + + @Autowired private Environment environment; @PostConstruct private void inist() { systemInistService = this; + initConfigs(); + SystemInfoPrinter.printInfo("Litemall 初始化信息", getSystemInfo()); + } - try { - SystemInfoPrinter.printInfo("Litemall 初始化信息", getSystemInfo()); - } catch (Exception e) { - e.printStackTrace(); + + private final static Map DEFAULT_CONFIGS = new HashMap<>(); + static { + // 小程序相关配置默认值 + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_NEW, "6"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_HOT, "6"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_BRAND, "4"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_TOPIC, "4"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_CATLOG_LIST, "4"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_INDEX_CATLOG_GOODS, "4"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_WX_SHARE, "false"); + // 运费相关配置默认值 + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_EXPRESS_FREIGHT_VALUE, "8"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_EXPRESS_FREIGHT_MIN, "88"); + // 订单相关配置默认值 + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_ORDER_UNPAID, "30"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_ORDER_UNCONFIRM, "7"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_ORDER_COMMENT, "7"); + // 订单相关配置默认值 + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_MALL_NAME, "litemall"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_MALL_ADDRESS, "上海"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_MALL_PHONE, "021-xxxx-xxxx"); + DEFAULT_CONFIGS.put(SystemConfig.LITEMALL_MALL_QQ, "738696120"); + } + + @Autowired + private LitemallSystemConfigService litemallSystemConfigService; + + private void initConfigs() { + // 1. 读取数据库全部配置信息 + Map configs = litemallSystemConfigService.queryAll(); + + // 2. 分析DEFAULT_CONFIGS + for (Map.Entry entry : DEFAULT_CONFIGS.entrySet()) { + if(configs.containsKey(entry.getKey())){ + continue; + } + + configs.put(entry.getKey(), entry.getValue()); + litemallSystemConfigService.addConfig(entry.getKey(), entry.getValue()); } + + SystemConfig.setConfigs(configs); } private Map getSystemInfo() { diff --git a/litemall-core/src/main/java/org/linlinjava/litemall/core/util/JacksonUtil.java b/litemall-core/src/main/java/org/linlinjava/litemall/core/util/JacksonUtil.java index 890c1591..d81d40e1 100644 --- a/litemall-core/src/main/java/org/linlinjava/litemall/core/util/JacksonUtil.java +++ b/litemall-core/src/main/java/org/linlinjava/litemall/core/util/JacksonUtil.java @@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.util.List; +import java.util.Map; public class JacksonUtil { public static String parseString(String body, String field) { @@ -144,4 +145,14 @@ public class JacksonUtil { return null; } + public static Map toMap(String data) { + ObjectMapper objectMapper = new ObjectMapper(); + try { + return objectMapper.readValue(data, new TypeReference>(){}); + } catch (IOException e) { + e.printStackTrace(); + } + return null; + } + } diff --git a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSystemConfigService.java b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSystemConfigService.java index b47224f7..07f92c82 100644 --- a/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSystemConfigService.java +++ b/litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallSystemConfigService.java @@ -6,16 +6,93 @@ import org.linlinjava.litemall.db.domain.LitemallSystemExample; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class LitemallSystemConfigService { @Resource private LitemallSystemMapper systemMapper; - public List queryAll() { + public Map queryAll() { LitemallSystemExample example = new LitemallSystemExample(); - example.or(); - return systemMapper.selectByExample(example); + example.or().andDeletedEqualTo(false); + + List systemList = systemMapper.selectByExample(example); + Map systemConfigs = new HashMap<>(); + for (LitemallSystem item : systemList) { + systemConfigs.put(item.getKeyName(), item.getKeyValue()); + } + + return systemConfigs; + } + + public Map listMail() { + LitemallSystemExample example = new LitemallSystemExample(); + example.or().andKeyNameLike("litemall_mall_%").andDeletedEqualTo(false); + List systemList = systemMapper.selectByExample(example); + Map data = new HashMap<>(); + for(LitemallSystem system : systemList){ + data.put(system.getKeyName(), system.getKeyValue()); + } + return data; + } + + public Map listWx() { + LitemallSystemExample example = new LitemallSystemExample(); + example.or().andKeyNameLike("litemall_wx_%").andDeletedEqualTo(false); + List systemList = systemMapper.selectByExample(example); + Map data = new HashMap<>(); + for(LitemallSystem system : systemList){ + data.put(system.getKeyName(), system.getKeyValue()); + } + return data; + } + + public Map listOrder() { + LitemallSystemExample example = new LitemallSystemExample(); + example.or().andKeyNameLike("litemall_order_%").andDeletedEqualTo(false); + List systemList = systemMapper.selectByExample(example); + Map data = new HashMap<>(); + for(LitemallSystem system : systemList){ + data.put(system.getKeyName(), system.getKeyValue()); + } + return data; + } + + public Map listExpress() { + LitemallSystemExample example = new LitemallSystemExample(); + example.or().andKeyNameLike("litemall_express_%").andDeletedEqualTo(false); + List systemList = systemMapper.selectByExample(example); + Map data = new HashMap<>(); + for(LitemallSystem system : systemList){ + data.put(system.getKeyName(), system.getKeyValue()); + } + return data; + } + + public void updateConfig(Map data) { + for (Map.Entry entry : data.entrySet()) { + LitemallSystemExample example = new LitemallSystemExample(); + example.or().andKeyNameEqualTo(entry.getKey()).andDeletedEqualTo(false); + + LitemallSystem system = new LitemallSystem(); + system.setKeyName(entry.getKey()); + system.setKeyValue(entry.getValue()); + system.setUpdateTime(LocalDateTime.now()); + systemMapper.updateByExampleSelective(system, example); + } + + } + + public void addConfig(String key, String value) { + LitemallSystem system = new LitemallSystem(); + system.setKeyName(key); + system.setKeyValue(value); + system.setAddTime(LocalDateTime.now()); + system.setUpdateTime(LocalDateTime.now()); + systemMapper.insertSelective(system); } }