123333
This commit is contained in:
@@ -16,6 +16,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@@ -32,9 +34,33 @@ public class UserDynamicAppController {
|
|||||||
public R<List<DynamicListVo>> page(PageQuery pageQuery, DynamicQuery query){
|
public R<List<DynamicListVo>> page(PageQuery pageQuery, DynamicQuery query){
|
||||||
query.setCurrentUserId(LoginHelper.getUserId());
|
query.setCurrentUserId(LoginHelper.getUserId());
|
||||||
Page<DynamicListVo> resp = dynamicService.pageApp(pageQuery,query);
|
Page<DynamicListVo> resp = dynamicService.pageApp(pageQuery,query);
|
||||||
|
resp.getRecords().forEach(i -> {
|
||||||
|
i.setTimeDiffText(diffTime(i.getCreateTime()));
|
||||||
|
});
|
||||||
return R.ok(resp.getRecords());
|
return R.ok(resp.getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String diffTime(LocalDateTime time){
|
||||||
|
Duration duration = Duration.between(time, LocalDateTime.now());
|
||||||
|
long seconds = duration.getSeconds();
|
||||||
|
long absSeconds = Math.abs(seconds);
|
||||||
|
long days = absSeconds / (60 * 60 * 24);
|
||||||
|
long hours = (absSeconds % (60 * 60 * 24)) / (60 * 60);
|
||||||
|
long minutes = (absSeconds % (60 * 60)) / 60;
|
||||||
|
long secs = absSeconds % 60;
|
||||||
|
if(days > 0){
|
||||||
|
return "1天前";
|
||||||
|
}
|
||||||
|
if(hours > 0){
|
||||||
|
return hours+"小时前";
|
||||||
|
}
|
||||||
|
if(minutes > 0){
|
||||||
|
return minutes+"分钟前";
|
||||||
|
}
|
||||||
|
return (secs == 0 ? 1 : secs) + "秒前";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/push")
|
@PostMapping("/push")
|
||||||
@Operation(summary = "发布动态")
|
@Operation(summary = "发布动态")
|
||||||
@Log(title = "发布动态", businessType = BusinessType.OTHER, isSaveDb = true)
|
@Log(title = "发布动态", businessType = BusinessType.OTHER, isSaveDb = true)
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public class DynamicListVo extends DynamicVo{
|
|||||||
private String avatar;
|
private String avatar;
|
||||||
@Schema(description = "昵称")
|
@Schema(description = "昵称")
|
||||||
private String nickname;
|
private String nickname;
|
||||||
|
@Schema(description = "时间差值文字显示")
|
||||||
|
private String timeDiffText;
|
||||||
@Schema(description = "是否关注用户")
|
@Schema(description = "是否关注用户")
|
||||||
private boolean star;
|
private boolean star;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ public class UserMinInfoVo {
|
|||||||
private Integer isAnchor;
|
private Integer isAnchor;
|
||||||
@Schema(description = "蜜瓜号")
|
@Schema(description = "蜜瓜号")
|
||||||
private String usercode;
|
private String usercode;
|
||||||
|
|
||||||
|
@Schema(description = "性别")
|
||||||
|
private Integer gender;
|
||||||
@Schema(description = "昵称")
|
@Schema(description = "昵称")
|
||||||
private String nickname;
|
private String nickname;
|
||||||
@Schema(description = "头像")
|
@Schema(description = "头像")
|
||||||
|
|||||||
@@ -33,10 +33,15 @@ public class UserBlacklistServiceImpl extends ServiceImpl<UserBlacklistMapper, U
|
|||||||
throw new ServiceException("不能对自己操作哦");
|
throw new ServiceException("不能对自己操作哦");
|
||||||
}
|
}
|
||||||
if(actionType == 1){ // 拉黑
|
if(actionType == 1){ // 拉黑
|
||||||
UserBlacklist userBlacklist = new UserBlacklist();
|
UserBlacklist one = this.getOne(Wrappers.lambdaQuery(UserBlacklist.class)
|
||||||
userBlacklist.setUserId(userId);
|
.eq(UserBlacklist::getUserId, userId)
|
||||||
userBlacklist.setBlackUid(blackUserId);
|
.eq(UserBlacklist::getBlackUid, blackUserId));
|
||||||
this.save(userBlacklist);
|
if(one == null){
|
||||||
|
UserBlacklist userBlacklist = new UserBlacklist();
|
||||||
|
userBlacklist.setUserId(userId);
|
||||||
|
userBlacklist.setBlackUid(blackUserId);
|
||||||
|
this.save(userBlacklist);
|
||||||
|
}
|
||||||
}else { // 取消拉黑
|
}else { // 取消拉黑
|
||||||
this.remove(Wrappers.lambdaQuery(UserBlacklist.class)
|
this.remove(Wrappers.lambdaQuery(UserBlacklist.class)
|
||||||
.eq(UserBlacklist::getUserId,userId)
|
.eq(UserBlacklist::getUserId,userId)
|
||||||
|
|||||||
@@ -393,6 +393,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||||||
vo.setIsAnchor(user.getIsAnchor());
|
vo.setIsAnchor(user.getIsAnchor());
|
||||||
vo.setUsercode(user.getUsercode());
|
vo.setUsercode(user.getUsercode());
|
||||||
vo.setNickname(user.getNickname());
|
vo.setNickname(user.getNickname());
|
||||||
|
vo.setGender(user.getGender());
|
||||||
vo.setAvatar(user.getAvatar());
|
vo.setAvatar(user.getAvatar());
|
||||||
vo.setAge(user.getAge());
|
vo.setAge(user.getAge());
|
||||||
vo.setCity(user.getCity());
|
vo.setCity(user.getCity());
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserListVo">
|
<select id="pageApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserListVo">
|
||||||
select t2.id as user_id,t2.avatar,t2.gender,t2.city_id,t2.city,t2.nickname,t2.usercode,t2.age
|
select t2.id as user_id,t2.avatar,t2.gender,t2.city_id,t2.city,t2.nickname,t2.usercode,t2.age
|
||||||
from cai_user_blacklist t1
|
from cai_user_blacklist t1
|
||||||
join cai_user t2 on t1.user_id = t2.id
|
join cai_user t2 on t1.black_uid = t2.id
|
||||||
where t1.user_id = #{userId}
|
where t1.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user