vue版本上线

This commit is contained in:
季圣华
2021-04-07 23:53:57 +08:00
parent 76a0033a4e
commit f4ef5aa067
803 changed files with 171959 additions and 27 deletions

View File

@@ -0,0 +1,73 @@
package com.jsh.erp.service.functions;
import com.alibaba.fastjson.JSONObject;
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 = "function_component")
@FunctionResource
public class FunctionComponent implements ICommonQuery {
@Resource
private FunctionService functionService;
@Override
public Object selectOne(Long id) throws Exception {
return functionService.getFunction(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getFunctionsList(map);
}
private List<?> getFunctionsList(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 functionService.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 functionService.countFunction(name, type);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return functionService.insertFunction(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return functionService.updateFunction(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return functionService.deleteFunction(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return functionService.batchDeleteFunction(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return functionService.checkIsNameExist(id, name);
}
}

View File

@@ -0,0 +1,15 @@
package com.jsh.erp.service.functions;
import com.jsh.erp.service.ResourceInfo;
import java.lang.annotation.*;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo(value = "function")
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface FunctionResource {
}

View File

@@ -0,0 +1,209 @@
package com.jsh.erp.service.functions;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.datasource.entities.Function;
import com.jsh.erp.datasource.entities.FunctionExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.FunctionMapper;
import com.jsh.erp.datasource.mappers.FunctionMapperEx;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.user.UserService;
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.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class FunctionService {
private Logger logger = LoggerFactory.getLogger(FunctionService.class);
@Resource
private FunctionMapper functionsMapper;
@Resource
private FunctionMapperEx functionMapperEx;
@Resource
private UserService userService;
@Resource
private LogService logService;
public Function getFunction(long id)throws Exception {
Function result=null;
try{
result=functionsMapper.selectByPrimaryKey(id);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<Function> getFunctionListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<Function> list = new ArrayList<>();
try{
FunctionExample example = new FunctionExample();
example.createCriteria().andIdIn(idList);
list = functionsMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Function> getFunction()throws Exception {
FunctionExample example = new FunctionExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Function> list=null;
try{
list=functionsMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Function> select(String name, String type, int offset, int rows)throws Exception {
List<Function> list=null;
try{
list= functionMapperEx.selectByConditionFunction(name, type, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countFunction(String name, String type)throws Exception {
Long result=null;
try{
result= functionMapperEx.countsByFunction(name, type);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertFunction(JSONObject obj, HttpServletRequest request)throws Exception {
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class);
int result=0;
try{
result=functionsMapper.insertSelective(functions);
logService.insertLog("功能",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(functions.getName()).toString(),request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateFunction(JSONObject obj, HttpServletRequest request) throws Exception{
Function functions = JSONObject.parseObject(obj.toJSONString(), Function.class);
int result=0;
try{
result=functionsMapper.updateByPrimaryKeySelective(functions);
logService.insertLog("功能",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(functions.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteFunction(Long id, HttpServletRequest request)throws Exception {
return batchDeleteFunctionByIds(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunction(String ids, HttpServletRequest request)throws Exception {
return batchDeleteFunctionByIds(ids);
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteFunctionByIds(String ids)throws Exception {
StringBuffer sb = new StringBuffer();
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
List<Function> list = getFunctionListByIds(ids);
for(Function functions: list){
sb.append("[").append(functions.getName()).append("]");
}
logService.insertLog("功能", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result = functionMapperEx.batchDeleteFunctionByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
public int checkIsNameExist(Long id, String name)throws Exception {
FunctionExample example = new FunctionExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Function> list=null;
try{
list = functionsMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
}
public List<Function> getRoleFunction(String pNumber)throws Exception {
FunctionExample example = new FunctionExample();
example.createCriteria().andEnabledEqualTo(true).andParentNumberEqualTo(pNumber)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort");
List<Function> list=null;
try{
list = functionsMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Function> findRoleFunction(String pnumber)throws Exception{
FunctionExample example = new FunctionExample();
example.createCriteria().andEnabledEqualTo(true).andParentNumberEqualTo(pnumber)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort");
List<Function> list=null;
try{
list =functionsMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Function> findByIds(String functionsIds)throws Exception{
List<Long> idList = StringUtil.strToLongList(functionsIds);
FunctionExample example = new FunctionExample();
example.createCriteria().andEnabledEqualTo(true).andIdIn(idList)
.andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
example.setOrderByClause("Sort asc");
List<Function> list=null;
try{
list =functionsMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
}