This commit is contained in:
张良(004796)
2024-04-10 17:20:26 +08:00
parent 2f3f1ca46b
commit fdc51206d1
6 changed files with 127 additions and 13 deletions

View File

@@ -0,0 +1,31 @@
package com.ruoyi.test.business;
import com.alibaba.fastjson.JSON;
import com.ruoyi.yunxin.client.ImUserRefClient;
import com.ruoyi.yunxin.req.GetUnifoReq;
import com.ruoyi.yunxin.resp.YxUpdateUinfoR;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.ArrayList;
import java.util.List;
@SpringBootTest
@Slf4j
public class YxTest {
@Autowired
private ImUserRefClient imUserRefClient;
@Test
public void test(){
GetUnifoReq req = new GetUnifoReq();
List<String> list = new ArrayList<>();
list.add("1087");
req.setAccids(JSON.toJSONString(list));
YxUpdateUinfoR uinfos = imUserRefClient.getUinfos(req);
log.info(JSON.toJSONString(uinfos));
}
}

View File

@@ -179,14 +179,16 @@ public class CurrentUserManager {
throw new ServiceException("性别参数异常"); throw new ServiceException("性别参数异常");
} }
if(user.getGender() != 0 && !user.getGender().equals(res.getGender())){ if(user.getGender() != 0 && !user.getGender().equals(res.getGender())){
throw new ServiceException("性别不可以修改"); throw new ServiceException("性别确定后,无法二次修改");
}
if(!user.getGender().equals(res.getGender())){
update.set(User::getGender,genderEnum.getCode());
update.set(User::getAvatar,genderEnum.getDefaultAvatar());
imAvatar = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN) + genderEnum.getDefaultAvatar();
imGender = genderEnum.getCode();
updateFlag=true;
updateYunxin=true;
} }
update.set(User::getGender,genderEnum.getCode());
update.set(User::getAvatar,genderEnum.getDefaultAvatar());
imAvatar = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
imGender = genderEnum.getCode();
updateFlag=true;
updateYunxin=true;
} }
if(res.getCityId() != null){ if(res.getCityId() != null){
update.set(User::getCityId,res.getCityId()); update.set(User::getCityId,res.getCityId());

View File

@@ -71,12 +71,7 @@ public class UserAdminManager {
boolean b = userService.updateById(update); boolean b = userService.updateById(update);
if(b){ if(b){
userService.checkFinishStatus(user.getId()); userService.checkFinishStatus(user.getId());
String imAvatar = null; imManager.updateImInfo(user.getId(),userUpdateAdmin.getAvatar(),userUpdateAdmin.getNickname(),userUpdateAdmin.getGender());
if(StringUtils.isNotBlank(userUpdateAdmin.getAvatar())){
String cosDomain = systemConfigManager.getSystemConfig(SystemConfigEnum.COS_DOMAIN);
imAvatar = cosDomain + userUpdateAdmin.getAvatar();
}
imManager.updateImInfo(user.getId(),imAvatar,userUpdateAdmin.getNickname(),userUpdateAdmin.getGender());
} }
return true; return true;
} }

View File

@@ -5,9 +5,11 @@ import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.Post; import com.dtflys.forest.annotation.Post;
import com.ruoyi.yunxin.interceptor.GlodonTokenInterceptor; import com.ruoyi.yunxin.interceptor.GlodonTokenInterceptor;
import com.ruoyi.yunxin.req.CreateUserReq; import com.ruoyi.yunxin.req.CreateUserReq;
import com.ruoyi.yunxin.req.GetUnifoReq;
import com.ruoyi.yunxin.req.UpdateUinfoReq; import com.ruoyi.yunxin.req.UpdateUinfoReq;
import com.ruoyi.yunxin.resp.YxCommonR; import com.ruoyi.yunxin.resp.YxCommonR;
import com.ruoyi.yunxin.resp.YxInfoR; import com.ruoyi.yunxin.resp.YxInfoR;
import com.ruoyi.yunxin.resp.YxUpdateUinfoR;
@BaseRequest(baseURL = "${baseUrl}", interceptor = GlodonTokenInterceptor.class) @BaseRequest(baseURL = "${baseUrl}", interceptor = GlodonTokenInterceptor.class)
public interface ImUserRefClient { public interface ImUserRefClient {
@@ -16,4 +18,6 @@ public interface ImUserRefClient {
@Post(url = "/nimserver/user/updateUinfo.action") @Post(url = "/nimserver/user/updateUinfo.action")
YxCommonR updateUinfo(@Body UpdateUinfoReq query); YxCommonR updateUinfo(@Body UpdateUinfoReq query);
@Post(url = "nimserver/user/getUinfos.action")
YxUpdateUinfoR getUinfos(@Body GetUnifoReq query);
} }

View File

@@ -0,0 +1,8 @@
package com.ruoyi.yunxin.req;
import lombok.Data;
@Data
public class GetUnifoReq {
private String accids;
}

View File

@@ -0,0 +1,74 @@
package com.ruoyi.yunxin.resp;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
public class YxUpdateUinfoR {
private Integer code;
private List<Uinfos> uinfos;
@NoArgsConstructor
@Data
public static class Uinfos {
/**
* 账号
*/
@JsonProperty("accid")
private String accid;
/**
* 昵称
*/
@JsonProperty("name")
private String name;
/**
* 头像
*/
@JsonProperty("icon")
private String icon;
/**
* 签名
*/
@JsonProperty("sign")
private String sign;
/**
* 邮箱
*/
@JsonProperty("email")
private String email;
/**
* 生日
*/
@JsonProperty("birth")
private String birth;
/**
* 手机号
*/
@JsonProperty("mobile")
private String mobile;
/**
* 扩展信息
*/
@JsonProperty("ex")
private String ex;
/**
* 性别0表示未知1表示男2表示女
*/
@JsonProperty("gender")
private Integer gender;
/**
* 账号是否有效
*/
@JsonProperty("valid")
private Boolean valid;
/**
* 账号是否被全局禁言
*/
@JsonProperty("mute")
private Boolean mute;
}
}