异常封装之应用信息后台修改

This commit is contained in:
qiankunpingtai
2019-04-17 10:09:26 +08:00
parent afcf2edb4c
commit ae416e8fec
5 changed files with 171 additions and 47 deletions

View File

@@ -48,7 +48,7 @@ public class AppController {
* @return
*/
@GetMapping(value = "/findAppByUserId")
public JSONObject findAppByUserId(@RequestParam("userId") String userId, HttpServletRequest request) {
public JSONObject findAppByUserId(@RequestParam("userId") String userId, HttpServletRequest request)throws Exception {
List<UserBusiness> roleList = userBusinessService.findRoleByUserId(userId);
String roles = null;
if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){
@@ -109,7 +109,7 @@ public class AppController {
}
@GetMapping(value = "/findDesk")
public JSONObject findDesk(HttpServletRequest request) {
public JSONObject findDesk(HttpServletRequest request)throws Exception {
JSONObject obj = new JSONObject();
List<App> dockList = appService.findDock();
JSONArray dockArray = new JSONArray();
@@ -160,7 +160,7 @@ public class AppController {
*/
@PostMapping(value = "/findRoleAPP")
public JSONArray findRoleAPP(@RequestParam("UBType") String type, @RequestParam("UBKeyId") String keyId,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
JSONArray arr = new JSONArray();
try {
List<App> dataListApp = appService.findRoleAPP();
@@ -229,7 +229,7 @@ public class AppController {
*/
@PostMapping(value = "/uploadImg")
public BaseResponseInfo uploadImg(MultipartFile fileInfo, @RequestParam("fileInfoName") String fileName,
HttpServletRequest request) {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
try {
if (fileInfo != null) {

View File

@@ -19,16 +19,16 @@ public class AppComponent implements ICommonQuery {
private AppService appService;
@Override
public Object selectOne(String condition) {
public Object selectOne(String condition)throws Exception {
return null;
}
@Override
public List<?> select(Map<String, String> map) {
public List<?> select(Map<String, String> map)throws Exception {
return getAppList(map);
}
private List<?> getAppList(Map<String, String> map) {
private List<?> getAppList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
@@ -37,7 +37,7 @@ public class AppComponent implements ICommonQuery {
}
@Override
public Long counts(Map<String, String> map) {
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String type = StringUtil.getInfo(search, "type");
@@ -45,27 +45,27 @@ public class AppComponent implements ICommonQuery {
}
@Override
public int insert(String beanJson, HttpServletRequest request) {
public int insert(String beanJson, HttpServletRequest request)throws Exception {
return appService.insertApp(beanJson, request);
}
@Override
public int update(String beanJson, Long id) {
public int update(String beanJson, Long id)throws Exception {
return appService.updateApp(beanJson, id);
}
@Override
public int delete(Long id) {
public int delete(Long id)throws Exception {
return appService.deleteApp(id);
}
@Override
public int batchDelete(String ids) {
public int batchDelete(String ids)throws Exception {
return appService.batchDeleteApp(ids);
}
@Override
public int checkIsNameExist(Long id, String name) {
public int checkIsNameExist(Long id, String name)throws Exception {
return 0;
}

View File

@@ -2,12 +2,14 @@ package com.jsh.erp.service.app;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.App;
import com.jsh.erp.datasource.entities.AppExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.entities.UserBusiness;
import com.jsh.erp.datasource.mappers.AppMapper;
import com.jsh.erp.datasource.mappers.AppMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.service.userBusiness.UserBusinessService;
@@ -40,11 +42,19 @@ public class AppService {
@Resource
private UserBusinessService userBusinessService;
public List<App> findDock(){
public List<App> findDock()throws Exception{
AppExample example = new AppExample();
example.createCriteria().andZlEqualTo("dock").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example);
List<App> list=null;
try{
list=appMapper.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;
}
/**
@@ -55,86 +65,191 @@ public class AppService {
* @Param: null
* @return
*/
public List<App> findDesk(){
public List<App> findDesk()throws Exception{
AppExample example = new AppExample();
example.createCriteria().andZlEqualTo("desk").andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example);
List<App> list=null;
try{
list=appMapper.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;
}
public App getApp(long id) {
return appMapper.selectByPrimaryKey(id);
public App getApp(long id)throws Exception {
App result=null;
try{
result=appMapper.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<App> getApp() {
public List<App> getApp()throws Exception {
AppExample example = new AppExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
return appMapper.selectByExample(example);
List<App> list=null;
try{
list=appMapper.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;
}
public List<App> select(String name, String type, int offset, int rows) {
return appMapperEx.selectByConditionApp(name, type, offset, rows);
public List<App> select(String name, String type, int offset, int rows)throws Exception {
List<App> list=null;
try{
list=appMapperEx.selectByConditionApp(name, type, offset, rows);
}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;
}
public Long countApp(String name, String type) {
return appMapperEx.countsByApp(name, type);
public Long countApp(String name, String type)throws Exception {
Long result=null;
try{
result=appMapperEx.countsByApp(name, type);
}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;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertApp(String beanJson, HttpServletRequest request) {
public int insertApp(String beanJson, HttpServletRequest request)throws Exception {
App app = JSONObject.parseObject(beanJson, App.class);
return appMapper.insertSelective(app);
int result=0;
try{
result=appMapper.insertSelective(app);
}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)
public int updateApp(String beanJson, Long id) {
public int updateApp(String beanJson, Long id) throws Exception{
App app = JSONObject.parseObject(beanJson, App.class);
app.setId(id);
return appMapper.updateByPrimaryKeySelective(app);
int result=0;
try{
result=appMapper.updateByPrimaryKeySelective(app);
}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)
public int deleteApp(Long id) {
return appMapper.deleteByPrimaryKey(id);
public int deleteApp(Long id)throws Exception {
int result=0;
try{
result=appMapper.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)
public int batchDeleteApp(String ids) {
public int batchDeleteApp(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
AppExample example = new AppExample();
example.createCriteria().andIdIn(idList);
return appMapper.deleteByExample(example);
int result=0;
try{
result=appMapper.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 List<App> findRoleAPP(){
public List<App> findRoleAPP()throws Exception{
AppExample example = new AppExample();
example.createCriteria().andEnabledEqualTo(true).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example);
List<App> list=null;
try{
list=appMapper.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;
}
public List<App> findAppInIds(String ids, String type){
public List<App> findAppInIds(String ids, String type)throws Exception{
List<Long> idList = StringUtil.strToLongList(ids);
AppExample example = new AppExample();
example.createCriteria().andZlEqualTo(type).andEnabledEqualTo(true).andIdIn(idList)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort");
List<App> list = appMapper.selectByExample(example);
List<App> list=null;
try{
list=appMapper.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)
public int batchDeleteAppByIds(String ids) {
public int batchDeleteAppByIds(String ids) throws Exception{
logService.insertLog(BusinessConstants.LOG_INTERFACE_NAME_APP,
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
return appMapperEx.batchDeleteAppByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
int result=0;
try{
result=appMapperEx.batchDeleteAppByIds(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;
}
public List<App> findAppByUserId(String userId) {
public List<App> findAppByUserId(String userId)throws Exception {
List<UserBusiness> roleList = userBusinessService.findRoleByUserId(userId);
String roles = null;
if(roleList!=null && roleList.size()>0 && roleList.get(0)!=null){
@@ -162,10 +277,19 @@ public class AppService {
* @param numberList
* @return
*/
public List<App> findAppByNumber(List<String> numberList) {
public List<App> findAppByNumber(List<String> numberList) throws Exception{
AppExample example = new AppExample();
example.createCriteria().andEnabledEqualTo(true).andNumberIn(numberList);
return appMapper.selectByExample(example);
List<App> list=null;
try{
list=appMapper.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;
}
}

View File

@@ -41,12 +41,12 @@ public class UserBusinessComponent implements ICommonQuery {
}
@Override
public int insert(String beanJson, HttpServletRequest request) {
public int insert(String beanJson, HttpServletRequest request) throws Exception {
return userBusinessService.insertUserBusiness(beanJson, request);
}
@Override
public int update(String beanJson, Long id) {
public int update(String beanJson, Long id)throws Exception {
return userBusinessService.updateUserBusiness(beanJson, id);
}

View File

@@ -64,7 +64,7 @@ public class UserBusinessService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUserBusiness(String beanJson, HttpServletRequest request) {
public int insertUserBusiness(String beanJson, HttpServletRequest request) throws Exception {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
int inserts = userBusinessMapper.insertSelective(userBusiness);
// 更新应用权限
@@ -75,7 +75,7 @@ public class UserBusinessService {
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserBusiness(String beanJson, Long id) {
public int updateUserBusiness(String beanJson, Long id) throws Exception {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
userBusiness.setId(id);
int updates = userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
@@ -187,7 +187,7 @@ public class UserBusinessService {
* @param functionIds
* @return
*/
public int insertOrUpdateAppValue(String type, String keyId, String functionIds) {
public int insertOrUpdateAppValue(String type, String keyId, String functionIds) throws Exception{
int updates = 0;