u
This commit is contained in:
1 parent
aa813c9649
commit
62550b8182
45 files changed
+12535
-566
No files matched your search
+35
-1
@@ -2,11 +2,13 @@ package cn.g3soft.controller;
|
||||
|
||||
import cn.g3soft.config.datasource.DataSourceManager;
|
||||
import cn.g3soft.context.DataSourceContextHolder;
|
||||
import cn.g3soft.context.UserContext;
|
||||
import cn.g3soft.utils.DbUtils;
|
||||
import cn.g3soft.utils.Result;
|
||||
import cn.g3soft.utils.jwt.JwtPayload;
|
||||
import cn.g3soft.utils.jwt.JwtUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -77,7 +79,7 @@ public class AuthController {
|
||||
}
|
||||
|
||||
if (!canuse.equals("1")){
|
||||
return Result.fail("账号已被禁用");
|
||||
return Result.fail("账号未启用");
|
||||
}
|
||||
|
||||
// 校验成功
|
||||
@@ -90,4 +92,36 @@ public class AuthController {
|
||||
|
||||
return Result.ok(map);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updatePassword")
|
||||
@Transactional
|
||||
public Result<Map<String,Object>> updatePassword(@RequestBody Map<String,Object> params){
|
||||
String oldPassword = (String) params.get("oldPassword");
|
||||
String newPassword = (String) params.get("newPassword");
|
||||
|
||||
String userId = UserContext.get().getUserId();
|
||||
|
||||
String sql = "SELECT b_id,b_password FROM b_user WHERE b_id = ?";
|
||||
|
||||
List<Map<String, Object>> list = dbUtils.loadData(sql, userId);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
return Result.fail("账号不存在");
|
||||
}
|
||||
|
||||
Map<String, Object> user = list.get(0);
|
||||
|
||||
String dbPassword = Objects.toString(user.get("b_password"), "");
|
||||
|
||||
if (!dbPassword.equals(oldPassword)) {
|
||||
return Result.fail("旧密码错误");
|
||||
}
|
||||
|
||||
user.put("b_password", newPassword);
|
||||
|
||||
dbUtils.update("b_user", "b_id", user);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
+57
-20
@@ -32,20 +32,22 @@ public class ColumnController {
|
||||
String viewName = (String) params.get("viewName");
|
||||
|
||||
List<String> columns = Arrays.asList(
|
||||
"col_field_name",
|
||||
"col_caption",
|
||||
"col_display_format",
|
||||
"col_show_summary",
|
||||
"col_group_index"
|
||||
"b_id",
|
||||
"col_FieldName",
|
||||
"col_Caption",
|
||||
"col_Width",
|
||||
"col_DisplayFormat",
|
||||
"col_ShowSummary",
|
||||
"col_BandIndex"
|
||||
);
|
||||
|
||||
String where = "col_table_name = '" + viewName + "' AND col_visible = '1'";
|
||||
String where = "col_TableName = '" + viewName + "' AND col_Visible = '1'";
|
||||
|
||||
List<Map<String,Object>> data =
|
||||
dbUtils.loadData(
|
||||
"s_columnLib",
|
||||
where,
|
||||
"col_position desc",
|
||||
"col_Position ",
|
||||
columns
|
||||
);
|
||||
|
||||
@@ -66,22 +68,23 @@ public class ColumnController {
|
||||
String viewName = (String) params.get("viewName");
|
||||
|
||||
List<String> columns = Arrays.asList(
|
||||
"col_field_name",
|
||||
"col_field_name_v",
|
||||
"col_caption",
|
||||
"col_type",
|
||||
"col_width",
|
||||
"col_allow_readonly",
|
||||
"col_display_format",
|
||||
|
||||
"b_id",
|
||||
"col_FieldName",
|
||||
"col_FieldName_v",
|
||||
"col_Caption",
|
||||
"col_edit_type",
|
||||
"col_edit_width",
|
||||
"col_edit_source_data",
|
||||
"col_ReadOnly",
|
||||
"col_DisplayFormat",
|
||||
|
||||
"col_edit_source_table",
|
||||
"col_edit_source_field",
|
||||
"col_edit_height",
|
||||
"col_edit_group_index"
|
||||
"col_edit_grouping",
|
||||
"col_edit_total_column"
|
||||
);
|
||||
|
||||
String where = "col_table_name = '" + viewName + "' AND col_edit = '1'";
|
||||
String where = "col_TableName = '" + viewName + "' AND col_edit = '1'";
|
||||
|
||||
List<Map<String,Object>> data =
|
||||
dbUtils.loadData(
|
||||
@@ -107,7 +110,7 @@ public class ColumnController {
|
||||
|
||||
String viewName = (String) params.get("viewName");
|
||||
|
||||
String where = "col_table_name = '" + viewName + "'";
|
||||
String where = "col_TableName = '" + viewName + "'";
|
||||
List<Map<String,Object>> data =
|
||||
dbUtils.loadData(
|
||||
"s_columnLib",
|
||||
@@ -119,6 +122,33 @@ public class ColumnController {
|
||||
return Result.ok(data);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/detail")
|
||||
public Result<List<Map<String,Object>>> loadDetailColumns(@RequestBody Map<String, Object> params) {
|
||||
ValidationUtils.checkRequiredFields(params, "viewName");
|
||||
|
||||
String viewName = (String) params.get("viewName");
|
||||
|
||||
List<String> columns = Arrays.asList(
|
||||
"col_FieldName",
|
||||
"col_Caption",
|
||||
"col_DisplayFormat"
|
||||
);
|
||||
|
||||
String where = "col_TableName = '" + viewName + "' AND col_ShowDetail = '1'";
|
||||
|
||||
List<Map<String,Object>> data =
|
||||
dbUtils.loadData(
|
||||
"s_columnLib",
|
||||
where,
|
||||
"col_Caption desc",
|
||||
columns
|
||||
);
|
||||
|
||||
|
||||
return Result.ok(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验列配置接口
|
||||
*
|
||||
@@ -136,7 +166,14 @@ public class ColumnController {
|
||||
Map<String, Object> procParams = new HashMap<>();
|
||||
procParams.put("viewName", viewName);
|
||||
|
||||
dbUtils.executeProc("G3_CheckColumnSettings_New", procParams, false);
|
||||
dbUtils.executeProc("G3_CheckColumnSettings", procParams, false);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/updateColumns")
|
||||
public Result<Void> updateColumns(@RequestBody List<Map<String,Object>> params) {
|
||||
dbUtils.batchUpdate("s_columnLib", "b_id", params);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
+35
@@ -129,4 +129,39 @@ public class DataListController {
|
||||
|
||||
return Result.ok(data);
|
||||
}
|
||||
|
||||
@PostMapping("loadObject")
|
||||
public Result<Map<String, Object>> loadObject(@RequestBody Map<String, Object> params) {
|
||||
|
||||
ValidationUtils.checkRequiredFields(params, "viewName", "keyField", "keyValue");
|
||||
|
||||
String viewName = (String) params.get("viewName");
|
||||
String keyField = (String) params.get("keyField");
|
||||
String keyValue = (String) params.get("keyValue");
|
||||
|
||||
String searchCondition = (String) params.get("searchCondition");
|
||||
String orderField = (String) params.get("orderField");
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT * FROM ")
|
||||
.append(viewName)
|
||||
.append(" WHERE ")
|
||||
.append(keyField)
|
||||
.append(" = ?");
|
||||
|
||||
if (StringUtils.isNotBlank(searchCondition)) {
|
||||
sql.append(" ").append(searchCondition);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(orderField)) {
|
||||
sql.append(" ").append(orderField);
|
||||
}
|
||||
|
||||
List<Map<String, Object>> list = dbUtils.loadData(sql.toString(), keyValue);
|
||||
|
||||
if (list.isEmpty()) {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
return Result.ok(list.get(0));
|
||||
}
|
||||
}
|
||||
+72
-4
@@ -1,5 +1,6 @@
|
||||
package cn.g3soft.controller;
|
||||
|
||||
import cn.g3soft.utils.ValidationUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import cn.g3soft.context.UserContext;
|
||||
@@ -14,10 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data")
|
||||
@@ -194,6 +192,76 @@ public class DataSaveController {
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/deleteModule")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result<Map<String, Integer>> deleteModule(@RequestBody Map<String, Object> params) {
|
||||
ValidationUtils.checkRequiredFields(params, "moduleId", "Id");
|
||||
|
||||
String moduleId = params.get("moduleId").toString();
|
||||
String id = params.get("Id").toString();
|
||||
|
||||
Map<String, Integer> operationCounts = new LinkedHashMap<>();
|
||||
operationCounts.put("total", 0);
|
||||
|
||||
try {
|
||||
// ================== 1. 校验依赖 ==================
|
||||
String judgeSql = "SELECT b_JudgeCondition FROM s_module WHERE b_id = ?";
|
||||
List<Map<String, Object>> judgeList = dbUtils.loadData(judgeSql, moduleId);
|
||||
|
||||
if (!judgeList.isEmpty()) {
|
||||
String conditionSql = (String) judgeList.get(0).get("b_JudgeCondition");
|
||||
|
||||
if (conditionSql != null && !conditionSql.trim().isEmpty()) {
|
||||
conditionSql = conditionSql.replace(":b_id", "'" + id + "'");
|
||||
|
||||
List<Map<String, Object>> checkList = dbUtils.loadData(conditionSql);
|
||||
|
||||
if (!checkList.isEmpty()) {
|
||||
return Result.fail("存在依赖数据,禁止删除");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ================== 2. 查主表 ==================
|
||||
String mainSql = "SELECT b_SaveTable FROM s_module WHERE b_id = ?";
|
||||
List<Map<String, Object>> mainList = dbUtils.loadData(mainSql, moduleId);
|
||||
|
||||
if (mainList.isEmpty()) {
|
||||
return Result.fail("未找到模块配置");
|
||||
}
|
||||
|
||||
String mainTable = (String) mainList.get(0).get("b_SaveTable");
|
||||
|
||||
// ================== 3. 查关联表 ==================
|
||||
String linkSql = "SELECT b_SaveTable FROM s_module WHERE b_LinkTable = ?";
|
||||
List<Map<String, Object>> linkTables = dbUtils.loadData(linkSql, moduleId);
|
||||
|
||||
// ================== 4. 删除子表 ==================
|
||||
for (Map<String, Object> row : linkTables) {
|
||||
String tableName = (String) row.get("b_SaveTable");
|
||||
|
||||
// validateIdentifier(tableName);
|
||||
//
|
||||
int count = dbUtils.deleteById(tableName,"father",id);
|
||||
|
||||
operationCounts.merge(tableName, count, Integer::sum);
|
||||
operationCounts.merge("total", count, Integer::sum);
|
||||
}
|
||||
|
||||
// ================== 5. 删除主表 ==================
|
||||
// validateIdentifier(mainTable);
|
||||
|
||||
int mainCount = dbUtils.deleteById(mainTable,"b_id",id);
|
||||
|
||||
operationCounts.merge(mainTable, mainCount, Integer::sum);
|
||||
operationCounts.merge("total", mainCount, Integer::sum);
|
||||
|
||||
return Result.ok("删除成功", operationCounts);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("删除失败:" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addOperationLog(List<Map<String,Object>> logList,String table, String operation, List<Map<String, Object>> data) throws JsonProcessingException {
|
||||
if (ObjectUtils.isEmpty(data)){
|
||||
|
||||
Reference in new issue
Block a user