Browse Source

feat[litemall-admin-api, litemall-core, litemall-admin]: 支持配置管理,但后端部分配置信息(如订单、运费)还没有真正接入。

Junling Bu 6 years ago
parent
commit
05aa809c9d

+ 2 - 0
README.md

@@ -54,6 +54,8 @@ litemall = Spring Boot后端 + Vue管理员前端 + 微信小程序用户前端
 * 商品管理
 * 推广管理
 * 系统管理
+* 配置管理
+* 统计报表
 
 ## 云演示
 

+ 96 - 0
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<String, String> data = systemConfigService.listMail();
+        return ResponseUtil.ok(data);
+    }
+
+    @RequiresPermissions("admin:config:mall:updateConfigs")
+    @RequiresPermissionsDesc(menu={"配置管理" , "商场配置"}, button="编辑")
+    @PostMapping("/mall")
+    public Object updateMall(@RequestBody String body ) {
+        Map<String, String> 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<String, String> data = systemConfigService.listExpress();
+        return ResponseUtil.ok(data);
+    }
+
+    @RequiresPermissions("admin:config:express:updateConfigs")
+    @RequiresPermissionsDesc(menu={"配置管理" , "运费配置"}, button="编辑")
+    @PostMapping("/express")
+    public Object updateExpress(@RequestBody String body) {
+        Map<String, String> 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<String, String> data = systemConfigService.listOrder();
+        return ResponseUtil.ok(data);
+    }
+
+    @RequiresPermissions("admin:config:order:updateConfigs")
+    @RequiresPermissionsDesc(menu={"配置管理" , "订单配置"}, button="编辑")
+    @PostMapping("/order")
+    public Object updateOrder(@RequestBody String body) {
+        Map<String, String> data = JacksonUtil.toMap(body);
+        systemConfigService.updateConfig(data);
+        return ResponseUtil.ok();
+    }
+
+    @RequiresPermissions("admin:config:wx:list")
+    @RequiresPermissionsDesc(menu={"配置管理" , "小程序配置"}, button="详情")
+    @GetMapping("/wx")
+    public Object listWx() {
+        Map<String, String> data = systemConfigService.listWx();
+        return ResponseUtil.ok(data);
+    }
+
+    @RequiresPermissions("admin:config:wx:updateConfigs")
+    @RequiresPermissionsDesc(menu={"配置管理" , "小程序配置"}, button="编辑")
+    @PostMapping("/wx")
+    public Object updateWx(@RequestBody String body) {
+        Map<String, String> data = JacksonUtil.toMap(body);
+        systemConfigService.updateConfig(data);
+        SystemConfig.updateConfigs(data);
+        return ResponseUtil.ok();
+    }
+}

+ 61 - 0
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
+  })
+}

+ 2 - 2
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: [

+ 70 - 0
litemall-admin/src/views/config/express.vue

@@ -0,0 +1,70 @@
+<template>
+  <div class="app-container">
+    <el-form ref="dataForm" :rules="rules" :model="dataForm" status-icon label-width="300px">
+      <el-form-item label="运费满减所需最低消费" prop="litemall_express_freight_min">
+        <el-input v-model="dataForm.litemall_express_freight_min"/>
+      </el-form-item>
+      <el-form-item label="运费满减不足所需运费" prop="litemall_express_freight_value">
+        <el-input v-model="dataForm.litemall_express_freight_value"/>
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="cancel">取消</el-button>
+        <el-button type="primary" @click="update">确定</el-button>
+      </el-form-item>
+  </el-form></div>
+</template>
+
+<script>
+import { listExpress, updateExpress } from '@/api/config'
+
+export default {
+  name: 'ConfigExpress',
+  data() {
+    return {
+      dataForm: {
+        litemall_express_freight_min: 0,
+        litemall_express_freight_value: 0
+      },
+      rules: {
+        litemall_express_freight_min: [
+          { required: true, message: '不能为空', trigger: 'blur' }
+        ],
+        litemall_express_freight_value: [
+          { required: true, message: '不能为空', trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  created() {
+    this.init()
+  },
+  methods: {
+    init: function() {
+      listExpress().then(response => {
+        this.dataForm = response.data.data
+      })
+    },
+    cancel() {
+      this.init()
+    },
+    update() {
+      this.$refs['dataForm'].validate((valid) => {
+        if (!valid) {
+          return
+        }
+        updateExpress(this.dataForm).then(response => {
+          this.$notify.success({
+            title: '成功',
+            message: '运费配置修改成功'
+          })
+        }).catch(response => {
+          this.$notify.error({
+            title: '失败',
+            message: response.data.errmsg
+          })
+        })
+      })
+    }
+  }
+}
+</script>

+ 68 - 0
litemall-admin/src/views/config/mall.vue

@@ -0,0 +1,68 @@
+<template>
+  <div class="app-container">
+    <el-form ref="dataForm" :rules="rules" :model="dataForm" status-icon label-width="300px">
+      <el-form-item label="商场名称" prop="litemall_mall_name">
+        <el-input v-model="dataForm.litemall_mall_name"/>
+      </el-form-item>
+      <el-form-item label="商场地址" prop="litemall_mall_address">
+        <el-input v-model="dataForm.litemall_mall_address"/>
+      </el-form-item>
+      <el-form-item label="联系电话" prop="litemall_mall_phone">
+        <el-input v-model="dataForm.litemall_mall_phone"/>
+      </el-form-item>
+      <el-form-item label="联系QQ" prop="litemall_mall_qq">
+        <el-input v-model="dataForm.litemall_mall_qq"/>
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="cancel">取消</el-button>
+        <el-button type="primary" @click="update">确定</el-button>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+
+<script>
+import { listMall, updateMall } from '@/api/config'
+
+export default {
+  name: 'ConfigMail',
+  data() {
+    return {
+      dataForm: {
+        litemall_mall_name: '',
+        litemall_mall_address: '',
+        litemall_mall_phone: '',
+        litemall_mall_qq: ''
+      }
+    }
+  },
+  created() {
+    this.init()
+  },
+  methods: {
+    init: function() {
+      listMall().then(response => {
+        this.dataForm = response.data.data
+      })
+    },
+    cancel() {
+      this.init()
+    },
+    update() {
+      updateMall(this.dataForm)
+        .then(response => {
+          this.$notify.success({
+            title: '成功',
+            message: '商场配置成功'
+          })
+        })
+        .catch(response => {
+          this.$notify.error({
+            title: '失败',
+            message: response.data.errmsg
+          })
+        })
+    }
+  }
+}
+</script>

+ 66 - 0
litemall-admin/src/views/config/order.vue

@@ -0,0 +1,66 @@
+<template>
+  <div class="app-container">
+    <el-form ref="dataForm" :rules="rules" :model="dataForm" status-icon label-width="300px">
+      <el-form-item label="下单后超期自动取消" prop="litemall_order_unpaid">
+        <el-input v-model="dataForm.litemall_order_unpaid">
+          <template slot="append">分钟</template>
+        </el-input>
+      </el-form-item>
+      <el-form-item label="发货后超期自动确认收货" prop="litemall_order_unconfirm">
+        <el-input v-model="dataForm.litemall_order_unconfirm">
+          <template slot="append">天</template>
+        </el-input>
+      </el-form-item>
+      <el-form-item label="确认收货后超期取消评论资格" prop="litemall_order_comment">
+        <el-input v-model="dataForm.litemall_order_comment">
+          <template slot="append">天</template>
+        </el-input>
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="cancel">取消</el-button>
+        <el-button type="primary" @click="update">确定</el-button>
+      </el-form-item>
+    </el-form>
+  </div>
+</template>
+
+<script>
+import { listOrder, updateOrder } from '@/api/config'
+
+export default {
+  name: 'ConfigOrder',
+  data() {
+    return {
+      dataForm: {}
+    }
+  },
+  created() {
+    this.init()
+  },
+  methods: {
+    init: function() {
+      listOrder().then(response => {
+        this.dataForm = response.data.data
+      })
+    },
+    cancel() {
+      this.init()
+    },
+    update() {
+      updateOrder(this.dataForm)
+        .then(response => {
+          this.$notify.success({
+            title: '成功',
+            message: '订单参数配置成功'
+          })
+        })
+        .catch(response => {
+          this.$notify.error({
+            title: '失败',
+            message: response.data.errmsg
+          })
+        })
+    }
+  }
+}
+</script>

+ 86 - 0
litemall-admin/src/views/config/wx.vue

@@ -0,0 +1,86 @@
+<template>
+  <div class="app-container">
+    <el-form
+      ref="dataForm"
+      :rules="rules"
+      :model="dataForm"
+      status-icon
+      label-width="300px"
+
+    >
+      <el-tabs tab-position="left" >
+        <el-tab-pane label="首页配置">
+          <el-form-item label="新品首发栏目商品显示数量" prop="litemall_wx_index_new">
+            <el-input v-model="dataForm.litemall_wx_index_new"/>
+          </el-form-item>
+          <el-form-item label="人气推荐栏目商品显示数量" prop="litemall_wx_index_hot">
+            <el-input v-model="dataForm.litemall_wx_index_hot"/>
+          </el-form-item>
+          <el-form-item label="品牌制造商直供栏目品牌商显示数量" prop="litemall_wx_index_brand">
+            <el-input v-model="dataForm.litemall_wx_index_brand"/>
+          </el-form-item>
+          <el-form-item label="专题精选栏目显示数量" prop="litemall_wx_index_topic">
+            <el-input v-model="dataForm.litemall_wx_index_topic"/>
+          </el-form-item>
+          <el-form-item label="分类栏目显示数量" prop="litemall_wx_catlog_list">
+            <el-input v-model="dataForm.litemall_wx_catlog_list"/>
+          </el-form-item>
+          <el-form-item label="分类栏目商品显示数量" prop="litemall_wx_catlog_goods">
+            <el-input v-model="dataForm.litemall_wx_catlog_goods"/>
+          </el-form-item>
+        </el-tab-pane>
+        <el-tab-pane label="其他配置">
+          <el-form-item label="商品分享功能" prop="litemall_wx_share">
+            <el-switch v-model="dataForm.litemall_wx_share"/>
+          </el-form-item>
+        </el-tab-pane>
+      </el-tabs>
+      <el-form-item>
+        <el-button @click="cancel">取消</el-button>
+        <el-button type="primary" @click="update">确定</el-button>
+      </el-form-item>
+    </el-form>
+
+  </div>
+</template>
+
+<script>
+import { listWx, updateWx } from '@/api/config'
+
+export default {
+  name: 'ConfigWx',
+  data() {
+    return {
+      dataForm: { }
+    }
+  },
+  created() {
+    this.init()
+  },
+  methods: {
+    init: function() {
+      listWx().then(response => {
+        this.dataForm = response.data.data
+      })
+    },
+    cancel() {
+      this.init()
+    },
+    update() {
+      updateWx(this.dataForm)
+        .then(response => {
+          this.$notify.success({
+            title: '成功',
+            message: '小程序配置成功'
+          })
+        })
+        .catch(response => {
+          this.$notify.error({
+            title: '失败',
+            message: response.data.errmsg
+          })
+        })
+    }
+  }
+}
+</script>

+ 0 - 76
litemall-core/src/main/java/org/linlinjava/litemall/core/system/BaseConfig.java

@@ -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<String, String> 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<Map.Entry<String, String>> it = configs.entrySet().iterator(); it.hasNext(); ) {
-            Map.Entry<String, String> 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();
-}

+ 0 - 58
litemall-core/src/main/java/org/linlinjava/litemall/core/system/ConfigService.java

@@ -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<LitemallSystem> list = litemallSystemConfigService.queryAll();
-        for (LitemallSystem item : list) {
-            //符合条件,添加
-            if (item.getKeyName().startsWith(prefix))
-                BaseConfig.addConfig(item.getKeyName(), item.getKeyValue());
-        }
-    }
-
-    /**
-     * 读取全部配置
-     */
-    private void inistConfigs() {
-        List<LitemallSystem> list = litemallSystemConfigService.queryAll();
-        for (LitemallSystem item : list) {
-            BaseConfig.addConfig(item.getKeyName(), item.getKeyValue());
-        }
-    }
-}

+ 76 - 29
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<String, String> 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");
+        return getConfigInt(LITEMALL_WX_INDEX_CATLOG_GOODS);
     }
 
-    public static String getHotBannerTitle() {
-        return getConfig(PRE_FIX + "banner.hot.title");
+    public static boolean isAutoCreateShareImage() {
+        return getConfigBoolean(LITEMALL_WX_SHARE);
     }
 
-    public static String getNewBannerTitle() {
-        return getConfig(PRE_FIX + "banner.new.title");
+    public static BigDecimal getFreight() {
+        return getConfigBigDec(LITEMALL_EXPRESS_FREIGHT_VALUE);
     }
 
-    public static String getHotImageUrl() {
-        return getConfig(PRE_FIX + "banner.hot.imageurl");
+    public static BigDecimal getFreightLimit() {
+        return getConfigBigDec(LITEMALL_EXPRESS_FREIGHT_MIN);
     }
 
-    public static String getNewImageUrl() {
-        return getConfig(PRE_FIX + "banner.new.imageurl");
+    public static String getMallName() {
+        return getConfig(LITEMALL_MALL_NAME);
     }
 
-    public static BigDecimal getFreight() {
-        return getConfigBigDec(PRE_FIX + "freight.value");
+    public static String getMallAddress() {
+        return getConfig(LITEMALL_MALL_ADDRESS);
     }
 
-    public static BigDecimal getFreightLimit() {
-        return getConfigBigDec(PRE_FIX + "freight.limit");
+    public static String getMallPhone() {
+        return getConfig(LITEMALL_MALL_PHONE);
     }
 
-    public static String getMallName() {
-        return getConfig(PRE_FIX + "mallname");
+    public static String getMallQQ() {
+        return getConfig(LITEMALL_MALL_QQ);
     }
 
-    public static boolean isAutoCreateShareImage() {
-        int autoCreate = getConfigInt(PRE_FIX + "shareimage.autocreate");
-        return autoCreate == 0 ? false : true;
+    public static void setConfigs(Map<String, String> configs) {
+        SYSTEM_CONFIGS = configs;
     }
 
-    @Override
-    public String getPrefix() {
-        return PRE_FIX;
+    public static void updateConfigs(Map<String, String> data) {
+        for (Map.Entry<String, String> entry : data.entrySet()) {
+            SYSTEM_CONFIGS.put(entry.getKey(), entry.getValue());
+        }
     }
 }

+ 50 - 7
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());
+    }
+
+
+    private final static Map<String, String> 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;
 
-        try {
-            SystemInfoPrinter.printInfo("Litemall 初始化信息", getSystemInfo());
-        } catch (Exception e) {
-            e.printStackTrace();
+    private void initConfigs() {
+        // 1. 读取数据库全部配置信息
+        Map<String, String> configs = litemallSystemConfigService.queryAll();
+
+        // 2. 分析DEFAULT_CONFIGS
+        for (Map.Entry<String, String> 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<String, String> getSystemInfo() {

+ 11 - 0
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<String, String> toMap(String data) {
+        ObjectMapper objectMapper = new ObjectMapper();
+        try {
+            return objectMapper.readValue(data, new TypeReference<Map<String, String>>(){});
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
 }

+ 80 - 3
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<LitemallSystem> queryAll() {
+    public Map<String, String> queryAll() {
         LitemallSystemExample example = new LitemallSystemExample();
-        example.or();
-        return systemMapper.selectByExample(example);
+        example.or().andDeletedEqualTo(false);
+
+        List<LitemallSystem> systemList = systemMapper.selectByExample(example);
+        Map<String, String> systemConfigs = new HashMap<>();
+        for (LitemallSystem item : systemList) {
+            systemConfigs.put(item.getKeyName(), item.getKeyValue());
+        }
+
+        return systemConfigs;
+    }
+
+    public Map<String, String> listMail() {
+        LitemallSystemExample example = new LitemallSystemExample();
+        example.or().andKeyNameLike("litemall_mall_%").andDeletedEqualTo(false);
+        List<LitemallSystem> systemList = systemMapper.selectByExample(example);
+        Map<String, String> data = new HashMap<>();
+        for(LitemallSystem system : systemList){
+            data.put(system.getKeyName(), system.getKeyValue());
+        }
+        return data;
+    }
+
+    public Map<String, String> listWx() {
+        LitemallSystemExample example = new LitemallSystemExample();
+        example.or().andKeyNameLike("litemall_wx_%").andDeletedEqualTo(false);
+        List<LitemallSystem> systemList = systemMapper.selectByExample(example);
+        Map<String, String> data = new HashMap<>();
+        for(LitemallSystem system : systemList){
+            data.put(system.getKeyName(), system.getKeyValue());
+        }
+        return data;
+    }
+
+    public Map<String, String> listOrder() {
+        LitemallSystemExample example = new LitemallSystemExample();
+        example.or().andKeyNameLike("litemall_order_%").andDeletedEqualTo(false);
+        List<LitemallSystem> systemList = systemMapper.selectByExample(example);
+        Map<String, String> data = new HashMap<>();
+        for(LitemallSystem system : systemList){
+            data.put(system.getKeyName(), system.getKeyValue());
+        }
+        return data;
+    }
+
+    public Map<String, String> listExpress() {
+        LitemallSystemExample example = new LitemallSystemExample();
+        example.or().andKeyNameLike("litemall_express_%").andDeletedEqualTo(false);
+        List<LitemallSystem> systemList = systemMapper.selectByExample(example);
+        Map<String, String> data = new HashMap<>();
+        for(LitemallSystem system : systemList){
+            data.put(system.getKeyName(), system.getKeyValue());
+        }
+        return data;
+    }
+
+    public void updateConfig(Map<String, String> data) {
+        for (Map.Entry<String, String> 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);
     }
 }