|
|
@@ -2,7 +2,13 @@ package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.response.PageInfo;
|
|
|
+import com.fdkankan.common.util.Base64Converter;
|
|
|
+import com.fdkankan.common.util.DateUtil;
|
|
|
+import com.fdkankan.common.util.SecurityUtil;
|
|
|
import com.fdkankan.manage.api.dto.ManageLoginResponse;
|
|
|
import com.fdkankan.manage.entity.SysMenu;
|
|
|
import com.fdkankan.manage.entity.SysRole;
|
|
|
@@ -11,13 +17,19 @@ import com.fdkankan.manage.mapper.ISysUserMapper;
|
|
|
import com.fdkankan.manage.service.ISysMenuService;
|
|
|
import com.fdkankan.manage.service.ISysRoleService;
|
|
|
import com.fdkankan.manage.service.ISysUserService;
|
|
|
+import com.fdkankan.manage.vo.request.SysUserParam;
|
|
|
+import com.fdkankan.manage.vo.response.SysRoleVo;
|
|
|
+import com.fdkankan.manage.vo.response.SysUserVo;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -77,4 +89,38 @@ public class SysUserServiceImpl extends ServiceImpl<ISysUserMapper, SysUser> imp
|
|
|
redisUtil.set(String.format(RedisKey.MANAGE_PERM_USER,sysUser.getId()), JSONObject.toJSONString(menuList));
|
|
|
return loginVO;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addOrUpdate(SysUserParam param) {
|
|
|
+ if(param.getId() == null){
|
|
|
+ SysUser user = this.getByUserName(param.getUserName());
|
|
|
+ if(user !=null){
|
|
|
+ throw new BusinessException(-1,"用户已存在!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
+ BeanUtils.copyProperties(param,sysUser);
|
|
|
+ if(!StringUtils.isEmpty(param.getPassword())){
|
|
|
+ String passwordMd5 = SecurityUtil.MD52(Base64Converter.decode(Base64Converter.subText(param.getPassword())));
|
|
|
+ sysUser.setPassword(passwordMd5);
|
|
|
+ }
|
|
|
+ sysUser.setUpdateTime(DateUtil.date2String(new Date(),DateUtil.DEFAULT_DATE_FORMAT));
|
|
|
+ this.saveOrUpdate(sysUser);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo pageList(SysUserParam param) {
|
|
|
+ Page<SysUserVo> page = this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
|
|
|
+ return PageInfo.PageInfo(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HashMap<Long, Long> groupByRoleId() {
|
|
|
+ HashMap<Long, Long> map = new HashMap<>();
|
|
|
+ List<SysRoleVo> roleVos = this.getBaseMapper().groupByRoleId();
|
|
|
+ for (SysRoleVo roleVo : roleVos) {
|
|
|
+ map.put(roleVo.getId(),roleVo.getAdminCount());
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
}
|