feat(server): add /api/saas-role-user/list api
This commit is contained in:
parent
10e237551c
commit
e6ceb71324
7
integration-test/src/test/resources/reponse-check.js
Normal file
7
integration-test/src/test/resources/reponse-check.js
Normal file
@ -0,0 +1,7 @@
|
||||
client.test("request executed successful", function () {
|
||||
client.assert(response.status == 200, "Response status is not 200")
|
||||
});
|
||||
|
||||
client.test("response body status successful", function () {
|
||||
client.assert(response.body.code == 0, "Response body code is not 0")
|
||||
});
|
||||
8
integration-test/src/test/resources/rest-client.env.json
Normal file
8
integration-test/src/test/resources/rest-client.env.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"local": {
|
||||
"host": "http://localhost:8080"
|
||||
},
|
||||
"dev": {
|
||||
"host": "https://dev-app.axzo.cn/msg-center/webApi/message/"
|
||||
}
|
||||
}
|
||||
13
integration-test/src/test/resources/role-user.http
Normal file
13
integration-test/src/test/resources/role-user.http
Normal file
@ -0,0 +1,13 @@
|
||||
###
|
||||
POST {{host}}/api/saas-role-user/list
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
> reponse-check.js
|
||||
|
||||
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserRelationDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
@ -20,6 +23,12 @@ public interface TyrSaasRoleUserApi {
|
||||
@PostMapping("/api/saas-role-user/save-or-update")
|
||||
ApiResult<Void> saveOrUpdate(@RequestBody @Valid RoleUserReq req);
|
||||
|
||||
|
||||
/**
|
||||
* 用户角色列表 限制1000条
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/saas-role-user/list")
|
||||
ApiResult<List<SaasRoleUserRelationDTO>> roleUserList(@RequestBody @Valid RoleUserParam param);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,71 @@
|
||||
package cn.axzo.tyr.client.model.roleuser.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author haiyangjin
|
||||
* @date 2023/9/14
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SaasRoleUserRelationDTO {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 身份Id
|
||||
*/
|
||||
private Long identityId;
|
||||
|
||||
/**
|
||||
* 身份类型 1:工人 2:从业人员 3:班组长 4:运营人员 5:政务人员
|
||||
*/
|
||||
private Integer identityType;
|
||||
|
||||
/**
|
||||
* 角色Id
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 自然人Id
|
||||
*/
|
||||
private Long naturalPersonId;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 所属单位Id 用户在当前工作台的所属单位
|
||||
*/
|
||||
private Long ouId;
|
||||
|
||||
/**
|
||||
* 工作台Id
|
||||
*/
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
private Integer resourceType;
|
||||
|
||||
/**
|
||||
* 资源Id
|
||||
*/
|
||||
private Long resourceId;
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package cn.axzo.tyr.client.model.roleuser.req;
|
||||
|
||||
import cn.axzo.tyr.client.model.enums.IdentityType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author haiyangjin
|
||||
* @date 2023/9/14
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class RoleUserParam {
|
||||
/**
|
||||
* 工作台id
|
||||
*/
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 单位id
|
||||
*/
|
||||
private Long ouId;
|
||||
|
||||
|
||||
/**
|
||||
* personId
|
||||
*/
|
||||
private Long personId;
|
||||
|
||||
/**
|
||||
* 身份id
|
||||
* 传身份id的时候请带上身份类型。 身份id会重复
|
||||
*/
|
||||
private Long identityId;
|
||||
|
||||
/**
|
||||
* 身份类型
|
||||
*/
|
||||
private IdentityType identityType;
|
||||
|
||||
/**
|
||||
* role ids
|
||||
*/
|
||||
private Set<Long> roleIds;
|
||||
}
|
||||
@ -47,6 +47,7 @@ public class RoleUserReq {
|
||||
*/
|
||||
@NotNull
|
||||
private IdentityType identityType;
|
||||
|
||||
/**
|
||||
* 完整的update,所有RoleId都被更新
|
||||
*/
|
||||
|
||||
@ -2,13 +2,18 @@ package cn.axzo.tyr.server.controller.roleuser;
|
||||
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.TyrSaasRoleUserApi;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserRelationDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tanjie@axzo.cn
|
||||
@ -19,10 +24,16 @@ import javax.validation.Valid;
|
||||
@RequiredArgsConstructor
|
||||
public class RoleUserController implements TyrSaasRoleUserApi {
|
||||
private final SaasRoleUserService saasRoleUserService;
|
||||
private final SaasRoleUserRelationService saasRoleUserRelationService;
|
||||
@Override
|
||||
public ApiResult<Void> saveOrUpdate(@Valid RoleUserReq req) {
|
||||
saasRoleUserService.saveOrUpdate(req);
|
||||
return ApiResult.ok();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<List<SaasRoleUserRelationDTO>> roleUserList(@RequestBody @Valid RoleUserParam param) {
|
||||
return ApiResult.ok(saasRoleUserRelationService.list(param));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.axzo.tyr.server.service;
|
||||
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserRelationDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author haiyangjin
|
||||
* @date 2023/9/14
|
||||
*/
|
||||
public interface SaasRoleUserRelationService {
|
||||
List<SaasRoleUserRelationDTO> list(RoleUserParam param);
|
||||
}
|
||||
@ -1,8 +1,11 @@
|
||||
package cn.axzo.tyr.server.service;
|
||||
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tanjie@axzo.cn
|
||||
@ -11,6 +14,4 @@ import javax.validation.Valid;
|
||||
public interface SaasRoleUserService {
|
||||
|
||||
void saveOrUpdate( RoleUserReq req);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
package cn.axzo.tyr.server.service.impl;
|
||||
|
||||
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserRelationDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
import cn.axzo.tyr.server.repository.service.SaasRoleUserRelationDao;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.checkerframework.checker.units.qual.C;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author haiyangjin
|
||||
* @date 2023/9/14
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SaasRoleUserRelationServiceImpl implements SaasRoleUserRelationService {
|
||||
|
||||
@Resource
|
||||
private SaasRoleUserRelationDao saasRoleUserRelationDao;
|
||||
@Override
|
||||
public List<SaasRoleUserRelationDTO> list(RoleUserParam param) {
|
||||
List<SaasRoleUserRelation> saasRoleUserRelations = saasRoleUserRelationDao.lambdaQuery().eq(Objects.nonNull(param.getIdentityId()), SaasRoleUserRelation::getIdentityId, param.getIdentityId())
|
||||
.eq(Objects.nonNull(param.getIdentityType()), SaasRoleUserRelation::getIdentityType, param.getIdentityType())
|
||||
.eq(Objects.nonNull(param.getWorkspaceId()), SaasRoleUserRelation::getWorkspaceId, param.getWorkspaceId())
|
||||
.eq(Objects.nonNull(param.getOuId()), SaasRoleUserRelation::getOuId, param.getOuId())
|
||||
.in(CollectionUtil.isNotEmpty(param.getRoleIds()), SaasRoleUserRelation::getRoleId, param.getRoleIds())
|
||||
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||
.last("LIMIT 1000")
|
||||
.list();
|
||||
if (CollectionUtil.isEmpty(saasRoleUserRelations)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return saasRoleUserRelations.stream().map(e -> BeanUtil.copyProperties(e, SaasRoleUserRelationDTO.class)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user