shiqian 4 gadi atpakaļ
vecāks
revīzija
1d29546a59

+ 5 - 0
boman-common/boman-common-redis/src/main/java/com/boman/common/redis/RedisKey.java

@@ -11,4 +11,9 @@ public class RedisKey {
      * eg: table:tableName
      * eg: table:tableName
      */
      */
     public static final String TABLE_INFO = "table:";
     public static final String TABLE_INFO = "table:";
+
+    /**
+     * 维护redis中每张表的sequence
+     */
+    public static final String SEQ = "SEQ:";
 }
 }

+ 9 - 10
boman-modules/boman-system/src/main/java/com/boman/system/common/TableServiceCmdService.java

@@ -3,7 +3,6 @@ package com.boman.system.common;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
-import com.boman.common.core.utils.StringUtils;
 import com.boman.common.core.utils.collection.CollectionUtils;
 import com.boman.common.core.utils.collection.CollectionUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.core.utils.obj.ObjectUtils;
 import com.boman.common.core.web.domain.AjaxResult;
 import com.boman.common.core.web.domain.AjaxResult;
@@ -12,15 +11,15 @@ import com.boman.common.redis.service.RedisService;
 import com.boman.gen.domain.GenTable;
 import com.boman.gen.domain.GenTable;
 import com.boman.gen.domain.GenTableColumn;
 import com.boman.gen.domain.GenTableColumn;
 import com.boman.system.mapper.StandardlyMapper;
 import com.boman.system.mapper.StandardlyMapper;
+import com.boman.system.service.IBaseDeleteService;
+import com.boman.system.service.IBaseSaveService;
 import com.boman.system.service.IBaseSelectService;
 import com.boman.system.service.IBaseSelectService;
-import com.boman.system.service.impl.BaseDeleteService;
-import com.boman.system.service.impl.BaseSaveService;
 import com.boman.system.utils.IdUtils;
 import com.boman.system.utils.IdUtils;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
+import javax.annotation.Resource;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
@@ -38,13 +37,13 @@ import static com.boman.system.common.FormDataConstant.SHOW_DATA;
 @Component
 @Component
 public class TableServiceCmdService {
 public class TableServiceCmdService {
 
 
-    @Autowired
-    private BaseDeleteService deleteService;
-    @Autowired
-    private BaseSaveService saveService;
-    @Autowired
+    @Resource
+    private IBaseDeleteService deleteService;
+    @Resource
+    private IBaseSaveService saveService;
+    @Resource
     private RedisService redisService;
     private RedisService redisService;
-    @Autowired
+    @Resource
     private IBaseSelectService selectService;
     private IBaseSelectService selectService;
 
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);
     private static final Logger LOGGER = LoggerFactory.getLogger(TableServiceCmdService.class);

+ 0 - 2
boman-modules/boman-system/src/main/java/com/boman/system/common/TableServiceContext.java

@@ -101,8 +101,6 @@ public class TableServiceContext {
             result.isDelMtable = isdelmtable;
             result.isDelMtable = isdelmtable;
         }
         }
 
 
-        result.currentTime = new Timestamp(System.currentTimeMillis());
-
         // 获取objid判断 新增或更新
         // 获取objid判断 新增或更新
         Long objid = baseTableDTO.getObjId();
         Long objid = baseTableDTO.getObjId();
         MainTableRecord mainRowData = new MainTableRecord(result, result.table, objid, fixedData, tabItem);
         MainTableRecord mainRowData = new MainTableRecord(result, result.table, objid, fixedData, tabItem);

+ 1 - 0
boman-modules/boman-system/src/main/java/com/boman/system/mapper/StandardlyMapper.java

@@ -106,6 +106,7 @@ public interface StandardlyMapper {
 
 
     /**
     /**
      * 功能描述: 自定义查询,需要查询的字段和value都在condition中
      * 功能描述: 自定义查询,需要查询的字段和value都在condition中
+     * {@link StandardlyMapper.SqlProvider#selectByCondition(java.util.Map)}
      *
      *
      * @param tableName     tableName
      * @param tableName     tableName
      * @param condition     condition
      * @param condition     condition

+ 35 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/IBaseDeleteService.java

@@ -0,0 +1,35 @@
+package com.boman.system.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.boman.system.common.RowResult;
+
+/**
+ * @author shiqian
+ * @date 2021年03月26日 11:16
+ **/
+public interface IBaseDeleteService {
+
+
+    /**
+     * 功能描述: 在此不对入参进行校验,所以在调用此方法之前一定要对参数进行校验,以免报错
+     *
+     * @param idArr     需要删除的iD
+     * @param tableName 业务主表
+     * @param pkName    业务表的主键名
+     * @return com.boman.system.common.RowResult
+     */
+    RowResult objectDelete(Long[] idArr, String tableName, String pkName);
+
+    /**
+     * 功能描述: 在此不对入参进行校验,所以在调用此方法之前一定要对参数进行校验,以免报错
+     *
+     * @param idArr     需要删除的iD
+     * @param tableName 业务主表
+     * @param pkName    业务表的主键名
+     * @param model     逻辑删除的字段和值
+     * @return com.boman.system.common.RowResult
+     */
+    RowResult objectLogicDelete(Long[] idArr, String tableName, String pkName, JSONObject model);
+
+
+}

+ 25 - 0
boman-modules/boman-system/src/main/java/com/boman/system/service/IBaseSaveService.java

@@ -0,0 +1,25 @@
+package com.boman.system.service;
+
+import com.boman.system.common.MainTableRecord;
+import com.boman.system.common.RowResult;
+
+/**
+ * @author shiqian
+ * @description
+ * @date 2021年03月22日 11:25
+ **/
+public interface IBaseSaveService {
+
+
+    /**
+     * 功能描述: 保存一行
+     *
+     * @param tableName tableName
+     * @param pkName    主键名称
+     * @param maxId     最大的SEQ
+     * @param row       要保存的数据
+     * @return com.boman.system.common.RowResult
+     */
+    RowResult insertRow(String tableName, String pkName, Long maxId, MainTableRecord row);
+
+}

+ 5 - 2
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/BaseDeleteService.java → boman-modules/boman-system/src/main/java/com/boman/system/service/impl/BaseDeleteServiceImpl.java

@@ -3,6 +3,7 @@ package com.boman.system.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.boman.system.common.RowResult;
 import com.boman.system.common.RowResult;
 import com.boman.system.mapper.StandardlyMapper;
 import com.boman.system.mapper.StandardlyMapper;
+import com.boman.system.service.IBaseDeleteService;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,9 +14,9 @@ import org.springframework.stereotype.Service;
  * @date 2021年03月26日 11:16
  * @date 2021年03月26日 11:16
  **/
  **/
 @Service
 @Service
-public class BaseDeleteService {
+public class BaseDeleteServiceImpl implements IBaseDeleteService {
 
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(BaseDeleteService.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(BaseDeleteServiceImpl.class);
 
 
     @Autowired
     @Autowired
     private StandardlyMapper mapper;
     private StandardlyMapper mapper;
@@ -28,6 +29,7 @@ public class BaseDeleteService {
      * @param pkName    业务表的主键名
      * @param pkName    业务表的主键名
      * @return com.boman.system.common.RowResult
      * @return com.boman.system.common.RowResult
      */
      */
+    @Override
     public RowResult objectDelete(Long[] idArr, String tableName, String pkName) {
     public RowResult objectDelete(Long[] idArr, String tableName, String pkName) {
         int delete = mapper.deleteByIds(tableName, idArr, pkName);
         int delete = mapper.deleteByIds(tableName, idArr, pkName);
         return RowResult.ok("共删除了 " + delete + " 条记录");
         return RowResult.ok("共删除了 " + delete + " 条记录");
@@ -42,6 +44,7 @@ public class BaseDeleteService {
      * @param model     逻辑删除的字段和值
      * @param model     逻辑删除的字段和值
      * @return com.boman.system.common.RowResult
      * @return com.boman.system.common.RowResult
      */
      */
+    @Override
     public RowResult objectLogicDelete(Long[] idArr, String tableName, String pkName, JSONObject model) {
     public RowResult objectLogicDelete(Long[] idArr, String tableName, String pkName, JSONObject model) {
         int delete = mapper.updateById(tableName, model, pkName, idArr);
         int delete = mapper.updateById(tableName, model, pkName, idArr);
         return RowResult.ok("共删除了 " + delete + " 条记录");
         return RowResult.ok("共删除了 " + delete + " 条记录");

+ 21 - 21
boman-modules/boman-system/src/main/java/com/boman/system/service/impl/BaseSaveService.java → boman-modules/boman-system/src/main/java/com/boman/system/service/impl/BaseSaveServiceImpl.java

@@ -1,10 +1,11 @@
 package com.boman.system.service.impl;
 package com.boman.system.service.impl;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.boman.common.core.utils.SecurityUtils;
 import com.boman.system.common.MainTableRecord;
 import com.boman.system.common.MainTableRecord;
 import com.boman.system.common.RowResult;
 import com.boman.system.common.RowResult;
-import com.boman.system.common.TableServiceContext;
 import com.boman.system.mapper.StandardlyMapper;
 import com.boman.system.mapper.StandardlyMapper;
+import com.boman.system.service.IBaseSaveService;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,35 +19,34 @@ import java.sql.Timestamp;
  * @date 2021年03月22日 11:25
  * @date 2021年03月22日 11:25
  **/
  **/
 @Component
 @Component
-public class BaseSaveService {
+public class BaseSaveServiceImpl implements IBaseSaveService {
 
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(BaseSaveService.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(BaseSaveServiceImpl.class);
 
 
     @Autowired
     @Autowired
     private StandardlyMapper mapper;
     private StandardlyMapper mapper;
 
 
-    public RowResult insertRow(TableServiceContext context, MainTableRecord row, Timestamp currentTime) {
-        JSONObject commitData = row.getMainData().getCommitData();
-        commitData.put("CREATE_TIME", currentTime);
-        commitData.put("CREATE_BY", "张三");
-        commitData.put("UPDATE_BY", "张三");
-        commitData.put("UPDATE_TIME", currentTime);
-        int ret = mapper.insert(context.getRealTableName(), commitData);
-        if (ret > 0) {
-            commitData.put("successCnt", ret);
-            return RowResult.ok("保存成功", commitData);
-        }
-
-        return RowResult.error("失败");
-    }
-
+    /**
+     * 功能描述: 保存一行
+     *
+     * @param tableName tableName
+     * @param pkName    主键名称
+     * @param maxId     最大的SEQ
+     * @param row       要保存的数据
+     * @return com.boman.system.common.RowResult
+     */
+    @Override
     public RowResult insertRow(String tableName, String pkName, Long maxId, MainTableRecord row) {
     public RowResult insertRow(String tableName, String pkName, Long maxId, MainTableRecord row) {
         JSONObject commitData = row.getMainData().getCommitData();
         JSONObject commitData = row.getMainData().getCommitData();
         Timestamp currentTime = new Timestamp(System.currentTimeMillis());
         Timestamp currentTime = new Timestamp(System.currentTimeMillis());
-        commitData.put("CREATE_TIME", currentTime);
-        commitData.put("CREATE_BY", "张三");
-        commitData.put("UPDATE_BY", "张三");
+        commitData.put("UPDATE_BY", SecurityUtils.getUserId());
         commitData.put("UPDATE_TIME", currentTime);
         commitData.put("UPDATE_TIME", currentTime);
+        // 新增
+        if (row.getId() > 0) {
+            commitData.put("CREATE_TIME", currentTime);
+            commitData.put("CREATE_BY", SecurityUtils.getUserId());
+        }
+
         commitData.put(pkName.toUpperCase(), maxId);
         commitData.put(pkName.toUpperCase(), maxId);
         int ret = mapper.insert(tableName, commitData);
         int ret = mapper.insert(tableName, commitData);
         if (ret > 0) {
         if (ret > 0) {

+ 2 - 1
boman-modules/boman-system/src/main/java/com/boman/system/utils/IdUtils.java

@@ -1,6 +1,7 @@
 package com.boman.system.utils;
 package com.boman.system.utils;
 
 
 import com.boman.common.core.utils.SpringUtils;
 import com.boman.common.core.utils.SpringUtils;
+import com.boman.common.redis.RedisKey;
 import com.boman.common.redis.service.RedisService;
 import com.boman.common.redis.service.RedisService;
 import com.boman.gen.domain.GenTableColumn;
 import com.boman.gen.domain.GenTableColumn;
 import com.boman.system.mapper.StandardlyMapper;
 import com.boman.system.mapper.StandardlyMapper;
@@ -18,7 +19,7 @@ public class IdUtils {
 
 
     public static Long getMaxId(String tableName, String pkName) {
     public static Long getMaxId(String tableName, String pkName) {
         RedisService redisService = SpringUtils.getBean(RedisService.class);
         RedisService redisService = SpringUtils.getBean(RedisService.class);
-        String sequencesKey = "SEQ:" + tableName.toUpperCase();
+        String sequencesKey = RedisKey.SEQ + tableName.toUpperCase();
         boolean isExist = redisService.exists(sequencesKey);
         boolean isExist = redisService.exists(sequencesKey);
         if (isExist) {
         if (isExist) {
             return redisService.increment(sequencesKey);
             return redisService.increment(sequencesKey);

+ 0 - 8
boman-modules/boman-system/src/main/resources/bootstrap.yml

@@ -1,25 +1,17 @@
-# Tomcat
 server:
 server:
   port: 9201
   port: 9201
 
 
-# Spring
 spring: 
 spring: 
   application:
   application:
-    # 应用名称
     name: boman-system
     name: boman-system
   profiles:
   profiles:
-    # 环境配置
     active: dev
     active: dev
   cloud:
   cloud:
     nacos:
     nacos:
       discovery:
       discovery:
-        # 服务注册地址
         server-addr: 192.168.101.10:8848
         server-addr: 192.168.101.10:8848
       config:
       config:
-        # 配置中心地址
         server-addr: 192.168.101.10:8848
         server-addr: 192.168.101.10:8848
-        # 配置文件格式
         file-extension: yml
         file-extension: yml
-        # 共享配置
         shared-configs:
         shared-configs:
           - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
           - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

+ 2 - 1
ruoyi-ui/vue.config.js

@@ -34,7 +34,8 @@ module.exports = {
     proxy: {
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://192.168.101.11:8090`,
+        // target: `http://shiqian:8080`,
+        target: `http://boman:8080`,
         // target: `http://192.168.101.110:8080`,
         // target: `http://192.168.101.110:8080`,
         // target: `http://192.168.101.10:8080`,
         // target: `http://192.168.101.10:8080`,
         changeOrigin: true,
         changeOrigin: true,