|
@@ -8,6 +8,8 @@ import com.zhentao.enums.ApiServerException;
|
|
|
import com.zhentao.exception.AsynException;
|
|
|
|
|
|
import com.zhentao.information.service.WebSocketService;
|
|
|
+import com.zhentao.shouye.domain.UserShouye;
|
|
|
+import com.zhentao.shouye.mapper.UserShouyeMapper;
|
|
|
import com.zhentao.tool.TokenUtils;
|
|
|
import com.zhentao.user.domain.UserLogin;
|
|
|
import com.zhentao.user.dto.*;
|
|
@@ -15,6 +17,8 @@ import com.zhentao.user.service.EmailService;
|
|
|
import com.zhentao.user.service.UserLoginService;
|
|
|
import com.zhentao.user.mapper.UserLoginMapper;
|
|
|
import com.zhentao.user.service.UserOnlineStatusService;
|
|
|
+import com.zhentao.userRelationships.domain.UserRelationships;
|
|
|
+import com.zhentao.userRelationships.mapper.UserRelationshipsMapper;
|
|
|
import com.zhentao.utils.HttpUtils;
|
|
|
import com.zhentao.utils.SnowflakeIdGenerator;
|
|
|
import com.zhentao.vo.Result;
|
|
@@ -30,11 +34,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
/**
|
|
@@ -58,6 +58,12 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginMapper, UserLogin
|
|
|
@Autowired
|
|
|
private UserOnlineStatusService onlineStatusService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserShouyeMapper userShouyeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserRelationshipsMapper userRelationshipsMapper;
|
|
|
+
|
|
|
//注册
|
|
|
@Override
|
|
|
public Result register(UserRegister userRegister) {
|
|
@@ -98,6 +104,27 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginMapper, UserLogin
|
|
|
userLoginMapper.insert(user);
|
|
|
String token = TokenUtils.generateToken(user.getId().toString());
|
|
|
stringRedisTemplate.opsForValue().set(user.getId().toString(),token,10, TimeUnit.MINUTES);
|
|
|
+
|
|
|
+ UserShouye userShouye = new UserShouye();
|
|
|
+ userShouye.setId(IdUtil.getSnowflake().nextId());
|
|
|
+ userShouye.setUid1(user.getId());
|
|
|
+ userShouye.setUid2(1933707308387405824L);
|
|
|
+ userShouye.setGid(0L);
|
|
|
+ userShouye.setStatus(0);
|
|
|
+ userShouyeMapper.insert(userShouye);
|
|
|
+
|
|
|
+ UserRelationships userRelationships=new UserRelationships();
|
|
|
+ userRelationships.setId(IdUtil.getSnowflake().nextId());
|
|
|
+ userRelationships.setFriendId(1933707308387405824L);
|
|
|
+ userRelationships.setStatus(1);
|
|
|
+ userRelationships.setCreatedAt(new Date());
|
|
|
+ userRelationships.setUpdatedAt(new Date());
|
|
|
+ userRelationships.setIsBlacklist(0);
|
|
|
+ userRelationships.setIsMoments(0);
|
|
|
+ userRelationships.setIsDel(0);
|
|
|
+ userRelationshipsMapper.insert(userRelationships);
|
|
|
+
|
|
|
+
|
|
|
return Result.OK(null,"注册成功");
|
|
|
}
|
|
|
if(userRegister.getType()==2){
|
|
@@ -106,6 +133,28 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginMapper, UserLogin
|
|
|
userLoginMapper.insert(user);
|
|
|
String token = TokenUtils.generateToken(user.getId().toString());
|
|
|
stringRedisTemplate.opsForValue().set(user.getUserUsername(),token,10, TimeUnit.MINUTES);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ UserShouye userShouye = new UserShouye();
|
|
|
+ userShouye.setId(IdUtil.getSnowflake().nextId());
|
|
|
+ userShouye.setUid1(user.getId());
|
|
|
+ userShouye.setUid2(1933707308387405824L);
|
|
|
+ userShouye.setGid(0L);
|
|
|
+ userShouye.setStatus(0);
|
|
|
+ userShouyeMapper.insert(userShouye);
|
|
|
+
|
|
|
+ UserRelationships userRelationships=new UserRelationships();
|
|
|
+ userRelationships.setId(IdUtil.getSnowflake().nextId());
|
|
|
+ userRelationships.setFriendId(1933707308387405824L);
|
|
|
+ userRelationships.setStatus(1);
|
|
|
+ userRelationships.setCreatedAt(new Date());
|
|
|
+ userRelationships.setUpdatedAt(new Date());
|
|
|
+ userRelationships.setIsBlacklist(0);
|
|
|
+ userRelationships.setIsMoments(0);
|
|
|
+ userRelationships.setIsDel(0);
|
|
|
+ userRelationshipsMapper.insert(userRelationships);
|
|
|
+
|
|
|
return Result.OK(null,"注册成功");
|
|
|
}
|
|
|
}
|
|
@@ -341,6 +390,22 @@ public class UserLoginServiceImpl extends ServiceImpl<UserLoginMapper, UserLogin
|
|
|
}
|
|
|
return Result.ERR(null,"验证码错误");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result updateUserInfo(Userinfox userinfox) {
|
|
|
+ UserLogin one = this.getOne(new QueryWrapper<UserLogin>().eq("id", userinfox.getId()));
|
|
|
+ one.setNickName(userinfox.getNickName());
|
|
|
+ one.setGender(userinfox.getGender());
|
|
|
+ one.setUserIntro(userinfox.getUserIntro());
|
|
|
+ one.setAvatar(userinfox.getAvatar());
|
|
|
+ boolean b = this.updateById(one);
|
|
|
+ if(b){
|
|
|
+ return Result.OK("修改成功",null);
|
|
|
+ }else {
|
|
|
+ return Result.ERR("修改失败", null);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|