去除多余的app等三张表
This commit is contained in:
@@ -6,7 +6,6 @@ import java.lang.annotation.*;
|
||||
* @author jishenghua 2018-10-7 15:25:39
|
||||
* user-5
|
||||
* role-10
|
||||
* app-15
|
||||
* depot-20
|
||||
* log-25
|
||||
* functions-30
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.jsh.erp.service.app;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(value = "app_component")
|
||||
@AppResource
|
||||
public class AppComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private AppService appService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(Long id) throws Exception {
|
||||
return appService.getApp(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map)throws Exception {
|
||||
return getAppList(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");
|
||||
String order = QueryUtils.order(map);
|
||||
return appService.select(name, type, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
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");
|
||||
return appService.countApp(name, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request)throws Exception {
|
||||
return appService.insertApp(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id)throws Exception {
|
||||
return appService.updateApp(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id)throws Exception {
|
||||
return appService.deleteApp(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids)throws Exception {
|
||||
return appService.batchDeleteApp(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.jsh.erp.service.app;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "app", type = 15)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AppResource {
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
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.exception.JshException;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class AppService {
|
||||
private Logger logger = LoggerFactory.getLogger(AppService.class);
|
||||
|
||||
@Resource
|
||||
private AppMapper appMapper;
|
||||
@Resource
|
||||
private AppMapperEx appMapperEx;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
|
||||
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=null;
|
||||
try{
|
||||
list=appMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 桌面功能菜单初始化列表
|
||||
* create time: 2019/1/11 16:59
|
||||
* @Param: null
|
||||
* @return
|
||||
*/
|
||||
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=null;
|
||||
try{
|
||||
list=appMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public App getApp(long id)throws Exception {
|
||||
App result=null;
|
||||
try{
|
||||
result=appMapper.selectByPrimaryKey(id);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<App> getApp()throws Exception {
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<App> list=null;
|
||||
try{
|
||||
list=appMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
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){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Long countApp(String name, String type)throws Exception {
|
||||
Long result=null;
|
||||
try{
|
||||
result=appMapperEx.countsByApp(name, type);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int insertApp(String beanJson, HttpServletRequest request)throws Exception {
|
||||
App app = JSONObject.parseObject(beanJson, App.class);
|
||||
int result=0;
|
||||
try{
|
||||
result=appMapper.insertSelective(app);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int updateApp(String beanJson, Long id) throws Exception{
|
||||
App app = JSONObject.parseObject(beanJson, App.class);
|
||||
app.setId(id);
|
||||
int result=0;
|
||||
try{
|
||||
result=appMapper.updateByPrimaryKeySelective(app);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int deleteApp(Long id)throws Exception {
|
||||
int result=0;
|
||||
try{
|
||||
result=appMapper.deleteByPrimaryKey(id);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteApp(String ids)throws Exception {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
int result=0;
|
||||
try{
|
||||
result=appMapper.deleteByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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=null;
|
||||
try{
|
||||
list=appMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
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=null;
|
||||
try{
|
||||
list=appMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
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(",");
|
||||
int result=0;
|
||||
try{
|
||||
result=appMapperEx.batchDeleteAppByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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){
|
||||
roles = roleList.get(0).getValue();
|
||||
}
|
||||
if(roles!=null) {
|
||||
roles = roles.replaceAll("\\]\\[",",").replaceAll("\\]","").replaceAll("\\[",""); //转为逗号隔开的
|
||||
}
|
||||
List<UserBusiness> appList = userBusinessService.findAppByRoles(roles);
|
||||
String apps = null;
|
||||
if(appList!=null && appList.size()>0 && appList.get(0)!=null){
|
||||
apps = appList.get(0).getValue();
|
||||
}
|
||||
if(apps!=null) {
|
||||
apps = apps.replaceAll("\\]\\[",",").replaceAll("\\]","").replaceAll("\\[",""); //转为逗号隔开的
|
||||
}
|
||||
|
||||
List<App> deskList = findAppInIds(apps,"desk");
|
||||
|
||||
return deskList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过number列表查询app list
|
||||
* @param numberList
|
||||
* @return
|
||||
*/
|
||||
public List<App> findAppByNumber(List<String> numberList) throws Exception{
|
||||
|
||||
AppExample example = new AppExample();
|
||||
example.createCriteria().andEnabledEqualTo(true).andNumberIn(numberList);
|
||||
List<App> list=null;
|
||||
try{
|
||||
list=appMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.jsh.erp.service.depot;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.service.app.AppResource;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.jsh.erp.service.functions;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.service.app.AppResource;
|
||||
import com.jsh.erp.service.functions.FunctionsService;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.jsh.erp.service.unit;
|
||||
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.service.app.AppResource;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.jsh.erp.datasource.mappers.UserBusinessMapperEx;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.CommonQueryManager;
|
||||
import com.jsh.erp.service.app.AppService;
|
||||
import com.jsh.erp.service.functions.FunctionsService;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
@@ -42,9 +41,6 @@ public class UserBusinessService {
|
||||
@Resource
|
||||
private FunctionsService functionsService;
|
||||
|
||||
@Resource
|
||||
private AppService appService;
|
||||
|
||||
@Resource
|
||||
private CommonQueryManager configResourceManager;
|
||||
|
||||
@@ -79,10 +75,6 @@ public class UserBusinessService {
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
// 更新应用权限
|
||||
if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && result > 0) {
|
||||
result = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -96,10 +88,6 @@ public class UserBusinessService {
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
// 更新应用权限
|
||||
if (BusinessConstants.TYPE_NAME_ROLE_FUNCTIONS.equals(userBusiness.getType()) && result > 0) {
|
||||
result = insertOrUpdateAppValue(BusinessConstants.TYPE_NAME_ROLE_APP, userBusiness.getKeyid(), userBusiness.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -245,51 +233,4 @@ public class UserBusinessService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过功能(RoleFunctions)权限更新应用(RoleApp)权限
|
||||
* @param type
|
||||
* @param keyId
|
||||
* @param functionIds
|
||||
* @return
|
||||
*/
|
||||
public int insertOrUpdateAppValue(String type, String keyId, String functionIds) throws Exception{
|
||||
int result=0;
|
||||
functionIds = functionIds.replaceAll("\\]\\[", ",").
|
||||
replaceAll("\\[","").replaceAll("\\]","");
|
||||
List<Functions> functionsList = functionsService.findByIds(functionIds);
|
||||
if (!CollectionUtils.isEmpty(functionsList)) {
|
||||
Set<String> appNumbers = new HashSet<>();
|
||||
String appNumber;
|
||||
for (Functions functions : functionsList) {
|
||||
appNumber = functions.getNumber().substring(0, 2);
|
||||
appNumbers.add(appNumber);
|
||||
}
|
||||
List<String> appNumberList = new ArrayList<>(appNumbers);
|
||||
List<App> appList = appService.findAppByNumber(appNumberList);
|
||||
StringBuilder appIdSb = new StringBuilder();
|
||||
if (!CollectionUtils.isEmpty(appList)) {
|
||||
for (App app : appList) {
|
||||
appIdSb.append("[" + app.getId() + "]");
|
||||
}
|
||||
List<UserBusiness> userBusinessList = getBasicData(keyId, type);
|
||||
try{
|
||||
if(userBusinessList.size() > 0) {
|
||||
UserBusiness userBusiness = userBusinessList.get(0);
|
||||
userBusiness.setValue(appIdSb.toString());
|
||||
result = userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
|
||||
} else {
|
||||
UserBusiness userBusiness = new UserBusiness();
|
||||
userBusiness.setType(type);
|
||||
userBusiness.setKeyid(keyId);
|
||||
userBusiness.setValue(appIdSb.toString());
|
||||
result = userBusinessMapper.insertSelective(userBusiness);
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user