parent
8f99e1b247
commit
0d5daac9e8
|
@ -57,4 +57,7 @@ public class CurrentMenu implements Serializable {
|
||||||
this.menuType = menuType;
|
this.menuType = menuType;
|
||||||
this.num = num;
|
this.num = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CurrentMenu() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.len.base;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
@ -11,9 +12,7 @@ import lombok.ToString;
|
||||||
* @date 2017/12/30.
|
* @date 2017/12/30.
|
||||||
* @email 154040976@qq.com
|
* @email 154040976@qq.com
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Data
|
||||||
@Setter
|
|
||||||
@ToString
|
|
||||||
public class CurrentRole implements Serializable {
|
public class CurrentRole implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,4 +31,7 @@ public class CurrentRole implements Serializable {
|
||||||
this.roleName = roleName;
|
this.roleName = roleName;
|
||||||
this.remark = remark;
|
this.remark = remark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CurrentRole() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
package com.len;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Hello world!
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class App
|
|
||||||
{
|
|
||||||
public static void main( String[] args )
|
|
||||||
{
|
|
||||||
System.out.println( "Hello World!" );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,7 +15,6 @@ import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.authc.ExcessiveAttemptsException;
|
import org.apache.shiro.authc.ExcessiveAttemptsException;
|
||||||
import org.apache.shiro.authc.IncorrectCredentialsException;
|
import org.apache.shiro.authc.IncorrectCredentialsException;
|
||||||
import org.apache.shiro.authc.UnknownAccountException;
|
import org.apache.shiro.authc.UnknownAccountException;
|
||||||
import org.apache.shiro.session.Session;
|
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
@ -40,10 +39,10 @@ import java.util.List;
|
||||||
public class LoginController {
|
public class LoginController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserService userService;
|
private MenuService menuService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MenuService menuService;
|
SysUserService userService;
|
||||||
|
|
||||||
@GetMapping(value = "")
|
@GetMapping(value = "")
|
||||||
public String loginInit() {
|
public String loginInit() {
|
||||||
|
@ -66,7 +65,6 @@ public class LoginController {
|
||||||
Subject sub = SecurityUtils.getSubject();
|
Subject sub = SecurityUtils.getSubject();
|
||||||
Boolean flag2 = sub.isRemembered();
|
Boolean flag2 = sub.isRemembered();
|
||||||
boolean flag = sub.isAuthenticated() || flag2;
|
boolean flag = sub.isAuthenticated() || flag2;
|
||||||
Session session = sub.getSession();
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
return "/main/main";
|
return "/main/main";
|
||||||
}
|
}
|
||||||
|
@ -84,11 +82,11 @@ public class LoginController {
|
||||||
@ApiOperation(value = "/login", httpMethod = "POST", notes = "登录method")
|
@ApiOperation(value = "/login", httpMethod = "POST", notes = "登录method")
|
||||||
@PostMapping(value = "/login")
|
@PostMapping(value = "/login")
|
||||||
public String login(SysUser user, Model model, String rememberMe, HttpServletRequest request) {
|
public String login(SysUser user, Model model, String rememberMe, HttpServletRequest request) {
|
||||||
/*String codeMsg = (String) request.getAttribute("shiroLoginFailure");
|
String codeMsg = (String) request.getAttribute("shiroLoginFailure");
|
||||||
if ("code.error".equals(codeMsg)) {
|
if ("code.error".equals(codeMsg)) {
|
||||||
model.addAttribute("message", "验证码错误");
|
model.addAttribute("message", "验证码错误");
|
||||||
return "/login";
|
return "/login";
|
||||||
}*/
|
}
|
||||||
CustomUsernamePasswordToken token = new CustomUsernamePasswordToken(user.getUsername().trim(),
|
CustomUsernamePasswordToken token = new CustomUsernamePasswordToken(user.getUsername().trim(),
|
||||||
user.getPassword(), "UserLogin");
|
user.getPassword(), "UserLogin");
|
||||||
Subject subject = ShiroUtil.getSubject();
|
Subject subject = ShiroUtil.getSubject();
|
||||||
|
@ -96,6 +94,8 @@ public class LoginController {
|
||||||
try {
|
try {
|
||||||
subject.login(token);
|
subject.login(token);
|
||||||
if (subject.isAuthenticated()) {
|
if (subject.isAuthenticated()) {
|
||||||
|
userService.setMenuAndRoles(token.getUsername());
|
||||||
|
token.getUsername();
|
||||||
return "redirect:/main";
|
return "redirect:/main";
|
||||||
}
|
}
|
||||||
} catch (UnknownAccountException | IncorrectCredentialsException e) {
|
} catch (UnknownAccountException | IncorrectCredentialsException e) {
|
||||||
|
|
|
@ -16,9 +16,6 @@ import com.len.util.BeanUtil;
|
||||||
import com.len.util.JsonUtil;
|
import com.len.util.JsonUtil;
|
||||||
import com.len.util.ReType;
|
import com.len.util.ReType;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -29,6 +26,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhuxiaomeng
|
* @author zhuxiaomeng
|
||||||
* @date 2017/12/19.
|
* @date 2017/12/19.
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class JobTask {
|
||||||
.withMisfireHandlingInstructionDoNothing();
|
.withMisfireHandlingInstructionDoNothing();
|
||||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey)
|
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey)
|
||||||
.withDescription(createTime).withSchedule(schedBuilder).build();
|
.withDescription(createTime).withSchedule(schedBuilder).build();
|
||||||
Class clazz = null;
|
|
||||||
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
|
JobDetail jobDetail = scheduler.getJobDetail(jobKey);
|
||||||
HashSet<Trigger> triggerSet = new HashSet<>();
|
HashSet<Trigger> triggerSet = new HashSet<>();
|
||||||
triggerSet.add(trigger);
|
triggerSet.add(trigger);
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
package com.len.core.shiro;
|
package com.len.core.shiro;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.len.base.CurrentMenu;
|
import com.len.base.CurrentMenu;
|
||||||
import com.len.base.CurrentRole;
|
import com.len.base.CurrentRole;
|
||||||
import com.len.base.CurrentUser;
|
import com.len.base.CurrentUser;
|
||||||
import com.len.entity.SysMenu;
|
|
||||||
import com.len.entity.SysRole;
|
|
||||||
import com.len.entity.SysUser;
|
import com.len.entity.SysUser;
|
||||||
import com.len.service.MenuService;
|
|
||||||
import com.len.service.RoleMenuService;
|
|
||||||
import com.len.service.RoleUserService;
|
|
||||||
import com.len.service.SysUserService;
|
import com.len.service.SysUserService;
|
||||||
import com.len.util.JWTUtil;
|
import com.len.util.JWTUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -17,15 +11,12 @@ import org.apache.shiro.authc.*;
|
||||||
import org.apache.shiro.authz.AuthorizationInfo;
|
import org.apache.shiro.authz.AuthorizationInfo;
|
||||||
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
import org.apache.shiro.authz.SimpleAuthorizationInfo;
|
||||||
import org.apache.shiro.realm.AuthorizingRealm;
|
import org.apache.shiro.realm.AuthorizingRealm;
|
||||||
import org.apache.shiro.session.Session;
|
|
||||||
import org.apache.shiro.subject.PrincipalCollection;
|
import org.apache.shiro.subject.PrincipalCollection;
|
||||||
import org.apache.shiro.subject.Subject;
|
|
||||||
import org.apache.shiro.util.ByteSource;
|
import org.apache.shiro.util.ByteSource;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -40,15 +31,6 @@ public class LoginRealm extends AuthorizingRealm {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserService userService;
|
private SysUserService userService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MenuService menuService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RoleUserService roleUserService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RoleMenuService roleMenuService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取授权
|
* 获取授权
|
||||||
|
@ -75,7 +57,7 @@ public class LoginRealm extends AuthorizingRealm {
|
||||||
info.addRole(cRole.getId());
|
info.addRole(cRole.getId());
|
||||||
}
|
}
|
||||||
for (CurrentMenu cMenu : cUser.getCurrentMenuList()) {
|
for (CurrentMenu cMenu : cUser.getCurrentMenuList()) {
|
||||||
if (!StringUtils.isEmpty(cMenu.getPermission())){
|
if (!StringUtils.isEmpty(cMenu.getPermission())) {
|
||||||
info.addStringPermission(cMenu.getPermission());
|
info.addStringPermission(cMenu.getPermission());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +76,6 @@ public class LoginRealm extends AuthorizingRealm {
|
||||||
@Override
|
@Override
|
||||||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken)
|
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken)
|
||||||
throws AuthenticationException {
|
throws AuthenticationException {
|
||||||
UsernamePasswordToken upToken = (UsernamePasswordToken) authenticationToken;
|
|
||||||
String username = (String) authenticationToken.getPrincipal();
|
String username = (String) authenticationToken.getPrincipal();
|
||||||
SysUser s = null;
|
SysUser s = null;
|
||||||
try {
|
try {
|
||||||
|
@ -104,33 +85,6 @@ public class LoginRealm extends AuthorizingRealm {
|
||||||
}
|
}
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
throw new UnknownAccountException("账户密码不正确");
|
throw new UnknownAccountException("账户密码不正确");
|
||||||
} else {
|
|
||||||
CurrentUser currentUser = new CurrentUser(s.getId(), s.getUsername(), s.getAge(), s.getEmail(), s.getPhoto(), s.getRealName());
|
|
||||||
Subject subject = ShiroUtil.getSubject();
|
|
||||||
/**角色权限封装进去*/
|
|
||||||
//根据用户获取菜单
|
|
||||||
List<SysMenu> menuList = new ArrayList<>(new HashSet<>(menuService.getUserMenu(s.getId())));
|
|
||||||
JSONArray json = menuService.getMenuJsonByUser(menuList);
|
|
||||||
Session session = subject.getSession();
|
|
||||||
session.setAttribute("menu", json);
|
|
||||||
CurrentMenu currentMenu = null;
|
|
||||||
List<CurrentMenu> currentMenuList = new ArrayList<>();
|
|
||||||
List<SysRole> roleList = new ArrayList<>();
|
|
||||||
for (SysMenu m : menuList) {
|
|
||||||
currentMenu = new CurrentMenu(m.getId(), m.getName(), m.getPId(), m.getUrl(), m.getOrderNum(), m.getIcon(), m.getPermission(), m.getMenuType(), m.getNum());
|
|
||||||
currentMenuList.add(currentMenu);
|
|
||||||
roleList.addAll(m.getRoleList());
|
|
||||||
}
|
|
||||||
roleList = new ArrayList<>(new HashSet<>(roleList));
|
|
||||||
List<CurrentRole> currentRoleList = new ArrayList<>();
|
|
||||||
CurrentRole role = null;
|
|
||||||
for (SysRole r : roleList) {
|
|
||||||
role = new CurrentRole(r.getId(), r.getRoleName(), r.getRemark());
|
|
||||||
currentRoleList.add(role);
|
|
||||||
}
|
|
||||||
currentUser.setCurrentRoleList(currentRoleList);
|
|
||||||
currentUser.setCurrentMenuList(currentMenuList);
|
|
||||||
session.setAttribute("curentUser", currentUser);
|
|
||||||
}
|
}
|
||||||
ByteSource byteSource = ByteSource.Util.bytes(username);
|
ByteSource byteSource = ByteSource.Util.bytes(username);
|
||||||
return new SimpleAuthenticationInfo(username, s.getPassword(), byteSource, getName());
|
return new SimpleAuthenticationInfo(username, s.getPassword(), byteSource, getName());
|
||||||
|
|
|
@ -35,12 +35,7 @@ public class RoleServiceImpl extends BaseServiceImpl<SysRole,String> implements
|
||||||
record=super.addValue(record,true);
|
record=super.addValue(record,true);
|
||||||
return roleMapper.insert(record);
|
return roleMapper.insert(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @Override
|
|
||||||
public int insertSelective(SysRole record) {
|
|
||||||
return roleMapper.insertSelective(record);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SysRole selectByPrimaryKey(String id) {
|
public SysRole selectByPrimaryKey(String id) {
|
||||||
return roleMapper.selectByPrimaryKey(id);
|
return roleMapper.selectByPrimaryKey(id);
|
||||||
|
|
|
@ -1,206 +1,204 @@
|
||||||
package com.len.service.impl;
|
package com.len.service.impl;
|
||||||
|
|
||||||
import com.len.base.BaseMapper;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.len.base.impl.BaseServiceImpl;
|
import com.len.base.BaseMapper;
|
||||||
import com.len.entity.SysRole;
|
import com.len.base.CurrentMenu;
|
||||||
import com.len.entity.SysRoleUser;
|
import com.len.base.CurrentRole;
|
||||||
import com.len.entity.SysUser;
|
import com.len.base.CurrentUser;
|
||||||
import com.len.exception.MyException;
|
import com.len.base.impl.BaseServiceImpl;
|
||||||
import com.len.mapper.SysRoleUserMapper;
|
import com.len.core.shiro.ShiroUtil;
|
||||||
import com.len.mapper.SysUserMapper;
|
import com.len.entity.SysMenu;
|
||||||
import com.len.service.RoleService;
|
import com.len.entity.SysRole;
|
||||||
import com.len.service.RoleUserService;
|
import com.len.entity.SysRoleUser;
|
||||||
import com.len.service.SysUserService;
|
import com.len.entity.SysUser;
|
||||||
import com.len.util.Checkbox;
|
import com.len.exception.MyException;
|
||||||
import com.len.util.JsonUtil;
|
import com.len.mapper.SysRoleUserMapper;
|
||||||
import com.len.util.Md5Util;
|
import com.len.mapper.SysUserMapper;
|
||||||
import java.util.ArrayList;
|
import com.len.service.MenuService;
|
||||||
import java.util.HashMap;
|
import com.len.service.RoleService;
|
||||||
import java.util.List;
|
import com.len.service.RoleUserService;
|
||||||
import java.util.Map;
|
import com.len.service.SysUserService;
|
||||||
|
import com.len.util.BeanUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import com.len.util.Checkbox;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import com.len.util.JsonUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import com.len.util.Md5Util;
|
||||||
|
import java.util.ArrayList;
|
||||||
/**
|
import java.util.List;
|
||||||
* @author zhuxiaomeng
|
import org.apache.commons.lang3.StringUtils;
|
||||||
* @date 2017/12/4.
|
import org.apache.shiro.session.Session;
|
||||||
* @email 154040976@qq.com
|
import org.apache.shiro.subject.Subject;
|
||||||
*/
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@Service
|
import org.springframework.stereotype.Service;
|
||||||
public class SysUserServiceImpl extends BaseServiceImpl<SysUser,String> implements SysUserService {
|
|
||||||
|
import java.util.ArrayList;
|
||||||
@Autowired
|
import java.util.HashSet;
|
||||||
SysUserMapper sysUserMapper;
|
import java.util.List;
|
||||||
|
|
||||||
@Autowired
|
/**
|
||||||
SysRoleUserMapper sysRoleUserMapper;
|
* @author zhuxiaomeng
|
||||||
|
* @date 2017/12/4.
|
||||||
@Autowired
|
* @email 154040976@qq.com
|
||||||
RoleService roleService;
|
*/
|
||||||
|
@Service
|
||||||
@Autowired
|
public class SysUserServiceImpl extends BaseServiceImpl<SysUser, String> implements SysUserService {
|
||||||
RoleUserService roleUserService;
|
|
||||||
@Override
|
@Autowired
|
||||||
public BaseMapper<SysUser, String> getMappser() {
|
SysUserMapper sysUserMapper;
|
||||||
return sysUserMapper;
|
|
||||||
}
|
@Autowired
|
||||||
|
SysRoleUserMapper sysRoleUserMapper;
|
||||||
|
|
||||||
@Override
|
@Autowired
|
||||||
public SysUser login(String username) {
|
RoleService roleService;
|
||||||
return sysUserMapper.login(username);
|
|
||||||
}
|
@Autowired
|
||||||
|
RoleUserService roleUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
@Override
|
MenuService menuService;
|
||||||
public int deleteByPrimaryKey(String id) {
|
|
||||||
return sysUserMapper.deleteByPrimaryKey(id);
|
private static final String ADMIN = "admin";
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public BaseMapper<SysUser, String> getMappser() {
|
||||||
public int insert(SysUser record) {
|
return sysUserMapper;
|
||||||
return sysUserMapper.insert(record);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insertSelective(SysUser record) {
|
public SysUser login(String username) {
|
||||||
|
return sysUserMapper.login(username);
|
||||||
String pwd= Md5Util.getMD5(record.getPassword().trim(),record.getUsername().trim());
|
}
|
||||||
record.setPassword(pwd);
|
|
||||||
return super.insertSelective(record);
|
|
||||||
}
|
@Override
|
||||||
|
public int deleteByPrimaryKey(String id) {
|
||||||
@Override
|
return sysUserMapper.deleteByPrimaryKey(id);
|
||||||
public SysUser selectByPrimaryKey(String id) {
|
}
|
||||||
return sysUserMapper.selectByPrimaryKey(id);
|
|
||||||
}
|
@Override
|
||||||
|
public int insert(SysUser record) {
|
||||||
@Override
|
return sysUserMapper.insert(record);
|
||||||
public int updateByPrimaryKeySelective(SysUser record) {
|
}
|
||||||
return super.updateByPrimaryKeySelective(record);
|
|
||||||
}
|
@Override
|
||||||
|
public int insertSelective(SysUser record) {
|
||||||
@Override
|
|
||||||
public int updateByPrimaryKey(SysUser record) {
|
String pwd = Md5Util.getMD5(record.getPassword().trim(), record.getUsername().trim());
|
||||||
return sysUserMapper.updateByPrimaryKey(record);
|
record.setPassword(pwd);
|
||||||
}
|
return super.insertSelective(record);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public List<SysRoleUser> selectByCondition(SysRoleUser sysRoleUser) {
|
@Override
|
||||||
return sysRoleUserMapper.selectByCondition(sysRoleUser);
|
public SysUser selectByPrimaryKey(String id) {
|
||||||
}
|
return sysUserMapper.selectByPrimaryKey(id);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 分页查询
|
@Override
|
||||||
* @param
|
public int updateByPrimaryKeySelective(SysUser record) {
|
||||||
* @return
|
return super.updateByPrimaryKeySelective(record);
|
||||||
*/
|
}
|
||||||
@Override
|
|
||||||
public List<SysUser> selectListByPage(SysUser sysUser) {
|
@Override
|
||||||
return sysUserMapper.selectListByPage(sysUser);
|
public int updateByPrimaryKey(SysUser record) {
|
||||||
}
|
return sysUserMapper.updateByPrimaryKey(record);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int count() {
|
@Override
|
||||||
return sysUserMapper.count();
|
public List<SysRoleUser> selectByCondition(SysRoleUser sysRoleUser) {
|
||||||
}
|
return sysRoleUserMapper.selectByCondition(sysRoleUser);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int add(SysUser user) {
|
/**
|
||||||
//密码加密
|
* 分页查询
|
||||||
String pwd= Md5Util.getMD5(user.getPassword().trim(),user.getUsername().trim());
|
*
|
||||||
user.setPassword(pwd);
|
* @param
|
||||||
return sysUserMapper.add(user);
|
* @return
|
||||||
}
|
*/
|
||||||
|
@Override
|
||||||
@Override
|
public List<SysUser> selectListByPage(SysUser sysUser) {
|
||||||
public JsonUtil delById(String id,boolean flag) {
|
return sysUserMapper.selectListByPage(sysUser);
|
||||||
if (StringUtils.isEmpty(id)) {
|
}
|
||||||
return JsonUtil.error("获取数据失败");
|
|
||||||
}
|
@Override
|
||||||
JsonUtil j=new JsonUtil();
|
public int count() {
|
||||||
try {
|
return sysUserMapper.count();
|
||||||
SysUser sysUser = selectByPrimaryKey(id);
|
}
|
||||||
if("admin".equals(sysUser.getUsername())){
|
|
||||||
return JsonUtil.error("超管无法删除");
|
@Override
|
||||||
}
|
public int add(SysUser user) {
|
||||||
SysRoleUser roleUser=new SysRoleUser();
|
//密码加密
|
||||||
roleUser.setUserId(id);
|
String pwd = Md5Util.getMD5(user.getPassword().trim(), user.getUsername().trim());
|
||||||
int count=roleUserService.selectCountByCondition(roleUser);
|
user.setPassword(pwd);
|
||||||
if(count>0){
|
return sysUserMapper.add(user);
|
||||||
return JsonUtil.error("账户已经绑定角色,无法删除");
|
}
|
||||||
}
|
|
||||||
if (flag) {
|
@Override
|
||||||
//逻辑
|
public JsonUtil delById(String id, boolean flag) {
|
||||||
sysUser.setDelFlag(Byte.parseByte("1"));
|
if (StringUtils.isEmpty(id)) {
|
||||||
updateByPrimaryKeySelective(sysUser);
|
return JsonUtil.error("获取数据失败");
|
||||||
} else {
|
}
|
||||||
//物理
|
JsonUtil j = new JsonUtil();
|
||||||
sysUserMapper.delById(id);
|
try {
|
||||||
}
|
SysUser sysUser = selectByPrimaryKey(id);
|
||||||
j.setMsg("删除成功");
|
if (ADMIN.equals(sysUser.getUsername())) {
|
||||||
} catch (MyException e) {
|
return JsonUtil.error("超管无法删除");
|
||||||
j.setMsg("删除失败");
|
}
|
||||||
j.setFlag(false);
|
SysRoleUser roleUser = new SysRoleUser();
|
||||||
e.printStackTrace();
|
roleUser.setUserId(id);
|
||||||
}
|
int count = roleUserService.selectCountByCondition(roleUser);
|
||||||
return j;
|
if (count > 0) {
|
||||||
|
return JsonUtil.error("账户已经绑定角色,无法删除");
|
||||||
}
|
}
|
||||||
|
if (flag) {
|
||||||
@Override
|
//逻辑
|
||||||
public int checkUser(String username) {
|
sysUser.setDelFlag(Byte.parseByte("1"));
|
||||||
return sysUserMapper.checkUser(username);
|
updateByPrimaryKeySelective(sysUser);
|
||||||
}
|
} else {
|
||||||
|
//物理
|
||||||
@Override
|
sysUserMapper.delById(id);
|
||||||
public List<Checkbox> getUserRoleByJson(String id){
|
}
|
||||||
List<SysRole> roleList=roleService.selectListByPage(new SysRole());
|
j.setMsg("删除成功");
|
||||||
SysRoleUser sysRoleUser =new SysRoleUser();
|
} catch (MyException e) {
|
||||||
sysRoleUser.setUserId(id);
|
j.setMsg("删除失败");
|
||||||
List<SysRoleUser> kList= selectByCondition(sysRoleUser);
|
j.setFlag(false);
|
||||||
System.out.println(kList.size());
|
e.printStackTrace();
|
||||||
List<Checkbox> checkboxList=new ArrayList<>();
|
}
|
||||||
Checkbox checkbox=null;
|
return j;
|
||||||
for(SysRole sysRole:roleList){
|
|
||||||
checkbox=new Checkbox();
|
}
|
||||||
checkbox.setId(sysRole.getId());
|
|
||||||
checkbox.setName(sysRole.getRoleName());
|
@Override
|
||||||
for(SysRoleUser sysRoleUser1 :kList){
|
public int checkUser(String username) {
|
||||||
if(sysRoleUser1.getRoleId().equals(sysRole.getId())){
|
return sysUserMapper.checkUser(username);
|
||||||
checkbox.setCheck(true);
|
}
|
||||||
}
|
|
||||||
}
|
@Override
|
||||||
checkboxList.add(checkbox);
|
public List<Checkbox> getUserRoleByJson(String id) {
|
||||||
}
|
List<SysRole> roleList = roleService.selectListByPage(new SysRole());
|
||||||
return checkboxList;
|
SysRoleUser sysRoleUser = new SysRoleUser();
|
||||||
}
|
sysRoleUser.setUserId(id);
|
||||||
|
List<SysRoleUser> kList = selectByCondition(sysRoleUser);
|
||||||
@Override
|
|
||||||
public int rePass(SysUser user) {
|
List<Checkbox> checkboxList = new ArrayList<>();
|
||||||
return sysUserMapper.rePass(user);
|
Checkbox checkbox;
|
||||||
}
|
for (SysRole sysRole : roleList) {
|
||||||
|
checkbox = new Checkbox();
|
||||||
@Override
|
checkbox.setId(sysRole.getId());
|
||||||
public List<SysUser> getUserByRoleId(String roleId,int page,int limit)
|
checkbox.setName(sysRole.getRoleName());
|
||||||
{
|
for (SysRoleUser sysRoleUser1 : kList) {
|
||||||
Map map = new HashMap<>();
|
if (sysRoleUser1.getRoleId().equals(sysRole.getId())) {
|
||||||
map.put("roleId",roleId);
|
checkbox.setCheck(true);
|
||||||
map.put("page",(page-1)*limit );
|
break;
|
||||||
map.put("limit",limit);
|
}
|
||||||
return sysUserMapper.getUserByRoleId(map);
|
}
|
||||||
}
|
checkboxList.add(checkbox);
|
||||||
|
}
|
||||||
@Override
|
return checkboxList;
|
||||||
public int countUserByRoleId(String roleId,int page,int limit)
|
}
|
||||||
{
|
|
||||||
Map map = new HashMap<>();
|
@Override
|
||||||
map.put("roleId",roleId);
|
public int rePass(SysUser user) {
|
||||||
map.put("page",(page-1)*limit );
|
return sysUserMapper.rePass(user);
|
||||||
map.put("limit",limit);
|
}
|
||||||
return sysUserMapper.countUserByRoleId(map);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue