异常封装之关联关系信息后台修改
This commit is contained in:
@@ -36,7 +36,7 @@ public class UserBusinessController {
|
|||||||
@GetMapping(value = "/getBasicData")
|
@GetMapping(value = "/getBasicData")
|
||||||
public BaseResponseInfo getBasicData(@RequestParam(value = "KeyId") String keyId,
|
public BaseResponseInfo getBasicData(@RequestParam(value = "KeyId") String keyId,
|
||||||
@RequestParam(value = "Type") String type,
|
@RequestParam(value = "Type") String type,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request)throws Exception {
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
try {
|
try {
|
||||||
List<UserBusiness> list = userBusinessService.getBasicData(keyId, type);
|
List<UserBusiness> list = userBusinessService.getBasicData(keyId, type);
|
||||||
@@ -55,7 +55,7 @@ public class UserBusinessController {
|
|||||||
@GetMapping(value = "/checkIsValueExist")
|
@GetMapping(value = "/checkIsValueExist")
|
||||||
public String checkIsValueExist(@RequestParam(value ="type", required = false) String type,
|
public String checkIsValueExist(@RequestParam(value ="type", required = false) String type,
|
||||||
@RequestParam(value ="keyId", required = false) String keyId,
|
@RequestParam(value ="keyId", required = false) String keyId,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request)throws Exception {
|
||||||
Map<String, Object> objectMap = new HashMap<String, Object>();
|
Map<String, Object> objectMap = new HashMap<String, Object>();
|
||||||
Long id = userBusinessService.checkIsValueExist(type, keyId);
|
Long id = userBusinessService.checkIsValueExist(type, keyId);
|
||||||
if(id != null) {
|
if(id != null) {
|
||||||
@@ -76,7 +76,7 @@ public class UserBusinessController {
|
|||||||
@PostMapping(value = "/updateBtnStr")
|
@PostMapping(value = "/updateBtnStr")
|
||||||
public BaseResponseInfo updateBtnStr(@RequestParam(value ="userBusinessId", required = false) Long userBusinessId,
|
public BaseResponseInfo updateBtnStr(@RequestParam(value ="userBusinessId", required = false) Long userBusinessId,
|
||||||
@RequestParam(value ="btnStr", required = false) String btnStr,
|
@RequestParam(value ="btnStr", required = false) String btnStr,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request)throws Exception {
|
||||||
BaseResponseInfo res = new BaseResponseInfo();
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
try {
|
try {
|
||||||
int back = userBusinessService.updateBtnStr(userBusinessId, btnStr);
|
int back = userBusinessService.updateBtnStr(userBusinessId, btnStr);
|
||||||
|
|||||||
@@ -22,21 +22,21 @@ public class UserBusinessComponent implements ICommonQuery {
|
|||||||
private UserBusinessService userBusinessService;
|
private UserBusinessService userBusinessService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object selectOne(String condition) {
|
public Object selectOne(String condition)throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<?> select(Map<String, String> map) {
|
public List<?> select(Map<String, String> map)throws Exception {
|
||||||
return getUserBusinessList(map);
|
return getUserBusinessList(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<?> getUserBusinessList(Map<String, String> map) {
|
private List<?> getUserBusinessList(Map<String, String> map)throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long counts(Map<String, String> map) {
|
public Long counts(Map<String, String> map)throws Exception {
|
||||||
return BusinessConstants.DEFAULT_LIST_NULL_NUMBER;
|
return BusinessConstants.DEFAULT_LIST_NULL_NUMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,17 +51,17 @@ public class UserBusinessComponent implements ICommonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int delete(Long id) {
|
public int delete(Long id)throws Exception {
|
||||||
return userBusinessService.deleteUserBusiness(id);
|
return userBusinessService.deleteUserBusiness(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int batchDelete(String ids) {
|
public int batchDelete(String ids)throws Exception {
|
||||||
return userBusinessService.batchDeleteUserBusiness(ids);
|
return userBusinessService.batchDeleteUserBusiness(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkIsNameExist(Long id, String name) {
|
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||||
return userBusinessService.checkIsNameExist(id, name);
|
return userBusinessService.checkIsNameExist(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,14 @@ package com.jsh.erp.service.userBusiness;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jsh.erp.constants.BusinessConstants;
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
import com.jsh.erp.datasource.entities.App;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.Functions;
|
import com.jsh.erp.datasource.entities.*;
|
||||||
import com.jsh.erp.datasource.entities.User;
|
|
||||||
import com.jsh.erp.datasource.entities.UserBusiness;
|
|
||||||
import com.jsh.erp.datasource.entities.UserBusinessExample;
|
|
||||||
import com.jsh.erp.datasource.mappers.UserBusinessMapper;
|
import com.jsh.erp.datasource.mappers.UserBusinessMapper;
|
||||||
|
import com.jsh.erp.datasource.mappers.UserBusinessMapperEx;
|
||||||
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.service.CommonQueryManager;
|
import com.jsh.erp.service.CommonQueryManager;
|
||||||
import com.jsh.erp.service.app.AppService;
|
import com.jsh.erp.service.app.AppService;
|
||||||
import com.jsh.erp.service.functions.FunctionsService;
|
import com.jsh.erp.service.functions.FunctionsService;
|
||||||
import com.jsh.erp.datasource.mappers.UserBusinessMapperEx;
|
|
||||||
import com.jsh.erp.service.log.LogService;
|
import com.jsh.erp.service.log.LogService;
|
||||||
import com.jsh.erp.service.user.UserService;
|
import com.jsh.erp.service.user.UserService;
|
||||||
import com.jsh.erp.utils.StringUtil;
|
import com.jsh.erp.utils.StringUtil;
|
||||||
@@ -25,11 +23,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UserBusinessService {
|
public class UserBusinessService {
|
||||||
@@ -53,77 +47,145 @@ public class UserBusinessService {
|
|||||||
@Resource
|
@Resource
|
||||||
private CommonQueryManager configResourceManager;
|
private CommonQueryManager configResourceManager;
|
||||||
|
|
||||||
public UserBusiness getUserBusiness(long id) {
|
public UserBusiness getUserBusiness(long id)throws Exception {
|
||||||
return userBusinessMapper.selectByPrimaryKey(id);
|
UserBusiness result=null;
|
||||||
|
try{
|
||||||
|
result=userBusinessMapper.selectByPrimaryKey(id);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserBusiness> getUserBusiness() {
|
public List<UserBusiness> getUserBusiness()throws Exception {
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
return userBusinessMapper.selectByExample(example);
|
List<UserBusiness> list=null;
|
||||||
|
try{
|
||||||
|
list=userBusinessMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int insertUserBusiness(String beanJson, HttpServletRequest request) throws Exception {
|
public int insertUserBusiness(String beanJson, HttpServletRequest request) throws Exception {
|
||||||
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
|
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
|
||||||
int inserts = userBusinessMapper.insertSelective(userBusiness);
|
int result=0;
|
||||||
// 更新应用权限
|
try{
|
||||||
if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && inserts > 0) {
|
result=userBusinessMapper.insertSelective(userBusiness);
|
||||||
inserts = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue());
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
}
|
}
|
||||||
return inserts;
|
// 更新应用权限
|
||||||
|
if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && result > 0) {
|
||||||
|
result = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int updateUserBusiness(String beanJson, Long id) throws Exception {
|
public int updateUserBusiness(String beanJson, Long id) throws Exception {
|
||||||
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
|
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
|
||||||
userBusiness.setId(id);
|
userBusiness.setId(id);
|
||||||
int updates = userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
|
int result=0;
|
||||||
// 更新应用权限
|
try{
|
||||||
if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && updates > 0) {
|
result=userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
|
||||||
updates = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue());
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
}
|
}
|
||||||
return updates;
|
// 更新应用权限
|
||||||
|
if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && result > 0) {
|
||||||
|
result = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int deleteUserBusiness(Long id) {
|
public int deleteUserBusiness(Long id)throws Exception {
|
||||||
return userBusinessMapper.deleteByPrimaryKey(id);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=userBusinessMapper.deleteByPrimaryKey(id);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int batchDeleteUserBusiness(String ids) {
|
public int batchDeleteUserBusiness(String ids)throws Exception {
|
||||||
List<Long> idList = StringUtil.strToLongList(ids);
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
example.createCriteria().andIdIn(idList);
|
example.createCriteria().andIdIn(idList);
|
||||||
return userBusinessMapper.deleteByExample(example);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=userBusinessMapper.deleteByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkIsNameExist(Long id, String name) {
|
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserBusiness> getBasicData(String keyId, String type){
|
public List<UserBusiness> getBasicData(String keyId, String type)throws Exception{
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type)
|
example.createCriteria().andKeyidEqualTo(keyId).andTypeEqualTo(type)
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
|
List<UserBusiness> list=null;
|
||||||
|
try{
|
||||||
|
list= userBusinessMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long checkIsValueExist(String type, String keyId) {
|
public Long checkIsValueExist(String type, String keyId)throws Exception {
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId)
|
example.createCriteria().andTypeEqualTo(type).andKeyidEqualTo(keyId)
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
|
List<UserBusiness> list=null;
|
||||||
|
try{
|
||||||
|
list= userBusinessMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
Long id = null;
|
Long id = null;
|
||||||
if(list.size() > 0) {
|
if(list!=null&&list.size() > 0) {
|
||||||
id = list.get(0).getId();
|
id = list.get(0).getId();
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue) {
|
public Boolean checkIsUserBusinessExist(String TypeVale, String KeyIdValue, String UBValue)throws Exception {
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
String newVaule = "%" + UBValue + "%";
|
String newVaule = "%" + UBValue + "%";
|
||||||
if(TypeVale !=null && KeyIdValue !=null) {
|
if(TypeVale !=null && KeyIdValue !=null) {
|
||||||
@@ -133,8 +195,16 @@ public class UserBusinessService {
|
|||||||
example.createCriteria().andValueLike(newVaule)
|
example.createCriteria().andValueLike(newVaule)
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
}
|
}
|
||||||
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
|
List<UserBusiness> list=null;
|
||||||
if(list.size() > 0) {
|
try{
|
||||||
|
list= userBusinessMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
if(list!=null&&list.size() > 0) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -150,23 +220,48 @@ public class UserBusinessService {
|
|||||||
userBusiness.setBtnstr(btnStr);
|
userBusiness.setBtnstr(btnStr);
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
example.createCriteria().andIdEqualTo(userBusinessId);
|
example.createCriteria().andIdEqualTo(userBusinessId);
|
||||||
return userBusinessMapper.updateByExampleSelective(userBusiness, example);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result= userBusinessMapper.updateByExampleSelective(userBusiness, example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserBusiness> findRoleByUserId(String userId){
|
public List<UserBusiness> findRoleByUserId(String userId)throws Exception{
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
example.createCriteria().andKeyidEqualTo(userId).andTypeEqualTo("UserRole")
|
example.createCriteria().andKeyidEqualTo(userId).andTypeEqualTo("UserRole")
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
|
List<UserBusiness> list=null;
|
||||||
|
try{
|
||||||
|
list= userBusinessMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserBusiness> findAppByRoles(String roles){
|
public List<UserBusiness> findAppByRoles(String roles)throws Exception{
|
||||||
List<String> rolesList = StringUtil.strToStringList(roles);
|
List<String> rolesList = StringUtil.strToStringList(roles);
|
||||||
UserBusinessExample example = new UserBusinessExample();
|
UserBusinessExample example = new UserBusinessExample();
|
||||||
example.createCriteria().andKeyidIn(rolesList).andTypeEqualTo("RoleAPP")
|
example.createCriteria().andKeyidIn(rolesList).andTypeEqualTo("RoleAPP")
|
||||||
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
List<UserBusiness> list = userBusinessMapper.selectByExample(example);
|
List<UserBusiness> list=null;
|
||||||
|
try{
|
||||||
|
list= userBusinessMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +272,16 @@ public class UserBusinessService {
|
|||||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
String [] idArray=ids.split(",");
|
String [] idArray=ids.split(",");
|
||||||
return userBusinessMapperEx.batchDeleteUserBusinessByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result= userBusinessMapperEx.batchDeleteUserBusinessByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,48 +292,45 @@ public class UserBusinessService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int insertOrUpdateAppValue(String type, String keyId, String functionIds) throws Exception{
|
public int insertOrUpdateAppValue(String type, String keyId, String functionIds) throws Exception{
|
||||||
|
int result=0;
|
||||||
int updates = 0;
|
|
||||||
|
|
||||||
functionIds = functionIds.replaceAll("\\]\\[", ",").
|
functionIds = functionIds.replaceAll("\\]\\[", ",").
|
||||||
replaceAll("\\[","").replaceAll("\\]","");
|
replaceAll("\\[","").replaceAll("\\]","");
|
||||||
|
|
||||||
List<Functions> functionsList = functionsService.findByIds(functionIds);
|
List<Functions> functionsList = functionsService.findByIds(functionIds);
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(functionsList)) {
|
if (!CollectionUtils.isEmpty(functionsList)) {
|
||||||
|
|
||||||
Set<String> appNumbers = new HashSet<>();
|
Set<String> appNumbers = new HashSet<>();
|
||||||
String appNumber;
|
String appNumber;
|
||||||
for (Functions functions : functionsList) {
|
for (Functions functions : functionsList) {
|
||||||
|
|
||||||
appNumber = functions.getNumber().substring(0, 2);
|
appNumber = functions.getNumber().substring(0, 2);
|
||||||
appNumbers.add(appNumber);
|
appNumbers.add(appNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> appNumberList = new ArrayList<>(appNumbers);
|
List<String> appNumberList = new ArrayList<>(appNumbers);
|
||||||
List<App> appList = appService.findAppByNumber(appNumberList);
|
List<App> appList = appService.findAppByNumber(appNumberList);
|
||||||
|
|
||||||
StringBuilder appIdSb = new StringBuilder();
|
StringBuilder appIdSb = new StringBuilder();
|
||||||
|
|
||||||
if (!CollectionUtils.isEmpty(appList)) {
|
if (!CollectionUtils.isEmpty(appList)) {
|
||||||
for (App app : appList) {
|
for (App app : appList) {
|
||||||
appIdSb.append("[" + app.getId() + "]");
|
appIdSb.append("[" + app.getId() + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<UserBusiness> userBusinessList = getBasicData(keyId, type);
|
List<UserBusiness> userBusinessList = getBasicData(keyId, type);
|
||||||
if(userBusinessList.size() > 0) {
|
try{
|
||||||
UserBusiness userBusiness = userBusinessList.get(0);
|
if(userBusinessList.size() > 0) {
|
||||||
userBusiness.setValue(appIdSb.toString());
|
UserBusiness userBusiness = userBusinessList.get(0);
|
||||||
updates = userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
|
userBusiness.setValue(appIdSb.toString());
|
||||||
} else {
|
result = userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
|
||||||
UserBusiness userBusiness = new UserBusiness();
|
} else {
|
||||||
userBusiness.setType(type);
|
UserBusiness userBusiness = new UserBusiness();
|
||||||
userBusiness.setKeyid(keyId);
|
userBusiness.setType(type);
|
||||||
userBusiness.setValue(appIdSb.toString());
|
userBusiness.setKeyid(keyId);
|
||||||
updates = userBusinessMapper.insertSelective(userBusiness);
|
userBusiness.setValue(appIdSb.toString());
|
||||||
|
result = userBusinessMapper.insertSelective(userBusiness);
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return updates;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user