Commit 1cfe83c4 by zzrdark

1.增加dto

2.系统管理4个模块的查询
3.系统模块add功能
4.增加mysql注释
parent 5e295728
......@@ -104,13 +104,13 @@ CREATE TABLE `sys_dept` (
-- ----------------------------
DROP TABLE IF EXISTS `sys_func`;
CREATE TABLE `sys_func` (
`func_id` bigint(20) NOT NULL,
`parent_id` bigint(20) NOT NULL,
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`url` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`perms` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`type` int(11) DEFAULT NULL,
`order_num` int(11) DEFAULT NULL,
`func_id` bigint(20) NOT NULL COMMENT 'ID',
`parent_id` bigint(20) NOT NULL COMMENT '父类ID',
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '部门名称',
`url` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '地址',
`perms` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '授权',
`type` int(11) DEFAULT NULL COMMENT '类型 0:目录 1:菜单 2:按钮',
`order_num` int(11) DEFAULT NULL COMMENT '排序',
PRIMARY KEY (`func_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '功能表' ROW_FORMAT = Dynamic;
......@@ -164,7 +164,7 @@ CREATE TABLE `sys_user` (
`salt` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '加密盐',
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '邮箱',
`mobile` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '手机',
`status` int(11) DEFAULT NULL COMMENT '账户状态',
`status` int(11) DEFAULT NULL COMMENT '账户状态 0:禁用 1:正常',
`create_time` date DEFAULT NULL COMMENT '创建时间',
`dept_id` bigint(20) DEFAULT NULL COMMENT '部门id',
PRIMARY KEY (`user_id`) USING BTREE
......
......@@ -41,7 +41,7 @@ public class SysFuncEntity implements Serializable {
*/
private String perms;
/**
*
* 类型 0:目录 1:菜单 2:按钮
*/
private Integer type;
/**
......
......@@ -3,7 +3,9 @@ package com.mx.cneeds.server.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.springframework.transaction.annotation.Transactional;
import java.beans.Transient;
import java.io.Serializable;
import java.util.Date;
......@@ -41,4 +43,6 @@ public class SysRoleEntity implements Serializable {
*/
private Date createTime;
}
......@@ -45,7 +45,7 @@ public class SysUserEntity implements Serializable {
*/
private String mobile;
/**
* 账户状态
* 账户状态 0:禁用 1:正常
*/
private Integer status;
/**
......
......@@ -21,9 +21,18 @@ public class FuncDto implements Serializable {
private String url;
/**
* 授权
*/
private String perms;
/**
* 类型 0:目录 1:菜单 2:按钮
*/
private Integer type;
/**
* 排序
*/
private Integer orderNum;
}
package com.mx.cneeds.common.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName DeptDtp
* @Author zzrdark
* @Date 2020-03-10 16:00
* @Description TODO
**/
@Data
public class RoleDto implements Serializable {
/**
*
*/
private Long roleId;
/**
* 角色名称
*/
private String roleName;
/**
* 备注
*/
private String remark;
/**
* 部门Id
*/
private Long deptId;
/**
* 创建时间
*/
private Date createTime;
/**
* 部门名称
*/
private String deptName;
}
package com.mx.cneeds.common.vo;
import lombok.Data;
/**
* @ClassName DepartmentVO
* @Author zzrdark
* @Date 2020-03-10 20:14
* @Description TODO
**/
@Data
public class DepartmentVo {
private String deptName;
private String remark;
}
package com.mx.cneeds.common.converter;
import javax.xml.bind.DatatypeConverter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @ClassName RequestParamterConverter
......@@ -23,7 +25,68 @@ public class RequestParamterConverter {
return sb.toString();
}
/**
* 下划线命名转驼峰命名
* @param underscore
* @return
*/
public static String underscoreToCamelCase(String underscore){
String[] ss = underscore.split("_");
if(ss.length ==1){
return underscore;
}
StringBuffer sb = new StringBuffer();
sb.append(ss[0]);
for (int i = 1; i < ss.length; i++) {
sb.append(upperFirstCase(ss[i]));
}
return sb.toString();
}
/**
* 驼峰 转下划线
* @param camelCase
* @return
*/
public static String toLine(String camelCase){
Pattern humpPattern = Pattern.compile("[A-Z]");
Matcher matcher = humpPattern.matcher(camelCase);
StringBuffer sb = new StringBuffer();
while(matcher.find()){
matcher.appendReplacement(sb, "_"+matcher.group(0).toLowerCase());
}
matcher.appendTail(sb);
return sb.toString();
}
/**
* 首字母 转小写
* @param str
* @return
*/
private static String lowerFirstCase(String str) {
char[] chars = str.toCharArray();
chars[0] += 32;
return String.valueOf(chars);
}
/**
* 首字母 转大写
* @param str
* @return
*/
private static String upperFirstCase(String str) {
char[] chars = str.toCharArray();
chars[0] -= 32;
return String.valueOf(chars);
}
public static void main(String[] args) {
System.out.println(authorizationConverter("clientapp", "112233"));
// System.out.println(authorizationConverter("clientapp", "112233"));
System.out.println(toLine("userName"));
}
}
......@@ -16,6 +16,59 @@ import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(name = "CNEEDS-SERVER-USER")
public interface UserClient {
/**
*
* @param page
* @param pageSize
* @param order
* @param orderField
* @return
*/
@PostMapping("/sys/func/list")
PageDto funcList(@RequestParam Integer page, @RequestParam("limit") Integer pageSize);
PageDto funcList(@RequestParam Integer page,
@RequestParam("limit") Integer pageSize,
@RequestParam("sidx") String orderField,
@RequestParam("order") String order);
/**
*
* @param page
* @param pageSize
* @param orderField
* @param order
* @return
*/
@PostMapping("/sys/dept/list")
PageDto deptList(@RequestParam Integer page,
@RequestParam("limit") Integer pageSize,
@RequestParam("sidx") String orderField,
@RequestParam("order") String order);
/**
*
* @param page
* @param pageSize
* @param order
* @param orderField
* @return
*/
@PostMapping("/sys/role/list")
PageDto roleList(@RequestParam Integer page,
@RequestParam("limit") Integer pageSize,
@RequestParam("sidx") String orderField,
@RequestParam("order") String order);
/**
*
* @param page
* @param pageSize
* @param order
* @param orderField
* @return
*/
@PostMapping("/sys/user/list")
PageDto userList(@RequestParam Integer page,
@RequestParam("limit") Integer pageSize,
@RequestParam("sidx") String orderField,
@RequestParam("order") String order);
}
......@@ -27,8 +27,6 @@ public class CrossFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
log.info(httpServletRequest.getRequestURL().toString());
// log.info(httpServletRequest.getHeader("Access-Control-Allow-Origin"));
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.setHeader("Access-Control-Allow-Origin", "*");
httpResponse.setHeader("Access-Control-Allow-Methods", "*");
......
package com.mx.cneeds.server.datashow.web.system;
import com.mx.cneeds.common.converter.RequestParamterConverter;
import com.mx.cneeds.common.dto.PageDto;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.vo.DepartmentVo;
import com.mx.cneeds.server.datashow.client.UserClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -25,17 +28,139 @@ public class SystemController {
private UserClient userClient;
@PostMapping("/module/list")
public R funcList(@RequestParam Integer page, @RequestParam Integer pageSize){
if (page==null && page==0){
page = 1;
public R funcList(@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) String sort){
String orderField = null;
String order = null;
if (page==null || page==0){
page = new Integer(1);
}
if (pageSize==null || pageSize==0){
pageSize = new Integer(10);
}
if (StringUtils.isNotEmpty(sort) && StringUtils.isNotBlank(sort.trim())){
if (sort.contains("+")){
order = new String("asc");
}
if (sort.contains("-")){
order = new String("desc");
}
orderField = sort.substring(1);
orderField = RequestParamterConverter.toLine(orderField);
}
PageDto pageDto = userClient.funcList(page,pageSize,orderField,order);
return new R().put("data",pageDto);
}
@PostMapping("/dept/list")
public R deptList(@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) String sort){
String orderField = null;
String order = null;
if (page==null || page==0){
page = new Integer(1);
}
if (pageSize==null || pageSize==0){
pageSize = new Integer(10);
}
if (StringUtils.isNotEmpty(sort) && StringUtils.isNotBlank(sort.trim())){
if (sort.contains("+")){
order = new String("asc");
}
if (sort.contains("-")){
order = new String("desc");
}
orderField = sort.substring(1);
orderField = RequestParamterConverter.toLine(orderField);
}
PageDto pageDto = userClient.deptList(page,pageSize,orderField,order);
return new R().put("data",pageDto);
}
@PostMapping("/role/list")
public R roleList(@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) String sort){
String orderField = null;
String order = null;
if (page==null || page==0){
page = new Integer(1);
}
if (pageSize==null || pageSize==0){
pageSize = new Integer(10);
}
if (StringUtils.isNotEmpty(sort) && StringUtils.isNotBlank(sort.trim())){
if (sort.contains("+")){
order = new String("asc");
}
if (sort.contains("-")){
order = new String("desc");
}
if (pageSize==null && pageSize==0){
pageSize = 10;
orderField = sort.substring(1);
orderField = RequestParamterConverter.toLine(orderField);
}
PageDto pageDto = userClient.funcList(page,pageSize);
PageDto pageDto = userClient.roleList(page,pageSize,orderField,order);
return new R().put("data",pageDto);
}
@PostMapping("/user/list")
public R userList(@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer pageSize,
@RequestParam(required = false) String sort){
String orderField = null;
String order = null;
if (page==null || page==0){
page = new Integer(1);
}
if (pageSize==null || pageSize==0){
pageSize = new Integer(10);
}
if (StringUtils.isNotEmpty(sort) && StringUtils.isNotBlank(sort.trim())){
if (sort.contains("+")){
order = new String("asc");
}
if (sort.contains("-")){
order = new String("desc");
}
orderField = sort.substring(1);
orderField = RequestParamterConverter.toLine(orderField);
}
PageDto pageDto = userClient.userList(page,pageSize,orderField,order);
return new R().put("data",pageDto);
}
@PostMapping("/dept/add")
public R addDept(DepartmentVo departmentVo){
return R.ok();
}
}
......@@ -24,5 +24,6 @@ public interface SysDeptService extends IService<SysDeptEntity> {
List<Long> getSubDeptIdList(Long deptId);
List<Long> queryDetpIdList(Long parentId);
List<SysDeptEntity> queryDeptIdsBydeptName(List<Long> Ids);
}
......@@ -13,7 +13,7 @@ import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
@Service("sysDeptService")
......@@ -46,6 +46,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptDao, SysDeptEntity> i
return baseMapper.queryDetpIdList(parentId);
}
@Override
// @Transactional
public List<SysDeptEntity> queryDeptIdsBydeptName(List<Long> Ids) {
return baseMapper.selectList(new QueryWrapper<SysDeptEntity>()
.select("dept_id","name").in("dept_id",Ids));
}
/**
* 递归
*/
......
......@@ -3,9 +3,15 @@ package com.mx.cneeds.server.user.service.impl;
import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.common.pager.Query;
import com.mx.cneeds.server.dao.SysRoleDao;
import com.mx.cneeds.server.entity.SysDeptEntity;
import com.mx.cneeds.server.entity.SysRoleEntity;
import com.mx.cneeds.server.user.service.SysDeptService;
import com.mx.cneeds.server.user.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -15,6 +21,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service("sysRoleService")
public class SysRoleServiceImpl extends ServiceImpl<SysRoleDao, SysRoleEntity> implements SysRoleService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<SysRoleEntity> page = this.page(
......
......@@ -32,10 +32,9 @@ public class SysDeptController {
*/
@RequestMapping("/list")
// @RequiresPermissions("sys:sysdept:list")
public R list(@RequestParam Map<String, Object> params){
public PageUtils list(@RequestParam Map<String, Object> params){
PageUtils page = sysDeptService.queryPage(params);
return R.ok().put("page", page);
return page;
}
......
package com.mx.cneeds.server.user.web;
import com.mx.cneeds.common.dto.RoleDto;
import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.validator.ValidatorUtils;
import com.mx.cneeds.server.entity.SysDeptEntity;
import com.mx.cneeds.server.entity.SysRoleEntity;
import com.mx.cneeds.server.user.service.SysDeptService;
import com.mx.cneeds.server.user.service.SysRoleService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -27,15 +33,39 @@ public class SysRoleController {
@Autowired
private SysRoleService sysRoleService;
@Autowired
private SysDeptService sysDeptService;
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("sys:sysrole:list")
public R list(@RequestParam Map<String, Object> params){
public PageUtils list(@RequestParam Map<String, Object> params){
PageUtils page = sysRoleService.queryPage(params);
return R.ok().put("page", page);
List<Long> list = new ArrayList<>();
page.getList().forEach(e -> {
SysRoleEntity entity = (SysRoleEntity) e;
list.add(entity.getDeptId());
});
List<SysDeptEntity> sysDeptEntityList = sysDeptService.queryDeptIdsBydeptName(list);
List<RoleDto> roleDtos = new ArrayList<>();
page.getList().forEach(e -> {
SysRoleEntity entity = (SysRoleEntity) e;
for(SysDeptEntity deptEntity :sysDeptEntityList) {
if (deptEntity.getDeptId().equals(entity.getDeptId())){
RoleDto roleDto = new RoleDto();
BeanUtils.copyProperties(entity,roleDto);
roleDto.setDeptName(deptEntity.getName());
roleDtos.add(roleDto);
}
}
});
page.setList(roleDtos);
return page;
}
......
......@@ -41,10 +41,9 @@ public class SysUserController {
*/
@RequestMapping("/list")
// @RequiresPermissions("sys:sysuser:list")
public R list(@RequestParam Map<String, Object> params){
public PageUtils list(@RequestParam Map<String, Object> params){
PageUtils page = sysUserService.queryPage(params);
return R.ok().put("page", page);
return page;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment