完成 AdminUserApi、SocialUserApi 的 feign 支持

pull/4/head
YunaiV 2022-06-16 08:52:05 +08:00
parent cca4c9fceb
commit 97bcee429b
20 changed files with 111 additions and 408 deletions

View File

@ -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;
}
}

View File

@ -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<Boolean> sendSmsCode(@RequestBody UserSendSmsCodeReqDTO sendSmsCodeDTO) ;
@PostMapping("/user/sms/sverifySmsCode")
public CommonResult<Boolean> verifySmsCode(@RequestBody UserVerifySmsCodeReqDTO verifySmsCodeDTO);
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 分页插件
}
}

View File

@ -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<Boolean> sendSmsCode(@RequestBody UserSendSmsCodeReqDTO sendSmsCodeDTO) {
userSmsCodeManager.sendSmsCode(sendSmsCodeDTO);
return CommonResult.success(true);
}
@PostMapping("verifySmsCode")
public CommonResult<Boolean> verifySmsCode(@RequestBody UserVerifySmsCodeReqDTO verifySmsCodeDTO) {
userSmsCodeManager.verifySmsCode(verifySmsCodeDTO);
return CommonResult.success(true);
}
}

View File

@ -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<UserAddressBO> convertList(List<UserAddressDO> list);
UserAddressCreateBO convert(UserAddressCreateReqDTO bean);
UserAddressUpdateBO convert(UserAddressUpdateReqDTO bean);
UserAddressRespDTO convert(UserAddressBO bean);
List<UserAddressRespDTO> convertList02(List<UserAddressBO> list);
}

View File

@ -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<UserBO> convertPage(IPage<UserDO> page);
UserUpdateBO convert(UserUpdateReqDTO bean);
List<UserBO> convertList(List<UserDO> list);
UserPageBO convert(UserPageReqDTO bean);
PageResult<UserRespDTO> convertPage(PageResult<UserBO> page);
List<UserRespDTO> convertList02(List<UserBO> list);
}

View File

@ -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 中

View File

@ -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<DeptRespDTO> 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<List<DeptRespDTO>> getDepts(@RequestParam("ids") Collection<Long> ids);
@GetMapping(PREFIX + "/valid")
@ApiImplicitParam(name = "ids", value = "部门编号数组", required = true, allowMultiple = true)
@ApiImplicitParam(name = "ids", value = "部门编号数组", example = "1,2", required = true, allowMultiple = true)
CommonResult<Boolean> validDepts(@RequestParam("ids") Collection<Long> ids);
/**

View File

@ -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<Boolean> validPosts(@RequestParam("ids") Collection<Long> ids);
}

View File

@ -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<Boolean> validDictDatas(String dictType, Collection<String> values);
CommonResult<Boolean> validDictDatas(@RequestParam("dictType") String dictType,
@RequestParam("values") Collection<String> values);
}

View File

@ -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<Set<Long>> getUserRoleIdListByRoleIds(@RequestParam("roleIds") Collection<Long> 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<Boolean> 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<Boolean> 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<DeptDataPermissionRespDTO> getDeptDataPermission(@RequestParam("userId") Long userId);
}

View File

@ -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<Boolean> validRoles(@RequestParam("ids") Collection<Long> ids);
}

View File

@ -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<List<String>> validateText(@RequestParam("text") String text,
@RequestParam("tags") List<String> 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<Boolean> isTextValid(@RequestParam("text") String text,
@RequestParam("tags") List<String> tags);

View File

@ -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 的手机号")

View File

@ -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<String> getAuthorizeUrl(@RequestParam("type") Integer type,
@RequestParam("redirectUri") String redirectUri);
/**
*
*
* @param reqDTO
*/
void unbindSocialUser(@Valid SocialUserUnbindReqDTO reqDTO);
@PostMapping("/bind")
@ApiOperation("绑定社交用户")
CommonResult<Boolean> 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<Boolean> 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<Long> getBindUserId(@RequestParam("userType") Integer userType,
@RequestParam("type") Integer type,
@RequestParam("code") String code,
@RequestParam("state") String state);
}

View File

@ -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<AdminUserRespDTO> getUser(@RequestParam("id") Long id);
/**
* ID
*
* @param ids ID
* @return
*/
@GetMapping(PREFIX + "/list")
List<AdminUserRespDTO> getUsers(Collection<Long> ids);
@ApiOperation("通过用户 ID 查询用户们")
@ApiImplicitParam(name = "ids", value = "部门编号数组", example = "1,2", required = true, allowMultiple = true)
CommonResult<List<AdminUserRespDTO>> getUsers(@RequestParam("ids") Collection<Long> ids);
/**
*
*
* @param deptIds
* @return
*/
@GetMapping(PREFIX + "/list-by-dept-id")
List<AdminUserRespDTO> getUsersByDeptIds(Collection<Long> deptIds);
@ApiOperation("获得指定部门的用户数组")
@ApiImplicitParam(name = "deptIds", value = "部门编号数组", example = "1,2", required = true, allowMultiple = true)
CommonResult<List<AdminUserRespDTO>> getUsersByDeptIds(@RequestParam("deptIds") Collection<Long> deptIds);
/**
*
*
* @param postIds
* @return
*/
@GetMapping(PREFIX + "/list-by-post-id")
List<AdminUserRespDTO> getUsersByPostIds(Collection<Long> postIds);
@ApiOperation("获得指定岗位的用户数组")
@ApiImplicitParam(name = "postIds", value = "岗位编号数组", example = "2,3", required = true, allowMultiple = true)
CommonResult<List<AdminUserRespDTO>> getUsersByPostIds(@RequestParam("postIds") Collection<Long> postIds);
/**
* Map
@ -61,18 +49,14 @@ public interface AdminUserApi {
* @return Map
*/
default Map<Long, AdminUserRespDTO> getUserMap(Collection<Long> ids) {
List<AdminUserRespDTO> users = getUsers(ids);
return CollectionUtils.convertMap(users, AdminUserRespDTO::getId);
CommonResult<List<AdminUserRespDTO>> getUsersResult = getUsers(ids);
getUsersResult.checkError();
return CollectionUtils.convertMap(getUsersResult.getData(), AdminUserRespDTO::getId);
}
/**
*
* 1.
* 2.
*
* @param ids
*/
@GetMapping(PREFIX + "/valid")
void validUsers(Set<Long> ids);
@ApiOperation("校验用户们是否有效")
@ApiImplicitParam(name = "ids", value = "用户编号数组", example = "3,5", required = true)
CommonResult<Boolean> validUsers(@RequestParam("ids") Set<Long> ids);
}

View File

@ -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<String> getAuthorizeUrl(Integer type, String redirectUri) {
return success(socialUserService.getAuthorizeUrl(type, redirectUri));
}
@Override
public void bindSocialUser(SocialUserBindReqDTO reqDTO) {
public CommonResult<Boolean> bindSocialUser(SocialUserBindReqDTO reqDTO) {
socialUserService.bindSocialUser(reqDTO);
return success(true);
}
@Override
public void unbindSocialUser(SocialUserUnbindReqDTO reqDTO) {
public CommonResult<Boolean> 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<Long> getBindUserId(Integer userType, Integer type, String code, String state) {
return success(socialUserService.getBindUserId(userType, type, code, state));
}
}

View File

@ -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<AdminUserRespDTO> getUser(Long id) {
AdminUserDO user = userService.getUser(id);
return UserConvert.INSTANCE.convert4(user);
return success(UserConvert.INSTANCE.convert4(user));
}
@Override
public List<AdminUserRespDTO> getUsers(Collection<Long> ids) {
public CommonResult<List<AdminUserRespDTO>> getUsers(Collection<Long> ids) {
List<AdminUserDO> users = userService.getUsers(ids);
return UserConvert.INSTANCE.convertList4(users);
return success(UserConvert.INSTANCE.convertList4(users));
}
@Override
public List<AdminUserRespDTO> getUsersByDeptIds(Collection<Long> deptIds) {
public CommonResult<List<AdminUserRespDTO>> getUsersByDeptIds(Collection<Long> deptIds) {
List<AdminUserDO> users = userService.getUsersByDeptIds(deptIds);
return UserConvert.INSTANCE.convertList4(users);
return success(UserConvert.INSTANCE.convertList4(users));
}
@Override
public List<AdminUserRespDTO> getUsersByPostIds(Collection<Long> postIds) {
public CommonResult<List<AdminUserRespDTO>> getUsersByPostIds(Collection<Long> postIds) {
List<AdminUserDO> users = userService.getUsersByPostIds(postIds);
return UserConvert.INSTANCE.convertList4(users);
return success(UserConvert.INSTANCE.convertList4(users));
}
@Override
public void validUsers(Set<Long> ids) {
public CommonResult<Boolean> validUsers(Set<Long> ids) {
userService.validUsers(ids);
return success(true);
}
}