系统结构

master
胡锐 10 months ago
parent 95ad210517
commit 7c6d7cfe6f
  1. 146
      bweb/src/main/java/com/bweb/config/AuthConfig.java
  2. 223
      bweb/src/main/java/com/bweb/controller/SecMenuController.java
  3. 129
      bweb/src/main/java/com/bweb/controller/SecRoleController.java
  4. 221
      bweb/src/main/java/com/bweb/controller/SecUserController.java
  5. 9
      cweb/src/main/java/com/cweb/config/AuthConfig.java
  6. 177
      order/src/main/java/com/order/config/AuthConfig.java
  7. 175
      schedule/src/main/java/com/hfkj/config/AuthConfig.java
  8. 4
      service/pom.xml
  9. 106
      service/src/main/java/com/hfkj/common/exception/ErrorCode.java
  10. 7
      service/src/main/java/com/hfkj/common/security/AESEncodeUtil.java
  11. 56
      service/src/main/java/com/hfkj/common/security/SessionObject.java
  12. 160
      service/src/main/java/com/hfkj/common/security/UserCenter.java
  13. 34
      service/src/main/java/com/hfkj/common/utils/StreamUtil.java
  14. 119
      service/src/main/java/com/hfkj/dao/SecMenuMapper.java
  15. 7
      service/src/main/java/com/hfkj/dao/SecMenuMapperExt.java
  16. 304
      service/src/main/java/com/hfkj/dao/SecMenuSqlProvider.java
  17. 102
      service/src/main/java/com/hfkj/dao/SecRoleMapper.java
  18. 7
      service/src/main/java/com/hfkj/dao/SecRoleMapperExt.java
  19. 89
      service/src/main/java/com/hfkj/dao/SecRoleMenuRelMapper.java
  20. 22
      service/src/main/java/com/hfkj/dao/SecRoleMenuRelMapperExt.java
  21. 206
      service/src/main/java/com/hfkj/dao/SecRoleMenuRelSqlProvider.java
  22. 248
      service/src/main/java/com/hfkj/dao/SecRoleSqlProvider.java
  23. 133
      service/src/main/java/com/hfkj/dao/SecUserMapper.java
  24. 7
      service/src/main/java/com/hfkj/dao/SecUserMapperExt.java
  25. 360
      service/src/main/java/com/hfkj/dao/SecUserSqlProvider.java
  26. 209
      service/src/main/java/com/hfkj/entity/SecMenu.java
  27. 863
      service/src/main/java/com/hfkj/entity/SecMenuExample.java
  28. 145
      service/src/main/java/com/hfkj/entity/SecRole.java
  29. 603
      service/src/main/java/com/hfkj/entity/SecRoleExample.java
  30. 93
      service/src/main/java/com/hfkj/entity/SecRoleMenuRel.java
  31. 402
      service/src/main/java/com/hfkj/entity/SecRoleMenuRelExample.java
  32. 264
      service/src/main/java/com/hfkj/entity/SecUser.java
  33. 1143
      service/src/main/java/com/hfkj/entity/SecUserExample.java
  34. 137
      service/src/main/java/com/hfkj/model/MenuTreeModel.java
  35. 43
      service/src/main/java/com/hfkj/model/SecUserSessionObject.java
  36. 6
      service/src/main/java/com/hfkj/model/UserInfoModel.java
  37. 77
      service/src/main/java/com/hfkj/service/SecMenuService.java
  38. 40
      service/src/main/java/com/hfkj/service/SecRoleMenuRelService.java
  39. 42
      service/src/main/java/com/hfkj/service/SecRoleService.java
  40. 66
      service/src/main/java/com/hfkj/service/SecUserService.java
  41. 291
      service/src/main/java/com/hfkj/service/impl/SecMenuServiceImpl.java
  42. 46
      service/src/main/java/com/hfkj/service/impl/SecRoleMenuRelServiceImpl.java
  43. 72
      service/src/main/java/com/hfkj/service/impl/SecRoleServiceImpl.java
  44. 146
      service/src/main/java/com/hfkj/service/impl/SecUserServiceImpl.java
  45. 47
      service/src/main/java/com/hfkj/sysenum/SecMenuTypeEnum.java
  46. 52
      service/src/main/java/com/hfkj/sysenum/SecUserStatusEnum.java
  47. 175
      user/src/main/java/com/user/config/AuthConfig.java
  48. 111
      user/src/main/java/com/user/controller/SecUserController.java

@ -1,4 +1,4 @@
package com.bweb.config;
package com.cweb.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
@ -7,7 +7,6 @@ import com.hfkj.common.security.UserCenter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
@ -17,6 +16,7 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -26,7 +26,7 @@ public class AuthConfig implements WebMvcConfigurer {
private static Logger log = LoggerFactory.getLogger(AuthConfig.class);
@Autowired
@Resource
private UserCenter userCenter;
/**
@ -53,84 +53,72 @@ public class AuthConfig implements WebMvcConfigurer {
}
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptorAdapter() {
registry.addInterceptor(new HandlerInterceptorAdapter() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getParameter("Authorization");
if (StringUtils.isBlank(token)) {
token = request.getHeader("Authorization");
}
if((StringUtils.isNotBlank(token) && userCenter.isTokenLogin(token)) || userCenter.isLogin(request)){//如果未登录,将无法使用任何接口
userCenter.refreshCookie(request, response);
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/login/userLogin")
.excludePathPatterns("/login/logout")
.excludePathPatterns("/common/*")
.excludePathPatterns("/sms/*")
.excludePathPatterns("/coupon/getGuizhouSinopec")
.excludePathPatterns("/cmsContent/get*")
.excludePathPatterns("/highGoldRec/*")
.excludePathPatterns("/test/*")
.excludePathPatterns("/openApi/*")
;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getHeader("Authorization");
if(StringUtils.isNotBlank(token) && userCenter.isLogin(token)){//如果未登录,将无法使用任何接口
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
;
}
public String getIpAddress(HttpServletRequest request) {
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
}

@ -0,0 +1,223 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecRoleMenuRel;
import com.hfkj.model.MenuTreeModel;
import com.hfkj.model.ResponseData;
import com.hfkj.service.SecMenuService;
import com.hfkj.service.SecRoleMenuRelService;
import com.hfkj.sysenum.SecMenuTypeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @className: SecMenu
* @author: HuRui
* @date: 2024/3/28
**/
@Controller
@RequestMapping(value="/secMenu")
@Api(value="系统菜单管理")
public class SecMenuController {
Logger log = LoggerFactory.getLogger(SecUserController.class);
@Resource
private SecMenuService secMenuService;
@Resource
private SecRoleMenuRelService secRoleMenuRelService;
@RequestMapping(value="/editMenu",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "编辑菜单")
public ResponseData editMenu(@RequestBody SecMenu body) {
try {
if (body == null
|| body.getMenuType() == null
|| StringUtils.isBlank(body.getMenuName())
|| StringUtils.isBlank(body.getMenuUrl())
|| body.getMenuSort() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
SecMenu secMenu;
if (body.getId() != null) {
// 查询菜单
secMenu = secMenuService.queryDetail(body.getId());
if (secMenu == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
} else {
secMenu = new SecMenu();
}
secMenu.setMenuType(body.getMenuType());
secMenu.setMenuName(body.getMenuName());
secMenu.setMenuUrl(body.getMenuUrl());
secMenu.setMenuUrlImg(body.getMenuUrlImg());
secMenu.setMenuPSid(body.getMenuPSid());
secMenu.setMenuSort(body.getMenuSort());
secMenu.setMenuDesc(body.getMenuDesc());
if (secMenu.getId() == null) {
secMenuService.create(secMenu);
} else {
secMenuService.update(secMenu);
}
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryDetail",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询详情")
public ResponseData queryDetail(@RequestParam(value = "menuId" , required = true) Long menuId) {
try {
return ResponseMsgUtil.success(secMenuService.queryDetail(menuId));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/assignMenu",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "分配菜单")
public ResponseData assignMenu(@RequestBody JSONObject body) {
try {
if (body == null
|| body.getLong("roleId") == null
|| body.getJSONArray("menuIds").isEmpty()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
List<Long> list = body.getJSONArray("menuIds")
.stream().map(o -> Long.parseLong(o.toString()))
.collect(Collectors.toList());
secMenuService.assignMenu(body.getLong("roleId"),list );
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryAssignMenuTree",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询分配菜单树")
public ResponseData queryAssignMenuTree(@RequestParam(value = "roleId" , required = true) Long roleId) {
try {
List<MenuTreeModel> treeModelList = new ArrayList<>();
MenuTreeModel menuTree;
// 获取系统菜单
List<SecMenu> sysMenuList = secMenuService.getAllList();
Map<Long, SecRoleMenuRel> roleMenuRelMap = secRoleMenuRelService.getRelListByRole(roleId)
.stream()
.collect(Collectors.toMap(SecRoleMenuRel::getMenuId, Function.identity()));
// 获取系统顶级菜单
List<SecMenu> topLevelMenuList = sysMenuList.stream().filter(o -> o.getMenuPSid() == null)
.sorted(Comparator.comparing(SecMenu::getMenuSort))
.collect(Collectors.toList());
for (SecMenu topLevelMenu : topLevelMenuList) {
menuTree = new MenuTreeModel();
menuTree.setId(topLevelMenu.getId());
menuTree.setMenuName(topLevelMenu.getMenuName());
menuTree.setMenuType(topLevelMenu.getMenuType());
menuTree.setMenuUrl(topLevelMenu.getMenuUrl());
menuTree.setMenuUrlImg(topLevelMenu.getMenuUrlImg());
menuTree.setMenuPSid(topLevelMenu.getMenuPSid());
menuTree.setMenuSort(topLevelMenu.getMenuSort());
menuTree.setMenuDesc(topLevelMenu.getMenuDesc());
// 递归子菜单
menuTree.setChildMenuList(recursionMenu(sysMenuList, roleMenuRelMap, topLevelMenu.getId()));
// 获取角色菜单
menuTree.setAuthority(roleMenuRelMap.get(topLevelMenu.getId()) != null ? true : false);
treeModelList.add(menuTree);
}
return ResponseMsgUtil.success(treeModelList);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryRoleMenuTree",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询角色菜单树")
public ResponseData queryRoleMenuTree(@RequestParam(value = "roleId" , required = false) Long roleId) {
try {
return ResponseMsgUtil.success(secMenuService.queryMenuTree(roleId));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
/**
* 递归菜单
* @param sysMenu 系统菜单
* @param roleMenuRel 角色菜单
* @param parentMenuId 父类菜单id
* @return
*/
public List<MenuTreeModel> recursionMenu(List<SecMenu> sysMenu, Map<Long, SecRoleMenuRel> roleMenuRel, Long parentMenuId) {
List<MenuTreeModel> treeModelList = new ArrayList<>();
MenuTreeModel menuTree;
List<SecMenu> collect = sysMenu.stream()
.filter(o -> o.getMenuPSid() != null && o.getMenuPSid().equals(parentMenuId))
.sorted(Comparator.comparing(SecMenu::getMenuSort))
.collect(Collectors.toList());
for (SecMenu menu : collect) {
menuTree = new MenuTreeModel();
menuTree.setId(menu.getId());
menuTree.setMenuName(menu.getMenuName());
menuTree.setMenuType(menu.getMenuType());
menuTree.setMenuUrl(menu.getMenuUrl());
menuTree.setMenuUrlImg(menu.getMenuUrlImg());
menuTree.setMenuPSid(menu.getMenuPSid());
menuTree.setMenuSort(menu.getMenuSort());
menuTree.setMenuDesc(menu.getMenuDesc());
// 获取角色菜单
menuTree.setAuthority(roleMenuRel.get(menuTree.getId()) != null ? true : false);
menuTree.setChildMenuList(recursionMenu(sysMenu, roleMenuRel, menu.getId()));
treeModelList.add(menuTree);
}
return treeModelList;
}
}

@ -0,0 +1,129 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.MD5Util;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecUser;
import com.hfkj.model.ResponseData;
import com.hfkj.service.SecRoleService;
import com.hfkj.service.SecUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* @className: SecRoleController
* @author: HuRui
* @date: 2024/3/27
**/
@Controller
@RequestMapping(value="/secRole")
@Api(value="系统用户角色管理")
public class SecRoleController {
Logger log = LoggerFactory.getLogger(SecUserController.class);
@Resource
private SecRoleService secRoleService;
@RequestMapping(value="/editRole",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "编辑角色")
public ResponseData editRole(@RequestBody SecRole body) {
try {
if (body == null || StringUtils.isBlank(body.getRoleName())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
SecRole secRole;
if (body.getId() != null) {
// 查询角色
secRole = secRoleService.getDetail(body.getId());
if (secRole == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
} else {
secRole = new SecRole();
secRole.setStatus(1);
}
secRole.setRoleName(body.getRoleName());
secRole.setRoleDesc(body.getRoleDesc());
secRoleService.editData(secRole);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/delRole",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "删除角色")
public ResponseData delRole(@RequestBody SecRole body) {
try {
if (body == null || body.getId() == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
secRoleService.delete(body.getId());
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryDetail",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询详情")
public ResponseData queryDetail(@RequestParam(value = "roleId" , required = true) Long roleId) {
try {
secRoleService.delete(roleId);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询列表")
public ResponseData queryList(@RequestParam(value = "roleName" , required = false) String roleName,
@RequestParam(value = "pageNum" , required = true) Integer pageNum,
@RequestParam(value = "pageSize" , required = true) Integer pageSize) {
try {
Map<String,Object> param = new HashMap<>();
param.put("roleName", roleName);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(secRoleService.getList(param)));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,221 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.MD5Util;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.SecUser;
import com.hfkj.model.ResponseData;
import com.hfkj.service.SecUserService;
import com.hfkj.sysenum.SecUserStatusEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value="/secUser")
@Api(value="系统用户管理")
public class SecUserController {
Logger log = LoggerFactory.getLogger(SecUserController.class);
@Resource
private SecUserService secUserService;
@RequestMapping(value="/create",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "创建用户")
public ResponseData create(@RequestBody JSONObject body) {
try {
if (body == null
|| StringUtils.isBlank(body.getString("userName"))
|| StringUtils.isBlank(body.getString("loginName"))
|| StringUtils.isBlank(body.getString("telephone"))
|| body.getLong("roleId") == null
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 校验重复登录账户
if (secUserService.getDetailByLoginName(body.getString("loginName")) != null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录账户已存在");
}
SecUser secUser = new SecUser();
secUser.setUserName(body.getString("userName"));
secUser.setLoginName(body.getString("loginName"));
secUser.setPassword(MD5Util.encode("123456".getBytes()));
secUser.setTelephone(body.getString("telephone"));
secUser.setRoleId(body.getLong("roleId"));
secUserService.create(secUser);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/update",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改用户")
public ResponseData update(@RequestBody JSONObject body) {
try {
if (body == null
|| body.getLong("userId") == null
|| StringUtils.isBlank(body.getString("userName"))
|| StringUtils.isBlank(body.getString("telephone"))
|| body.getLong("roleId") == null
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询用户详情
SecUser secUser = secUserService.getDetail(body.getLong("userId"));
if (secUser == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
secUser.setUserName(body.getString("userName"));
secUser.setTelephone(body.getString("telephone"));
secUser.setRoleId(body.getLong("roleId"));
secUserService.update(secUser);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/restore",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "删除用户")
public ResponseData delete(@RequestBody JSONObject body) {
try {
if (body == null || body.getLong("userId") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询用户详情
SecUser secUser = secUserService.getDetail(body.getLong("userId"));
if (secUser == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
secUser.setStatus(SecUserStatusEnum.status0.getCode());
secUserService.editUser(secUser);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/restore1",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "恢复")
public ResponseData restore1(@RequestBody JSONObject body) {
try {
if (body == null || body.getLong("userId") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询用户详情
SecUser secUser = secUserService.getDetail(body.getLong("userId"));
if (secUser == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
secUser.setStatus(SecUserStatusEnum.status1.getCode());
secUserService.editUser(secUser);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/disable",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "禁用")
public ResponseData disable(@RequestBody JSONObject body) {
try {
if (body == null || body.getLong("userId") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 查询用户详情
SecUser secUser = secUserService.getDetail(body.getLong("userId"));
if (secUser == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
secUser.setStatus(SecUserStatusEnum.status2.getCode());
secUserService.editUser(secUser);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryDetail",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询详情")
public ResponseData queryDetail(@RequestParam(value = "userId" , required = true) Long userId) {
try {
// 查询详情
SecUser secUser = secUserService.getDetail(userId);
if (secUser != null) {
secUser.setPassword(null);
}
return ResponseMsgUtil.success(secUser);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询列表")
public ResponseData queryList(@RequestParam(value = "userName", required = false) String userName,
@RequestParam(value = "telephone", required = false) String telephone,
@RequestParam(value = "status", required = false) Integer status,
@RequestParam(value = "pageNum", required = true) Integer pageNum,
@RequestParam(value = "pageSize", required = true) Integer pageSize) {
try {
Map<String,Object> param = new HashMap<>();
param.put("userName", userName);
param.put("telephone", telephone);
param.put("status", status);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(secUserService.getList(param));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -61,12 +61,9 @@ public class AuthConfig implements WebMvcConfigurer {
if(debug){
return true;
}
String token = request.getParameter("Authorization");
if (StringUtils.isBlank(token)) {
token = request.getHeader("Authorization");
}
if((StringUtils.isNotBlank(token) && userCenter.isTokenLogin(token)) || userCenter.isLogin(request)){//如果未登录,将无法使用任何接口
userCenter.refreshCookie(request, response);
String token = request.getHeader("Authorization");
if(StringUtils.isNotBlank(token) && userCenter.isLogin(token)){//如果未登录,将无法使用任何接口
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;

@ -1,9 +1,9 @@
package com.order.config;
package com.cweb.config;
import com.hfkj.common.security.UserCenter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.hfkj.common.security.UserCenter;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -53,117 +53,72 @@ public class AuthConfig implements WebMvcConfigurer {
}
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptorAdapter() {
registry.addInterceptor(new HandlerInterceptorAdapter() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getParameter("Authorization");
if (StringUtils.isBlank(token)) {
token = request.getHeader("Authorization");
}
if((StringUtils.isNotBlank(token) && userCenter.isTokenLogin(token)) || userCenter.isLogin(request)){//如果未登录,将无法使用任何接口
userCenter.refreshCookie(request, response);
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/login/*")
.excludePathPatterns("/order/*")
.excludePathPatterns("/coupon/getCouponList")
.excludePathPatterns("/wechatpay/*")
.excludePathPatterns("/coupon/getCouponById")
.excludePathPatterns("/discount/getDiscountByQrCode")
.excludePathPatterns("/discount/getDiscountById")
.excludePathPatterns("/discount/getCouponByDiscount")
.excludePathPatterns("/discount/getDiscountByDiscountAgentId")
.excludePathPatterns("/highMerchantStore/getMerchantStoreById")
.excludePathPatterns("/highMerchantStore/getStoreListByCoupon")
.excludePathPatterns("/highMerchantStore/getStoreList")
.excludePathPatterns("/highMerchantStore/getMerchantList")
.excludePathPatterns("/highMerchantStore/getStoreListByMerchant")
.excludePathPatterns("/sms/sendSmsCode")
.excludePathPatterns("/sms/getSmsCode")
.excludePathPatterns("/activity/getWinLotteryList")
.excludePathPatterns("/user/login")
.excludePathPatterns("/user/unionPhoneLogin")
.excludePathPatterns("/user/getUnionId")
.excludePathPatterns("/highUser/setCacheParam")
.excludePathPatterns("/highUser/getCacheParam")
.excludePathPatterns("/highUser/delCacheParam")
.excludePathPatterns("/order/orderToH5Pay")
.excludePathPatterns("/order/orderToPay")
.excludePathPatterns("/test/*")
.excludePathPatterns("/cmsContent/*")
.excludePathPatterns("/highGas/*")
.excludePathPatterns("/outRechargeOrder/*")
.excludePathPatterns("/wechat/*")
.excludePathPatterns("/tuanyou/*")
.excludePathPatterns("/unionPay/*")
.excludePathPatterns("/highGas/*")
.excludePathPatterns("/common/*")
.excludePathPatterns("/order/qzOrderToPay")
.excludePathPatterns("/czOrder/orderRefundNotify")
.excludePathPatterns("/cmsContent/*")
.excludePathPatterns("/highBrand/*")
.excludePathPatterns("/highGoodsType/*")
.excludePathPatterns("/sendSms/*")
.excludePathPatterns("/test/*")
.excludePathPatterns("/sms/*")
;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getHeader("Authorization");
if(StringUtils.isNotBlank(token) && userCenter.isLogin(token)){//如果未登录,将无法使用任何接口
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
;
}
public String getIpAddress(HttpServletRequest request) {
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
}

@ -1,4 +1,4 @@
package com.hfkj.config;
package com.cweb.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
@ -53,117 +53,72 @@ public class AuthConfig implements WebMvcConfigurer {
}
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptorAdapter() {
registry.addInterceptor(new HandlerInterceptorAdapter() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getParameter("Authorization");
if (StringUtils.isBlank(token)) {
token = request.getHeader("Authorization");
}
if((StringUtils.isNotBlank(token) && userCenter.isTokenLogin(token)) || userCenter.isLogin(request)){//如果未登录,将无法使用任何接口
userCenter.refreshCookie(request, response);
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/login/*")
.excludePathPatterns("/order/*")
.excludePathPatterns("/coupon/getCouponList")
.excludePathPatterns("/wechatpay/*")
.excludePathPatterns("/coupon/getCouponById")
.excludePathPatterns("/discount/getDiscountByQrCode")
.excludePathPatterns("/discount/getDiscountById")
.excludePathPatterns("/discount/getCouponByDiscount")
.excludePathPatterns("/discount/getDiscountByDiscountAgentId")
.excludePathPatterns("/highMerchantStore/getMerchantStoreById")
.excludePathPatterns("/highMerchantStore/getStoreListByCoupon")
.excludePathPatterns("/highMerchantStore/getStoreList")
.excludePathPatterns("/highMerchantStore/getMerchantList")
.excludePathPatterns("/highMerchantStore/getStoreListByMerchant")
.excludePathPatterns("/sms/sendSmsCode")
.excludePathPatterns("/sms/getSmsCode")
.excludePathPatterns("/activity/getWinLotteryList")
.excludePathPatterns("/user/login")
.excludePathPatterns("/user/unionPhoneLogin")
.excludePathPatterns("/user/getUnionId")
.excludePathPatterns("/highUser/setCacheParam")
.excludePathPatterns("/highUser/getCacheParam")
.excludePathPatterns("/highUser/delCacheParam")
.excludePathPatterns("/order/orderToH5Pay")
.excludePathPatterns("/order/orderToPay")
.excludePathPatterns("/test/*")
.excludePathPatterns("/cmsContent/*")
.excludePathPatterns("/highGas/*")
.excludePathPatterns("/outRechargeOrder/*")
.excludePathPatterns("/wechat/*")
.excludePathPatterns("/tuanyou/*")
.excludePathPatterns("/unionPay/*")
.excludePathPatterns("/highGas/*")
.excludePathPatterns("/common/*")
.excludePathPatterns("/order/qzOrderToPay")
.excludePathPatterns("/czOrder/orderRefundNotify")
.excludePathPatterns("/cmsContent/*")
.excludePathPatterns("/highBrand/*")
.excludePathPatterns("/highGoodsType/*")
.excludePathPatterns("/sendSms/*")
.excludePathPatterns("/test/*")
.excludePathPatterns("/sms/*")
;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getHeader("Authorization");
if(StringUtils.isNotBlank(token) && userCenter.isLogin(token)){//如果未登录,将无法使用任何接口
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
;
}
public String getIpAddress(HttpServletRequest request) {
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
}

@ -234,6 +234,10 @@
<artifactId>jersey-client</artifactId>
<version>1.16</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<resources>

@ -20,116 +20,14 @@ public enum ErrorCode {
DB_CONNECT_ERROR("0000","数据库连接异常"),
FTP_CONNECT_ERROR("0001","FTP服务器连接失败"),
FTP_CONFIG_NOT_FOUND("0002","FTP服务地址路径配置缺失"),
//////////////////APP///////////////
WECHAT_DECRYPT_ERROR("3001","微信解密错误->%s"),
WECHAT_LOGIN_ERROR("3002","微信登录失败"),
WECHAT_LOGIN_TEACHER_ERROR("3003","当前微信用户不是老师,请联系管理员"),
SERVER_BUSY_ERROR("3004","服务器繁忙,请稍后重试"),
//////////////////业务异常/////////////
COMMON_ERROR("2000",""),
REQ_PARAMS_ERROR("2001","请求参数校验失败"),
PHONE_REGISTER_ERROR("2002","手机号已注册"),
VERIFICATION_CODE_ERROR("2003","验证码错误"),
SEC_USER_OR_PASSWORD_ERROR("2005","手机号或密码错误"),
NOT_FOUND_PHONE("2006","未找到手机号"),
OLD_PASSWORD("2007","旧密码错误"),
BS_COMPANY_UNAVAILABLE("2013","公司不可用"),
NOT_FOUND_USER_ERROR("2016","用户不存在"),
NOT_FOUND_COMPANY("2018","未找到公司"),
USER_PHONE_HAS_ONE_ERROR("2020","该用户电话已被绑定,请更换"),
USER_ROLE_PERMISSION_ALLOT_ERROR("2011","请联系管理员核实用户角色权限是否启用"),
COMPANY_REGION_HAS_IN_CITY_ERROR("2031","单位区域必须选择到市级区域"),
UN_FIND_ORGANIZATION_ERROR("2032","未找到该部门信息"),
COMPANY_ADMIN_USER_ERROR("2033","公司主账号异常"),
ORGANIZATION_NAME_IS_EXIST_ERROR("2034","部门名称已经存在"),
TOP_ORGANIZATION_DELETE_ERROR("2035","顶级组织不允许删除"),
SON_ORGANIZATION_IS_EXIST_ERROR("2036","存在子级部门,不能删除"),
ORG_REGION_HAS_IN_REGION_ERROR("2037","区级单位所属区域必须选择到区级"),
CMS_CATEGORY_NOT_FOUND("2038", "未找到分类"),
CMS_CATEGORY_MODULE_NOT_FOUND("2039", "未找到模板"),
CMS_CATEGORY_MODULE_EXISTS("2040", "同一分类下存在相同名称的模板"),
CMS_CATEGORY_EXISTS_CHILDREN("2041", "分类存在子级,无法删除"),
CMS_CATEGORY_EXISTS("2042", "存在相同编码的分类"),
CMS_CREATE_HTML_ERROR("2043", "生成页面错误"),
CMS_CONTENT_NOT_FOUND("2044", "未找到内容信息"),
CMS_PATCH_NOT_FOUND("2045", "未找到附件"),
MENU_TREE_HAS_NOT_ERROR("2041","该主角色没有权限"),
PERMISSION_NAME_IS_EXIST_ERROR("2043","该权限名称已经存在"),
PERMISSION_CODE_IS_EXIST_ERROR("2044","该权限编码已经存在"),
MENU_TYPE_IS_NOT_EDIT_ERROR("2046","菜单类型不允许修改"),
MENU_HAS_SON_ERROR("2047","存在子菜单,不能删除"),
ROLE_NAME_IS_EXIST_ERROR("2048","该角色名已经存在"),
USER_LOGIN_NAME_IS_EXIST_ERROR("2049","该登录用户名已经存在"),
USER_ROLE_HAS_ALLOT_ERROR("2050","该角色已分配给用户,不能删除"),
COMPANY_NAME_IS_EXIST_ERROR("2055","公司已经存在"),
UN_FIND_TOP_ORGANIZATION_ERROR("2051","找不到顶级组织架构"),
BASE_ORGANIZATION_HAS_NOT_MANAGE_ERROR("2056","该部门暂无管理员"),
BASE_ORGANIZATION_HAS_NOT_PARENT_ERROR("2057","该部门无上级部门"),
SEC_USER_EXPIRED("2068","用户身份错误或已过期"),
UN_MEMBER_ERROR("2084","未找到用户"),
SING_ERROR("2089","签名错误"),
REGION_ABBREVIATE_EXIST("2098","地区简称已存在"),
NOT_FOUND_CHANNEL("2099","未找到渠道商"),
PASSWORD_ERROR("2102","密码错误"),
SMS_CODE_ERROR("2103","验证码错误"),
ID_CARD_NUM_IS_ERROR("2104","身份证号码错误"),
MERCHANT_NOF_FOUND("2105","未找到商户"),
MERCHANT_STORE_NOF_FOUND("2106","未找到商户门店"),
PHONE_NUM_IS_ERROR("2107","请输入正确的电话号码"),
PHONE_NUM_EXISTED("2108","电话号码已被使用"),
MERCHANT_STATUS_ERROR("2109","商户状态不正常,请联系管理员"),
SELECT_HANDSEL_COUPON_ERROR("2110","请选择赠送卡卷名单"),
NOT_FOUND_COUPON("2111","未找到卡券信息"),
WRITE_COUPON_NUMBER_ERROR("2112","请填写卡卷数量"),
COUPON_UNABLE_UP_SHELF("2113","卡卷状态错误"),
NOT_FOUND_APPROVE("2114","未找到审批记录"),
APPROVE_PROCESSED("2115","审批已处理"),
COUPON_STOCK_ERROR("2116","卡卷库存数量错误"),
COUPON_TYPE_ERROR("2117","卡卷类型错误"),
COUPON_STATUS_ERROR("2118","卡卷状态错误"),
GOODS_PRICE_REFER_ERROR("2119","未找到价格信息"),
DISCOUNT_PRICE_BIG_SALES_PRICE_ERROR("2120","折扣价格不能大于原价"),
INVALID_TIME_BIG_EFFECTIVE_TIME_ERROR("2121","失效时间不能大于生效时间"),
PRICE_REFER_STATUS_ERROR("2122","暂时无法增加,有处于在待编辑、待生效、审批中的价格"),
NEED_WRITE_NEW_SALE_PRICE("2123","请填写正确的新销售价格"),
NEED_WRITE_DISCOUNT_PRICE("2124","请填写正确的折扣数,折扣数范围【0】 ~ 【10】"),
DISCOUNT_PRICE_RANGE("2125","请输入正确的"),
TEL_EXISTED("2126","联系方式已被使用"),
ORDER_TYPE_ERROR("2127","订单类型错误"),
COUPON_STOCK_INSUFFICIENT("2118","卡卷库存数量不足"),
NOT_FOUND_ORDER("2119","未找到订单信息"),
ORDER_NO_STAY_PAY("2120","订单不处于待支付状态"),
NOT_FOUND_COUPON_CODE("2121","销售码不存在"),
COUPON_CODE_STATUS("2122","卡券码状态错误"),
COUPON_CODE_OVERDUE("2122","卡券码已过期"),
COUPON_CODE_NAME("2123","卡券名称已存在"),
AGENT_NAME("2124","代理商名称已存在"),
NOT_FOUND_DISCOUNT("2125","未找到优惠券信息"),
NOT_FOUND_AGENT("2126","未找到代理商信息"),
DISCOUNT_STOCK_COUNT_ERROR("2127","优惠券库存数量不足"),
RECHARGE_CLOSE("2128","系统已关闭,请稍后充值"),
REPEAT_SET_USER_PAY_PWD("2129","已设置支付密码"),
NOT_SET_USER_PAY_PWD("2130","未设置支付密码"),
NOT_ENTER_USER_PAY_PWD("2131","未输入支付密码"),
USER_PAY_PWD_ERROR("2132","支付密码错误"),
NO_BIND_PHONE("2133","未绑定手机号"),
title_("2134","名称已存在"),
ADD_REPEATEDLY("2135","重复添加"),
ACCOUNT_LOGIN_EXPIRE("2002","登录账户已过期"),
ACCOUNT_LOGIN_NOT("2003","账户未登录"),
STATUS_ERROR("3000","状态错误"),
ADD_DATA_ERROR("3001","增加数据失败"),
UPDATE_DATA_ERROR("3002","修改数据失败"),
DELETE_DATA_ERROR("3003","删除数据失败"),
COMPETENCE_INSUFFICIENT("3004","权限不足"),
REQUEST_ERROR("3005","请求错误"),
REQUEST_TIMED_OUT("3006","请求超时,请稍后重试"),
MSG_EVENT_NULL("2999","消息类型为空"),
USE_VISIT_ILLEGAL("4001","用户身份错误"),
RC_VISIT_ERROR("2998",""),
UNKNOW_ERROR("999999","未知异常"),
EXCEL_ERROR("80000","Excel处理异常"),
;//注意:上面为逗号,此次为分号

@ -35,9 +35,12 @@ public class AESEncodeUtil {
}
public static String aesEncrypt(String content) throws Exception{
public static String aesEncrypt(String content) throws Exception {
return base64Encode(aesEncryptToBytes(content, SEC_KEY));
//return content;
}
public static String aesEncrypt(String content, String key) throws Exception {
return base64Encode(aesEncryptToBytes(content, key));
}
public static String aesDecryptByBytes(byte[] encryptBytes, String decryptKey) throws Exception{

@ -1,57 +1,33 @@
package com.hfkj.common.security;
import org.apache.commons.lang3.StringUtils;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecUser;
import com.hfkj.model.MenuTreeModel;
import lombok.Data;
import java.util.List;
/**
* session 对象
* @author hurui
*/
@Data
public class SessionObject {
/**
* 登录用户的唯一标识
*/
private String uniqueCode;
/**
* 1:会员2渠道3.管理员
*/
private Integer type;
private String token;
/**
* 存储用户基本信息
*/
private Object object;
public SessionObject(){
}
public SessionObject(String uniqueCode, Integer type, Object object){
this.uniqueCode = uniqueCode;
this.type = type;
this.object = object;
}
public String getUniqueCode() throws Exception {
if(StringUtils.isEmpty(uniqueCode)){
throw new Exception("SessionObject uniqueCode is null");
}
return uniqueCode;
}
public void setUniqueCode(String uniqueCode) {
this.uniqueCode = uniqueCode;
}
public Object getObject() {
return object;
}
public void setObject(Object object) {
public SessionObject(String token, Object object) {
this.token = token;
this.object = object;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}

@ -4,11 +4,14 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.RedisUtil;
import com.hfkj.model.SecUserSessionObject;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@ -21,133 +24,88 @@ public class UserCenter {
@Autowired
private RedisUtil redisUtil;
private final int EXPIRE = 3600 * 24 * 3; // 登录过期时间为3天
private final String COOKIE_FIELD = "_ida";
private final int EXPIRE = 3600 * 24 * 7;//cookie过期时间为7天
/**
* 保存登录信息
* @throws Exception
*/
public void save(SessionObject seObj) {
redisUtil.set(seObj.getToken(), seObj, EXPIRE);
}
/**
* 判断用户是否登录,并且不能单个用户同时登录
* 是否登录
* @param request
* @return boolean
* @throws Exception
* @return
*/
public boolean isLogin(HttpServletRequest request){
String token = request.getHeader("Authorization");
if(StringUtils.isBlank(token)){
Cookie cookie = CookieUtil.getCookieByName(request, COOKIE_FIELD);
if(cookie != null && StringUtils.isNotBlank(cookie.getValue())){
token = cookie.getValue();
}
}
if(StringUtils.isBlank(token)){
return false;
if(StringUtils.isBlank(token)) {
return false;
}
try {
if (!StringUtils.isEmpty(token)) {
SessionObject cacheStr = (SessionObject)redisUtil.get(token);
if (cacheStr != null) {
redisUtil.expire(token,EXPIRE);
return true;
}
}
}catch (Exception e){
e.printStackTrace();
}
return false;
return redisUtil.hasKey(token);
}
/**
*
* @Title: isTokenLogin
* @Description: 支持token形式的校验登录
* @author: 机器猫
* @param: @param token
* @param: @return
* @param: @throws Exception
* @return: boolean
* @throws
* 是否登录
* @param token 账户token
* @return
*/
public boolean isTokenLogin(String token){
try {
log.error("------------------------------" + token);
if(!StringUtils.isEmpty(token)){
SessionObject cacheStr = (SessionObject)redisUtil.get(token);
if (cacheStr != null) {
redisUtil.expire(token,EXPIRE);
return true;
}
}
return false;
} catch (Exception e) {
log.error("isTokenLogin failed",e);
return false;
}
}
public String read(HttpServletRequest request){
Cookie cookie = CookieUtil.getCookieByName(request, COOKIE_FIELD);
if(cookie == null){
return null;
public boolean isLogin(String token){
if(StringUtils.isBlank(token)) {
return false;
}
return cookie.getValue();
}
public SessionObject getSessionObject(HttpServletRequest request) throws Exception{
String token = request.getHeader("Authorization");
if (StringUtils.isBlank(token)) {
if (StringUtils.isNotBlank(read(request))) {
token = read(request);
}
}
if (redisUtil.get(token) == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.USE_VISIT_ILLEGAL, "");
}
return (SessionObject) redisUtil.get(token);
return redisUtil.hasKey(token);
}
/**
* 退出登录
* @param request
* @param response
* @param response
* @throws Exception
*/
public void save(HttpServletRequest request, HttpServletResponse response, SessionObject seObj) throws Exception{
CookieUtil.saveCookie(request, response, COOKIE_FIELD, seObj.getUniqueCode(), EXPIRE);
redisUtil.set(seObj.getUniqueCode(), seObj, EXPIRE);
public void remove(HttpServletRequest request) {
String token = request.getHeader("Authorization");
if (StringUtils.isNotBlank(token)) {
//通过token方式登录
redisUtil.del(token);
}
}
/**
* 刷新cookie信息
*
* @param request
* @param response
* @throws Exception
* 获取session信息
* @param clazz
* @return
* @param <E>
*/
public void refreshCookie(HttpServletRequest request, HttpServletResponse response) throws Exception{
CookieUtil.refreshCookie(request, response, COOKIE_FIELD, EXPIRE);
public <E> E getSessionModel(Class<E> clazz){
if (RequestContextHolder.getRequestAttributes()!=null) {
HttpServletRequest req = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
SessionObject sessionObject = getSessionObject(req);
if (sessionObject == null){
return null;
}
if (clazz.equals(sessionObject.getObject().getClass())) {
return (E)sessionObject.getObject();
}
}
return null;
}
/**
* 获取session信息
* @param request
* @param response
* @throws Exception
* @return
*/
public void remove(HttpServletRequest request, HttpServletResponse response) {
public SessionObject getSessionObject(HttpServletRequest request) {
String token = request.getHeader("Authorization");
if(StringUtils.isNotBlank(token)){
//通过token方式登录
redisUtil.del(token);
CookieUtil.delCookie(response, COOKIE_FIELD);
}else{
String jo = read(request);
if(StringUtils.isNotBlank(jo)){
redisUtil.del(jo);
CookieUtil.delCookie(response, COOKIE_FIELD);
}
if (StringUtils.isBlank(token)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
Object obj = redisUtil.get(token);
if (obj == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_LOGIN_NOT, "");
}
return (SessionObject) obj;
}
}

@ -0,0 +1,34 @@
package com.hfkj.common.utils;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
/**
*
* @ClassName: StreamUtil
* @Description:TODO(List Steam)
* @author: 胡锐
* @date: 2019年3月25日 下午4:14:00
*
* @Copyright: 2019 www.shinwoten.com Inc. All rights reserved.
*/
public class StreamUtil {
/**
*
* @Title: distinctByKey
* @Description: TODO(对象 去重)
* @author: 胡锐
* @param: @param keyExtractor
* @param: @return
* @return: Predicate<T>
* @throws
*/
public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Map<Object,Boolean> seen = new ConcurrentHashMap<>();
return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
}
}

@ -0,0 +1,119 @@
package com.hfkj.dao;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecMenuExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
/**
*
* 代码由工具生成,请勿修改!!!
* 如果需要扩展请在其父类进行扩展
*
**/
@Repository
public interface SecMenuMapper extends SecMenuMapperExt {
@SelectProvider(type=SecMenuSqlProvider.class, method="countByExample")
long countByExample(SecMenuExample example);
@DeleteProvider(type=SecMenuSqlProvider.class, method="deleteByExample")
int deleteByExample(SecMenuExample example);
@Delete({
"delete from sec_menu",
"where id = #{id,jdbcType=BIGINT}"
})
int deleteByPrimaryKey(Long id);
@Insert({
"insert into sec_menu (menu_name, menu_type, ",
"menu_url, menu_url_img, ",
"menu_p_sid, menu_sort, ",
"menu_desc, create_time, ",
"update_time)",
"values (#{menuName,jdbcType=VARCHAR}, #{menuType,jdbcType=INTEGER}, ",
"#{menuUrl,jdbcType=VARCHAR}, #{menuUrlImg,jdbcType=VARCHAR}, ",
"#{menuPSid,jdbcType=BIGINT}, #{menuSort,jdbcType=INTEGER}, ",
"#{menuDesc,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(SecMenu record);
@InsertProvider(type=SecMenuSqlProvider.class, method="insertSelective")
@Options(useGeneratedKeys=true,keyProperty="id")
int insertSelective(SecMenu record);
@SelectProvider(type=SecMenuSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_type", property="menuType", jdbcType=JdbcType.INTEGER),
@Result(column="menu_url", property="menuUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_url_img", property="menuUrlImg", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_p_sid", property="menuPSid", jdbcType=JdbcType.BIGINT),
@Result(column="menu_sort", property="menuSort", jdbcType=JdbcType.INTEGER),
@Result(column="menu_desc", property="menuDesc", jdbcType=JdbcType.VARCHAR),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
})
List<SecMenu> selectByExample(SecMenuExample example);
@Select({
"select",
"id, menu_name, menu_type, menu_url, menu_url_img, menu_p_sid, menu_sort, menu_desc, ",
"create_time, update_time",
"from sec_menu",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="menu_name", property="menuName", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_type", property="menuType", jdbcType=JdbcType.INTEGER),
@Result(column="menu_url", property="menuUrl", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_url_img", property="menuUrlImg", jdbcType=JdbcType.VARCHAR),
@Result(column="menu_p_sid", property="menuPSid", jdbcType=JdbcType.BIGINT),
@Result(column="menu_sort", property="menuSort", jdbcType=JdbcType.INTEGER),
@Result(column="menu_desc", property="menuDesc", jdbcType=JdbcType.VARCHAR),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
})
SecMenu selectByPrimaryKey(Long id);
@UpdateProvider(type=SecMenuSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") SecMenu record, @Param("example") SecMenuExample example);
@UpdateProvider(type=SecMenuSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") SecMenu record, @Param("example") SecMenuExample example);
@UpdateProvider(type=SecMenuSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(SecMenu record);
@Update({
"update sec_menu",
"set menu_name = #{menuName,jdbcType=VARCHAR},",
"menu_type = #{menuType,jdbcType=INTEGER},",
"menu_url = #{menuUrl,jdbcType=VARCHAR},",
"menu_url_img = #{menuUrlImg,jdbcType=VARCHAR},",
"menu_p_sid = #{menuPSid,jdbcType=BIGINT},",
"menu_sort = #{menuSort,jdbcType=INTEGER},",
"menu_desc = #{menuDesc,jdbcType=VARCHAR},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"update_time = #{updateTime,jdbcType=TIMESTAMP}",
"where id = #{id,jdbcType=BIGINT}"
})
int updateByPrimaryKey(SecMenu record);
}

@ -0,0 +1,7 @@
package com.hfkj.dao;
/**
* mapper扩展类
*/
public interface SecMenuMapperExt {
}

@ -0,0 +1,304 @@
package com.hfkj.dao;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecMenuExample.Criteria;
import com.hfkj.entity.SecMenuExample.Criterion;
import com.hfkj.entity.SecMenuExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;
public class SecMenuSqlProvider {
public String countByExample(SecMenuExample example) {
SQL sql = new SQL();
sql.SELECT("count(*)").FROM("sec_menu");
applyWhere(sql, example, false);
return sql.toString();
}
public String deleteByExample(SecMenuExample example) {
SQL sql = new SQL();
sql.DELETE_FROM("sec_menu");
applyWhere(sql, example, false);
return sql.toString();
}
public String insertSelective(SecMenu record) {
SQL sql = new SQL();
sql.INSERT_INTO("sec_menu");
if (record.getMenuName() != null) {
sql.VALUES("menu_name", "#{menuName,jdbcType=VARCHAR}");
}
if (record.getMenuType() != null) {
sql.VALUES("menu_type", "#{menuType,jdbcType=INTEGER}");
}
if (record.getMenuUrl() != null) {
sql.VALUES("menu_url", "#{menuUrl,jdbcType=VARCHAR}");
}
if (record.getMenuUrlImg() != null) {
sql.VALUES("menu_url_img", "#{menuUrlImg,jdbcType=VARCHAR}");
}
if (record.getMenuPSid() != null) {
sql.VALUES("menu_p_sid", "#{menuPSid,jdbcType=BIGINT}");
}
if (record.getMenuSort() != null) {
sql.VALUES("menu_sort", "#{menuSort,jdbcType=INTEGER}");
}
if (record.getMenuDesc() != null) {
sql.VALUES("menu_desc", "#{menuDesc,jdbcType=VARCHAR}");
}
if (record.getCreateTime() != null) {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
}
return sql.toString();
}
public String selectByExample(SecMenuExample example) {
SQL sql = new SQL();
if (example != null && example.isDistinct()) {
sql.SELECT_DISTINCT("id");
} else {
sql.SELECT("id");
}
sql.SELECT("menu_name");
sql.SELECT("menu_type");
sql.SELECT("menu_url");
sql.SELECT("menu_url_img");
sql.SELECT("menu_p_sid");
sql.SELECT("menu_sort");
sql.SELECT("menu_desc");
sql.SELECT("create_time");
sql.SELECT("update_time");
sql.FROM("sec_menu");
applyWhere(sql, example, false);
if (example != null && example.getOrderByClause() != null) {
sql.ORDER_BY(example.getOrderByClause());
}
return sql.toString();
}
public String updateByExampleSelective(Map<String, Object> parameter) {
SecMenu record = (SecMenu) parameter.get("record");
SecMenuExample example = (SecMenuExample) parameter.get("example");
SQL sql = new SQL();
sql.UPDATE("sec_menu");
if (record.getId() != null) {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getMenuName() != null) {
sql.SET("menu_name = #{record.menuName,jdbcType=VARCHAR}");
}
if (record.getMenuType() != null) {
sql.SET("menu_type = #{record.menuType,jdbcType=INTEGER}");
}
if (record.getMenuUrl() != null) {
sql.SET("menu_url = #{record.menuUrl,jdbcType=VARCHAR}");
}
if (record.getMenuUrlImg() != null) {
sql.SET("menu_url_img = #{record.menuUrlImg,jdbcType=VARCHAR}");
}
if (record.getMenuPSid() != null) {
sql.SET("menu_p_sid = #{record.menuPSid,jdbcType=BIGINT}");
}
if (record.getMenuSort() != null) {
sql.SET("menu_sort = #{record.menuSort,jdbcType=INTEGER}");
}
if (record.getMenuDesc() != null) {
sql.SET("menu_desc = #{record.menuDesc,jdbcType=VARCHAR}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
}
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByExample(Map<String, Object> parameter) {
SQL sql = new SQL();
sql.UPDATE("sec_menu");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("menu_name = #{record.menuName,jdbcType=VARCHAR}");
sql.SET("menu_type = #{record.menuType,jdbcType=INTEGER}");
sql.SET("menu_url = #{record.menuUrl,jdbcType=VARCHAR}");
sql.SET("menu_url_img = #{record.menuUrlImg,jdbcType=VARCHAR}");
sql.SET("menu_p_sid = #{record.menuPSid,jdbcType=BIGINT}");
sql.SET("menu_sort = #{record.menuSort,jdbcType=INTEGER}");
sql.SET("menu_desc = #{record.menuDesc,jdbcType=VARCHAR}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
SecMenuExample example = (SecMenuExample) parameter.get("example");
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByPrimaryKeySelective(SecMenu record) {
SQL sql = new SQL();
sql.UPDATE("sec_menu");
if (record.getMenuName() != null) {
sql.SET("menu_name = #{menuName,jdbcType=VARCHAR}");
}
if (record.getMenuType() != null) {
sql.SET("menu_type = #{menuType,jdbcType=INTEGER}");
}
if (record.getMenuUrl() != null) {
sql.SET("menu_url = #{menuUrl,jdbcType=VARCHAR}");
}
if (record.getMenuUrlImg() != null) {
sql.SET("menu_url_img = #{menuUrlImg,jdbcType=VARCHAR}");
}
if (record.getMenuPSid() != null) {
sql.SET("menu_p_sid = #{menuPSid,jdbcType=BIGINT}");
}
if (record.getMenuSort() != null) {
sql.SET("menu_sort = #{menuSort,jdbcType=INTEGER}");
}
if (record.getMenuDesc() != null) {
sql.SET("menu_desc = #{menuDesc,jdbcType=VARCHAR}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
}
sql.WHERE("id = #{id,jdbcType=BIGINT}");
return sql.toString();
}
protected void applyWhere(SQL sql, SecMenuExample example, boolean includeExamplePhrase) {
if (example == null) {
return;
}
String parmPhrase1;
String parmPhrase1_th;
String parmPhrase2;
String parmPhrase2_th;
String parmPhrase3;
String parmPhrase3_th;
if (includeExamplePhrase) {
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
} else {
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
}
StringBuilder sb = new StringBuilder();
List<Criteria> oredCriteria = example.getOredCriteria();
boolean firstCriteria = true;
for (int i = 0; i < oredCriteria.size(); i++) {
Criteria criteria = oredCriteria.get(i);
if (criteria.isValid()) {
if (firstCriteria) {
firstCriteria = false;
} else {
sb.append(" or ");
}
sb.append('(');
List<Criterion> criterions = criteria.getAllCriteria();
boolean firstCriterion = true;
for (int j = 0; j < criterions.size(); j++) {
Criterion criterion = criterions.get(j);
if (firstCriterion) {
firstCriterion = false;
} else {
sb.append(" and ");
}
if (criterion.isNoValue()) {
sb.append(criterion.getCondition());
} else if (criterion.isSingleValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
} else {
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
}
} else if (criterion.isBetweenValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
} else {
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
}
} else if (criterion.isListValue()) {
sb.append(criterion.getCondition());
sb.append(" (");
List<?> listItems = (List<?>) criterion.getValue();
boolean comma = false;
for (int k = 0; k < listItems.size(); k++) {
if (comma) {
sb.append(", ");
} else {
comma = true;
}
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase3, i, j, k));
} else {
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
}
}
sb.append(')');
}
}
sb.append(')');
}
}
if (sb.length() > 0) {
sql.WHERE(sb.toString());
}
}
}

@ -0,0 +1,102 @@
package com.hfkj.dao;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecRoleExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
/**
*
* 代码由工具生成,请勿修改!!!
* 如果需要扩展请在其父类进行扩展
*
**/
@Repository
public interface SecRoleMapper extends SecRoleMapperExt {
@SelectProvider(type=SecRoleSqlProvider.class, method="countByExample")
long countByExample(SecRoleExample example);
@DeleteProvider(type=SecRoleSqlProvider.class, method="deleteByExample")
int deleteByExample(SecRoleExample example);
@Delete({
"delete from sec_role",
"where id = #{id,jdbcType=BIGINT}"
})
int deleteByPrimaryKey(Long id);
@Insert({
"insert into sec_role (role_name, role_desc, ",
"`status`, create_time, ",
"update_time)",
"values (#{roleName,jdbcType=VARCHAR}, #{roleDesc,jdbcType=VARCHAR}, ",
"#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(SecRole record);
@InsertProvider(type=SecRoleSqlProvider.class, method="insertSelective")
@Options(useGeneratedKeys=true,keyProperty="id")
int insertSelective(SecRole record);
@SelectProvider(type=SecRoleSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="role_name", property="roleName", jdbcType=JdbcType.VARCHAR),
@Result(column="role_desc", property="roleDesc", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
})
List<SecRole> selectByExample(SecRoleExample example);
@Select({
"select",
"id, role_name, role_desc, `status`, create_time, update_time",
"from sec_role",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="role_name", property="roleName", jdbcType=JdbcType.VARCHAR),
@Result(column="role_desc", property="roleDesc", jdbcType=JdbcType.VARCHAR),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP)
})
SecRole selectByPrimaryKey(Long id);
@UpdateProvider(type=SecRoleSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") SecRole record, @Param("example") SecRoleExample example);
@UpdateProvider(type=SecRoleSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") SecRole record, @Param("example") SecRoleExample example);
@UpdateProvider(type=SecRoleSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(SecRole record);
@Update({
"update sec_role",
"set role_name = #{roleName,jdbcType=VARCHAR},",
"role_desc = #{roleDesc,jdbcType=VARCHAR},",
"`status` = #{status,jdbcType=INTEGER},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"update_time = #{updateTime,jdbcType=TIMESTAMP}",
"where id = #{id,jdbcType=BIGINT}"
})
int updateByPrimaryKey(SecRole record);
}

@ -0,0 +1,7 @@
package com.hfkj.dao;
/**
* mapper扩展类
*/
public interface SecRoleMapperExt {
}

@ -0,0 +1,89 @@
package com.hfkj.dao;
import com.hfkj.entity.SecRoleMenuRel;
import com.hfkj.entity.SecRoleMenuRelExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
/**
*
* 代码由工具生成,请勿修改!!!
* 如果需要扩展请在其父类进行扩展
*
**/
@Repository
public interface SecRoleMenuRelMapper extends SecRoleMenuRelMapperExt {
@SelectProvider(type=SecRoleMenuRelSqlProvider.class, method="countByExample")
long countByExample(SecRoleMenuRelExample example);
@DeleteProvider(type=SecRoleMenuRelSqlProvider.class, method="deleteByExample")
int deleteByExample(SecRoleMenuRelExample example);
@Delete({
"delete from sec_role_menu_rel",
"where id = #{id,jdbcType=BIGINT}"
})
int deleteByPrimaryKey(Long id);
@Insert({
"insert into sec_role_menu_rel (role_id, menu_id)",
"values (#{roleId,jdbcType=BIGINT}, #{menuId,jdbcType=BIGINT})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(SecRoleMenuRel record);
@InsertProvider(type=SecRoleMenuRelSqlProvider.class, method="insertSelective")
@Options(useGeneratedKeys=true,keyProperty="id")
int insertSelective(SecRoleMenuRel record);
@SelectProvider(type=SecRoleMenuRelSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="role_id", property="roleId", jdbcType=JdbcType.BIGINT),
@Result(column="menu_id", property="menuId", jdbcType=JdbcType.BIGINT)
})
List<SecRoleMenuRel> selectByExample(SecRoleMenuRelExample example);
@Select({
"select",
"id, role_id, menu_id",
"from sec_role_menu_rel",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="role_id", property="roleId", jdbcType=JdbcType.BIGINT),
@Result(column="menu_id", property="menuId", jdbcType=JdbcType.BIGINT)
})
SecRoleMenuRel selectByPrimaryKey(Long id);
@UpdateProvider(type=SecRoleMenuRelSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") SecRoleMenuRel record, @Param("example") SecRoleMenuRelExample example);
@UpdateProvider(type=SecRoleMenuRelSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") SecRoleMenuRel record, @Param("example") SecRoleMenuRelExample example);
@UpdateProvider(type=SecRoleMenuRelSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(SecRoleMenuRel record);
@Update({
"update sec_role_menu_rel",
"set role_id = #{roleId,jdbcType=BIGINT},",
"menu_id = #{menuId,jdbcType=BIGINT}",
"where id = #{id,jdbcType=BIGINT}"
})
int updateByPrimaryKey(SecRoleMenuRel record);
}

@ -0,0 +1,22 @@
package com.hfkj.dao;
import com.hfkj.entity.SecRoleMenuRel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* mapper扩展类
*/
public interface SecRoleMenuRelMapperExt {
@Insert({"<script>" +
" insert into sec_role_menu_rel (role_id, menu_id) " +
" VALUES " +
" <foreach collection='list' item='item' index='index' separator=','>" +
" (#{item.roleId, #{menuId})" +
" </foreach>" +
" </script>"})
void batchAdd(@Param("list") List<SecRoleMenuRel> list);
}

@ -0,0 +1,206 @@
package com.hfkj.dao;
import com.hfkj.entity.SecRoleMenuRel;
import com.hfkj.entity.SecRoleMenuRelExample.Criteria;
import com.hfkj.entity.SecRoleMenuRelExample.Criterion;
import com.hfkj.entity.SecRoleMenuRelExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;
public class SecRoleMenuRelSqlProvider {
public String countByExample(SecRoleMenuRelExample example) {
SQL sql = new SQL();
sql.SELECT("count(*)").FROM("sec_role_menu_rel");
applyWhere(sql, example, false);
return sql.toString();
}
public String deleteByExample(SecRoleMenuRelExample example) {
SQL sql = new SQL();
sql.DELETE_FROM("sec_role_menu_rel");
applyWhere(sql, example, false);
return sql.toString();
}
public String insertSelective(SecRoleMenuRel record) {
SQL sql = new SQL();
sql.INSERT_INTO("sec_role_menu_rel");
if (record.getRoleId() != null) {
sql.VALUES("role_id", "#{roleId,jdbcType=BIGINT}");
}
if (record.getMenuId() != null) {
sql.VALUES("menu_id", "#{menuId,jdbcType=BIGINT}");
}
return sql.toString();
}
public String selectByExample(SecRoleMenuRelExample example) {
SQL sql = new SQL();
if (example != null && example.isDistinct()) {
sql.SELECT_DISTINCT("id");
} else {
sql.SELECT("id");
}
sql.SELECT("role_id");
sql.SELECT("menu_id");
sql.FROM("sec_role_menu_rel");
applyWhere(sql, example, false);
if (example != null && example.getOrderByClause() != null) {
sql.ORDER_BY(example.getOrderByClause());
}
return sql.toString();
}
public String updateByExampleSelective(Map<String, Object> parameter) {
SecRoleMenuRel record = (SecRoleMenuRel) parameter.get("record");
SecRoleMenuRelExample example = (SecRoleMenuRelExample) parameter.get("example");
SQL sql = new SQL();
sql.UPDATE("sec_role_menu_rel");
if (record.getId() != null) {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getRoleId() != null) {
sql.SET("role_id = #{record.roleId,jdbcType=BIGINT}");
}
if (record.getMenuId() != null) {
sql.SET("menu_id = #{record.menuId,jdbcType=BIGINT}");
}
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByExample(Map<String, Object> parameter) {
SQL sql = new SQL();
sql.UPDATE("sec_role_menu_rel");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("role_id = #{record.roleId,jdbcType=BIGINT}");
sql.SET("menu_id = #{record.menuId,jdbcType=BIGINT}");
SecRoleMenuRelExample example = (SecRoleMenuRelExample) parameter.get("example");
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByPrimaryKeySelective(SecRoleMenuRel record) {
SQL sql = new SQL();
sql.UPDATE("sec_role_menu_rel");
if (record.getRoleId() != null) {
sql.SET("role_id = #{roleId,jdbcType=BIGINT}");
}
if (record.getMenuId() != null) {
sql.SET("menu_id = #{menuId,jdbcType=BIGINT}");
}
sql.WHERE("id = #{id,jdbcType=BIGINT}");
return sql.toString();
}
protected void applyWhere(SQL sql, SecRoleMenuRelExample example, boolean includeExamplePhrase) {
if (example == null) {
return;
}
String parmPhrase1;
String parmPhrase1_th;
String parmPhrase2;
String parmPhrase2_th;
String parmPhrase3;
String parmPhrase3_th;
if (includeExamplePhrase) {
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
} else {
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
}
StringBuilder sb = new StringBuilder();
List<Criteria> oredCriteria = example.getOredCriteria();
boolean firstCriteria = true;
for (int i = 0; i < oredCriteria.size(); i++) {
Criteria criteria = oredCriteria.get(i);
if (criteria.isValid()) {
if (firstCriteria) {
firstCriteria = false;
} else {
sb.append(" or ");
}
sb.append('(');
List<Criterion> criterions = criteria.getAllCriteria();
boolean firstCriterion = true;
for (int j = 0; j < criterions.size(); j++) {
Criterion criterion = criterions.get(j);
if (firstCriterion) {
firstCriterion = false;
} else {
sb.append(" and ");
}
if (criterion.isNoValue()) {
sb.append(criterion.getCondition());
} else if (criterion.isSingleValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
} else {
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
}
} else if (criterion.isBetweenValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
} else {
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
}
} else if (criterion.isListValue()) {
sb.append(criterion.getCondition());
sb.append(" (");
List<?> listItems = (List<?>) criterion.getValue();
boolean comma = false;
for (int k = 0; k < listItems.size(); k++) {
if (comma) {
sb.append(", ");
} else {
comma = true;
}
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase3, i, j, k));
} else {
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
}
}
sb.append(')');
}
}
sb.append(')');
}
}
if (sb.length() > 0) {
sql.WHERE(sb.toString());
}
}
}

@ -0,0 +1,248 @@
package com.hfkj.dao;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecRoleExample.Criteria;
import com.hfkj.entity.SecRoleExample.Criterion;
import com.hfkj.entity.SecRoleExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;
public class SecRoleSqlProvider {
public String countByExample(SecRoleExample example) {
SQL sql = new SQL();
sql.SELECT("count(*)").FROM("sec_role");
applyWhere(sql, example, false);
return sql.toString();
}
public String deleteByExample(SecRoleExample example) {
SQL sql = new SQL();
sql.DELETE_FROM("sec_role");
applyWhere(sql, example, false);
return sql.toString();
}
public String insertSelective(SecRole record) {
SQL sql = new SQL();
sql.INSERT_INTO("sec_role");
if (record.getRoleName() != null) {
sql.VALUES("role_name", "#{roleName,jdbcType=VARCHAR}");
}
if (record.getRoleDesc() != null) {
sql.VALUES("role_desc", "#{roleDesc,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
}
return sql.toString();
}
public String selectByExample(SecRoleExample example) {
SQL sql = new SQL();
if (example != null && example.isDistinct()) {
sql.SELECT_DISTINCT("id");
} else {
sql.SELECT("id");
}
sql.SELECT("role_name");
sql.SELECT("role_desc");
sql.SELECT("`status`");
sql.SELECT("create_time");
sql.SELECT("update_time");
sql.FROM("sec_role");
applyWhere(sql, example, false);
if (example != null && example.getOrderByClause() != null) {
sql.ORDER_BY(example.getOrderByClause());
}
return sql.toString();
}
public String updateByExampleSelective(Map<String, Object> parameter) {
SecRole record = (SecRole) parameter.get("record");
SecRoleExample example = (SecRoleExample) parameter.get("example");
SQL sql = new SQL();
sql.UPDATE("sec_role");
if (record.getId() != null) {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getRoleName() != null) {
sql.SET("role_name = #{record.roleName,jdbcType=VARCHAR}");
}
if (record.getRoleDesc() != null) {
sql.SET("role_desc = #{record.roleDesc,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
}
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByExample(Map<String, Object> parameter) {
SQL sql = new SQL();
sql.UPDATE("sec_role");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("role_name = #{record.roleName,jdbcType=VARCHAR}");
sql.SET("role_desc = #{record.roleDesc,jdbcType=VARCHAR}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
SecRoleExample example = (SecRoleExample) parameter.get("example");
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByPrimaryKeySelective(SecRole record) {
SQL sql = new SQL();
sql.UPDATE("sec_role");
if (record.getRoleName() != null) {
sql.SET("role_name = #{roleName,jdbcType=VARCHAR}");
}
if (record.getRoleDesc() != null) {
sql.SET("role_desc = #{roleDesc,jdbcType=VARCHAR}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
}
sql.WHERE("id = #{id,jdbcType=BIGINT}");
return sql.toString();
}
protected void applyWhere(SQL sql, SecRoleExample example, boolean includeExamplePhrase) {
if (example == null) {
return;
}
String parmPhrase1;
String parmPhrase1_th;
String parmPhrase2;
String parmPhrase2_th;
String parmPhrase3;
String parmPhrase3_th;
if (includeExamplePhrase) {
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
} else {
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
}
StringBuilder sb = new StringBuilder();
List<Criteria> oredCriteria = example.getOredCriteria();
boolean firstCriteria = true;
for (int i = 0; i < oredCriteria.size(); i++) {
Criteria criteria = oredCriteria.get(i);
if (criteria.isValid()) {
if (firstCriteria) {
firstCriteria = false;
} else {
sb.append(" or ");
}
sb.append('(');
List<Criterion> criterions = criteria.getAllCriteria();
boolean firstCriterion = true;
for (int j = 0; j < criterions.size(); j++) {
Criterion criterion = criterions.get(j);
if (firstCriterion) {
firstCriterion = false;
} else {
sb.append(" and ");
}
if (criterion.isNoValue()) {
sb.append(criterion.getCondition());
} else if (criterion.isSingleValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
} else {
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
}
} else if (criterion.isBetweenValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
} else {
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
}
} else if (criterion.isListValue()) {
sb.append(criterion.getCondition());
sb.append(" (");
List<?> listItems = (List<?>) criterion.getValue();
boolean comma = false;
for (int k = 0; k < listItems.size(); k++) {
if (comma) {
sb.append(", ");
} else {
comma = true;
}
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase3, i, j, k));
} else {
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
}
}
sb.append(')');
}
}
sb.append(')');
}
}
if (sb.length() > 0) {
sql.WHERE(sb.toString());
}
}
}

@ -0,0 +1,133 @@
package com.hfkj.dao;
import com.hfkj.entity.SecUser;
import com.hfkj.entity.SecUserExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.springframework.stereotype.Repository;
/**
*
* 代码由工具生成,请勿修改!!!
* 如果需要扩展请在其父类进行扩展
*
**/
@Repository
public interface SecUserMapper extends SecUserMapperExt {
@SelectProvider(type=SecUserSqlProvider.class, method="countByExample")
long countByExample(SecUserExample example);
@DeleteProvider(type=SecUserSqlProvider.class, method="deleteByExample")
int deleteByExample(SecUserExample example);
@Delete({
"delete from sec_user",
"where id = #{id,jdbcType=BIGINT}"
})
int deleteByPrimaryKey(Long id);
@Insert({
"insert into sec_user (avatar, user_name, ",
"login_name, `password`, ",
"telephone, object_type, ",
"role_id, `status`, create_time, ",
"update_time, ext_1, ",
"ext_2, ext_3)",
"values (#{avatar,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, ",
"#{loginName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, ",
"#{telephone,jdbcType=VARCHAR}, #{objectType,jdbcType=INTEGER}, ",
"#{roleId,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(SecUser record);
@InsertProvider(type=SecUserSqlProvider.class, method="insertSelective")
@Options(useGeneratedKeys=true,keyProperty="id")
int insertSelective(SecUser record);
@SelectProvider(type=SecUserSqlProvider.class, method="selectByExample")
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="avatar", property="avatar", jdbcType=JdbcType.VARCHAR),
@Result(column="user_name", property="userName", jdbcType=JdbcType.VARCHAR),
@Result(column="login_name", property="loginName", jdbcType=JdbcType.VARCHAR),
@Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
@Result(column="telephone", property="telephone", jdbcType=JdbcType.VARCHAR),
@Result(column="object_type", property="objectType", jdbcType=JdbcType.INTEGER),
@Result(column="role_id", property="roleId", jdbcType=JdbcType.BIGINT),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<SecUser> selectByExample(SecUserExample example);
@Select({
"select",
"id, avatar, user_name, login_name, `password`, telephone, object_type, role_id, ",
"`status`, create_time, update_time, ext_1, ext_2, ext_3",
"from sec_user",
"where id = #{id,jdbcType=BIGINT}"
})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="avatar", property="avatar", jdbcType=JdbcType.VARCHAR),
@Result(column="user_name", property="userName", jdbcType=JdbcType.VARCHAR),
@Result(column="login_name", property="loginName", jdbcType=JdbcType.VARCHAR),
@Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
@Result(column="telephone", property="telephone", jdbcType=JdbcType.VARCHAR),
@Result(column="object_type", property="objectType", jdbcType=JdbcType.INTEGER),
@Result(column="role_id", property="roleId", jdbcType=JdbcType.BIGINT),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
SecUser selectByPrimaryKey(Long id);
@UpdateProvider(type=SecUserSqlProvider.class, method="updateByExampleSelective")
int updateByExampleSelective(@Param("record") SecUser record, @Param("example") SecUserExample example);
@UpdateProvider(type=SecUserSqlProvider.class, method="updateByExample")
int updateByExample(@Param("record") SecUser record, @Param("example") SecUserExample example);
@UpdateProvider(type=SecUserSqlProvider.class, method="updateByPrimaryKeySelective")
int updateByPrimaryKeySelective(SecUser record);
@Update({
"update sec_user",
"set avatar = #{avatar,jdbcType=VARCHAR},",
"user_name = #{userName,jdbcType=VARCHAR},",
"login_name = #{loginName,jdbcType=VARCHAR},",
"`password` = #{password,jdbcType=VARCHAR},",
"telephone = #{telephone,jdbcType=VARCHAR},",
"object_type = #{objectType,jdbcType=INTEGER},",
"role_id = #{roleId,jdbcType=BIGINT},",
"`status` = #{status,jdbcType=INTEGER},",
"create_time = #{createTime,jdbcType=TIMESTAMP},",
"update_time = #{updateTime,jdbcType=TIMESTAMP},",
"ext_1 = #{ext1,jdbcType=VARCHAR},",
"ext_2 = #{ext2,jdbcType=VARCHAR},",
"ext_3 = #{ext3,jdbcType=VARCHAR}",
"where id = #{id,jdbcType=BIGINT}"
})
int updateByPrimaryKey(SecUser record);
}

@ -0,0 +1,7 @@
package com.hfkj.dao;
/**
* mapper扩展类
*/
public interface SecUserMapperExt {
}

@ -0,0 +1,360 @@
package com.hfkj.dao;
import com.hfkj.entity.SecUser;
import com.hfkj.entity.SecUserExample.Criteria;
import com.hfkj.entity.SecUserExample.Criterion;
import com.hfkj.entity.SecUserExample;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.jdbc.SQL;
public class SecUserSqlProvider {
public String countByExample(SecUserExample example) {
SQL sql = new SQL();
sql.SELECT("count(*)").FROM("sec_user");
applyWhere(sql, example, false);
return sql.toString();
}
public String deleteByExample(SecUserExample example) {
SQL sql = new SQL();
sql.DELETE_FROM("sec_user");
applyWhere(sql, example, false);
return sql.toString();
}
public String insertSelective(SecUser record) {
SQL sql = new SQL();
sql.INSERT_INTO("sec_user");
if (record.getAvatar() != null) {
sql.VALUES("avatar", "#{avatar,jdbcType=VARCHAR}");
}
if (record.getUserName() != null) {
sql.VALUES("user_name", "#{userName,jdbcType=VARCHAR}");
}
if (record.getLoginName() != null) {
sql.VALUES("login_name", "#{loginName,jdbcType=VARCHAR}");
}
if (record.getPassword() != null) {
sql.VALUES("`password`", "#{password,jdbcType=VARCHAR}");
}
if (record.getTelephone() != null) {
sql.VALUES("telephone", "#{telephone,jdbcType=VARCHAR}");
}
if (record.getObjectType() != null) {
sql.VALUES("object_type", "#{objectType,jdbcType=INTEGER}");
}
if (record.getRoleId() != null) {
sql.VALUES("role_id", "#{roleId,jdbcType=BIGINT}");
}
if (record.getStatus() != null) {
sql.VALUES("`status`", "#{status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.VALUES("ext_1", "#{ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.VALUES("ext_2", "#{ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.VALUES("ext_3", "#{ext3,jdbcType=VARCHAR}");
}
return sql.toString();
}
public String selectByExample(SecUserExample example) {
SQL sql = new SQL();
if (example != null && example.isDistinct()) {
sql.SELECT_DISTINCT("id");
} else {
sql.SELECT("id");
}
sql.SELECT("avatar");
sql.SELECT("user_name");
sql.SELECT("login_name");
sql.SELECT("`password`");
sql.SELECT("telephone");
sql.SELECT("object_type");
sql.SELECT("role_id");
sql.SELECT("`status`");
sql.SELECT("create_time");
sql.SELECT("update_time");
sql.SELECT("ext_1");
sql.SELECT("ext_2");
sql.SELECT("ext_3");
sql.FROM("sec_user");
applyWhere(sql, example, false);
if (example != null && example.getOrderByClause() != null) {
sql.ORDER_BY(example.getOrderByClause());
}
return sql.toString();
}
public String updateByExampleSelective(Map<String, Object> parameter) {
SecUser record = (SecUser) parameter.get("record");
SecUserExample example = (SecUserExample) parameter.get("example");
SQL sql = new SQL();
sql.UPDATE("sec_user");
if (record.getId() != null) {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
}
if (record.getAvatar() != null) {
sql.SET("avatar = #{record.avatar,jdbcType=VARCHAR}");
}
if (record.getUserName() != null) {
sql.SET("user_name = #{record.userName,jdbcType=VARCHAR}");
}
if (record.getLoginName() != null) {
sql.SET("login_name = #{record.loginName,jdbcType=VARCHAR}");
}
if (record.getPassword() != null) {
sql.SET("`password` = #{record.password,jdbcType=VARCHAR}");
}
if (record.getTelephone() != null) {
sql.SET("telephone = #{record.telephone,jdbcType=VARCHAR}");
}
if (record.getObjectType() != null) {
sql.SET("object_type = #{record.objectType,jdbcType=INTEGER}");
}
if (record.getRoleId() != null) {
sql.SET("role_id = #{record.roleId,jdbcType=BIGINT}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
}
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByExample(Map<String, Object> parameter) {
SQL sql = new SQL();
sql.UPDATE("sec_user");
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("avatar = #{record.avatar,jdbcType=VARCHAR}");
sql.SET("user_name = #{record.userName,jdbcType=VARCHAR}");
sql.SET("login_name = #{record.loginName,jdbcType=VARCHAR}");
sql.SET("`password` = #{record.password,jdbcType=VARCHAR}");
sql.SET("telephone = #{record.telephone,jdbcType=VARCHAR}");
sql.SET("object_type = #{record.objectType,jdbcType=INTEGER}");
sql.SET("role_id = #{record.roleId,jdbcType=BIGINT}");
sql.SET("`status` = #{record.status,jdbcType=INTEGER}");
sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}");
sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}");
sql.SET("ext_1 = #{record.ext1,jdbcType=VARCHAR}");
sql.SET("ext_2 = #{record.ext2,jdbcType=VARCHAR}");
sql.SET("ext_3 = #{record.ext3,jdbcType=VARCHAR}");
SecUserExample example = (SecUserExample) parameter.get("example");
applyWhere(sql, example, true);
return sql.toString();
}
public String updateByPrimaryKeySelective(SecUser record) {
SQL sql = new SQL();
sql.UPDATE("sec_user");
if (record.getAvatar() != null) {
sql.SET("avatar = #{avatar,jdbcType=VARCHAR}");
}
if (record.getUserName() != null) {
sql.SET("user_name = #{userName,jdbcType=VARCHAR}");
}
if (record.getLoginName() != null) {
sql.SET("login_name = #{loginName,jdbcType=VARCHAR}");
}
if (record.getPassword() != null) {
sql.SET("`password` = #{password,jdbcType=VARCHAR}");
}
if (record.getTelephone() != null) {
sql.SET("telephone = #{telephone,jdbcType=VARCHAR}");
}
if (record.getObjectType() != null) {
sql.SET("object_type = #{objectType,jdbcType=INTEGER}");
}
if (record.getRoleId() != null) {
sql.SET("role_id = #{roleId,jdbcType=BIGINT}");
}
if (record.getStatus() != null) {
sql.SET("`status` = #{status,jdbcType=INTEGER}");
}
if (record.getCreateTime() != null) {
sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
}
if (record.getUpdateTime() != null) {
sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
}
if (record.getExt1() != null) {
sql.SET("ext_1 = #{ext1,jdbcType=VARCHAR}");
}
if (record.getExt2() != null) {
sql.SET("ext_2 = #{ext2,jdbcType=VARCHAR}");
}
if (record.getExt3() != null) {
sql.SET("ext_3 = #{ext3,jdbcType=VARCHAR}");
}
sql.WHERE("id = #{id,jdbcType=BIGINT}");
return sql.toString();
}
protected void applyWhere(SQL sql, SecUserExample example, boolean includeExamplePhrase) {
if (example == null) {
return;
}
String parmPhrase1;
String parmPhrase1_th;
String parmPhrase2;
String parmPhrase2_th;
String parmPhrase3;
String parmPhrase3_th;
if (includeExamplePhrase) {
parmPhrase1 = "%s #{example.oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{example.oredCriteria[%d].allCriteria[%d].value} and #{example.oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{example.oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{example.oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{example.oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{example.oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
} else {
parmPhrase1 = "%s #{oredCriteria[%d].allCriteria[%d].value}";
parmPhrase1_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s}";
parmPhrase2 = "%s #{oredCriteria[%d].allCriteria[%d].value} and #{oredCriteria[%d].criteria[%d].secondValue}";
parmPhrase2_th = "%s #{oredCriteria[%d].allCriteria[%d].value,typeHandler=%s} and #{oredCriteria[%d].criteria[%d].secondValue,typeHandler=%s}";
parmPhrase3 = "#{oredCriteria[%d].allCriteria[%d].value[%d]}";
parmPhrase3_th = "#{oredCriteria[%d].allCriteria[%d].value[%d],typeHandler=%s}";
}
StringBuilder sb = new StringBuilder();
List<Criteria> oredCriteria = example.getOredCriteria();
boolean firstCriteria = true;
for (int i = 0; i < oredCriteria.size(); i++) {
Criteria criteria = oredCriteria.get(i);
if (criteria.isValid()) {
if (firstCriteria) {
firstCriteria = false;
} else {
sb.append(" or ");
}
sb.append('(');
List<Criterion> criterions = criteria.getAllCriteria();
boolean firstCriterion = true;
for (int j = 0; j < criterions.size(); j++) {
Criterion criterion = criterions.get(j);
if (firstCriterion) {
firstCriterion = false;
} else {
sb.append(" and ");
}
if (criterion.isNoValue()) {
sb.append(criterion.getCondition());
} else if (criterion.isSingleValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase1, criterion.getCondition(), i, j));
} else {
sb.append(String.format(parmPhrase1_th, criterion.getCondition(), i, j,criterion.getTypeHandler()));
}
} else if (criterion.isBetweenValue()) {
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase2, criterion.getCondition(), i, j, i, j));
} else {
sb.append(String.format(parmPhrase2_th, criterion.getCondition(), i, j, criterion.getTypeHandler(), i, j, criterion.getTypeHandler()));
}
} else if (criterion.isListValue()) {
sb.append(criterion.getCondition());
sb.append(" (");
List<?> listItems = (List<?>) criterion.getValue();
boolean comma = false;
for (int k = 0; k < listItems.size(); k++) {
if (comma) {
sb.append(", ");
} else {
comma = true;
}
if (criterion.getTypeHandler() == null) {
sb.append(String.format(parmPhrase3, i, j, k));
} else {
sb.append(String.format(parmPhrase3_th, i, j, k, criterion.getTypeHandler()));
}
}
sb.append(')');
}
}
sb.append(')');
}
}
if (sb.length() > 0) {
sql.WHERE(sb.toString());
}
}
}

@ -0,0 +1,209 @@
package com.hfkj.entity;
import java.io.Serializable;
import java.util.Date;
/**
* sec_menu
* @author
*/
/**
*
* 代码由工具生成
*
**/
public class SecMenu implements Serializable {
/**
* 主键
*/
private Long id;
/**
* 菜单名称
*/
private String menuName;
/**
* 菜单类型 0:菜单 1:按钮
*/
private Integer menuType;
/**
* 菜单URL
*/
private String menuUrl;
/**
* 图标URL
*/
private String menuUrlImg;
/**
* 父级菜单主键
*/
private Long menuPSid;
/**
* 菜单顺序
*/
private Integer menuSort;
/**
* 菜单描述
*/
private String menuDesc;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public Integer getMenuType() {
return menuType;
}
public void setMenuType(Integer menuType) {
this.menuType = menuType;
}
public String getMenuUrl() {
return menuUrl;
}
public void setMenuUrl(String menuUrl) {
this.menuUrl = menuUrl;
}
public String getMenuUrlImg() {
return menuUrlImg;
}
public void setMenuUrlImg(String menuUrlImg) {
this.menuUrlImg = menuUrlImg;
}
public Long getMenuPSid() {
return menuPSid;
}
public void setMenuPSid(Long menuPSid) {
this.menuPSid = menuPSid;
}
public Integer getMenuSort() {
return menuSort;
}
public void setMenuSort(Integer menuSort) {
this.menuSort = menuSort;
}
public String getMenuDesc() {
return menuDesc;
}
public void setMenuDesc(String menuDesc) {
this.menuDesc = menuDesc;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
SecMenu other = (SecMenu) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getMenuName() == null ? other.getMenuName() == null : this.getMenuName().equals(other.getMenuName()))
&& (this.getMenuType() == null ? other.getMenuType() == null : this.getMenuType().equals(other.getMenuType()))
&& (this.getMenuUrl() == null ? other.getMenuUrl() == null : this.getMenuUrl().equals(other.getMenuUrl()))
&& (this.getMenuUrlImg() == null ? other.getMenuUrlImg() == null : this.getMenuUrlImg().equals(other.getMenuUrlImg()))
&& (this.getMenuPSid() == null ? other.getMenuPSid() == null : this.getMenuPSid().equals(other.getMenuPSid()))
&& (this.getMenuSort() == null ? other.getMenuSort() == null : this.getMenuSort().equals(other.getMenuSort()))
&& (this.getMenuDesc() == null ? other.getMenuDesc() == null : this.getMenuDesc().equals(other.getMenuDesc()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getMenuName() == null) ? 0 : getMenuName().hashCode());
result = prime * result + ((getMenuType() == null) ? 0 : getMenuType().hashCode());
result = prime * result + ((getMenuUrl() == null) ? 0 : getMenuUrl().hashCode());
result = prime * result + ((getMenuUrlImg() == null) ? 0 : getMenuUrlImg().hashCode());
result = prime * result + ((getMenuPSid() == null) ? 0 : getMenuPSid().hashCode());
result = prime * result + ((getMenuSort() == null) ? 0 : getMenuSort().hashCode());
result = prime * result + ((getMenuDesc() == null) ? 0 : getMenuDesc().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", menuName=").append(menuName);
sb.append(", menuType=").append(menuType);
sb.append(", menuUrl=").append(menuUrl);
sb.append(", menuUrlImg=").append(menuUrlImg);
sb.append(", menuPSid=").append(menuPSid);
sb.append(", menuSort=").append(menuSort);
sb.append(", menuDesc=").append(menuDesc);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,863 @@
package com.hfkj.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class SecMenuExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public SecMenuExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andMenuNameIsNull() {
addCriterion("menu_name is null");
return (Criteria) this;
}
public Criteria andMenuNameIsNotNull() {
addCriterion("menu_name is not null");
return (Criteria) this;
}
public Criteria andMenuNameEqualTo(String value) {
addCriterion("menu_name =", value, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameNotEqualTo(String value) {
addCriterion("menu_name <>", value, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameGreaterThan(String value) {
addCriterion("menu_name >", value, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameGreaterThanOrEqualTo(String value) {
addCriterion("menu_name >=", value, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameLessThan(String value) {
addCriterion("menu_name <", value, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameLessThanOrEqualTo(String value) {
addCriterion("menu_name <=", value, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameLike(String value) {
addCriterion("menu_name like", value, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameNotLike(String value) {
addCriterion("menu_name not like", value, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameIn(List<String> values) {
addCriterion("menu_name in", values, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameNotIn(List<String> values) {
addCriterion("menu_name not in", values, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameBetween(String value1, String value2) {
addCriterion("menu_name between", value1, value2, "menuName");
return (Criteria) this;
}
public Criteria andMenuNameNotBetween(String value1, String value2) {
addCriterion("menu_name not between", value1, value2, "menuName");
return (Criteria) this;
}
public Criteria andMenuTypeIsNull() {
addCriterion("menu_type is null");
return (Criteria) this;
}
public Criteria andMenuTypeIsNotNull() {
addCriterion("menu_type is not null");
return (Criteria) this;
}
public Criteria andMenuTypeEqualTo(Integer value) {
addCriterion("menu_type =", value, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeNotEqualTo(Integer value) {
addCriterion("menu_type <>", value, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeGreaterThan(Integer value) {
addCriterion("menu_type >", value, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeGreaterThanOrEqualTo(Integer value) {
addCriterion("menu_type >=", value, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeLessThan(Integer value) {
addCriterion("menu_type <", value, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeLessThanOrEqualTo(Integer value) {
addCriterion("menu_type <=", value, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeIn(List<Integer> values) {
addCriterion("menu_type in", values, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeNotIn(List<Integer> values) {
addCriterion("menu_type not in", values, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeBetween(Integer value1, Integer value2) {
addCriterion("menu_type between", value1, value2, "menuType");
return (Criteria) this;
}
public Criteria andMenuTypeNotBetween(Integer value1, Integer value2) {
addCriterion("menu_type not between", value1, value2, "menuType");
return (Criteria) this;
}
public Criteria andMenuUrlIsNull() {
addCriterion("menu_url is null");
return (Criteria) this;
}
public Criteria andMenuUrlIsNotNull() {
addCriterion("menu_url is not null");
return (Criteria) this;
}
public Criteria andMenuUrlEqualTo(String value) {
addCriterion("menu_url =", value, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlNotEqualTo(String value) {
addCriterion("menu_url <>", value, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlGreaterThan(String value) {
addCriterion("menu_url >", value, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlGreaterThanOrEqualTo(String value) {
addCriterion("menu_url >=", value, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlLessThan(String value) {
addCriterion("menu_url <", value, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlLessThanOrEqualTo(String value) {
addCriterion("menu_url <=", value, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlLike(String value) {
addCriterion("menu_url like", value, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlNotLike(String value) {
addCriterion("menu_url not like", value, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlIn(List<String> values) {
addCriterion("menu_url in", values, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlNotIn(List<String> values) {
addCriterion("menu_url not in", values, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlBetween(String value1, String value2) {
addCriterion("menu_url between", value1, value2, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlNotBetween(String value1, String value2) {
addCriterion("menu_url not between", value1, value2, "menuUrl");
return (Criteria) this;
}
public Criteria andMenuUrlImgIsNull() {
addCriterion("menu_url_img is null");
return (Criteria) this;
}
public Criteria andMenuUrlImgIsNotNull() {
addCriterion("menu_url_img is not null");
return (Criteria) this;
}
public Criteria andMenuUrlImgEqualTo(String value) {
addCriterion("menu_url_img =", value, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgNotEqualTo(String value) {
addCriterion("menu_url_img <>", value, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgGreaterThan(String value) {
addCriterion("menu_url_img >", value, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgGreaterThanOrEqualTo(String value) {
addCriterion("menu_url_img >=", value, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgLessThan(String value) {
addCriterion("menu_url_img <", value, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgLessThanOrEqualTo(String value) {
addCriterion("menu_url_img <=", value, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgLike(String value) {
addCriterion("menu_url_img like", value, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgNotLike(String value) {
addCriterion("menu_url_img not like", value, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgIn(List<String> values) {
addCriterion("menu_url_img in", values, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgNotIn(List<String> values) {
addCriterion("menu_url_img not in", values, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgBetween(String value1, String value2) {
addCriterion("menu_url_img between", value1, value2, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuUrlImgNotBetween(String value1, String value2) {
addCriterion("menu_url_img not between", value1, value2, "menuUrlImg");
return (Criteria) this;
}
public Criteria andMenuPSidIsNull() {
addCriterion("menu_p_sid is null");
return (Criteria) this;
}
public Criteria andMenuPSidIsNotNull() {
addCriterion("menu_p_sid is not null");
return (Criteria) this;
}
public Criteria andMenuPSidEqualTo(Long value) {
addCriterion("menu_p_sid =", value, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidNotEqualTo(Long value) {
addCriterion("menu_p_sid <>", value, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidGreaterThan(Long value) {
addCriterion("menu_p_sid >", value, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidGreaterThanOrEqualTo(Long value) {
addCriterion("menu_p_sid >=", value, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidLessThan(Long value) {
addCriterion("menu_p_sid <", value, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidLessThanOrEqualTo(Long value) {
addCriterion("menu_p_sid <=", value, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidIn(List<Long> values) {
addCriterion("menu_p_sid in", values, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidNotIn(List<Long> values) {
addCriterion("menu_p_sid not in", values, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidBetween(Long value1, Long value2) {
addCriterion("menu_p_sid between", value1, value2, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuPSidNotBetween(Long value1, Long value2) {
addCriterion("menu_p_sid not between", value1, value2, "menuPSid");
return (Criteria) this;
}
public Criteria andMenuSortIsNull() {
addCriterion("menu_sort is null");
return (Criteria) this;
}
public Criteria andMenuSortIsNotNull() {
addCriterion("menu_sort is not null");
return (Criteria) this;
}
public Criteria andMenuSortEqualTo(Integer value) {
addCriterion("menu_sort =", value, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortNotEqualTo(Integer value) {
addCriterion("menu_sort <>", value, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortGreaterThan(Integer value) {
addCriterion("menu_sort >", value, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortGreaterThanOrEqualTo(Integer value) {
addCriterion("menu_sort >=", value, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortLessThan(Integer value) {
addCriterion("menu_sort <", value, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortLessThanOrEqualTo(Integer value) {
addCriterion("menu_sort <=", value, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortIn(List<Integer> values) {
addCriterion("menu_sort in", values, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortNotIn(List<Integer> values) {
addCriterion("menu_sort not in", values, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortBetween(Integer value1, Integer value2) {
addCriterion("menu_sort between", value1, value2, "menuSort");
return (Criteria) this;
}
public Criteria andMenuSortNotBetween(Integer value1, Integer value2) {
addCriterion("menu_sort not between", value1, value2, "menuSort");
return (Criteria) this;
}
public Criteria andMenuDescIsNull() {
addCriterion("menu_desc is null");
return (Criteria) this;
}
public Criteria andMenuDescIsNotNull() {
addCriterion("menu_desc is not null");
return (Criteria) this;
}
public Criteria andMenuDescEqualTo(String value) {
addCriterion("menu_desc =", value, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescNotEqualTo(String value) {
addCriterion("menu_desc <>", value, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescGreaterThan(String value) {
addCriterion("menu_desc >", value, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescGreaterThanOrEqualTo(String value) {
addCriterion("menu_desc >=", value, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescLessThan(String value) {
addCriterion("menu_desc <", value, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescLessThanOrEqualTo(String value) {
addCriterion("menu_desc <=", value, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescLike(String value) {
addCriterion("menu_desc like", value, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescNotLike(String value) {
addCriterion("menu_desc not like", value, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescIn(List<String> values) {
addCriterion("menu_desc in", values, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescNotIn(List<String> values) {
addCriterion("menu_desc not in", values, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescBetween(String value1, String value2) {
addCriterion("menu_desc between", value1, value2, "menuDesc");
return (Criteria) this;
}
public Criteria andMenuDescNotBetween(String value1, String value2) {
addCriterion("menu_desc not between", value1, value2, "menuDesc");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

@ -0,0 +1,145 @@
package com.hfkj.entity;
import java.io.Serializable;
import java.util.Date;
/**
* sec_role
* @author
*/
/**
*
* 代码由工具生成
*
**/
public class SecRole implements Serializable {
/**
* 主键
*/
private Long id;
/**
* 角色名称
*/
private String roleName;
/**
* 角色描述
*/
private String roleDesc;
/**
* 启用状态 0删除 1正常
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName;
}
public String getRoleDesc() {
return roleDesc;
}
public void setRoleDesc(String roleDesc) {
this.roleDesc = roleDesc;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
SecRole other = (SecRole) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getRoleName() == null ? other.getRoleName() == null : this.getRoleName().equals(other.getRoleName()))
&& (this.getRoleDesc() == null ? other.getRoleDesc() == null : this.getRoleDesc().equals(other.getRoleDesc()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getRoleName() == null) ? 0 : getRoleName().hashCode());
result = prime * result + ((getRoleDesc() == null) ? 0 : getRoleDesc().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", roleName=").append(roleName);
sb.append(", roleDesc=").append(roleDesc);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,603 @@
package com.hfkj.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class SecRoleExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public SecRoleExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andRoleNameIsNull() {
addCriterion("role_name is null");
return (Criteria) this;
}
public Criteria andRoleNameIsNotNull() {
addCriterion("role_name is not null");
return (Criteria) this;
}
public Criteria andRoleNameEqualTo(String value) {
addCriterion("role_name =", value, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameNotEqualTo(String value) {
addCriterion("role_name <>", value, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameGreaterThan(String value) {
addCriterion("role_name >", value, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameGreaterThanOrEqualTo(String value) {
addCriterion("role_name >=", value, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameLessThan(String value) {
addCriterion("role_name <", value, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameLessThanOrEqualTo(String value) {
addCriterion("role_name <=", value, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameLike(String value) {
addCriterion("role_name like", value, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameNotLike(String value) {
addCriterion("role_name not like", value, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameIn(List<String> values) {
addCriterion("role_name in", values, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameNotIn(List<String> values) {
addCriterion("role_name not in", values, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameBetween(String value1, String value2) {
addCriterion("role_name between", value1, value2, "roleName");
return (Criteria) this;
}
public Criteria andRoleNameNotBetween(String value1, String value2) {
addCriterion("role_name not between", value1, value2, "roleName");
return (Criteria) this;
}
public Criteria andRoleDescIsNull() {
addCriterion("role_desc is null");
return (Criteria) this;
}
public Criteria andRoleDescIsNotNull() {
addCriterion("role_desc is not null");
return (Criteria) this;
}
public Criteria andRoleDescEqualTo(String value) {
addCriterion("role_desc =", value, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescNotEqualTo(String value) {
addCriterion("role_desc <>", value, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescGreaterThan(String value) {
addCriterion("role_desc >", value, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescGreaterThanOrEqualTo(String value) {
addCriterion("role_desc >=", value, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescLessThan(String value) {
addCriterion("role_desc <", value, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescLessThanOrEqualTo(String value) {
addCriterion("role_desc <=", value, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescLike(String value) {
addCriterion("role_desc like", value, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescNotLike(String value) {
addCriterion("role_desc not like", value, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescIn(List<String> values) {
addCriterion("role_desc in", values, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescNotIn(List<String> values) {
addCriterion("role_desc not in", values, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescBetween(String value1, String value2) {
addCriterion("role_desc between", value1, value2, "roleDesc");
return (Criteria) this;
}
public Criteria andRoleDescNotBetween(String value1, String value2) {
addCriterion("role_desc not between", value1, value2, "roleDesc");
return (Criteria) this;
}
public Criteria andStatusIsNull() {
addCriterion("`status` is null");
return (Criteria) this;
}
public Criteria andStatusIsNotNull() {
addCriterion("`status` is not null");
return (Criteria) this;
}
public Criteria andStatusEqualTo(Integer value) {
addCriterion("`status` =", value, "status");
return (Criteria) this;
}
public Criteria andStatusNotEqualTo(Integer value) {
addCriterion("`status` <>", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThan(Integer value) {
addCriterion("`status` >", value, "status");
return (Criteria) this;
}
public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
addCriterion("`status` >=", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThan(Integer value) {
addCriterion("`status` <", value, "status");
return (Criteria) this;
}
public Criteria andStatusLessThanOrEqualTo(Integer value) {
addCriterion("`status` <=", value, "status");
return (Criteria) this;
}
public Criteria andStatusIn(List<Integer> values) {
addCriterion("`status` in", values, "status");
return (Criteria) this;
}
public Criteria andStatusNotIn(List<Integer> values) {
addCriterion("`status` not in", values, "status");
return (Criteria) this;
}
public Criteria andStatusBetween(Integer value1, Integer value2) {
addCriterion("`status` between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andStatusNotBetween(Integer value1, Integer value2) {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

@ -0,0 +1,93 @@
package com.hfkj.entity;
import java.io.Serializable;
/**
* sec_role_menu_rel
* @author
*/
/**
*
* 代码由工具生成
*
**/
public class SecRoleMenuRel implements Serializable {
private Long id;
/**
* 角色id
*/
private Long roleId;
/**
* 菜单id
*/
private Long menuId;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public Long getMenuId() {
return menuId;
}
public void setMenuId(Long menuId) {
this.menuId = menuId;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
SecRoleMenuRel other = (SecRoleMenuRel) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId()))
&& (this.getMenuId() == null ? other.getMenuId() == null : this.getMenuId().equals(other.getMenuId()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode());
result = prime * result + ((getMenuId() == null) ? 0 : getMenuId().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", roleId=").append(roleId);
sb.append(", menuId=").append(menuId);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,402 @@
package com.hfkj.entity;
import java.util.ArrayList;
import java.util.List;
public class SecRoleMenuRelExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
private Integer limit;
private Long offset;
public SecRoleMenuRelExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getLimit() {
return limit;
}
public void setOffset(Long offset) {
this.offset = offset;
}
public Long getOffset() {
return offset;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andRoleIdIsNull() {
addCriterion("role_id is null");
return (Criteria) this;
}
public Criteria andRoleIdIsNotNull() {
addCriterion("role_id is not null");
return (Criteria) this;
}
public Criteria andRoleIdEqualTo(Long value) {
addCriterion("role_id =", value, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdNotEqualTo(Long value) {
addCriterion("role_id <>", value, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdGreaterThan(Long value) {
addCriterion("role_id >", value, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdGreaterThanOrEqualTo(Long value) {
addCriterion("role_id >=", value, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdLessThan(Long value) {
addCriterion("role_id <", value, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdLessThanOrEqualTo(Long value) {
addCriterion("role_id <=", value, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdIn(List<Long> values) {
addCriterion("role_id in", values, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdNotIn(List<Long> values) {
addCriterion("role_id not in", values, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdBetween(Long value1, Long value2) {
addCriterion("role_id between", value1, value2, "roleId");
return (Criteria) this;
}
public Criteria andRoleIdNotBetween(Long value1, Long value2) {
addCriterion("role_id not between", value1, value2, "roleId");
return (Criteria) this;
}
public Criteria andMenuIdIsNull() {
addCriterion("menu_id is null");
return (Criteria) this;
}
public Criteria andMenuIdIsNotNull() {
addCriterion("menu_id is not null");
return (Criteria) this;
}
public Criteria andMenuIdEqualTo(Long value) {
addCriterion("menu_id =", value, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdNotEqualTo(Long value) {
addCriterion("menu_id <>", value, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdGreaterThan(Long value) {
addCriterion("menu_id >", value, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdGreaterThanOrEqualTo(Long value) {
addCriterion("menu_id >=", value, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdLessThan(Long value) {
addCriterion("menu_id <", value, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdLessThanOrEqualTo(Long value) {
addCriterion("menu_id <=", value, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdIn(List<Long> values) {
addCriterion("menu_id in", values, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdNotIn(List<Long> values) {
addCriterion("menu_id not in", values, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdBetween(Long value1, Long value2) {
addCriterion("menu_id between", value1, value2, "menuId");
return (Criteria) this;
}
public Criteria andMenuIdNotBetween(Long value1, Long value2) {
addCriterion("menu_id not between", value1, value2, "menuId");
return (Criteria) this;
}
}
/**
*/
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

@ -0,0 +1,264 @@
package com.hfkj.entity;
import java.io.Serializable;
import java.util.Date;
/**
* sec_user
* @author
*/
/**
*
* 代码由工具生成
*
**/
public class SecUser implements Serializable {
/**
* 主键
*/
private Long id;
/**
* 头像
*/
private String avatar;
/**
* 用户姓名
*/
private String userName;
/**
* 登录账户
*/
private String loginName;
/**
* 登录密码
*/
private String password;
/**
* 联系方式
*/
private String telephone;
/**
* 对象类型
*/
private Integer objectType;
/**
* 角色id
*/
private Long roleId;
/**
* 状态 0删除 1可用 2禁用
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
private String ext1;
private String ext2;
private String ext3;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public Integer getObjectType() {
return objectType;
}
public void setObjectType(Integer objectType) {
this.objectType = objectType;
}
public Long getRoleId() {
return roleId;
}
public void setRoleId(Long roleId) {
this.roleId = roleId;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getExt1() {
return ext1;
}
public void setExt1(String ext1) {
this.ext1 = ext1;
}
public String getExt2() {
return ext2;
}
public void setExt2(String ext2) {
this.ext2 = ext2;
}
public String getExt3() {
return ext3;
}
public void setExt3(String ext3) {
this.ext3 = ext3;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
SecUser other = (SecUser) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
&& (this.getUserName() == null ? other.getUserName() == null : this.getUserName().equals(other.getUserName()))
&& (this.getLoginName() == null ? other.getLoginName() == null : this.getLoginName().equals(other.getLoginName()))
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
&& (this.getTelephone() == null ? other.getTelephone() == null : this.getTelephone().equals(other.getTelephone()))
&& (this.getObjectType() == null ? other.getObjectType() == null : this.getObjectType().equals(other.getObjectType()))
&& (this.getRoleId() == null ? other.getRoleId() == null : this.getRoleId().equals(other.getRoleId()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getExt1() == null ? other.getExt1() == null : this.getExt1().equals(other.getExt1()))
&& (this.getExt2() == null ? other.getExt2() == null : this.getExt2().equals(other.getExt2()))
&& (this.getExt3() == null ? other.getExt3() == null : this.getExt3().equals(other.getExt3()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
result = prime * result + ((getUserName() == null) ? 0 : getUserName().hashCode());
result = prime * result + ((getLoginName() == null) ? 0 : getLoginName().hashCode());
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
result = prime * result + ((getTelephone() == null) ? 0 : getTelephone().hashCode());
result = prime * result + ((getObjectType() == null) ? 0 : getObjectType().hashCode());
result = prime * result + ((getRoleId() == null) ? 0 : getRoleId().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getExt1() == null) ? 0 : getExt1().hashCode());
result = prime * result + ((getExt2() == null) ? 0 : getExt2().hashCode());
result = prime * result + ((getExt3() == null) ? 0 : getExt3().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", avatar=").append(avatar);
sb.append(", userName=").append(userName);
sb.append(", loginName=").append(loginName);
sb.append(", password=").append(password);
sb.append(", telephone=").append(telephone);
sb.append(", objectType=").append(objectType);
sb.append(", roleId=").append(roleId);
sb.append(", status=").append(status);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", ext1=").append(ext1);
sb.append(", ext2=").append(ext2);
sb.append(", ext3=").append(ext3);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

File diff suppressed because it is too large Load Diff

@ -1,130 +1,39 @@
package com.hfkj.model;
import com.hfkj.entity.SecMenu;
import java.util.ArrayList;
import java.util.List;
public class MenuTreeModel {
private Long sid;
private String menuName;
private String menuUrl;
private String menuUrlImg;
private Long menuPSid;
//父名称
private String parentName;
private Integer menuSort;
private String menuDesc;
private String menuMobileUrl;//手机端URL
private Integer showOnMobile;//是否在手机端展示
private List<MenuTreeModel> children;
public String getMenuMobileUrl() {
return menuMobileUrl;
}
public void setMenuMobileUrl(String menuMobileUrl) {
this.menuMobileUrl = menuMobileUrl;
}
/**
* 菜单结构模型
* @author hurui
*/
public class MenuTreeModel extends SecMenu {
public Integer getShowOnMobile() {
return showOnMobile;
}
public void setShowOnMobile(Integer showOnMobile) {
this.showOnMobile = showOnMobile;
}
public Long getSid() {
return sid;
}
public void setSid(Long sid) {
this.sid = sid;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public String getMenuUrl() {
return menuUrl;
}
public void setMenuUrl(String menuUrl) {
this.menuUrl = menuUrl;
}
public String getMenuUrlImg() {
return menuUrlImg;
}
public void setMenuUrlImg(String menuUrlImg) {
this.menuUrlImg = menuUrlImg;
}
public Long getMenuPSid() {
return menuPSid;
}
public void setMenuPSid(Long menuPSid) {
this.menuPSid = menuPSid;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public Integer getMenuSort() {
return menuSort;
}
public void setMenuSort(Integer menuSort) {
this.menuSort = menuSort;
}
/**
* 子菜单列表
*/
List<MenuTreeModel> childMenuList;
public String getMenuDesc() {
return menuDesc;
}
/**
* 菜单权限
*/
Boolean authority;
public void setMenuDesc(String menuDesc) {
this.menuDesc = menuDesc;
public List<MenuTreeModel> getChildMenuList() {
return childMenuList;
}
public List<MenuTreeModel> getChildren() {
return children;
public void setChildMenuList(List<MenuTreeModel> childMenuList) {
this.childMenuList = childMenuList;
}
public void setChildren(List<MenuTreeModel> children) {
this.children = children;
public Boolean getAuthority() {
return authority;
}
/**
* 添加子节点.
* @param child
*/
public void add(MenuTreeModel child) {
if (children == null) {
children = new ArrayList<>();
}
children.add(child);
public void setAuthority(Boolean authority) {
this.authority = authority;
}
}

@ -0,0 +1,43 @@
package com.hfkj.model;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecUser;
import lombok.Data;
import java.util.List;
/**
* 系统用户登录session对象
*/
@Data
public class SecUserSessionObject {
/**
* 登录账户
*/
private SecUser account;
/**
* 角色信息
*/
private SecRole role;
/**
* 菜单
*/
private List<MenuTreeModel> menuTree;
/**
* 按钮
*/
private List<SecMenu> button;
public SecUserSessionObject(SecUser account, SecRole role, List<MenuTreeModel> menuTree, List<SecMenu> button){
this.account = account;
this.role = role;
this.menuTree = menuTree;
this.button = button;
}
}

@ -1,6 +0,0 @@
package com.hfkj.model;
public class UserInfoModel {
}

@ -0,0 +1,77 @@
package com.hfkj.service;
import com.hfkj.entity.SecMenu;
import com.hfkj.model.MenuTreeModel;
import com.hfkj.sysenum.SecMenuTypeEnum;
import java.util.List;
import java.util.Map;
/**
* @className: SecMenuService
* @author: HuRui
* @date: 2024/3/26
**/
public interface SecMenuService {
/**
* 创建
* @param menu 菜单
*/
void create(SecMenu menu);
/**
* 修改
* @param menu 菜单
*/
void update(SecMenu menu);
/**
* 删除数据
* @param menuId
*/
void delete(Long menuId);
/**
* 查询详情
* @param menuId
* @return
*/
SecMenu queryDetail(Long menuId);
/**
* 查询菜单列表
* @param param
* @return
*/
List<SecMenu> getList(Map<String,Object> param);
/**
* 查询角色菜单
* @param roleId 角色id
* @param menuType 菜单类型
* @return
*/
List<SecMenu> queryRoleMenu(Long roleId, SecMenuTypeEnum menuType);
/**
* 查询菜单列表
* @return
*/
List<SecMenu> getAllList();
/**
* 分配系统菜单
* @param roleId 角色id
* @return
*/
void assignMenu(Long roleId, List<Long> menuIds);
/**
* 查询系统菜单结构
* @param roleId 角色id
* @return
*/
List<MenuTreeModel> queryMenuTree(Long roleId);
}

@ -0,0 +1,40 @@
package com.hfkj.service;
import com.hfkj.entity.SecRoleMenuRel;
import java.util.List;
/**
* @className: SecRoleMenuRelService
* @author: HuRui
* @date: 2024/3/26
**/
public interface SecRoleMenuRelService {
/**
* 批量增加
* @param dataList
*/
void batchAdd(List<SecRoleMenuRel> dataList);
/**
* 删除
* @param relId 关系id
*/
void delete(Long relId);
/**
* 查询角色菜单关系
* @param roleId 角色id
* @return
*/
List<SecRoleMenuRel> getRelListByRole(Long roleId);
/**
* 查询角色菜单关系
* @param menuId 菜单id
* @return
*/
List<SecRoleMenuRel> getRelListByMenu(Long menuId);
}

@ -0,0 +1,42 @@
package com.hfkj.service;
import com.hfkj.entity.SecRole;
import java.util.List;
import java.util.Map;
/**
* @className: SecRoleService
* @author: HuRui
* @date: 2024/3/26
**/
public interface SecRoleService {
/**
* 编辑数据
* @param role 数据
*/
void editData(SecRole role);
/**
* 删除
* @param roleId 角色id
*/
void delete(Long roleId);
/**
* 查询详情
* @param roleId 角色id
* @return
*/
SecRole getDetail(Long roleId);
/**
* 查询集合
* @param param 参数
* @return
*/
List<SecRole> getList(Map<String, Object> param);
}

@ -0,0 +1,66 @@
package com.hfkj.service;
import com.hfkj.common.security.SessionObject;
import com.hfkj.entity.SecUser;
import com.hfkj.model.SecUserSessionObject;
import java.util.List;
import java.util.Map;
/**
* @className: SecUserService
* @author: HuRui
* @date: 2024/3/26
**/
public interface SecUserService {
/**
* 编辑数据
* @param data
*/
void editUser(SecUser data);
/**
* 创建
* @param secUser 账户
*/
void create(SecUser secUser);
/**
* 创建
* @param secUser 账户
*/
void update(SecUser secUser);
/**
* 查询详情
* @param id
* @return
*/
SecUser getDetail(Long id);
/**
* 根据登录账户查询详情
* @param loginName
* @return
*/
SecUser getDetailByLoginName(String loginName);
/**
* 查询列表
* @param param
* @return
*/
List<SecUser> getList(Map<String,Object> param);
/**
* 登录
* @param loginName 登录账户
* @param password 登录密码未加密字符串
* @return
*/
SessionObject login(String loginName, String password) throws Exception;
}

@ -0,0 +1,291 @@
package com.hfkj.service.impl;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.RedisUtil;
import com.hfkj.common.utils.StreamUtil;
import com.hfkj.dao.SecMenuMapper;
import com.hfkj.dao.SecRoleMenuRelMapper;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecMenuExample;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecRoleMenuRel;
import com.hfkj.model.MenuTreeModel;
import com.hfkj.service.SecMenuService;
import com.hfkj.service.SecRoleMenuRelService;
import com.hfkj.service.SecRoleService;
import com.hfkj.sysenum.SecMenuTypeEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @className: SecMenuServiceImpl
* @author: HuRui
* @date: 2024/3/28
**/
@Service("secMenuService")
public class SecMenuServiceImpl implements SecMenuService {
@Resource
private SecMenuMapper secMenuMapper;
@Resource
private SecRoleService secRoleService;
@Resource
private SecRoleMenuRelService secRoleMenuRelService;
@Resource
private RedisUtil redisUtil;
// 缓存k
private static final String CACHE_MENU = "SEC_MENU";
private static final String CACHE_ROLE_MENU = "SEC_ROLE_MENU";
@Override
public void create(SecMenu menu) {
menu.setCreateTime(new Date());
menu.setUpdateTime(new Date());
secMenuMapper.insert(menu);
// 加入缓存
redisUtil.hset(CACHE_MENU, ""+menu.getId(), menu);
}
@Override
public void update(SecMenu menu) {
menu.setCreateTime(new Date());
menu.setUpdateTime(new Date());
secMenuMapper.updateByPrimaryKey(menu);
// 查询角色菜单
List<SecRoleMenuRel> relList = secRoleMenuRelService.getRelListByMenu(menu.getId());
for (SecRoleMenuRel rel : relList) {
// 删除角色菜单缓存
redisUtil.hdel(CACHE_ROLE_MENU, ""+rel.getRoleId());
}
// 更新菜单缓存
redisUtil.hset(CACHE_MENU, ""+menu.getId(), menu);
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class})
public void delete(Long menuId) {
// 查询菜单
SecMenu secMenu = queryDetail(menuId);
if (secMenu == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到数据");
}
secMenuMapper.deleteByPrimaryKey(menuId);
// 查询角色菜单
List<SecRoleMenuRel> relList = secRoleMenuRelService.getRelListByMenu(menuId);
for (SecRoleMenuRel rel : relList) {
secRoleMenuRelService.delete(rel.getId());
// 删除角色菜单缓存
redisUtil.hdel(CACHE_ROLE_MENU, ""+rel.getRoleId());
}
// 删除缓存
redisUtil.hdel(CACHE_MENU, ""+secMenu.getId());
}
@Override
public SecMenu queryDetail(Long menuId) {
return secMenuMapper.selectByPrimaryKey(menuId);
}
@Override
public List<SecMenu> getList(Map<String, Object> param) {
SecMenuExample example = new SecMenuExample();
SecMenuExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(MapUtils.getString(param, "menuName"))) {
criteria.andMenuNameLike("%"+MapUtils.getString(param, "menuName")+"%");
}
if (MapUtils.getInteger(param, "menuType") != null) {
criteria.andMenuTypeEqualTo(MapUtils.getInteger(param, "menuType"));
}
example.setOrderByClause("menu_sort desc");
return secMenuMapper.selectByExample(example);
}
@Override
public List<SecMenu> queryRoleMenu(Long roleId, SecMenuTypeEnum menuType) {
// 获取角色菜单关系
Map<Long, SecRoleMenuRel> roleMenuRelMap = secRoleMenuRelService.getRelListByRole(roleId).stream()
.collect(Collectors.toMap(SecRoleMenuRel::getMenuId, Function.identity()));
// 获取系统菜单
List<SecMenu> menuList = getAllList().stream()
.filter(o->o.getMenuType().equals(SecMenuTypeEnum.type2.getCode()))
.collect(Collectors.toList());
Iterator<SecMenu> iterator = menuList.iterator();
while (iterator.hasNext()) {
if (roleMenuRelMap.get(iterator.next().getId()) == null) {
iterator.remove();
}
}
return menuList;
}
@Override
public List<SecMenu> getAllList() {
Map cacheObj = redisUtil.hmget(CACHE_MENU);
if (!cacheObj.isEmpty()) {
return new ArrayList<>(cacheObj.values());
}
SecMenuExample example = new SecMenuExample();
example.createCriteria();
List<SecMenu> menuList = secMenuMapper.selectByExample(example);
for (SecMenu menu : menuList) {
redisUtil.hset(CACHE_MENU, ""+menu.getId(), menu);
}
return menuList;
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class})
public void assignMenu(Long roleId, List<Long> menuIds) {
// 查询角色
SecRole secRole = secRoleService.getDetail(roleId);
if (secRole == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的角色");
}
// 查询角色菜单
List<SecRoleMenuRel> roleMenuList = secRoleMenuRelService.getRelListByRole(roleId);
SecRoleMenuRel rel;
List<SecRoleMenuRel> relList = new ArrayList<>();
for (Long menuId : menuIds) {
rel = new SecRoleMenuRel();
rel.setRoleId(roleId);
rel.setMenuId(menuId);
relList.add(rel);
}
// 数据集合并
relList.addAll(roleMenuList);
// 根据菜单id去重
List<SecRoleMenuRel> collectList = relList.stream().filter(StreamUtil.distinctByKey(b -> b.getMenuId())).collect(Collectors.toList());
// 绑定角色与菜单关系
secRoleMenuRelService.batchAdd(collectList);
// 更新缓存
redisUtil.hdel(CACHE_ROLE_MENU, ""+roleId);
}
@Override
public List<MenuTreeModel> queryMenuTree(Long roleId) {
List<MenuTreeModel> treeModelList = new ArrayList<>();
MenuTreeModel menuTree;
if (roleId != null) {
// 获取缓存
Object cacheObj = redisUtil.hget(CACHE_ROLE_MENU, ""+roleId);
if (cacheObj != null) {
return (List<MenuTreeModel>) cacheObj;
}
// 获取缓存菜单
Map<String,Object> secMenuMap = (Map) redisUtil.hmget(CACHE_MENU);
if (secMenuMap.isEmpty()) {
getAllList(); // 刷新缓存
secMenuMap = (Map) redisUtil.hmget(CACHE_MENU);
}
// 角色菜单
List<SecMenu> roleMenuList = new ArrayList<>();
// 查询角色菜单关系
List<SecRoleMenuRel> roleMenuRelList = secRoleMenuRelService.getRelListByRole(roleId);
for (SecRoleMenuRel rel : roleMenuRelList) {
Object obj = secMenuMap.get(""+rel.getMenuId());
roleMenuList.add((SecMenu) obj);
}
// 获取最顶层菜单
List<SecMenu> topLevelMenuList = roleMenuList.stream()
.filter(o -> o.getMenuPSid() == null)
.sorted(Comparator.comparing(SecMenu::getMenuSort))
.collect(Collectors.toList());
for (SecMenu topLevelMenu : topLevelMenuList) {
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
menuTree = new MenuTreeModel();
menuTree.setId(topLevelMenu.getId());
menuTree.setMenuName(topLevelMenu.getMenuName());
menuTree.setMenuType(topLevelMenu.getMenuType());
menuTree.setMenuUrl(topLevelMenu.getMenuUrl());
menuTree.setMenuUrlImg(topLevelMenu.getMenuUrlImg());
menuTree.setMenuPSid(topLevelMenu.getMenuPSid());
menuTree.setMenuSort(topLevelMenu.getMenuSort());
menuTree.setMenuDesc(topLevelMenu.getMenuDesc());
// 获取下级菜单
menuTree.setChildMenuList(recursionMenu(roleMenuList, topLevelMenu.getId()));
treeModelList.add(menuTree);
}
}
// 存入缓存
redisUtil.hset(CACHE_ROLE_MENU, ""+roleId, treeModelList);
return treeModelList;
} else {
List<SecMenu> menuList = getAllList();
// 获取最顶层菜单
List<SecMenu> topLevelMenuList = menuList.stream()
.filter(o -> o.getMenuPSid() == null)
.sorted(Comparator.comparing(SecMenu::getMenuSort))
.collect(Collectors.toList());
for (SecMenu topLevelMenu : topLevelMenuList) {
if (topLevelMenu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
menuTree = new MenuTreeModel();
menuTree.setId(topLevelMenu.getId());
menuTree.setMenuName(topLevelMenu.getMenuName());
menuTree.setMenuType(topLevelMenu.getMenuType());
menuTree.setMenuUrl(topLevelMenu.getMenuUrl());
menuTree.setMenuUrlImg(topLevelMenu.getMenuUrlImg());
menuTree.setMenuPSid(topLevelMenu.getMenuPSid());
menuTree.setMenuSort(topLevelMenu.getMenuSort());
menuTree.setMenuDesc(topLevelMenu.getMenuDesc());
// 获取下级菜单
menuTree.setChildMenuList(recursionMenu(menuList, topLevelMenu.getId()));
treeModelList.add(menuTree);
}
}
return treeModelList;
}
}
/**
* 递归获取菜单
* @param dataSource 数据源
* @param parentMenuId 父级菜单id
* @return
*/
public List<MenuTreeModel> recursionMenu(List<SecMenu> dataSource, Long parentMenuId) {
List<MenuTreeModel> treeModelList = new ArrayList<>();
MenuTreeModel menuTree;
List<SecMenu> collect = dataSource.stream()
.filter(o -> o.getMenuPSid() != null && o.getMenuPSid().equals(parentMenuId))
.sorted(Comparator.comparing(SecMenu::getMenuSort))
.collect(Collectors.toList());
for (SecMenu menu : collect) {
if (menu.getMenuType().equals(SecMenuTypeEnum.type1.getCode())) {
menuTree = new MenuTreeModel();
menuTree.setId(menu.getId());
menuTree.setMenuName(menu.getMenuName());
menuTree.setMenuType(menu.getMenuType());
menuTree.setMenuUrl(menu.getMenuUrl());
menuTree.setMenuUrlImg(menu.getMenuUrlImg());
menuTree.setMenuPSid(menu.getMenuPSid());
menuTree.setMenuSort(menu.getMenuSort());
menuTree.setMenuDesc(menu.getMenuDesc());
menuTree.setChildMenuList(recursionMenu(dataSource, menu.getId()));
treeModelList.add(menuTree);
}
}
return treeModelList;
}
}

@ -0,0 +1,46 @@
package com.hfkj.service.impl;
import com.hfkj.dao.SecRoleMenuRelMapper;
import com.hfkj.entity.SecRoleMenuRel;
import com.hfkj.entity.SecRoleMenuRelExample;
import com.hfkj.service.SecRoleMenuRelService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @className: SecRoleMenuRelServiceImpl
* @author: HuRui
* @date: 2024/4/1
**/
@Service("secRoleMenuRel")
public class SecRoleMenuRelServiceImpl implements SecRoleMenuRelService {
@Resource
private SecRoleMenuRelMapper secRoleMenuRelMapper;
@Override
public void batchAdd(List<SecRoleMenuRel> dataList) {
secRoleMenuRelMapper.batchAdd(dataList);
}
@Override
public void delete(Long relId) {
secRoleMenuRelMapper.deleteByPrimaryKey(relId);
}
@Override
public List<SecRoleMenuRel> getRelListByRole(Long roleId) {
SecRoleMenuRelExample example = new SecRoleMenuRelExample();
example.createCriteria().andRoleIdEqualTo(roleId);
return secRoleMenuRelMapper.selectByExample(example);
}
@Override
public List<SecRoleMenuRel> getRelListByMenu(Long menuId) {
SecRoleMenuRelExample example = new SecRoleMenuRelExample();
example.createCriteria().andMenuIdEqualTo(menuId);
return secRoleMenuRelMapper.selectByExample(example);
}
}

@ -0,0 +1,72 @@
package com.hfkj.service.impl;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.dao.SecRoleMapper;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecRoleExample;
import com.hfkj.service.SecRoleService;
import com.hfkj.service.SecUserService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @className: SecRoleServiceImpl
* @author: HuRui
* @date: 2024/3/26
**/
@Service("secRoleService")
public class SecRoleServiceImpl implements SecRoleService {
@Resource
private SecRoleMapper secRoleMapper;
@Override
public void editData(SecRole role) {
role.setUpdateTime(new Date());
if (role.getId() == null) {
role.setCreateTime(new Date());
secRoleMapper.insert(role);
} else {
secRoleMapper.updateByPrimaryKey(role);
}
}
@Override
public void delete(Long roleId) {
// 查询角色
SecRole secRole = getDetail(roleId);
if (secRole == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到数据");
}
secRole.setStatus(0);
editData(secRole);
}
@Override
public SecRole getDetail(Long roleId) {
return secRoleMapper.selectByPrimaryKey(roleId);
}
@Override
public List<SecRole> getList(Map<String, Object> param) {
SecRoleExample example = new SecRoleExample();
SecRoleExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0);
if (StringUtils.isNotBlank(MapUtils.getString(param, "roleName"))) {
criteria.andRoleNameLike("%"+MapUtils.getString(param, "roleName")+"%");
}
example.setOrderByClause("create_time desc");
return secRoleMapper.selectByExample(example);
}
}

@ -0,0 +1,146 @@
package com.hfkj.service.impl;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.AESEncodeUtil;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.MD5Util;
import com.hfkj.dao.SecUserMapper;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecRole;
import com.hfkj.entity.SecUser;
import com.hfkj.entity.SecUserExample;
import com.hfkj.model.MenuTreeModel;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.service.SecMenuService;
import com.hfkj.service.SecRoleService;
import com.hfkj.service.SecUserService;
import com.hfkj.sysenum.SecMenuTypeEnum;
import com.hfkj.sysenum.SecUserStatusEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @className: SecUserServiceImpl
* @author: HuRui
* @date: 2024/3/26
**/
@Service("secUserService")
public class SecUserServiceImpl implements SecUserService {
@Resource
private SecUserMapper secUserMapper;
@Resource
private UserCenter userCenter;
@Resource
private SecRoleService secRoleService;
@Resource
private SecMenuService secMenuService;
@Override
public void editUser(SecUser data) {
data.setUpdateTime(new Date());
if (data.getId() == null) {
data.setCreateTime(new Date());
secUserMapper.insert(data);
} else {
secUserMapper.updateByPrimaryKey(data);
}
}
@Override
public void create(SecUser secUser) {
secUser.setStatus(SecUserStatusEnum.status1.getCode());
editUser(secUser);
}
@Override
public void update(SecUser secUser) {
editUser(secUser);
}
@Override
public SecUser getDetail(Long id) {
return secUserMapper.selectByPrimaryKey(id);
}
@Override
public SecUser getDetailByLoginName(String loginName) {
SecUserExample example = new SecUserExample();
example.createCriteria().andLoginNameEqualTo(loginName).andStatusNotEqualTo(SecUserStatusEnum.status0.getCode());
List<SecUser> list = secUserMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public List<SecUser> getList(Map<String, Object> param) {
SecUserExample example = new SecUserExample();
SecUserExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(SecUserStatusEnum.status0.getCode());
if (StringUtils.isNotBlank(MapUtils.getString(param, "userName"))) {
criteria.andUserNameLike("%"+MapUtils.getString(param, "userName")+"%");
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "telephone"))) {
criteria.andTelephoneLike("%"+MapUtils.getString(param, "telephone")+"%");
}
if (MapUtils.getInteger(param, "userName") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(param, "userName"));
}
example.setOrderByClause("create_time desc");
List<SecUser> list = secUserMapper.selectByExample(example);
for (SecUser user : list) {
user.setPassword(null);
}
return list;
}
@Override
public SessionObject login(String loginName, String password) throws Exception {
// 查询用户
SecUser user = getDetailByLoginName(loginName);
if (user == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录账户不存在");
}
if (!user.getStatus().equals(SecUserStatusEnum.status1.getCode())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败!当前账户已被禁用");
}
if (!user.getPassword().equals(MD5Util.encode(password.getBytes()))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录密码错误");
}
user.setPassword(null);
// 查询账户角色
SecRole role = secRoleService.getDetail(user.getRoleId());
if (role == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录账户角色不存在");
}
// 角色菜单
List<MenuTreeModel> menuTree = secMenuService.queryMenuTree(role.getId());
// 角色按钮
List<SecMenu> button = secMenuService.queryRoleMenu(role.getId(), SecMenuTypeEnum.type2);
// token 生成格式:账户id + 时间戳
String token = AESEncodeUtil.aesEncrypt(user.getId()+"", "O8gTZ6wIovDPjhsaz0zAoqZmm3jtjIcO");
SessionObject sessionObject = new SessionObject(token, new SecUserSessionObject(user, role, menuTree, button));
userCenter.save(sessionObject);
return sessionObject;
}
}

@ -0,0 +1,47 @@
package com.hfkj.sysenum;
/**
* 菜单类型
* @className: SecMenuTypeEnum
* @author: HuRui
* @date: 2024/4/2
**/
public enum SecMenuTypeEnum {
/**
* 菜单
*/
type1(1, "菜单"),
/**
* 按钮
*/
type2(2, "按钮"),
;
private int code;
private String name;
SecMenuTypeEnum(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -0,0 +1,52 @@
package com.hfkj.sysenum;
/**
* 系统用户状态
* @className: SecUserStatusEnum
* @author: HuRui
* @date: 2024/3/26
**/
public enum SecUserStatusEnum {
/**
* 删除
*/
status0(0, "删除"),
/**
* 正常
*/
status1(1, "正常"),
/**
* 禁用
*/
status2(2, "禁用"),
;
private int code;
private String name;
SecUserStatusEnum(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

@ -1,4 +1,4 @@
package com.user.config;
package com.cweb.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
@ -53,117 +53,72 @@ public class AuthConfig implements WebMvcConfigurer {
}
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new HandlerInterceptorAdapter() {
registry.addInterceptor(new HandlerInterceptorAdapter() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getParameter("Authorization");
if (StringUtils.isBlank(token)) {
token = request.getHeader("Authorization");
}
if((StringUtils.isNotBlank(token) && userCenter.isTokenLogin(token)) || userCenter.isLogin(request)){//如果未登录,将无法使用任何接口
userCenter.refreshCookie(request, response);
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/login/*")
.excludePathPatterns("/order/*")
.excludePathPatterns("/coupon/getCouponList")
.excludePathPatterns("/wechatpay/*")
.excludePathPatterns("/coupon/getCouponById")
.excludePathPatterns("/discount/getDiscountByQrCode")
.excludePathPatterns("/discount/getDiscountById")
.excludePathPatterns("/discount/getCouponByDiscount")
.excludePathPatterns("/discount/getDiscountByDiscountAgentId")
.excludePathPatterns("/highMerchantStore/getMerchantStoreById")
.excludePathPatterns("/highMerchantStore/getStoreListByCoupon")
.excludePathPatterns("/highMerchantStore/getStoreList")
.excludePathPatterns("/highMerchantStore/getMerchantList")
.excludePathPatterns("/highMerchantStore/getStoreListByMerchant")
.excludePathPatterns("/sms/sendSmsCode")
.excludePathPatterns("/sms/getSmsCode")
.excludePathPatterns("/activity/getWinLotteryList")
.excludePathPatterns("/user/login")
.excludePathPatterns("/user/unionPhoneLogin")
.excludePathPatterns("/user/getUnionId")
.excludePathPatterns("/highUser/setCacheParam")
.excludePathPatterns("/highUser/getCacheParam")
.excludePathPatterns("/highUser/delCacheParam")
.excludePathPatterns("/order/orderToH5Pay")
.excludePathPatterns("/order/orderToPay")
.excludePathPatterns("/test/*")
.excludePathPatterns("/cmsContent/*")
.excludePathPatterns("/highGas/*")
.excludePathPatterns("/outRechargeOrder/*")
.excludePathPatterns("/wechat/*")
.excludePathPatterns("/tuanyou/*")
.excludePathPatterns("/unionPay/*")
.excludePathPatterns("/highGas/*")
.excludePathPatterns("/common/*")
.excludePathPatterns("/order/qzOrderToPay")
.excludePathPatterns("/czOrder/orderRefundNotify")
.excludePathPatterns("/cmsContent/*")
.excludePathPatterns("/highBrand/*")
.excludePathPatterns("/highGoodsType/*")
.excludePathPatterns("/sendSms/*")
.excludePathPatterns("/test/*")
.excludePathPatterns("/sms/*")
;
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
if(debug){
return true;
}
String token = request.getHeader("Authorization");
if(StringUtils.isNotBlank(token) && userCenter.isLogin(token)){//如果未登录,将无法使用任何接口
return true;
} else if(request instanceof StandardMultipartHttpServletRequest) {
StandardMultipartHttpServletRequest re = (StandardMultipartHttpServletRequest)request;
if(userCenter.isLogin(re.getRequest())){
return true;
} else {
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
} else{
log.error("the user is not logged in,remoteAddr:"+getIpAddress(request)+",requestUrl:"+request.getRequestURL());
response.setStatus(401);
return false;
}
}
})
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**")
.excludePathPatterns("/**/api-docs")
.excludePathPatterns("/**/springfox-swagger-ui/**")
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/secUser/login")
;
}
public String getIpAddress(HttpServletRequest request) {
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
// 获取请求主机IP地址,如果通过代理进来,则透过防火墙获取真实IP地址
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
} else if (ip.length() > 15) {
String[] ips = ip.split(",");
for (int index = 0; index < ips.length; index++) {
String strIp = ips[index];
if (!("unknown".equalsIgnoreCase(strIp))) {
ip = strIp;
break;
}
}
}
return ip;
}
}

@ -0,0 +1,111 @@
package com.user.controller;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.MD5Util;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.SecMenu;
import com.hfkj.entity.SecRoleMenuRel;
import com.hfkj.entity.SecUser;
import com.hfkj.model.MenuTreeModel;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.service.SecMenuService;
import com.hfkj.service.SecRoleMenuRelService;
import com.hfkj.service.SecUserService;
import com.hfkj.sysenum.SecUserStatusEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @className: secUser
* @author: HuRui
* @date: 2024/3/28
**/
@Controller
@RequestMapping(value="/secUser")
@Api(value="系统用户")
public class SecUserController {
Logger log = LoggerFactory.getLogger(SecUserController.class);
@Resource
private SecUserService secUserService;
@Resource
private UserCenter userCenter;
@RequestMapping(value="/login",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "登录")
public ResponseData login(@RequestBody JSONObject body) {
try {
if (body == null
|| StringUtils.isBlank(body.getString("loginName"))
|| StringUtils.isBlank(body.getString("password"))
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
return ResponseMsgUtil.success(secUserService.login(body.getString("loginName"), body.getString("password")));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryUser",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询账户")
public ResponseData queryUser() {
try {
return ResponseMsgUtil.success(userCenter.getSessionModel(SecUserSessionObject.class));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/loginOut",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "退出登录")
public ResponseData loginOut(HttpServletRequest request) {
try {
SecUserSessionObject session = userCenter.getSessionModel(SecUserSessionObject.class);
if (session != null) {
userCenter.remove(request);
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "账户已退出登录");
}
return ResponseMsgUtil.success("退出成功");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}
Loading…
Cancel
Save