Commit 66200d6e authored by hezhen's avatar hezhen

修改上传

parent 2546f4d1
......@@ -18,6 +18,8 @@ public class AppUserLogin {
private int id;
@Column(name = "im_userid")
private Integer imUserid;
@Column(name = "im_password")
private String imPassword;
@Column(name = "username")
private String username;
private String password;
......
......@@ -40,6 +40,11 @@
<artifactId>xx-universal-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-im-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
......
......@@ -33,7 +33,7 @@ import java.util.List;
@EnableDiscoveryClient
@EnableCircuitBreaker
@SpringBootApplication
@EnableFeignClients({"com.github.wxiaoqi.security.auth.client.feign", "com.xxfc.platform.universal.feign"})
@EnableFeignClients({"com.github.wxiaoqi.security.auth.client.feign","com.xxfc.platform"})
@EnableScheduling
@EnableAceAuthClient
@EnableAceCache
......
......@@ -78,6 +78,7 @@ public class AppUserRest {
mobilecode, null, null,0);
}
/**
* 微信注册/微信绑定
* @param username
......
......@@ -9,12 +9,14 @@ import com.github.wxiaoqi.security.admin.constant.RedisKey;
import com.github.wxiaoqi.security.admin.entity.*;
import com.github.wxiaoqi.security.api.vo.authority.PermissionInfo;
import com.github.wxiaoqi.security.api.vo.user.AppUserInfo;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.EmojiFilter;
import com.github.wxiaoqi.security.common.util.VerificationUtils;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.util.result.JsonResultUtil;
import com.xxfc.platform.im.feign.ImFeign;
import com.xxfc.platform.universal.feign.ThirdFeign;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
......@@ -23,9 +25,10 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
......@@ -44,6 +47,9 @@ public class AppPermissionService {
@Autowired
ThirdFeign thirdFeign;
@Autowired
ImFeign imFeign;
private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
@Autowired
private RedisTemplate userRedisTemplate;
......@@ -56,9 +62,9 @@ public class AppPermissionService {
public AppUserInfo validate(String username, String password) {
AppUserInfo info = new AppUserInfo();
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
if (user!=null&&encoder.matches(password, user.getPassword())) {
if (user != null && encoder.matches(password, user.getPassword())) {
info.setUsername(user.getUsername());
info.setId(user.getId()+"");
info.setId(user.getId() + "");
}
return info;
}
......@@ -128,10 +134,10 @@ public class AppPermissionService {
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "手机号未注册");
}
// String sms = PassportUtil.SendSMS(phone, SystemConfig.SENDSMS_TITLE);
String mobilecode=null;
JSONObject data=thirdFeign.send(phone);
if(data!=null&&data.getInteger("status")== ResultCode.SUCCESS_CODE){
mobilecode=data.getString("data");
String mobilecode = null;
JSONObject data = thirdFeign.send(phone);
if (data != null && data.getInteger("status") == ResultCode.SUCCESS_CODE) {
mobilecode = data.getString("data");
}
log.info("调用短信发送接口返回值为:{}", mobilecode);
// 判断返回值是否为空,并且是否可以转换成JSONObject
......@@ -139,10 +145,10 @@ public class AppPermissionService {
return JsonResultUtil.createDefaultFail();
try {
result.put("mobilecode", mobilecode);
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX+phone+mobilecode;
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX + phone + mobilecode;
Boolean suc = userRedisTemplate.opsForValue().setIfAbsent(redisLockKey, mobilecode);
if(suc){
userRedisTemplate.expire(redisLockKey,5, TimeUnit.MINUTES);//5分钟内过期
if (suc) {
userRedisTemplate.expire(redisLockKey, 5, TimeUnit.MINUTES);//5分钟内过期
}
} catch (Exception e) {
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
......@@ -160,13 +166,13 @@ public class AppPermissionService {
*/
@Transactional
public JSONObject register(String username, String password, String headimgurl,
String nickname, String mobilecode,String openId, String unionid,Integer type) {
String nickname, String mobilecode, String openId, String unionid, Integer type) {
// 判断参数和验证码
if (StringUtils.isBlank(username) || StringUtils.isBlank(password) || StringUtils.isBlank(mobilecode)) {
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空");
}
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX+username+mobilecode;
String mobilecodeRedis=userRedisTemplate.opsForValue().get(redisLockKey)==null?"":userRedisTemplate.opsForValue().get(redisLockKey).toString();
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX + username + mobilecode;
String mobilecodeRedis = userRedisTemplate.opsForValue().get(redisLockKey) == null ? "" : userRedisTemplate.opsForValue().get(redisLockKey).toString();
log.error("注册接口,获取redis中的验证码:" + mobilecodeRedis);
// 获取到缓存的验证码后要先清空缓存对应键的值
userRedisTemplate.delete(redisLockKey);
......@@ -174,7 +180,7 @@ public class AppPermissionService {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
}
// 是否已存在
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
if (null != user) {
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "用户已存在");
}
......@@ -187,9 +193,9 @@ public class AppPermissionService {
appUserLogin.setIsdel(0);
appUserLogin.setStatus(0);
//QQ
if(type==1&&StringUtils.isNotBlank(openId)){
if (type == 1 && StringUtils.isNotBlank(openId)) {
appUserLogin.setOpenid(openId);
}else{
} else {
if (StringUtils.isNotBlank(openId)) {
appUserLogin.setWxOpenid(openId);
}
......@@ -200,7 +206,7 @@ public class AppPermissionService {
appUserLogin.setCreatetime(now);
appUserLogin.setUpdatetime(now);
appUserLoginBiz.insertSelective(appUserLogin);
Integer userid=appUserLogin.getId();
Integer userid = appUserLogin.getId();
log.error("注册:新增登陆用户信息: " + userid);
// 新增用户详情
AppUserDetail rsUserDetail = new AppUserDetail();
......@@ -214,9 +220,20 @@ public class AppPermissionService {
log.error("注册:新增用户详情: " + userid);
// 登录结果要做做统一处理
JSONObject data = autoLogin(userid, username, headimgurl, nickname);
/* // 到im注册,获取返回结果
// 到im注册,获取返回结果
Map<String,Object> map=registerIm(username,appUserLogin.getPassword(),nickname);
if(map!=null){
Integer imUserId=Integer.parseInt(map.get("userId").toString());
String access_token=map.get("access_token").toString();
String imPassword=map.get("password").toString();
if(imUserId!=null&&imUserId>0&&StringUtils.isNotBlank(imPassword)){
AppUserLogin userLogin = new AppUserLogin();
userLogin.setId(userid);
userLogin.setImPassword(imPassword);
userLogin.setImUserid(imUserId);
}
}
*/
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
} else {
......@@ -233,26 +250,26 @@ public class AppPermissionService {
*/
public JSONObject autoLogin(Integer userid, String username, String headimgurl, String nickname) {
JSONObject data = new JSONObject();
AppUserLogin userLoign = appUserLoginBiz.selectById(userid);
if (userLoign!=null) {
AppUserLogin userLoign = appUserLoginBiz.selectById(userid);
if (userLoign != null) {
data.put("nickname", nickname);
data.put("headerurl",headimgurl);
AppUserDetail appUserDetail=appUserDetailBiz.getUserByUserid(userid);
if(appUserDetail!=null){
if(StringUtils.isNotBlank(appUserDetail.getNickname())){
data.put("headerurl", headimgurl);
AppUserDetail appUserDetail = appUserDetailBiz.getUserByUserid(userid);
if (appUserDetail != null) {
if (StringUtils.isNotBlank(appUserDetail.getNickname())) {
data.put("nickname", appUserDetail.getNickname());
}
if(StringUtils.isNotBlank(appUserDetail.getHeadimgurl())){
if (StringUtils.isNotBlank(appUserDetail.getHeadimgurl())) {
data.put("headerurl", appUserDetail.getHeadimgurl());
}
}
// 缓存操作
String token="";
String imtoken_="";
//userRedisTemplate.opsForValue().set("token_" + userid,token, SystemConfig.REDISTOKENTIME, TimeUnit.SECONDS);
//userRedisTemplate.opsForValue().set("imtoken_" + userid,imtoken_,SystemConfig.REDISTOKENTIME, TimeUnit.SECONDS);
String token = "";
String imtoken_ = "";
//userRedisTemplate.opsForValue().set("token_" + userid,token, SystemConfig.REDISTOKENTIME, TimeUnit.SECONDS);
//userRedisTemplate.opsForValue().set("imtoken_" + userid,imtoken_,SystemConfig.REDISTOKENTIME, TimeUnit.SECONDS);
// 返回结果
// data.put("token", token);
// data.put("token", token);
data.put("username", username);
data.put("userid", userid);
......@@ -262,6 +279,7 @@ public class AppPermissionService {
/**
* 微信绑定/注册
*
* @param username
* @param password
* @param openId
......@@ -274,7 +292,7 @@ public class AppPermissionService {
*/
@Transactional
public JSONObject weCahtRegister(String username, String password, String openId,
String unionid, String nickname,String headimgurl, int type, String mobilecode,Integer isQQ) {
String unionid, String nickname, String headimgurl, int type, String mobilecode, Integer isQQ) {
// 校验参数和验证码
if (StringUtils.isBlank(username) || StringUtils.isBlank(mobilecode)) {
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空");
......@@ -287,7 +305,7 @@ public class AppPermissionService {
try {
// 获取缓存用户信息
log.error("weCahtRegister:" + openId);
if(StringUtils.isNotBlank(openId)) {
if (StringUtils.isNotBlank(openId)) {
if (StringUtils.isNotBlank(nickname)) {
// 转换特殊字符
nickname = EmojiFilter.filterEmoji(nickname);
......@@ -299,24 +317,24 @@ public class AppPermissionService {
}
if (type == 1) { // 绑定
Long now = System.currentTimeMillis() / 1000;
AppUserLogin userLogin = appUserLoginBiz.checkeUserLogin(username);
if ((isQQ==1&&StringUtils.isNotBlank(userLogin.getOpenid()))||(isQQ==0&&StringUtils.isNotBlank(userLogin.getWxOpenid()))) {
AppUserLogin userLogin = appUserLoginBiz.checkeUserLogin(username);
if ((isQQ == 1 && StringUtils.isNotBlank(userLogin.getOpenid())) || (isQQ == 0 && StringUtils.isNotBlank(userLogin.getWxOpenid()))) {
// 已绑定微信
return JsonResultUtil.createFailedResultMsg(ResultCode.WX_BIND_CODE);
}
Integer userid = userLogin.getId();
if(isQQ==1){
Integer userid = userLogin.getId();
if (isQQ == 1) {
userLogin.setOpenid(openId);
}else{
} else {
userLogin.setWxOpenid(openId);
// 添加unionid
userLogin.setUnionid(unionid);
}
userLogin.setUpdatetime(now);
appUserLoginBiz.updateSelectiveById(userLogin);
AppUserDetail userDetail=appUserDetailBiz.getUserByUserid(userid);
if(userDetail==null){
userDetail=new AppUserDetail();
AppUserDetail userDetail = appUserDetailBiz.getUserByUserid(userid);
if (userDetail == null) {
userDetail = new AppUserDetail();
userDetail.setUserid(userid);
userDetail.setHeadimgurl(headimgurl);
userDetail.setNickname(nickname);
......@@ -324,7 +342,7 @@ public class AppPermissionService {
userDetail.setUpdatetime(now);
userDetail.setIsdel(0);
appUserDetailBiz.insertSelective(userDetail);
}else {
} else {
userDetail.setHeadimgurl(headimgurl);
userDetail.setNickname(nickname);
appUserDetailBiz.updateSelectiveById(userDetail);
......@@ -336,7 +354,7 @@ public class AppPermissionService {
}
} else if (type == 2) { // 新增
JSONObject register = register(username, password, headimgurl, nickname, mobilecode,
openId, unionid,isQQ);
openId, unionid, isQQ);
if (register.getInteger("status") != ResultCode.SUCCESS_CODE) {
if (register.getInteger("status") == ResultCode.EXIST_CODE) {
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "用户已存在");
......@@ -385,54 +403,55 @@ public class AppPermissionService {
/**
* 微信登录
*
* @param openId
* @return
*/
@Transactional
public JSONObject weCahtLogin(String openId,Integer isQQ) {
public JSONObject weCahtLogin(String openId, Integer isQQ) {
if (StringUtils.isBlank(openId)) {
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "参数为空");
}
AppUserLogin userLogin = appUserLoginBiz.getUserByOpenid(openId,isQQ);
if(userLogin==null){
AppUserLogin userLogin = appUserLoginBiz.getUserByOpenid(openId, isQQ);
if (userLogin == null) {
return JsonResultUtil.createFailedResult(ResultCode.WXNOTEXIST_CODE, "该微信号尚未绑定手机号");
}
if(userLogin.getStatus()==1){
if (userLogin.getStatus() == 1) {
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "用户已被禁用");
}
Integer userid=userLogin.getId();
AppUserDetail userDetail=appUserDetailBiz.getUserByUserid(userid);
String headimgurl="";
String nickname="";
if(userDetail!=null){
headimgurl=userDetail.getHeadimgurl();
nickname=userDetail.getNickname();
Integer userid = userLogin.getId();
AppUserDetail userDetail = appUserDetailBiz.getUserByUserid(userid);
String headimgurl = "";
String nickname = "";
if (userDetail != null) {
headimgurl = userDetail.getHeadimgurl();
nickname = userDetail.getNickname();
}
JSONObject data = autoLogin(userid,userLogin.getUsername(),headimgurl,nickname);
JSONObject data = autoLogin(userid, userLogin.getUsername(), headimgurl, nickname);
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
}
return JsonResultUtil.createDefaultFail();
}
public JSONObject login(String username, String password,String mobilecode,int type) {
if (StringUtils.isBlank(username) || ((StringUtils.isBlank(password)&&type==1)|| (StringUtils.isBlank(mobilecode)&&type==2))) {
public JSONObject login(String username, String password, String mobilecode, int type) {
if (StringUtils.isBlank(username) || ((StringUtils.isBlank(password) && type == 1) || (StringUtils.isBlank(mobilecode) && type == 2))) {
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "请求参数为空");
}
try {
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
if(type==1){
if (user==null||!encoder.matches(password,user.getPassword()))
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "用户名或密码错误");
}else {
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX+username+mobilecode;
String mobilecodeRedis=userRedisTemplate.opsForValue().get(redisLockKey)==null?"":userRedisTemplate.opsForValue().get(redisLockKey).toString();
if (type == 1) {
if (user == null || !encoder.matches(password, user.getPassword()))
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "用户名或密码错误");
} else {
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX + username + mobilecode;
String mobilecodeRedis = userRedisTemplate.opsForValue().get(redisLockKey) == null ? "" : userRedisTemplate.opsForValue().get(redisLockKey).toString();
log.error("验证码登录接口,获取redis中的验证码:" + mobilecodeRedis);
// 获取到缓存的验证码后要先清空缓存对应键的值
userRedisTemplate.delete(redisLockKey);
if (StringUtils.isBlank(mobilecodeRedis))
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
if (user==null)
if (user == null)
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "用户不存在");
}
......@@ -441,79 +460,141 @@ public class AppPermissionService {
return JsonResultUtil.createFailedResult(ResultCode.EXIST_CODE, "用户已被禁用");
}
Integer userid = user.getId();
String nickname=SystemConfig.USER_NIKENAME_DEFAULT+(int)((Math.random()*9+1)*100000);
JSONObject data = autoLogin(userid,user.getUsername(),SystemConfig.USER_HEADER_URL_DEFAULT,nickname);
String nickname = SystemConfig.USER_NIKENAME_DEFAULT + (int) ((Math.random() * 9 + 1) * 100000);
JSONObject data = autoLogin(userid, user.getUsername(), SystemConfig.USER_HEADER_URL_DEFAULT, nickname);
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
}
return JsonResultUtil.createDefaultFail();
}catch (Exception e) {
log.error("userlogin->error:{}", e.getMessage(), e);
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
}
} catch (Exception e) {
log.error("userlogin->error:{}", e.getMessage(), e);
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
}
}
@Transactional
public JSONObject reset(String username, String mobilecode, String password) {
if (StringUtils.isBlank(username) || StringUtils.isBlank(mobilecode)|| StringUtils.isBlank(password)) {
if (StringUtils.isBlank(username) || StringUtils.isBlank(mobilecode) || StringUtils.isBlank(password)) {
return JsonResultUtil.createFailedResult(ResultCode.NULL_CODE, "请求参数为空");
}
try {
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX+username+mobilecode;
String mobilecodeRedis=userRedisTemplate.opsForValue().get(redisLockKey)==null?"":userRedisTemplate.opsForValue().get(redisLockKey).toString();
log.error("验证码登录接口,获取redis中的验证码:" + mobilecodeRedis);
// 获取到缓存的验证码后要先清空缓存对应键的值
userRedisTemplate.delete(redisLockKey);
if (StringUtils.isBlank(mobilecodeRedis)){
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
}
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
if(user==null){
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "用户不存在");
try {
String redisLockKey = RedisKey.CONSTANT_CODE_PREFIX + username + mobilecode;
String mobilecodeRedis = userRedisTemplate.opsForValue().get(redisLockKey) == null ? "" : userRedisTemplate.opsForValue().get(redisLockKey).toString();
log.error("验证码登录接口,获取redis中的验证码:" + mobilecodeRedis);
// 获取到缓存的验证码后要先清空缓存对应键的值
userRedisTemplate.delete(redisLockKey);
if (StringUtils.isBlank(mobilecodeRedis)) {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "验证码错误");
}
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
if (user == null) {
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "用户不存在");
}
user.setPassword(password);
appUserLoginBiz.updatePasswordById(user);
Integer userid = user.getId();
String nickname = SystemConfig.USER_NIKENAME_DEFAULT + (int) ((Math.random() * 9 + 1) * 100000);
JSONObject data = autoLogin(userid, user.getUsername(), SystemConfig.USER_HEADER_URL_DEFAULT, nickname);
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
}
return JsonResultUtil.createDefaultFail();
} catch (Exception e) {
log.error("userlogin->error:{}", e.getMessage(), e);
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
}
user.setPassword(password);
appUserLoginBiz.updatePasswordById(user);
Integer userid=user.getId();
String nickname=SystemConfig.USER_NIKENAME_DEFAULT+(int)((Math.random()*9+1)*100000);
JSONObject data = autoLogin(userid,user.getUsername(),SystemConfig.USER_HEADER_URL_DEFAULT,nickname);
if (data != null) {
return JsonResultUtil.createSuccessResultWithObj(data);
}
return JsonResultUtil.createDefaultFail();
}catch (Exception e) {
log.error("userlogin->error:{}", e.getMessage(), e);
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
}
}
//实名认证
@Transactional
public ObjectRestResponse upAuthentication(Integer userid, String idNumber, Integer status) {
if(userid==null||userid==0||(status==1&&StringUtils.isBlank(idNumber))){
if (userid == null || userid == 0 || (status == 1 && StringUtils.isBlank(idNumber))) {
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE, "参数为空");
}
try {
AppUserLogin user=appUserLoginBiz.getUserById(userid);
if(user==null){
AppUserLogin user = appUserLoginBiz.getUserById(userid);
if (user == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "用户不存在");
}
if(user.getCertificationStatus()==1){
return ObjectRestResponse.createFailedResultWithObj(ResultCode.EXIST_CODE, "用户已认证",user.getIdNumber());
if (user.getCertificationStatus() == 1) {
return ObjectRestResponse.createFailedResultWithObj(ResultCode.EXIST_CODE, "用户已认证", user.getIdNumber());
}
if(status==1){
String username=user.getUsername();
user=new AppUserLogin();
if (status == 1) {
String username = user.getUsername();
user = new AppUserLogin();
user.setId(userid);
user.setUsername(username);
user.setIdNumber(idNumber);
user.setCertificationStatus(1);
appUserLoginBiz.updateSelectiveById(user);
}
return ObjectRestResponse.succ();
}catch (Exception e) {
return ObjectRestResponse.succ();
} catch (Exception e) {
log.error("upAuthentication->error:{}", e.getMessage(), e);
return ObjectRestResponse.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
}
}
//注册im
public Map<String, Object> registerIm(String username, String password, String nickname) {
log.error("------注册registerIm----username====="+username+"-----password==="+password+"---nickname==="+nickname);
Map<String, Object> map = new HashMap<>();
map.put("telephone", username);
map.put("password", password);
map.put("nickname", nickname);
BaseResponse response = imFeign.register(map);
log.error("registerIm->response:{}", response);
if (response.getStatus() == ResultCode.SUCCESS_CODE) {
String result = response.getMessage();
log.error("------im注册----result======"+result);
if (StringUtils.isNotBlank(result)) {
JSONObject object = JSONObject.parseObject(result);
password = object.getString("password");
if (StringUtils.isNotBlank(result)) {
map.put("password", password);
}
JSONObject data = object.getJSONObject("data");
log.error("------im注册----data======"+data);
if (data != null) {
map.put("userId", data.getString("userId"));
map.put("access_token", data.getString("access_token"));
} else {
map.put("userId", "");
map.put("access_token", "");
}
}
}
return map;
}
//登录im
public String loginIm(String username, String password, String userId) {
log.error("------登录loginIm----username====="+username+"-----password==="+password+"---userId==="+userId);
Map<String, Object> map = new HashMap<>();
map.put("telephone", username);
map.put("password", password);
map.put("userId", userId);
BaseResponse response = imFeign.login(map);
log.error("registerIm->response:{}", response);
String access_token = "";
if (response.getStatus() == ResultCode.SUCCESS_CODE) {
String result = response.getMessage();
log.error("------im登录----result======"+result);
if (StringUtils.isNotBlank(result)) {
JSONObject object = JSONObject.parseObject(result);
JSONObject data = object.getJSONObject("data");
log.error("------im登录----data======"+data);
if (data != null) {
access_token = data.getString("access_token");
}
}
}
log.error("------im登录----access_token======"+access_token);
return access_token;
}
}
......@@ -8,7 +8,7 @@
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-im-api</artifactId>
......
......@@ -45,7 +45,7 @@ public class UploadController{
return JsonResultUtil.createSuccessResultWithObj(uploadService.uploadFile(file,prefix));
}
@RequestMapping(value = "/admin/upload", method = RequestMethod.POST)
@RequestMapping(value = "/app/unauth/admin/upload", method = RequestMethod.POST)
public JSONObject uploads(
@RequestParam("file") MultipartFile file,
@RequestParam(value = "prefix",defaultValue = "admin")String prefix
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment