|
|
@@ -30,24 +30,26 @@ public class StorePlatformUserRoleController {
|
|
|
@ApiOperation("根据用户ID查询角色ID列表")
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "int", paramType = "query", required = true)
|
|
|
+ @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "int", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "int", paramType = "query", required = true)
|
|
|
})
|
|
|
@GetMapping("/getRoleIdsByUserId")
|
|
|
- public R<List<Long>> getRoleIdsByUserId(@RequestParam("userId") Integer userId) {
|
|
|
- log.info("StorePlatformUserRoleController.getRoleIdsByUserId?userId={}", userId);
|
|
|
- List<Long> roleIds = storePlatformUserRoleService.getRoleIdsByUserId(userId);
|
|
|
+ public R<List<Long>> getRoleIdsByUserId(@RequestParam("userId") Integer userId, @RequestParam("storeId") Integer storeId) {
|
|
|
+ log.info("StorePlatformUserRoleController.getRoleIdsByUserId?userId={}, storeId={}", userId, storeId);
|
|
|
+ List<Long> roleIds = storePlatformUserRoleService.getRoleIdsByUserId(userId, storeId);
|
|
|
return R.data(roleIds);
|
|
|
}
|
|
|
|
|
|
@ApiOperation("根据角色ID查询用户ID列表")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "roleId", value = "角色ID", dataType = "Long", paramType = "query", required = true)
|
|
|
+ @ApiImplicitParam(name = "roleId", value = "角色ID", dataType = "Long", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "int", paramType = "query", required = true)
|
|
|
})
|
|
|
@GetMapping("/getUserIdsByRoleId")
|
|
|
- public R<List<Integer>> getUserIdsByRoleId(@RequestParam("roleId") Long roleId) {
|
|
|
- log.info("StorePlatformUserRoleController.getUserIdsByRoleId?roleId={}", roleId);
|
|
|
- List<Integer> userIds = storePlatformUserRoleService.getUserIdsByRoleId(roleId);
|
|
|
+ public R<List<Integer>> getUserIdsByRoleId(@RequestParam("roleId") Long roleId, @RequestParam("storeId") Integer storeId) {
|
|
|
+ log.info("StorePlatformUserRoleController.getUserIdsByRoleId?roleId={}, storeId={}", roleId, storeId);
|
|
|
+ List<Integer> userIds = storePlatformUserRoleService.getUserIdsByRoleId(roleId, storeId);
|
|
|
return R.data(userIds);
|
|
|
}
|
|
|
|
|
|
@@ -55,9 +57,9 @@ public class StorePlatformUserRoleController {
|
|
|
@ApiOperationSupport(order = 3)
|
|
|
@PostMapping("/assignRoles")
|
|
|
public R<String> assignRoles(@RequestBody AssignRolesDto assignRolesDto) {
|
|
|
- log.info("StorePlatformUserRoleController.assignRoles?userId={}, roleIds={}",
|
|
|
- assignRolesDto.getUserId(), assignRolesDto.getRoleIds());
|
|
|
- boolean result = storePlatformUserRoleService.assignRoles(assignRolesDto.getUserId(), assignRolesDto.getRoleIds());
|
|
|
+ log.info("StorePlatformUserRoleController.assignRoles?userId={}, roleIds={}, storeId={}",
|
|
|
+ assignRolesDto.getUserId(), assignRolesDto.getRoleIds(), assignRolesDto.getStoreId());
|
|
|
+ boolean result = storePlatformUserRoleService.assignRoles(assignRolesDto.getUserId(), assignRolesDto.getRoleIds(), assignRolesDto.getStoreId());
|
|
|
if (result) {
|
|
|
return R.success("分配成功");
|
|
|
}
|
|
|
@@ -67,12 +69,13 @@ public class StorePlatformUserRoleController {
|
|
|
@ApiOperation("移除用户的所有角色")
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
@ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "int", paramType = "query", required = true)
|
|
|
+ @ApiImplicitParam(name = "userId", value = "用户ID", dataType = "int", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "int", paramType = "query", required = true)
|
|
|
})
|
|
|
@DeleteMapping("/removeAllRoles")
|
|
|
- public R<String> removeAllRoles(@RequestParam("userId") Integer userId) {
|
|
|
- log.info("StorePlatformUserRoleController.removeAllRoles?userId={}", userId);
|
|
|
- boolean result = storePlatformUserRoleService.removeAllRoles(userId);
|
|
|
+ public R<String> removeAllRoles(@RequestParam("userId") Integer userId, @RequestParam("storeId") Integer storeId) {
|
|
|
+ log.info("StorePlatformUserRoleController.removeAllRoles?userId={}, storeId={}", userId, storeId);
|
|
|
+ boolean result = storePlatformUserRoleService.removeAllRoles(userId, storeId);
|
|
|
if (result) {
|
|
|
return R.success("移除成功");
|
|
|
}
|
|
|
@@ -83,18 +86,36 @@ public class StorePlatformUserRoleController {
|
|
|
@ApiOperationSupport(order = 5)
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "userId", value = "用户ID", dataType = "int", paramType = "query", required = true),
|
|
|
- @ApiImplicitParam(name = "roleId", value = "角色ID", dataType = "Long", paramType = "query", required = true)
|
|
|
+ @ApiImplicitParam(name = "roleId", value = "角色ID", dataType = "Long", paramType = "query", required = true),
|
|
|
+ @ApiImplicitParam(name = "storeId", value = "店铺ID", dataType = "int", paramType = "query", required = true)
|
|
|
})
|
|
|
@DeleteMapping("/removeRole")
|
|
|
- public R<String> removeRole(@RequestParam("userId") Integer userId, @RequestParam("roleId") Long roleId) {
|
|
|
- log.info("StorePlatformUserRoleController.removeRole?userId={}, roleId={}", userId, roleId);
|
|
|
- boolean result = storePlatformUserRoleService.removeRole(userId, roleId);
|
|
|
+ public R<String> removeRole(@RequestParam("userId") Integer userId, @RequestParam("roleId") Long roleId, @RequestParam("storeId") Integer storeId) {
|
|
|
+ log.info("StorePlatformUserRoleController.removeRole?userId={}, roleId={}, storeId={}", userId, roleId, storeId);
|
|
|
+ boolean result = storePlatformUserRoleService.removeRole(userId, roleId, storeId);
|
|
|
if (result) {
|
|
|
return R.success("移除成功");
|
|
|
}
|
|
|
return R.fail("移除失败");
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("创建账号并分配角色")
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
+ @PostMapping("/createAccountAndAssignRole")
|
|
|
+ public R<String> createAccountAndAssignRole(@RequestBody CreateAccountDto createAccountDto) {
|
|
|
+ log.info("StorePlatformUserRoleController.createAccountAndAssignRole?phone={}, accountName={}, storeId={}, roleId={}",
|
|
|
+ createAccountDto.getPhone(), createAccountDto.getAccountName(), createAccountDto.getStoreId(), createAccountDto.getRoleId());
|
|
|
+ boolean result = storePlatformUserRoleService.createAccountAndAssignRole(
|
|
|
+ createAccountDto.getPhone(),
|
|
|
+ createAccountDto.getAccountName(),
|
|
|
+ createAccountDto.getStoreId(),
|
|
|
+ createAccountDto.getRoleId());
|
|
|
+ if (result) {
|
|
|
+ return R.success("创建账号并分配角色成功");
|
|
|
+ }
|
|
|
+ return R.fail("创建账号并分配角色失败");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 分配角色请求DTO
|
|
|
*/
|
|
|
@@ -106,6 +127,28 @@ public class StorePlatformUserRoleController {
|
|
|
|
|
|
@ApiModelProperty(value = "角色ID列表", required = true)
|
|
|
private List<Long> roleIds;
|
|
|
+
|
|
|
+ @ApiModelProperty(value = "店铺ID", required = true)
|
|
|
+ private Integer storeId;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建账号请求DTO
|
|
|
+ */
|
|
|
+ @Data
|
|
|
+ @ApiModel(value = "CreateAccountDto", description = "创建账号请求参数")
|
|
|
+ static class CreateAccountDto {
|
|
|
+ @ApiModelProperty(value = "手机号", required = true)
|
|
|
+ private String phone;
|
|
|
+
|
|
|
+ @ApiModelProperty(value = "账号名称")
|
|
|
+ private String accountName;
|
|
|
+
|
|
|
+ @ApiModelProperty(value = "店铺ID", required = true)
|
|
|
+ private Integer storeId;
|
|
|
+
|
|
|
+ @ApiModelProperty(value = "角色ID", required = true)
|
|
|
+ private Long roleId;
|
|
|
}
|
|
|
}
|
|
|
|