From 97bcee429bae93aadeed61b2d4935df2d0ddcc4a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 16 Jun 2022 08:52:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=20AdminUserApi=E3=80=81Socia?= =?UTF-8?q?lUserApi=20=E7=9A=84=20feign=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enums/sms/UserSmsSceneEnum.java | 39 ---------- .../userservice/rpc/sms/UserSmsCodeFeign.java | 21 ----- .../rpc/sms/dto/UserSendSmsCodeReqDTO.java | 37 --------- .../rpc/sms/dto/UserVerifySmsCodeReqDTO.java | 42 ---------- .../config/DatabaseConfiguration.java | 28 ------- .../controller/UserSmsCodeController.java | 32 -------- .../convert/address/UserAddressConvert.java | 36 --------- .../userservice/convert/user/UserConvert.java | 49 ------------ .../service/codegen/CodegenServiceImpl.java | 2 +- .../yudao/module/system/api/dept/DeptApi.java | 6 +- .../yudao/module/system/api/dept/PostApi.java | 2 +- .../module/system/api/dict/DictDataApi.java | 8 +- .../system/api/permission/PermissionApi.java | 12 +-- .../module/system/api/permission/RoleApi.java | 2 +- .../api/sensitiveword/SensitiveWordApi.java | 10 +-- .../module/system/api/sms/SmsSendApi.java | 2 +- .../system/api/social/SocialUserApi.java | 77 +++++++++---------- .../module/system/api/user/AdminUserApi.java | 60 ++++++--------- .../system/api/social/SocialUserApiImpl.java | 28 ++++--- .../system/api/user/AdminUserApiImpl.java | 26 +++---- 20 files changed, 111 insertions(+), 408 deletions(-) delete mode 100644 user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/enums/sms/UserSmsSceneEnum.java delete mode 100644 user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeFeign.java delete mode 100644 user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserSendSmsCodeReqDTO.java delete mode 100644 user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserVerifySmsCodeReqDTO.java delete mode 100644 user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/config/DatabaseConfiguration.java delete mode 100644 user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserSmsCodeController.java delete mode 100644 user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/address/UserAddressConvert.java delete mode 100644 user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/user/UserConvert.java diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/enums/sms/UserSmsSceneEnum.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/enums/sms/UserSmsSceneEnum.java deleted file mode 100644 index 72952da81..000000000 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/enums/sms/UserSmsSceneEnum.java +++ /dev/null @@ -1,39 +0,0 @@ -package cn.iocoder.mall.userservice.enums.sms; - -import cn.iocoder.common.framework.core.IntArrayValuable; - -import java.util.Arrays; - -/** - * 用户短信验证码发送场景的枚举 - */ -public enum UserSmsSceneEnum implements IntArrayValuable { - - LOGIN_BY_SMS(1, "手机号登陆"), - CHANGE_MOBILE_BY_SMS(2, "更换手机号"), - ; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(UserSmsSceneEnum::getValue).toArray(); - - private final Integer value; - private final String name; - - UserSmsSceneEnum(Integer value, String name) { - this.value = value; - this.name = name; - } - - @Override - public int[] array() { - return ARRAYS; - } - - public Integer getValue() { - return value; - } - - public String getName() { - return name; - } - -} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeFeign.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeFeign.java deleted file mode 100644 index eeb92be5e..000000000 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/UserSmsCodeFeign.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.mall.userservice.rpc.sms; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; -import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -/** - * 用户短信验证码 Rpc 接口 - */ -@FeignClient("user-service") -public interface UserSmsCodeFeign { - @PostMapping("/user/sms/sendSmsCode") - public CommonResult sendSmsCode(@RequestBody UserSendSmsCodeReqDTO sendSmsCodeDTO) ; - - @PostMapping("/user/sms/sverifySmsCode") - public CommonResult verifySmsCode(@RequestBody UserVerifySmsCodeReqDTO verifySmsCodeDTO); - -} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserSendSmsCodeReqDTO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserSendSmsCodeReqDTO.java deleted file mode 100644 index 67d1a39fe..000000000 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserSendSmsCodeReqDTO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.mall.userservice.rpc.sms.dto; - -import cn.iocoder.common.framework.validator.InEnum; -import cn.iocoder.mall.userservice.enums.sms.UserSmsSceneEnum; -import lombok.Builder; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -/** - * 用户发送短信验证码 Request DTO - */ -@Data -@Accessors(chain = true) -@Builder -public class UserSendSmsCodeReqDTO implements Serializable { - - /** - * 手机号码 - */ - @NotNull(message = "手机号码不能为空") - private String mobile; - /** - * IP - */ - @NotNull(message = "IP 不能为空") - private String ip; - /** - * 发送场景 - */ - @NotNull(message = "发送场景不能为空") - @InEnum(value = UserSmsSceneEnum.class, message = "发送场景不能为空") - private Integer scene; - -} diff --git a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserVerifySmsCodeReqDTO.java b/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserVerifySmsCodeReqDTO.java deleted file mode 100644 index 4eda0bfd2..000000000 --- a/user-service-project/user-service-api/src/main/java/cn/iocoder/mall/userservice/rpc/sms/dto/UserVerifySmsCodeReqDTO.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.mall.userservice.rpc.sms.dto; - -import cn.iocoder.common.framework.validator.InEnum; -import cn.iocoder.mall.userservice.enums.sms.UserSmsSceneEnum; -import lombok.Builder; -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; -import java.io.Serializable; - -/** - * 用户校验验证码 Request DTO - */ -@Data -@Accessors(chain = true) -@Builder -public class UserVerifySmsCodeReqDTO implements Serializable { - - /** - * 手机号码 - */ - @NotNull(message = "手机号码不能为空") - private String mobile; - /** - * IP - */ - @NotNull(message = "IP 不能为空") - private String ip; - /** - * 发送场景 - */ - @NotNull(message = "发送场景不能为空") - @InEnum(value = UserSmsSceneEnum.class, message = "发送场景不能为空") - private Integer scene; - /** - * 验证码 - */ - @NotNull(message = "验证码不能为空") - private String code; - -} diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/config/DatabaseConfiguration.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/config/DatabaseConfiguration.java deleted file mode 100644 index 3e70da644..000000000 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/config/DatabaseConfiguration.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.iocoder.mall.userservice.config; - -import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; -import com.baomidou.mybatisplus.core.injector.ISqlInjector; -import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@MapperScan("cn.iocoder.mall.userservice.dal.mysql.mapper") // 扫描对应的 Mapper 接口 -@EnableTransactionManagement(proxyTargetClass = true) // 启动事务管理。 -public class DatabaseConfiguration { - - // 数据库连接池 Druid - - @Bean - public ISqlInjector sqlInjector() { - return new DefaultSqlInjector(); // MyBatis Plus 逻辑删除 - } - - @Bean - public PaginationInterceptor paginationInterceptor() { - return new PaginationInterceptor(); // MyBatis Plus 分页插件 - } - -} diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserSmsCodeController.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserSmsCodeController.java deleted file mode 100644 index 5a3c2dec0..000000000 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/controller/UserSmsCodeController.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.mall.userservice.controller; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.userservice.manager.sms.UserSmsCodeManager; -import cn.iocoder.mall.userservice.rpc.sms.dto.UserSendSmsCodeReqDTO; -import cn.iocoder.mall.userservice.rpc.sms.dto.UserVerifySmsCodeReqDTO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/user/sms") -public class UserSmsCodeController { - - @Autowired - private UserSmsCodeManager userSmsCodeManager; - - @PostMapping("sendSmsCode") - public CommonResult sendSmsCode(@RequestBody UserSendSmsCodeReqDTO sendSmsCodeDTO) { - userSmsCodeManager.sendSmsCode(sendSmsCodeDTO); - return CommonResult.success(true); - } - - @PostMapping("verifySmsCode") - public CommonResult verifySmsCode(@RequestBody UserVerifySmsCodeReqDTO verifySmsCodeDTO) { - userSmsCodeManager.verifySmsCode(verifySmsCodeDTO); - return CommonResult.success(true); - } - -} \ No newline at end of file diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/address/UserAddressConvert.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/address/UserAddressConvert.java deleted file mode 100644 index 607b0dfd1..000000000 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/address/UserAddressConvert.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.iocoder.mall.userservice.convert.address; - -import cn.iocoder.mall.userservice.dal.mysql.dataobject.address.UserAddressDO; -import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressCreateReqDTO; -import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressRespDTO; -import cn.iocoder.mall.userservice.rpc.address.dto.UserAddressUpdateReqDTO; -import cn.iocoder.mall.userservice.service.address.bo.UserAddressBO; -import cn.iocoder.mall.userservice.service.address.bo.UserAddressCreateBO; -import cn.iocoder.mall.userservice.service.address.bo.UserAddressUpdateBO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface UserAddressConvert { - - UserAddressConvert INSTANCE = Mappers.getMapper(UserAddressConvert.class); - - UserAddressDO convert(UserAddressCreateBO bean); - - UserAddressBO convert(UserAddressDO bean); - - UserAddressDO convert(UserAddressUpdateBO bean); - - List convertList(List list); - - UserAddressCreateBO convert(UserAddressCreateReqDTO bean); - - UserAddressUpdateBO convert(UserAddressUpdateReqDTO bean); - - UserAddressRespDTO convert(UserAddressBO bean); - - List convertList02(List list); - -} diff --git a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/user/UserConvert.java b/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/user/UserConvert.java deleted file mode 100644 index 0a92402f7..000000000 --- a/user-service-project/user-service-app/src/main/java/cn/iocoder/mall/userservice/convert/user/UserConvert.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.mall.userservice.convert.user; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.userservice.rpc.user.dto.UserCreateReqDTO; -import cn.iocoder.mall.userservice.rpc.user.dto.UserPageReqDTO; -import cn.iocoder.mall.userservice.rpc.user.dto.UserUpdateReqDTO; -import cn.iocoder.mall.userservice.service.user.bo.UserBO; -import cn.iocoder.mall.userservice.dal.mysql.dataobject.user.UserDO; -import cn.iocoder.mall.userservice.rpc.user.dto.UserRespDTO; -import cn.iocoder.mall.userservice.service.user.bo.UserCreateBO; -import cn.iocoder.mall.userservice.service.user.bo.UserPageBO; -import cn.iocoder.mall.userservice.service.user.bo.UserUpdateBO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface UserConvert { - - UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); - - UserRespDTO convert(UserBO bean); - - UserBO convert(UserDO bean); - - UserDO convert(UserCreateBO bean); - - @Mapping(source = "ip", target = "createIp") - UserCreateBO convert(UserCreateReqDTO bean); - - UserDO convert(UserUpdateBO bean); - - @Mapping(source = "records", target = "list") - PageResult convertPage(IPage page); - - UserUpdateBO convert(UserUpdateReqDTO bean); - - List convertList(List list); - - UserPageBO convert(UserPageReqDTO bean); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java index 333dbefa6..e3a1dd862 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/codegen/CodegenServiceImpl.java @@ -86,7 +86,7 @@ public class CodegenServiceImpl implements CodegenService { CodegenTableDO table = codegenBuilder.buildTable(tableInfo); table.setDataSourceConfigId(dataSourceConfigId); table.setScene(CodegenSceneEnum.ADMIN.getScene()); // 默认配置下,使用管理后台的模板 - table.setAuthor(userApi.getUser(userId).getNickname()); + table.setAuthor(userApi.getUser(userId).getData().getNickname()); codegenTableMapper.insert(table); // 构建 CodegenColumnDO 数组,插入到 DB 中 diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java index dbee645d2..ef583bcb2 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java @@ -24,16 +24,16 @@ public interface DeptApi { @GetMapping(PREFIX + "/get") @ApiOperation("获得部门信息") - @ApiImplicitParam(name = "id", value = "部门编号", required = true, dataTypeClass = Long.class) + @ApiImplicitParam(name = "id", value = "部门编号", example = "1024", required = true, dataTypeClass = Long.class) CommonResult getDept(@RequestParam("id") Long id); @GetMapping(PREFIX + "/list") @ApiOperation("获得部门信息数组") - @ApiImplicitParam(name = "ids", value = "部门编号数组", required = true, allowMultiple = true) + @ApiImplicitParam(name = "ids", value = "部门编号数组", example = "1,2", required = true, allowMultiple = true) CommonResult> getDepts(@RequestParam("ids") Collection ids); @GetMapping(PREFIX + "/valid") - @ApiImplicitParam(name = "ids", value = "部门编号数组", required = true, allowMultiple = true) + @ApiImplicitParam(name = "ids", value = "部门编号数组", example = "1,2", required = true, allowMultiple = true) CommonResult validDepts(@RequestParam("ids") Collection ids); /** diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java index 1f126ef65..0532d7524 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/PostApi.java @@ -17,7 +17,7 @@ public interface PostApi { String PREFIX = ApiConstants.PREFIX + "/post"; @GetMapping(PREFIX + "/valid") - @ApiImplicitParam(name = "ids", value = "部门编号数组", required = true, allowMultiple = true) + @ApiImplicitParam(name = "ids", value = "部门编号数组", example = "1,2", required = true, allowMultiple = true) CommonResult validPosts(@RequestParam("ids") Collection ids); } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java index 0b44c306e..4455da3af 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dict/DictDataApi.java @@ -8,6 +8,7 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; import java.util.Collection; @@ -20,9 +21,10 @@ public interface DictDataApi { @GetMapping(PREFIX + "/valid") @ApiOperation("校验字典数据们是否有效") @ApiImplicitParams({ - @ApiImplicitParam(name = "dictType", value = "字典类型", required = true, dataTypeClass = String.class), - @ApiImplicitParam(name = "values", value = "字典数据值的数组", required = true, allowMultiple = true) + @ApiImplicitParam(name = "dictType", value = "字典类型", example = "SEX", required = true, dataTypeClass = String.class), + @ApiImplicitParam(name = "values", value = "字典数据值的数组", example = "1,2", required = true, allowMultiple = true) }) - CommonResult validDictDatas(String dictType, Collection values); + CommonResult validDictDatas(@RequestParam("dictType") String dictType, + @RequestParam("values") Collection values); } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/PermissionApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/PermissionApi.java index 85914629b..a316afc74 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/PermissionApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/PermissionApi.java @@ -22,14 +22,14 @@ public interface PermissionApi { @GetMapping(PREFIX + "/user-role-id-list-by-role-id") @ApiOperation("获得拥有多个角色的用户编号集合") - @ApiImplicitParam(name = "roleIds", value = "角色编号集合", required = true, allowMultiple = true) + @ApiImplicitParam(name = "roleIds", value = "角色编号集合", example = "1,2", required = true, allowMultiple = true) CommonResult> getUserRoleIdListByRoleIds(@RequestParam("roleIds") Collection roleIds); @GetMapping(PREFIX + "/has-any-permissions") @ApiOperation("判断是否有权限,任一一个即可") @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataTypeClass = Long.class), - @ApiImplicitParam(name = "permissions", value = "权限", required = true, allowMultiple = true) + @ApiImplicitParam(name = "userId", value = "用户编号", example = "1", required = true, dataTypeClass = Long.class), + @ApiImplicitParam(name = "permissions", value = "权限", example = "read,write", required = true, allowMultiple = true) }) CommonResult hasAnyPermissions(@RequestParam("userId") Long userId, @RequestParam("permissions") String... permissions); @@ -37,15 +37,15 @@ public interface PermissionApi { @GetMapping(PREFIX + "/has-any-roles") @ApiOperation("判断是否有角色,任一一个即可") @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataTypeClass = Long.class), - @ApiImplicitParam(name = "roles", value = "角色数组", required = true, allowMultiple = true) + @ApiImplicitParam(name = "userId", value = "用户编号", example = "1", required = true, dataTypeClass = Long.class), + @ApiImplicitParam(name = "roles", value = "角色数组", example = "2", required = true, allowMultiple = true) }) CommonResult hasAnyRoles(@RequestParam("userId") Long userId, @RequestParam("roles") String... roles); @GetMapping(PREFIX + "/get-dept-data-permission") @ApiOperation("获得登陆用户的部门数据权限") - @ApiImplicitParam(name = "userId", value = "部门数据权限", required = true, dataTypeClass = Long.class) + @ApiImplicitParam(name = "userId", value = "用户编号", example = "2", required = true, dataTypeClass = Long.class) CommonResult getDeptDataPermission(@RequestParam("userId") Long userId); } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java index d70eb22c7..2f5d4f3b3 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/RoleApi.java @@ -17,7 +17,7 @@ public interface RoleApi { String PREFIX = ApiConstants.PREFIX + "/role"; @GetMapping(PREFIX + "/valid") - @ApiImplicitParam(name = "ids", value = "角色编号数组", required = true, allowMultiple = true) + @ApiImplicitParam(name = "ids", value = "角色编号数组", example = "1,2", required = true, allowMultiple = true) CommonResult validRoles(@RequestParam("ids") Collection ids); } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sensitiveword/SensitiveWordApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sensitiveword/SensitiveWordApi.java index 53de7d0d0..916d09a91 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sensitiveword/SensitiveWordApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sensitiveword/SensitiveWordApi.java @@ -16,13 +16,13 @@ import java.util.List; @Api(tags = "RPC 服务 - 敏感词") public interface SensitiveWordApi { - String PREFIX = ApiConstants.PREFIX + "/oauth2/sensitive-word"; + String PREFIX = ApiConstants.PREFIX + "/sensitive-word"; @GetMapping(PREFIX + "/validate-text") @ApiOperation("获得文本所包含的不合法的敏感词数组") @ApiImplicitParams({ - @ApiImplicitParam(name = "text", value = "文本", required = true, dataTypeClass = String.class), - @ApiImplicitParam(name = "tags", value = "标签数组", required = true, allowMultiple = true) + @ApiImplicitParam(name = "text", value = "文本", example = "傻瓜", required = true, dataTypeClass = String.class), + @ApiImplicitParam(name = "tags", value = "标签数组", example = "product,life", required = true, allowMultiple = true) }) CommonResult> validateText(@RequestParam("text") String text, @RequestParam("tags") List tags); @@ -30,8 +30,8 @@ public interface SensitiveWordApi { @GetMapping(PREFIX + "/is-text-valid") @ApiOperation("判断文本是否包含敏感词") @ApiImplicitParams({ - @ApiImplicitParam(name = "text", value = "文本", required = true, dataTypeClass = String.class), - @ApiImplicitParam(name = "tags", value = "标签数组", required = true, allowMultiple = true) + @ApiImplicitParam(name = "text", value = "文本", example = "傻瓜", required = true, dataTypeClass = String.class), + @ApiImplicitParam(name = "tags", value = "标签数组", example = "product,life", required = true, allowMultiple = true) }) CommonResult isTextValid(@RequestParam("text") String text, @RequestParam("tags") List tags); diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsSendApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsSendApi.java index 5514bc01d..59a02b9ae 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsSendApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/sms/SmsSendApi.java @@ -15,7 +15,7 @@ import javax.validation.Valid; @Api(tags = "RPC 服务 - 短信发送") public interface SmsSendApi { - String PREFIX = ApiConstants.PREFIX + "/oauth2/sms/send"; + String PREFIX = ApiConstants.PREFIX + "/sms/send"; @PostMapping(PREFIX + "/send-single-admin") @ApiOperation(value = "发送单条短信给 Admin 用户", notes = "在 mobile 为空时,使用 userId 加载对应 Admin 的手机号") diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApi.java index 5d42731c2..faf7f8162 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApi.java @@ -1,53 +1,52 @@ package cn.iocoder.yudao.module.system.api.social; -import cn.iocoder.yudao.framework.common.exception.ServiceException; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO; -import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; +import cn.iocoder.yudao.module.system.enums.ApiConstants; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; -/** - * 社交用户的 API 接口 - * - * @author 芋道源码 - */ +@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory = +@Api(tags = "RPC 服务 - 社交用户的") public interface SocialUserApi { - /** - * 获得社交平台的授权 URL - * - * @param type 社交平台的类型 {@link SocialTypeEnum} - * @param redirectUri 重定向 URL - * @return 社交平台的授权 URL - */ - String getAuthorizeUrl(Integer type, String redirectUri); + String PREFIX = ApiConstants.PREFIX + "/social-user"; - /** - * 绑定社交用户 - * - * @param reqDTO 绑定信息 - */ - void bindSocialUser(@Valid SocialUserBindReqDTO reqDTO); + @GetMapping("/get-authorize-url") + @ApiOperation("获得社交平台的授权 URL") + @ApiImplicitParams({ + @ApiImplicitParam(name = "type", value = "社交平台的类型", example = "1", required = true, dataTypeClass = Integer.class), + @ApiImplicitParam(name = "redirectUri", value = "重定向 URL", example = "https://www.iocoder.cn",required = true, dataTypeClass = String.class) + }) + CommonResult getAuthorizeUrl(@RequestParam("type") Integer type, + @RequestParam("redirectUri") String redirectUri); - /** - * 取消绑定社交用户 - * - * @param reqDTO 解绑 - */ - void unbindSocialUser(@Valid SocialUserUnbindReqDTO reqDTO); + @PostMapping("/bind") + @ApiOperation("绑定社交用户") + CommonResult bindSocialUser(@Valid @RequestBody SocialUserBindReqDTO reqDTO); - /** - * 获得社交用户的绑定用户编号 - * 注意,返回的是 MemberUser 或者 AdminUser 的 id 编号! - * 在认证信息不正确的情况下,也会抛出 {@link ServiceException} 业务异常 - * - * @param userType 用户类型 - * @param type 社交平台的类型 - * @param code 授权码 - * @param state state - * @return 绑定用户编号 - */ - Long getBindUserId(Integer userType, Integer type, String code, String state); + @DeleteMapping("/unbind") + @ApiOperation("取消绑定社交用户") + CommonResult unbindSocialUser(@Valid @RequestBody SocialUserUnbindReqDTO reqDTO); + + @GetMapping("/get-bind-user-id") + @ApiOperation("获得社交用户的绑定用户编号") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userType", value = "用户类型", example = "2", required = true, dataTypeClass = Integer.class), + @ApiImplicitParam(name = "type", value = "社交平台的类型", example = "1", required = true, dataTypeClass = Integer.class), + @ApiImplicitParam(name = "code", value = "授权码", required = true, example = "tudou", dataTypeClass = String.class), + @ApiImplicitParam(name = "state", value = "state", required = true, example = "coke", dataTypeClass = String.class) + }) + CommonResult getBindUserId(@RequestParam("userType") Integer userType, + @RequestParam("type") Integer type, + @RequestParam("code") String code, + @RequestParam("state") String state); } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java index dc35a3222..91dd07dfd 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApi.java @@ -1,11 +1,15 @@ package cn.iocoder.yudao.module.system.api.user; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.enums.ApiConstants; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; import java.util.Collection; import java.util.List; @@ -18,41 +22,25 @@ public interface AdminUserApi { String PREFIX = ApiConstants.PREFIX + "/user"; - /** - * 通过用户 ID 查询用户 - * - * @param id 用户ID - * @return 用户对象信息 - */ @GetMapping(PREFIX + "/get") - AdminUserRespDTO getUser(Long id); + @ApiOperation("通过用户 ID 查询用户") + @ApiImplicitParam(name = "id", value = "用户编号", example = "1", required = true, dataTypeClass = Long.class) + CommonResult getUser(@RequestParam("id") Long id); - /** - * 通过用户 ID 查询用户们 - * - * @param ids 用户 ID 们 - * @return 用户对象信息 - */ @GetMapping(PREFIX + "/list") - List getUsers(Collection ids); + @ApiOperation("通过用户 ID 查询用户们") + @ApiImplicitParam(name = "ids", value = "部门编号数组", example = "1,2", required = true, allowMultiple = true) + CommonResult> getUsers(@RequestParam("ids") Collection ids); - /** - * 获得指定部门的用户数组 - * - * @param deptIds 部门数组 - * @return 用户数组 - */ @GetMapping(PREFIX + "/list-by-dept-id") - List getUsersByDeptIds(Collection deptIds); + @ApiOperation("获得指定部门的用户数组") + @ApiImplicitParam(name = "deptIds", value = "部门编号数组", example = "1,2", required = true, allowMultiple = true) + CommonResult> getUsersByDeptIds(@RequestParam("deptIds") Collection deptIds); - /** - * 获得指定岗位的用户数组 - * - * @param postIds 岗位数组 - * @return 用户数组 - */ @GetMapping(PREFIX + "/list-by-post-id") - List getUsersByPostIds(Collection postIds); + @ApiOperation("获得指定岗位的用户数组") + @ApiImplicitParam(name = "postIds", value = "岗位编号数组", example = "2,3", required = true, allowMultiple = true) + CommonResult> getUsersByPostIds(@RequestParam("postIds") Collection postIds); /** * 获得用户 Map @@ -61,18 +49,14 @@ public interface AdminUserApi { * @return 用户 Map */ default Map getUserMap(Collection ids) { - List users = getUsers(ids); - return CollectionUtils.convertMap(users, AdminUserRespDTO::getId); + CommonResult> getUsersResult = getUsers(ids); + getUsersResult.checkError(); + return CollectionUtils.convertMap(getUsersResult.getData(), AdminUserRespDTO::getId); } - /** - * 校验用户们是否有效。如下情况,视为无效: - * 1. 用户编号不存在 - * 2. 用户被禁用 - * - * @param ids 用户编号数组 - */ @GetMapping(PREFIX + "/valid") - void validUsers(Set ids); + @ApiOperation("校验用户们是否有效") + @ApiImplicitParam(name = "ids", value = "用户编号数组", example = "3,5", required = true) + CommonResult validUsers(@RequestParam("ids") Set ids); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApiImpl.java index ae8903135..66009b22f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/social/SocialUserApiImpl.java @@ -1,19 +1,21 @@ package cn.iocoder.yudao.module.system.api.social; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserUnbindReqDTO; import cn.iocoder.yudao.module.system.service.social.SocialUserService; +import org.apache.dubbo.config.annotation.DubboService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -/** - * 社交用户的 API 实现类 - * - * @author 芋道源码 - */ -@Service +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.module.system.enums.ApiConstants.VERSION; + +@RestController // 提供 RESTful API 接口,给 Feign 调用 +@DubboService(version = VERSION) // 提供 Dubbo RPC 接口,给 Dubbo Consumer 调用 @Validated public class SocialUserApiImpl implements SocialUserApi { @@ -21,24 +23,26 @@ public class SocialUserApiImpl implements SocialUserApi { private SocialUserService socialUserService; @Override - public String getAuthorizeUrl(Integer type, String redirectUri) { - return socialUserService.getAuthorizeUrl(type, redirectUri); + public CommonResult getAuthorizeUrl(Integer type, String redirectUri) { + return success(socialUserService.getAuthorizeUrl(type, redirectUri)); } @Override - public void bindSocialUser(SocialUserBindReqDTO reqDTO) { + public CommonResult bindSocialUser(SocialUserBindReqDTO reqDTO) { socialUserService.bindSocialUser(reqDTO); + return success(true); } @Override - public void unbindSocialUser(SocialUserUnbindReqDTO reqDTO) { + public CommonResult unbindSocialUser(SocialUserUnbindReqDTO reqDTO) { socialUserService.unbindSocialUser(reqDTO.getUserId(), reqDTO.getUserType(), reqDTO.getType(), reqDTO.getUnionId()); + return success(true); } @Override - public Long getBindUserId(Integer userType, Integer type, String code, String state) { - return socialUserService.getBindUserId(userType, type, code, state); + public CommonResult getBindUserId(Integer userType, Integer type, String code, String state) { + return success(socialUserService.getBindUserId(userType, type, code, state)); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java index 540a35655..0351c94fd 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.api.user; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.convert.user.UserConvert; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; @@ -14,13 +15,9 @@ import java.util.Collection; import java.util.List; import java.util.Set; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.module.system.enums.ApiConstants.VERSION; -/** - * Admin 用户 API 实现类 - * - * @author 芋道源码 - */ @RestController // 提供 RESTful API 接口,给 Feign 调用 @DubboService(version = VERSION) // 提供 Dubbo RPC 接口,给 Dubbo Consumer 调用 @Validated @@ -30,32 +27,33 @@ public class AdminUserApiImpl implements AdminUserApi { private AdminUserService userService; @Override - public AdminUserRespDTO getUser(Long id) { + public CommonResult getUser(Long id) { AdminUserDO user = userService.getUser(id); - return UserConvert.INSTANCE.convert4(user); + return success(UserConvert.INSTANCE.convert4(user)); } @Override - public List getUsers(Collection ids) { + public CommonResult> getUsers(Collection ids) { List users = userService.getUsers(ids); - return UserConvert.INSTANCE.convertList4(users); + return success(UserConvert.INSTANCE.convertList4(users)); } @Override - public List getUsersByDeptIds(Collection deptIds) { + public CommonResult> getUsersByDeptIds(Collection deptIds) { List users = userService.getUsersByDeptIds(deptIds); - return UserConvert.INSTANCE.convertList4(users); + return success(UserConvert.INSTANCE.convertList4(users)); } @Override - public List getUsersByPostIds(Collection postIds) { + public CommonResult> getUsersByPostIds(Collection postIds) { List users = userService.getUsersByPostIds(postIds); - return UserConvert.INSTANCE.convertList4(users); + return success(UserConvert.INSTANCE.convertList4(users)); } @Override - public void validUsers(Set ids) { + public CommonResult validUsers(Set ids) { userService.validUsers(ids); + return success(true); } }