优化系统配置模块
This commit is contained in:
@@ -422,35 +422,6 @@
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查当前用户是否是演示用户
|
|
||||||
*/
|
|
||||||
function checkIsTestUser() {
|
|
||||||
var result = false;
|
|
||||||
var demonstrateOpen = false;
|
|
||||||
$.ajax({
|
|
||||||
type: "get",
|
|
||||||
url: "/user/getDemonstrateOpen",
|
|
||||||
dataType: "json",
|
|
||||||
async: false, //设置为同步
|
|
||||||
success: function (res) {
|
|
||||||
if (res && res.code === 200) {
|
|
||||||
demonstrateOpen = res.data.demonstrateOpen;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if(demonstrateOpen) {
|
|
||||||
var loginName = sessionStorage.getItem("loginName");
|
|
||||||
if (loginName == "jsh") {
|
|
||||||
$.messager.alert('提示', '演示用户禁止操作!', 'warning');
|
|
||||||
result = true;
|
|
||||||
} else {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断一个值是否数字
|
* 判断一个值是否数字
|
||||||
* @param value
|
* @param value
|
||||||
|
|||||||
@@ -246,21 +246,66 @@
|
|||||||
|
|
||||||
//删除系统配置信息
|
//删除系统配置信息
|
||||||
function deleteSystemConfig(systemConfigId) {
|
function deleteSystemConfig(systemConfigId) {
|
||||||
if(checkIsTestUser()) {
|
$.messager.confirm('删除确认', '确定要删除此系统配置信息吗?', function (r) {
|
||||||
|
if (r) {
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: "/systemConfig/batchDeleteSystemConfigByIds",
|
||||||
|
dataType: "json",
|
||||||
|
data: ({
|
||||||
|
ids: systemConfigId
|
||||||
|
}),
|
||||||
|
success: function (res) {
|
||||||
|
if(res && res.code == 200) {
|
||||||
|
$("#searchBtn").click();
|
||||||
|
} else if(res.code == -1) {
|
||||||
|
$.messager.alert('提示', '演示用户禁止操作!', 'warning');
|
||||||
|
} else {
|
||||||
|
$.messager.alert('删除提示', '删除系统配置信息失败,请稍后再试!', 'error');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//此处添加错误处理
|
||||||
|
error: function () {
|
||||||
|
$.messager.alert('删除提示', '删除系统配置信息异常,请稍后再试!', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//批量删除系统配置
|
||||||
|
function batDeleteSystemConfig() {
|
||||||
|
var row = $('#tableData').datagrid('getChecked');
|
||||||
|
if (row.length == 0) {
|
||||||
|
$.messager.alert('删除提示', '没有记录被选中!', 'warning');
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
$.messager.confirm('删除确认', '确定要删除此系统配置信息吗?', function (r) {
|
if (row.length > 0) {
|
||||||
|
$.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条系统配置信息吗?', function (r) {
|
||||||
if (r) {
|
if (r) {
|
||||||
|
var ids = "";
|
||||||
|
for (var i = 0; i < row.length; i++) {
|
||||||
|
if (i == row.length - 1) {
|
||||||
|
ids += row[i].id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ids += row[i].id + ",";
|
||||||
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "post",
|
type: "post",
|
||||||
url: "/systemConfig/batchDeleteSystemConfigByIds",
|
url: "/systemConfig/batchDeleteSystemConfigByIds",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
|
async: false,
|
||||||
data: ({
|
data: ({
|
||||||
ids: systemConfigId
|
ids: ids
|
||||||
}),
|
}),
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
if(res && res.code == 200) {
|
if(res && res.code === 200) {
|
||||||
$("#searchBtn").click();
|
$("#searchBtn").click();
|
||||||
|
$(":checkbox").attr("checked", false);
|
||||||
|
} else if(res.code === -1) {
|
||||||
|
$.messager.alert('提示', '演示用户禁止操作!', 'warning');
|
||||||
} else {
|
} else {
|
||||||
$.messager.alert('删除提示', '删除系统配置信息失败,请稍后再试!', 'error');
|
$.messager.alert('删除提示', '删除系统配置信息失败,请稍后再试!', 'error');
|
||||||
}
|
}
|
||||||
@@ -276,55 +321,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//批量删除系统配置
|
|
||||||
function batDeleteSystemConfig() {
|
|
||||||
if(checkIsTestUser()) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
var row = $('#tableData').datagrid('getChecked');
|
|
||||||
if (row.length == 0) {
|
|
||||||
$.messager.alert('删除提示', '没有记录被选中!', 'warning');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (row.length > 0) {
|
|
||||||
$.messager.confirm('删除确认', '确定要删除选中的' + row.length + '条系统配置信息吗?', function (r) {
|
|
||||||
if (r) {
|
|
||||||
var ids = "";
|
|
||||||
for (var i = 0; i < row.length; i++) {
|
|
||||||
if (i == row.length - 1) {
|
|
||||||
ids += row[i].id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ids += row[i].id + ",";
|
|
||||||
}
|
|
||||||
$.ajax({
|
|
||||||
type: "post",
|
|
||||||
url: "/systemConfig/batchDeleteSystemConfigByIds",
|
|
||||||
dataType: "json",
|
|
||||||
async: false,
|
|
||||||
data: ({
|
|
||||||
ids: ids
|
|
||||||
}),
|
|
||||||
success: function (res) {
|
|
||||||
if(res && res.code === 200) {
|
|
||||||
$("#searchBtn").click();
|
|
||||||
$(":checkbox").attr("checked", false);
|
|
||||||
} else {
|
|
||||||
$.messager.alert('删除提示', '删除系统配置信息失败,请稍后再试!', 'error');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//此处添加错误处理
|
|
||||||
error: function () {
|
|
||||||
$.messager.alert('删除提示', '删除系统配置信息异常,请稍后再试!', 'error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//增加系统配置
|
//增加系统配置
|
||||||
var url;
|
var url;
|
||||||
var systemConfigId = 0;
|
var systemConfigId = 0;
|
||||||
@@ -353,9 +349,6 @@
|
|||||||
|
|
||||||
//保存系统配置信息
|
//保存系统配置信息
|
||||||
$("#saveSystemConfig").off("click").on("click", function () {
|
$("#saveSystemConfig").off("click").on("click", function () {
|
||||||
if(checkIsTestUser()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (checkCompanyName()) {
|
if (checkCompanyName()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -377,11 +370,15 @@
|
|||||||
info: JSON.stringify(infoObj)
|
info: JSON.stringify(infoObj)
|
||||||
},
|
},
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
if(res && res.code === 200) {
|
if(res) {
|
||||||
$('#systemConfigDlg').dialog('close');
|
if(res.code === 200) {
|
||||||
//加载完以后重新初始化
|
$('#systemConfigDlg').dialog('close');
|
||||||
var opts = $("#tableData").datagrid('options');
|
//加载完以后重新初始化
|
||||||
showSystemConfigDetails(opts.pageNumber, opts.pageSize);
|
var opts = $("#tableData").datagrid('options');
|
||||||
|
showSystemConfigDetails(opts.pageNumber, opts.pageSize);
|
||||||
|
} else if(res.code === -1) {
|
||||||
|
$.messager.alert('提示', '演示用户禁止操作!', 'warning');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//此处添加错误处理
|
//此处添加错误处理
|
||||||
|
|||||||
@@ -385,6 +385,10 @@ public class ExceptionConstants {
|
|||||||
public static final int ORGA_USER_REL_EDIT_FAILED_CODE = 11500002;
|
public static final int ORGA_USER_REL_EDIT_FAILED_CODE = 11500002;
|
||||||
public static final String ORGA_USER_REL_EDIT_FAILED_MSG = "修改机构用户关联关系失败";
|
public static final String ORGA_USER_REL_EDIT_FAILED_MSG = "修改机构用户关联关系失败";
|
||||||
|
|
||||||
|
//演示用户禁止操作
|
||||||
|
public static final int SYSTEM_CONFIG_TEST_USER_CODE = -1;
|
||||||
|
public static final String SYSTEM_CONFIG_TEST_USER_MSG = "演示用户禁止操作";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标准正常返回/操作成功返回
|
* 标准正常返回/操作成功返回
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class ResourceController {
|
|||||||
int insert = configResourceManager.insert(apiName, beanJson, request);
|
int insert = configResourceManager.insert(apiName, beanJson, request);
|
||||||
if(insert > 0) {
|
if(insert > 0) {
|
||||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else if(insert == -1) {
|
||||||
|
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
|
||||||
} else {
|
} else {
|
||||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
}
|
}
|
||||||
@@ -95,6 +97,8 @@ public class ResourceController {
|
|||||||
int update = configResourceManager.update(apiName, beanJson, id, request);
|
int update = configResourceManager.update(apiName, beanJson, id, request);
|
||||||
if(update > 0) {
|
if(update > 0) {
|
||||||
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
||||||
|
} else if(update == -1) {
|
||||||
|
return returnJson(objectMap, ErpInfo.TEST_USER.name, ErpInfo.TEST_USER.code);
|
||||||
} else {
|
} else {
|
||||||
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||||
|
import com.jsh.erp.service.user.UserService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -21,21 +22,30 @@ import javax.annotation.Resource;
|
|||||||
@RequestMapping(value = "/systemConfig")
|
@RequestMapping(value = "/systemConfig")
|
||||||
public class SystemConfigController {
|
public class SystemConfigController {
|
||||||
private Logger logger = LoggerFactory.getLogger(SystemConfigController.class);
|
private Logger logger = LoggerFactory.getLogger(SystemConfigController.class);
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private SystemConfigService systemConfigService;
|
private SystemConfigService systemConfigService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UserService userService;
|
||||||
/**
|
/**
|
||||||
* 批量删除系统配置信息
|
* 批量删除系统配置信息
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value = "/batchDeleteSystemConfigByIds")
|
@RequestMapping(value = "/batchDeleteSystemConfigByIds")
|
||||||
public Object batchDeleteSystemConfigByIds(@RequestParam("ids") String ids) throws Exception {
|
public Object batchDeleteSystemConfigByIds(@RequestParam("ids") String ids) throws Exception {
|
||||||
JSONObject result = ExceptionConstants.standardSuccess();
|
JSONObject result = ExceptionConstants.standardSuccess();
|
||||||
int i= systemConfigService.batchDeleteSystemConfigByIds(ids);
|
int i= 0;
|
||||||
if(i<1){
|
if(userService.checkIsTestUser()) {
|
||||||
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
throw new BusinessRunTimeException(ExceptionConstants.SYSTEM_CONFIG_TEST_USER_CODE,
|
||||||
ExceptionConstants.SYSTEM_CONFIG_DELETE_FAILED_CODE,ExceptionConstants.SYSTEM_CONFIG_DELETE_FAILED_MSG,ids);
|
ExceptionConstants.SYSTEM_CONFIG_TEST_USER_MSG);
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.SYSTEM_CONFIG_DELETE_FAILED_CODE,
|
} else {
|
||||||
ExceptionConstants.SYSTEM_CONFIG_DELETE_FAILED_MSG);
|
i = systemConfigService.batchDeleteSystemConfigByIds(ids);
|
||||||
|
if(i<1){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
||||||
|
ExceptionConstants.SYSTEM_CONFIG_DELETE_FAILED_CODE,ExceptionConstants.SYSTEM_CONFIG_DELETE_FAILED_MSG,ids);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.SYSTEM_CONFIG_DELETE_FAILED_CODE,
|
||||||
|
ExceptionConstants.SYSTEM_CONFIG_DELETE_FAILED_MSG);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,6 @@ public class UserController {
|
|||||||
@Value("${manage.roleId}")
|
@Value("${manage.roleId}")
|
||||||
private Integer manageRoleId;
|
private Integer manageRoleId;
|
||||||
|
|
||||||
@Value("${demonstrate.open}")
|
|
||||||
private boolean demonstrateOpen;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@@ -59,27 +56,6 @@ public class UserController {
|
|||||||
private static final String HTTP = "http://";
|
private static final String HTTP = "http://";
|
||||||
private static final String CODE_OK = "200";
|
private static final String CODE_OK = "200";
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否开启演示状态,默认关闭
|
|
||||||
* @param request
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GetMapping(value = "/getDemonstrateOpen")
|
|
||||||
public BaseResponseInfo getDemonstrateOpen(HttpServletRequest request) {
|
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
|
||||||
try {
|
|
||||||
Map<String, Object> data = new HashMap<String, Object>();
|
|
||||||
data.put("demonstrateOpen", demonstrateOpen);
|
|
||||||
res.code = 200;
|
|
||||||
res.data = data;
|
|
||||||
} catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
res.code = 500;
|
|
||||||
res.data = "获取失败";
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/login")
|
@PostMapping(value = "/login")
|
||||||
public BaseResponseInfo login(@RequestParam(value = "loginName", required = false) String loginName,
|
public BaseResponseInfo login(@RequestParam(value = "loginName", required = false) String loginName,
|
||||||
@RequestParam(value = "password", required = false) String password,
|
@RequestParam(value = "password", required = false) String password,
|
||||||
|
|||||||
@@ -86,9 +86,13 @@ public class SystemConfigService {
|
|||||||
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
|
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
|
||||||
int result=0;
|
int result=0;
|
||||||
try{
|
try{
|
||||||
result=systemConfigMapper.insertSelective(systemConfig);
|
if(userService.checkIsTestUser()) {
|
||||||
logService.insertLog("系统配置",
|
result=-1;
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(systemConfig.getCompanyName()).toString(), request);
|
} else {
|
||||||
|
result=systemConfigMapper.insertSelective(systemConfig);
|
||||||
|
logService.insertLog("系统配置",
|
||||||
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(systemConfig.getCompanyName()).toString(), request);
|
||||||
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
JshException.writeFail(logger, e);
|
JshException.writeFail(logger, e);
|
||||||
}
|
}
|
||||||
@@ -101,9 +105,13 @@ public class SystemConfigService {
|
|||||||
systemConfig.setId(id);
|
systemConfig.setId(id);
|
||||||
int result=0;
|
int result=0;
|
||||||
try{
|
try{
|
||||||
result=systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
|
if(userService.checkIsTestUser()) {
|
||||||
logService.insertLog("系统配置",
|
result=-1;
|
||||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(systemConfig.getCompanyName()).toString(), request);
|
} else {
|
||||||
|
result = systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
|
||||||
|
logService.insertLog("系统配置",
|
||||||
|
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(systemConfig.getCompanyName()).toString(), request);
|
||||||
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
JshException.writeFail(logger, e);
|
JshException.writeFail(logger, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.jsh.erp.utils.StringUtil;
|
|||||||
import com.jsh.erp.utils.Tools;
|
import com.jsh.erp.utils.Tools;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
@@ -39,6 +40,12 @@ import java.util.Objects;
|
|||||||
@Service
|
@Service
|
||||||
public class UserService {
|
public class UserService {
|
||||||
private Logger logger = LoggerFactory.getLogger(UserService.class);
|
private Logger logger = LoggerFactory.getLogger(UserService.class);
|
||||||
|
|
||||||
|
private static final String TEST_USER = "jsh";
|
||||||
|
|
||||||
|
@Value("${demonstrate.open}")
|
||||||
|
private boolean demonstrateOpen;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserMapper userMapper;
|
private UserMapper userMapper;
|
||||||
|
|
||||||
@@ -55,7 +62,6 @@ public class UserService {
|
|||||||
@Resource
|
@Resource
|
||||||
private UserBusinessService userBusinessService;
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
|
|
||||||
public User getUser(long id)throws Exception {
|
public User getUser(long id)throws Exception {
|
||||||
User result=null;
|
User result=null;
|
||||||
try{
|
try{
|
||||||
@@ -314,6 +320,25 @@ public class UserService {
|
|||||||
return (User)request.getSession().getAttribute("user");
|
return (User)request.getSession().getAttribute("user");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查当前用户是否是演示用户
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean checkIsTestUser() throws Exception{
|
||||||
|
Boolean result = false;
|
||||||
|
try {
|
||||||
|
if (demonstrateOpen) {
|
||||||
|
User user = getCurrentUser();
|
||||||
|
if (TEST_USER.equals(user.getLoginName())) {
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
JshException.readFail(logger, e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户名查询id
|
* 根据用户名查询id
|
||||||
* @param loginName
|
* @param loginName
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ public enum ErpInfo {
|
|||||||
WARING_MSG(201, "提醒信息"),
|
WARING_MSG(201, "提醒信息"),
|
||||||
REDIRECT(301, "session失效,重定向"),
|
REDIRECT(301, "session失效,重定向"),
|
||||||
FORWARD_REDIRECT(302, "转发请求session失效"),
|
FORWARD_REDIRECT(302, "转发请求session失效"),
|
||||||
FORWARD_FAILED(303, "转发请求失败!");
|
FORWARD_FAILED(303, "转发请求失败!"),
|
||||||
|
TEST_USER(-1, "演示用户禁止操作");
|
||||||
|
|
||||||
public final int code;
|
public final int code;
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|||||||
Reference in New Issue
Block a user