更新后端,采用Springboot+mybatis

This commit is contained in:
季圣华
2018-12-19 23:54:53 +08:00
parent bb6f5528a7
commit 5cc26a22f2
1672 changed files with 52804 additions and 156085 deletions

View 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;
}
}

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", type = 10)
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface RoleResource {
}

View 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;
}
}