用户同步接口
This commit is contained in:
@@ -199,4 +199,11 @@ public class AuthController {
|
|||||||
return success(authService.socialLogin(reqVO));
|
return success(authService.socialLogin(reqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/api/user-add")
|
||||||
|
@PermitAll
|
||||||
|
@Operation(summary = "同步用户")
|
||||||
|
public CommonResult<Boolean> synchronize(@RequestBody @Valid UserReqVO reqVO) {
|
||||||
|
return success(authService.synchronize(reqVO));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.auth.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Schema(description = "同步用户")
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class UserReqVO {
|
||||||
|
/**
|
||||||
|
* 用户昵称
|
||||||
|
*/
|
||||||
|
private String nickname;
|
||||||
|
/**
|
||||||
|
* 手机号码
|
||||||
|
*/
|
||||||
|
private String phone;
|
||||||
|
}
|
||||||
@@ -64,6 +64,10 @@ public class UserSaveReqVO {
|
|||||||
@DiffLogField(name = "用户头像")
|
@DiffLogField(name = "用户头像")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
|
private Integer isSynchronize;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
// ========== 仅【创建】时,需要传递的字段 ==========
|
// ========== 仅【创建】时,需要传递的字段 ==========
|
||||||
|
|
||||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "123456")
|
||||||
|
|||||||
@@ -98,4 +98,5 @@ public class AdminUserDO extends TenantBaseDO {
|
|||||||
private String unionid;
|
private String unionid;
|
||||||
private String miniProgramAvatar;
|
private String miniProgramAvatar;
|
||||||
private String miniProgramNickname;
|
private String miniProgramNickname;
|
||||||
|
private Integer isSynchronize;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,4 +92,6 @@ public interface AdminAuthService {
|
|||||||
String getAccessToken();
|
String getAccessToken();
|
||||||
|
|
||||||
AuthLoginRespVO getPhoneNumber(@Valid WxLoginReqVO reqVO);
|
AuthLoginRespVO getPhoneNumber(@Valid WxLoginReqVO reqVO);
|
||||||
|
|
||||||
|
Boolean synchronize(@Valid UserReqVO reqVO);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
|
|||||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
|
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO;
|
||||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*;
|
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
|
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
@@ -365,6 +366,25 @@ public class AdminAuthServiceImpl implements AdminAuthService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean synchronize(UserReqVO reqVO) {
|
||||||
|
AdminUserDO userByMobile = userService.getUserByMobile(reqVO.getPhone());
|
||||||
|
if (userByMobile == null) {
|
||||||
|
UserSaveReqVO adminUserDO = new UserSaveReqVO();
|
||||||
|
adminUserDO.setMobile(reqVO.getPhone());
|
||||||
|
adminUserDO.setNickname(reqVO.getNickname());
|
||||||
|
adminUserDO.setUsername(reqVO.getPhone());
|
||||||
|
adminUserDO.setStatus(CommonStatusEnum.DISABLE.getStatus());
|
||||||
|
adminUserDO.setPassword("123456");
|
||||||
|
adminUserDO.setIsSynchronize(1);
|
||||||
|
userService.createUser(adminUserDO);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解密微信小程序数据
|
* 解密微信小程序数据
|
||||||
* 根据微信官方文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html
|
* 根据微信官方文档:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/signature.html
|
||||||
|
|||||||
@@ -105,7 +105,9 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||||||
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds());
|
createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds());
|
||||||
// 2.1 插入用户
|
// 2.1 插入用户
|
||||||
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class);
|
||||||
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
if(user.getStatus()==null){
|
||||||
|
user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启
|
||||||
|
}
|
||||||
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码
|
user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码
|
||||||
userMapper.insert(user);
|
userMapper.insert(user);
|
||||||
// 2.2 插入关联岗位
|
// 2.2 插入关联岗位
|
||||||
|
|||||||
@@ -70,9 +70,9 @@ mybatis-plus:
|
|||||||
global-config:
|
global-config:
|
||||||
db-config:
|
db-config:
|
||||||
id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。
|
id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。
|
||||||
# id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库
|
# id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库
|
||||||
# id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库
|
# id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库
|
||||||
# id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解
|
# id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解
|
||||||
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
logic-delete-value: 1 # 逻辑已删除值(默认为 1)
|
||||||
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
|
logic-not-delete-value: 0 # 逻辑未删除值(默认为 0)
|
||||||
banner: false # 关闭控制台的 Banner 打印
|
banner: false # 关闭控制台的 Banner 打印
|
||||||
@@ -219,13 +219,13 @@ yudao:
|
|||||||
model: Baichuan4-Turbo
|
model: Baichuan4-Turbo
|
||||||
midjourney:
|
midjourney:
|
||||||
enable: true
|
enable: true
|
||||||
# base-url: https://api.holdai.top/mj-relax/mj
|
# base-url: https://api.holdai.top/mj-relax/mj
|
||||||
base-url: https://api.holdai.top/mj
|
base-url: https://api.holdai.top/mj
|
||||||
api-key: sk-dZEPiVaNcT3FHhef51996bAa0bC74806BeAb620dA5Da10Bf
|
api-key: sk-dZEPiVaNcT3FHhef51996bAa0bC74806BeAb620dA5Da10Bf
|
||||||
notify-url: http://java.nat300.top/admin-api/ai/image/midjourney/notify
|
notify-url: http://java.nat300.top/admin-api/ai/image/midjourney/notify
|
||||||
suno:
|
suno:
|
||||||
enable: true
|
enable: true
|
||||||
# base-url: https://suno-55ishh05u-status2xxs-projects.vercel.app
|
# base-url: https://suno-55ishh05u-status2xxs-projects.vercel.app
|
||||||
base-url: http://127.0.0.1:3001
|
base-url: http://127.0.0.1:3001
|
||||||
|
|
||||||
--- #################### 芋道相关配置 ####################
|
--- #################### 芋道相关配置 ####################
|
||||||
@@ -280,6 +280,7 @@ yudao:
|
|||||||
- /admin-api/system/auth/get-access-token
|
- /admin-api/system/auth/get-access-token
|
||||||
- /admin-api/system/auth/get-session
|
- /admin-api/system/auth/get-session
|
||||||
- /admin-api/system/auth/get-phone-number
|
- /admin-api/system/auth/get-phone-number
|
||||||
|
- /admin-api/system/auth/api/user-add
|
||||||
ignore-visit-urls:
|
ignore-visit-urls:
|
||||||
- /admin-api/system/user/profile/**
|
- /admin-api/system/user/profile/**
|
||||||
- /admin-api/system/auth/**
|
- /admin-api/system/auth/**
|
||||||
|
|||||||
Reference in New Issue
Block a user