david 2 years ago
parent
commit
6255f67edf

BIN
out/artifacts/roma_api_jar/roma-api.jar


+ 37 - 1
src/main/java/com/roma/romaapi/controller/ApiController.java

@@ -233,9 +233,45 @@ public class ApiController {
         return CustomResponse.formatResponse(ret);
     }
 
+    // 返回带分页格式的数据-item列表管理页
+    @RequestMapping("/api/itemManageList")
+    public Map itemManageList(HttpServletRequest request, @RequestBody String data){
+        Map maps = commonUtil.analysisRequestParams(request, data); // 参数
+        Map<String, Object> ret = new HashMap<>();
+        ret = apiService.itemListHasPaging(maps);
+
+        return CustomResponse.formatResponse(ret);
+    }
+
+    // item管理-新增和编辑item
+    @RequestMapping("/api/itemSave")
+    public Map itemSave(HttpServletRequest request, @RequestBody String data,
+                        @RequestHeader("Authorization") String authorization) {
+        Map maps = commonUtil.analysisRequestParams(request, data); // 参数
+
+        Map ret = apiService.saveItem(maps, authorization);
+
+        return CustomResponse.formatResponse(ret);
+    }
+
+    // Item管理-获取item详情
+    @RequestMapping("/api/itemDetailed")
+    public Map itemDetailed(HttpServletRequest request, @RequestBody String data) {
+        Map maps = commonUtil.analysisRequestParams(request, data); // 参数
+        Map ret = apiService.itemDetailById(maps);
+
+        return CustomResponse.formatResponse(ret);
+    }
 
+    // 返回带分页格式的数据-用户管理列表页
+    @RequestMapping("/api/userManageList")
+    public Map userManageList(HttpServletRequest request, @RequestBody String data){
+        Map maps = commonUtil.analysisRequestParams(request, data); // 参数
+        Map<String, Object> ret = new HashMap<>();
+        ret = apiService.userListHasPaging(maps);
 
-    // 用户管理-获取全部用户
+        return CustomResponse.formatResponse(ret);
+    }
 
     // 用户分配角色
 }

+ 22 - 1
src/main/java/com/roma/romaapi/dao/ApiDao.java

@@ -174,7 +174,7 @@ public class ApiDao {
         }
     }
 
-    // 添加/编辑sql_details表数据
+    // 添加/编辑api_details表数据
     public Integer saveApiDetails(Map<String, Object> bindValue, String editId) {
         String sql = "";
         if (editId.length()==0) {
@@ -195,6 +195,27 @@ public class ApiDao {
         }
     }
 
+    // 添加/编辑item_details表数据
+    public Integer saveItemDetails(Map<String, Object> bindValue, String editId) {
+        String sql = "";
+        if (editId.length()==0) {
+            sql = " INSERT INTO `item_details` (`item_name`,`item_code`,`item_description`,`is_enable`,`created_at`) " +
+                    "VALUES (:itemName,:itemCode,:itemDesc,:isEnable,:createdAt)  ";
+            KeyHolder keyHolder = new GeneratedKeyHolder();
+            Integer row = namedParameterJdbcTemplate.update(sql, new MapSqlParameterSource(bindValue), keyHolder);
+            int k = keyHolder.getKey().intValue();
+
+            return k;
+        } else {
+            bindValue.put("id", editId);
+            sql = " UPDATE `item_details` SET `item_name`=:itemName,`item_code`=:itemCode,`item_description`=:itemDesc," +
+                    "`is_enable`=:isEnable WHERE id=:id";
+            Integer row = namedParameterJdbcTemplate.update(sql, bindValue);
+
+            return row;
+        }
+    }
+
     // Role角色管理-获取总数
     public Integer getAllRoleListHasPagingCount(Map bindValue) {
         // 获取总数

+ 42 - 0
src/main/java/com/roma/romaapi/dao/PageDao.java

@@ -136,6 +136,27 @@ public class PageDao {
         return resMap2;
     }
 
+    // item页面管理-获取总数
+    public Integer getAllItemListHasPagingCount(Map bindValue) {
+        // 获取总数
+        String countInnerSql = " SELECT * FROM `item_details` WHERE 1=1 ";
+        String countSql = "SELECT COUNT(*) AS `totalData` FROM ( " + countInnerSql + " ) AS ROMA";
+        Integer count = namedParameterJdbcTemplate.queryForObject(countSql, bindValue, Integer.class);
+
+        return count;
+    }
+
+    // item页面管理-获取带分页的列表数据
+    public List<Map<String, Object>> getAllItemListHasPaging(Map bindValue, String page, String perPage, Integer count) {
+        // 计算分页
+        String limitAfter = commonUtil.calcPagingString(count, page, perPage);
+        String listSql = "SELECT  *  FROM `item_details` WHERE 1=1 ORDER BY `id` DESC " + " LIMIT " + limitAfter;
+
+        List<Map<String, Object>> resMap2 = namedParameterJdbcTemplate.queryForList(listSql, bindValue);
+
+        return resMap2;
+    }
+
     // 获取全部的sql
     public List<Map<String, Object>> getAllSqlList() {
         Map<String, Object> paramMap = new HashMap<>();
@@ -162,4 +183,25 @@ public class PageDao {
 
         return resMap2;
     }
+
+    // 用户管理-获取总数
+    public Integer getAllUserListHasPagingCount(Map bindValue) {
+        // 获取总数
+        String countInnerSql = " SELECT * FROM `admin_user` WHERE 1=1 ";
+        String countSql = "SELECT COUNT(*) AS `totalData` FROM ( " + countInnerSql + " ) AS ROMA";
+        Integer count = namedParameterJdbcTemplate.queryForObject(countSql, bindValue, Integer.class);
+
+        return count;
+    }
+
+    // 用户管理-获取带分页的列表数据
+    public List<Map<String, Object>> getAllUserListHasPaging(Map bindValue, String page, String perPage, Integer count) {
+        // 计算分页
+        String limitAfter = commonUtil.calcPagingString(count, page, perPage);
+        String listSql = "SELECT  *  FROM `admin_user` WHERE 1=1 ORDER BY `id` DESC " + " LIMIT " + limitAfter;
+
+        List<Map<String, Object>> resMap2 = namedParameterJdbcTemplate.queryForList(listSql, bindValue);
+
+        return resMap2;
+    }
 }

+ 83 - 0
src/main/java/com/roma/romaapi/service/ApiService.java

@@ -219,6 +219,26 @@ public class ApiService {
         return res;
     }
 
+    // api管理列表-获取带分页的page数据
+    public Map itemListHasPaging(Map<String, String> maps) {
+        String page = "1"; // 页数
+        String perPage = "15"; // 显示多少条
+        Map res = new HashMap<>();
+        Map bindData = commonUtil.filterApiBindParams(maps);
+        if(maps.containsKey("page")) {
+            page = maps.get("page");
+        }
+        if(maps.containsKey("perPage")) {
+            perPage = maps.get("perPage");
+        }
+        Integer count = pageDao.getAllItemListHasPagingCount(bindData);
+        List info = pageDao.getAllItemListHasPaging(bindData, page, perPage, count);
+        res.put("count", count);
+        res.put("rows", info);
+
+        return res;
+    }
+
     // 获取全部sql_details
     public List sqlList() {
         Map<String, Object> map = new HashMap<>();
@@ -475,6 +495,69 @@ public class ApiService {
         return info;
     }
 
+    // 获取item详情
+    public Map itemDetailById(Map params) {
+        String id = params.get("id").toString();
+        Map info = apiDao.getDetailsInfoByIdAndType("item_details", id);
+
+        return info;
+    }
+
+    // 添加/编辑item_details表数据
+    public Map saveItem(Map maps, String authorization) {
+        String itemDesc = "";
+        String isEnable = maps.get("is_enable").toString();
+        String itemCode = maps.get("item_code").toString();
+        String itemName = maps.get("item_name").toString();
+        if(maps.containsKey("item_description")) {
+            itemDesc = maps.get("item_description").toString();
+        }
+        // 通过是否存在id,判读是新增还是修改
+        String editId = "";
+        if (maps.containsKey("id")) {
+            editId = maps.get("id").toString();
+        }
+        String createdAt = commonUtil.getNowYYMMDDHHIISS();
+        Map<String, Object> addPagePamars = new HashMap<>();
+        addPagePamars.put("isEnable", isEnable);
+        addPagePamars.put("itemCode", itemCode);
+        addPagePamars.put("itemName", itemName);
+        addPagePamars.put("itemDesc", itemDesc);
+//        Map<String, Object> loginResult = this.userInfo(authorization);
+//        addPagePamars.put("actionUser", loginResult.get("userName")); // 获取当前用户信息
+        if (editId.length()==0) {
+            // 如果不存在说明是新增
+            addPagePamars.put("createdAt", createdAt);
+        }
+        // 添加/编辑
+        Integer pageId = apiDao.saveItemDetails(addPagePamars, editId);
+        Map retInfo = new HashMap<>();
+        if(pageId <= 0){
+            retInfo.put("sysErrorCode", "500");
+        }
+        return retInfo;
+    }
+
+    // 用户管理列表-获取带分页的page数据
+    public Map userListHasPaging(Map<String, String> maps) {
+        String page = "1"; // 页数
+        String perPage = "15"; // 显示多少条
+        Map res = new HashMap<>();
+        Map bindData = commonUtil.filterApiBindParams(maps);
+        if(maps.containsKey("page")) {
+            page = maps.get("page");
+        }
+        if(maps.containsKey("perPage")) {
+            perPage = maps.get("perPage");
+        }
+        Integer count = pageDao.getAllUserListHasPagingCount(bindData);
+        List info = pageDao.getAllUserListHasPaging(bindData, page, perPage, count);
+        res.put("count", count);
+        res.put("rows", info);
+
+        return res;
+    }
+
     // 转换tree结构数据
     private List<Map<String, Object>> treeMenu(List<Map<String, Object>> renderMenu){
         // 处理的数据存在