CMM 1 yıl önce
ebeveyn
işleme
1c7099cad5
8 değiştirilmiş dosya ile 112 ekleme ve 19 silme
  1. +0
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/InitProcessTask.java
  2. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/RoleController.java
  3. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/RoleVO.java
  4. +8
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java
  5. +70
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java
  6. +21
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqGenerationLoginPO.java
  7. +1
    -3
      pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserInfoListVO.java
  8. +7
    -5
      pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java

+ 0
- 1
pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/InitProcessTask.java Dosyayı Görüntüle

@@ -108,7 +108,6 @@ public class InitProcessTask {
for(Integer processType : processTypeList){
String formName = ProjectProcessStageEnum.getDesc(processType);
WflowModelHistorysDto models = new WflowModelHistorysDto();
models.setCreated(GregorianCalendar.getInstance().getTime());
// models.setFormId("wf" + IdUtil.objectId());
models.setVersion(1);
models.setGroupId(1);


+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/controller/RoleController.java Dosyayı Görüntüle

@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.lang.Assert;
import com.ningdatech.basic.model.PageVo;
import com.ningdatech.log.annotation.WebLog;
import com.ningdatech.pmapi.common.util.BizUtils;
import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.model.req.RolePageReq;
import com.ningdatech.pmapi.sys.model.dto.RoleSaveDTO;
@@ -60,6 +61,7 @@ public class RoleController {
Role role = roleService.getById(id);
Assert.notNull(role, "角色不存在");
RoleVO query = BeanUtil.toBean(role, RoleVO.class);
query.setManageRoleIdList(BizUtils.splitToLong(role.getManageRoleIds()));
// 菜单
roleManage.buildMenu(query);
return query;


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/sys/model/vo/RoleVO.java Dosyayı Görüntüle

@@ -37,6 +37,9 @@ public class RoleVO extends BaseEntity {
@ApiModelProperty(value = "名称")
private String name;

@ApiModelProperty("管理角色ID")
private List<Long> manageRoleIdList;

/**
* 描述
*/


+ 8
- 4
pmapi/src/main/java/com/ningdatech/pmapi/user/controller/UserInfoController.java Dosyayı Görüntüle

@@ -3,10 +3,7 @@ package com.ningdatech.pmapi.user.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.pmapi.user.manage.UserInfoManage;
import com.ningdatech.pmapi.user.model.po.ReqUserDetailEditPO;
import com.ningdatech.pmapi.user.model.po.ReqUserDetailPO;
import com.ningdatech.pmapi.user.model.po.ReqUserDisableOrEnablePO;
import com.ningdatech.pmapi.user.model.po.ReqUserInfoListPO;
import com.ningdatech.pmapi.user.model.po.*;
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO;
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO;
import io.swagger.annotations.Api;
@@ -17,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
@@ -61,4 +59,10 @@ public class UserInfoController {
return userInfoManage.currentUserInfo();
}

@ApiOperation(value = "代登陆", notes = "代登陆")
@PostMapping("/generation-login")
public void generationLogin(@Valid @RequestBody ReqGenerationLoginPO reqGenerationLoginPO, HttpServletRequest httpServletRequest) {
userInfoManage.generationLogin(reqGenerationLoginPO);
}

}

+ 70
- 6
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserInfoManage.java Dosyayı Görüntüle

@@ -15,19 +15,24 @@ import com.ningdatech.pmapi.sys.model.entity.Role;
import com.ningdatech.pmapi.sys.model.entity.UserRole;
import com.ningdatech.pmapi.sys.service.IRoleService;
import com.ningdatech.pmapi.sys.service.IUserRoleService;
import com.ningdatech.pmapi.user.constant.LoginTypeEnum;
import com.ningdatech.pmapi.user.constant.UserAvailableEnum;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.model.po.ReqUserDetailEditPO;
import com.ningdatech.pmapi.user.model.po.ReqUserDetailPO;
import com.ningdatech.pmapi.user.model.po.ReqUserDisableOrEnablePO;
import com.ningdatech.pmapi.user.model.po.ReqUserInfoListPO;
import com.ningdatech.pmapi.user.model.po.*;
import com.ningdatech.pmapi.user.model.vo.ResUserDetailVO;
import com.ningdatech.pmapi.user.model.vo.ResUserInfoListVO;
import com.ningdatech.pmapi.user.model.vo.UserRoleVO;
import com.ningdatech.pmapi.user.security.auth.constants.UserDeatilsServiceConstant;
import com.ningdatech.pmapi.user.security.auth.credential.CredentialAuthToken;
import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import com.ningdatech.pmapi.user.util.LoginUserUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.security.web.context.HttpSessionSecurityContextRepository;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@@ -50,6 +55,7 @@ public class UserInfoManage {
private final IUserRoleService iUserRoleService;
private final IRoleService iRoleService;
private final UserInfoHelper userInfoHelper;
private final UserDetailsService userDetailsService;

public PageVo<ResUserInfoListVO> list(ReqUserInfoListPO reqUserInfoListPO) {
LambdaQueryWrapper<DingEmployeeInfo> wrapper = Wrappers.lambdaQuery(DingEmployeeInfo.class)
@@ -100,7 +106,7 @@ public class UserInfoManage {
resListVO.setUpdateTime(r.getUpdateOn());
// 从用户信息中获取
resListVO.setEmployeeCode(r.getEmployeeCode());
resListVO.setUserRoleList(new ArrayList<>());
resListVO.setUserRoleList(getUserRoleVOList(resListVO.getUserId()));
return resListVO;
}).collect(Collectors.toList());
}
@@ -111,6 +117,27 @@ public class UserInfoManage {
return pageVo;
}


private List<UserRoleVO> getUserRoleVOList(Long userId) {
List<UserRoleVO> userRoleInfoList = new ArrayList<>();
if (Objects.isNull(userId)) {
return userRoleInfoList;
}
List<UserRole> userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class)
.eq(UserRole::getUserId, userId));
if (CollUtil.isNotEmpty(userRoleList)) {
List<Long> roleIdList = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList());
List<Role> roleList = iRoleService.list(Wrappers.lambdaQuery(Role.class).in(Role::getId, roleIdList));
userRoleInfoList = roleList.stream().map(r -> {
UserRoleVO userRoleVO = new UserRoleVO();
userRoleVO.setId(r.getId());
userRoleVO.setName(r.getName());
return userRoleVO;
}).collect(Collectors.toList());
}
return userRoleInfoList;
}

public void disableOrEnable(ReqUserDisableOrEnablePO reqUserDisableOrEnablePO) {
Long userId = generateUserId(reqUserDisableOrEnablePO.getEmployeeCode());
UserInfo userInfo = iUserInfoService.getById(userId);
@@ -131,7 +158,8 @@ public class UserInfoManage {
resUserDetailVO.setStatus(userInfo.getAvailable());

// 装配用户角色信息列表
List<UserRole> userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class).eq(UserRole::getUserId, userId));
List<UserRole> userRoleList = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class)
.eq(UserRole::getUserId, userId));
List<UserRoleVO> userRoleInfoList = new ArrayList<>();
if (CollUtil.isNotEmpty(userRoleList)) {
List<Long> roleIdList = userRoleList.stream().map(UserRole::getRoleId).collect(Collectors.toList());
@@ -208,4 +236,40 @@ public class UserInfoManage {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
return null;
}

public void generationLogin(ReqGenerationLoginPO reqGenerationLoginPO) {
Long userId = reqGenerationLoginPO.getUserId();
UserInfo userInfo = iUserInfoService.getById(userId);
if (Objects.isNull(userInfo)) {
throw new BizException("该员工账号处于禁用状态中,无法使用");
}
if (!UserAvailableEnum.ENABLE.name().equals(userInfo.getAvailable())) {
throw new BizException("该员工账号处于禁用状态中,无法使用");
}
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);


// ReqGenerationLoginPO reqGenerationLoginPO
}

// public void autoLogin(Long userId){
// userDetailsService.loadUserByUsername(userId + UserDeatilsServiceConstant.USER_DETAILS_SERVICE_SEPARATOR + LoginTypeEnum.USERNAME_PASSWORD_LOGIN.name());
//
// CredentialAuthToken token = new CredentialAuthToken(email, password);
// try {
// token.setDetails(new WebAuthenticationDetails(httpServletRequest));
// UsernamePasswordAuthToken authenticatedUser = (UsernamePasswordAuthToken)usernamePasswordAuthSecurityConfig
// .getAuthenticationManager().authenticate(token);
// SecurityContextHolder.getContext().setAuthentication(authenticatedUser);
// httpServletRequest.getSession().setAttribute(
// HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());
// String sessionId = httpServletRequest.getSession().getId();
// putSessionIdToCache(LoginUserUtil.getUserId(), sessionId);
// } catch (
// AuthenticationException e) {
// throw new RuntimeException("autoLogIn Authentication failed!", e);
// }
// }


}

+ 21
- 0
pmapi/src/main/java/com/ningdatech/pmapi/user/model/po/ReqGenerationLoginPO.java Dosyayı Görüntüle

@@ -0,0 +1,21 @@
package com.ningdatech.pmapi.user.model.po;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
* @author liuxinxin
* @date 2023/2/21 下午3:39
*/
@Data
@ApiModel("代登陆请求PO")
public class ReqGenerationLoginPO {

@NotNull(message = "用户id 不能为空")
@ApiModelProperty("用户id")
private Long userId;

}

+ 1
- 3
pmapi/src/main/java/com/ningdatech/pmapi/user/model/vo/ResUserInfoListVO.java Dosyayı Görüntüle

@@ -1,6 +1,5 @@
package com.ningdatech.pmapi.user.model.vo;

import com.ningdatech.pmapi.sys.model.entity.Role;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -38,7 +37,7 @@ public class ResUserInfoListVO {
private Long regionId;

@ApiModelProperty("用户角色")
private List<Role> userRoleList;
private List<UserRoleVO> userRoleList;

@ApiModelProperty("状态")
private String status;
@@ -46,5 +45,4 @@ public class ResUserInfoListVO {
@ApiModelProperty("更新时间")
private LocalDateTime updateTime;


}

+ 7
- 5
pmapi/src/test/java/com/ningdatech/pmapi/sys/service/IMenuServiceTest.java Dosyayı Görüntüle

@@ -6,6 +6,7 @@ import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.sys.model.entity.Menu;
import com.ningdatech.pmapi.sys.model.entity.Role;
@@ -71,11 +72,12 @@ class IMenuServiceTest extends AppTests {

@Test
public void initMenu() {
menuService.remove(null);
roleMenuService.remove(null);
String str = FileUtil.readString("/Users/wendy/Desktop/long_text_2023-02-13-15-28-42.txt", "UTF-8");
List<JSONObject> obj = JSONUtil.toList(str, JSONObject.class);
save(obj, 0);
// menuService.remove(null);
roleMenuService.remove(Wrappers.lambdaQuery(RoleMenu.class)
.eq(RoleMenu::getRoleId,1));
// String str = FileUtil.readString("/Users/wendy/Desktop/long_text_2023-02-13-15-28-42.txt", "UTF-8");
// List<JSONObject> obj = JSONUtil.toList(str, JSONObject.class);
// save(obj, 0);
menuService.list().forEach(w -> {
roleMenuService.save(new RoleMenu() {{
setRoleId(1L);


Yükleniyor…
İptal
Kaydet