更新后端,采用Springboot+mybatis
This commit is contained in:
71
src/main/java/com/jsh/erp/service/role/RoleComponent.java
Normal file
71
src/main/java/com/jsh/erp/service/role/RoleComponent.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.jsh.erp.service.role;
|
||||
|
||||
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(String condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map) {
|
||||
return getRoleList(map);
|
||||
}
|
||||
|
||||
private List<?> getRoleList(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String order = QueryUtils.order(map);
|
||||
String filter = QueryUtils.filter(map);
|
||||
return roleService.select(name, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int counts(Map<String, String> map) {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
return roleService.countRole(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(String beanJson, HttpServletRequest request) {
|
||||
return roleService.insertRole(beanJson, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(String beanJson, Long id) {
|
||||
return roleService.updateRole(beanJson, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
return roleService.deleteRole(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchDelete(String ids) {
|
||||
return roleService.batchDeleteRole(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/main/java/com/jsh/erp/service/role/RoleResource.java
Normal file
15
src/main/java/com/jsh/erp/service/role/RoleResource.java
Normal 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", type = 10)
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface RoleResource {
|
||||
}
|
||||
71
src/main/java/com/jsh/erp/service/role/RoleService.java
Normal file
71
src/main/java/com/jsh/erp/service/role/RoleService.java
Normal file
@@ -0,0 +1,71 @@
|
||||
package com.jsh.erp.service.role;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.entities.UserExample;
|
||||
import com.jsh.erp.datasource.mappers.RoleMapper;
|
||||
import com.jsh.erp.datasource.mappers.UserMapper;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.RegExpTools;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class RoleService {
|
||||
@Resource
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
public Role getRole(long id) {
|
||||
return roleMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public List<Role> getRole() {
|
||||
RoleExample example = new RoleExample();
|
||||
return roleMapper.selectByExample(example);
|
||||
}
|
||||
|
||||
public List<Role> select(String name, int offset, int rows) {
|
||||
return roleMapper.selectByConditionRole(name, offset, rows);
|
||||
}
|
||||
|
||||
public int countRole(String name) {
|
||||
return roleMapper.countsByRole(name);
|
||||
}
|
||||
|
||||
public int insertRole(String beanJson, HttpServletRequest request) {
|
||||
Role role = JSONObject.parseObject(beanJson, Role.class);
|
||||
return roleMapper.insertSelective(role);
|
||||
}
|
||||
|
||||
public int updateRole(String beanJson, Long id) {
|
||||
Role role = JSONObject.parseObject(beanJson, Role.class);
|
||||
role.setId(id);
|
||||
return roleMapper.updateByPrimaryKeySelective(role);
|
||||
}
|
||||
|
||||
public int deleteRole(Long id) {
|
||||
return roleMapper.deleteByPrimaryKey(id);
|
||||
}
|
||||
|
||||
public int batchDeleteRole(String ids) {
|
||||
List<Long> idList = StringUtil.strToLongList(ids);
|
||||
RoleExample example = new RoleExample();
|
||||
example.createCriteria().andIdIn(idList);
|
||||
return roleMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
public List<Role> findUserRole(){
|
||||
RoleExample example = new RoleExample();
|
||||
example.setOrderByClause("Id");
|
||||
List<Role> list = roleMapper.selectByExample(example);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user