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,70 @@
package com.jsh.erp.service.role;
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 = "role_component")
@RoleResource
public class RoleComponent implements ICommonQuery {
@Resource
private RoleService roleService;
@Override
public Object selectOne(Long id) throws Exception {
return roleService.getRole(id);
}
@Override
public List<?> select(Map<String, String> map)throws Exception {
return getRoleList(map);
}
private List<?> getRoleList(Map<String, String> map) throws Exception{
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
return roleService.select(name, 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");
return roleService.countRole(name);
}
@Override
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
return roleService.insertRole(obj, request);
}
@Override
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
return roleService.updateRole(obj, request);
}
@Override
public int delete(Long id, HttpServletRequest request)throws Exception {
return roleService.deleteRole(id, request);
}
@Override
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
return roleService.batchDeleteRole(ids, request);
}
@Override
public int checkIsNameExist(Long id, String name)throws Exception {
return roleService.checkIsNameExist(id, name);
}
}

View File

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

View File

@@ -0,0 +1,186 @@
package com.jsh.erp.service.role;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.Role;
import com.jsh.erp.datasource.entities.RoleExample;
import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.datasource.mappers.RoleMapper;
import com.jsh.erp.datasource.mappers.RoleMapperEx;
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.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 RoleService {
private Logger logger = LoggerFactory.getLogger(RoleService.class);
@Resource
private RoleMapper roleMapper;
@Resource
private RoleMapperEx roleMapperEx;
@Resource
private LogService logService;
@Resource
private UserService userService;
public Role getRole(long id)throws Exception {
Role result=null;
try{
result=roleMapper.selectByPrimaryKey(id);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public List<Role> getRoleListByIds(String ids)throws Exception {
List<Long> idList = StringUtil.strToLongList(ids);
List<Role> list = new ArrayList<>();
try{
RoleExample example = new RoleExample();
example.createCriteria().andIdIn(idList);
list = roleMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Role> getRole()throws Exception {
RoleExample example = new RoleExample();
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Role> list=null;
try{
list=roleMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public List<Role> select(String name, int offset, int rows)throws Exception {
List<Role> list=null;
try{
list=roleMapperEx.selectByConditionRole(name, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public Long countRole(String name)throws Exception {
Long result=null;
try{
result=roleMapperEx.countsByRole(name);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertRole(JSONObject obj, HttpServletRequest request)throws Exception {
Role role = JSONObject.parseObject(obj.toJSONString(), Role.class);
int result=0;
try{
result=roleMapper.insertSelective(role);
logService.insertLog("角色",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(role.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateRole(JSONObject obj, HttpServletRequest request) throws Exception{
Role role = JSONObject.parseObject(obj.toJSONString(), Role.class);
int result=0;
try{
result=roleMapper.updateByPrimaryKeySelective(role);
logService.insertLog("角色",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(role.getName()).toString(), request);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteRole(Long id, HttpServletRequest request)throws Exception {
return batchDeleteRoleByIds(id.toString());
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteRole(String ids, HttpServletRequest request) throws Exception{
return batchDeleteRoleByIds(ids);
}
public int checkIsNameExist(Long id, String name) throws Exception{
RoleExample example = new RoleExample();
example.createCriteria().andIdNotEqualTo(id).andNameEqualTo(name).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Role> list =null;
try{
list=roleMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list==null?0:list.size();
}
public List<Role> findUserRole()throws Exception{
RoleExample example = new RoleExample();
example.setOrderByClause("Id");
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
List<Role> list=null;
try{
list=roleMapper.selectByExample(example);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
/**
* create by: qiankunpingtai
* 逻辑删除角色信息
* create time: 2019/3/28 15:44
* @Param: ids
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteRoleByIds(String ids) throws Exception{
StringBuffer sb = new StringBuffer();
sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
List<Role> list = getRoleListByIds(ids);
for(Role role: list){
sb.append("[").append(role.getName()).append("]");
}
logService.insertLog("角色", sb.toString(),
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
result=roleMapperEx.batchDeleteRoleByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}
}