123
This commit is contained in:
@@ -13,6 +13,7 @@ import com.ruoyi.common.enums.BusinessType;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -28,7 +29,7 @@ public class UserStartAppController {
|
||||
@PostMapping("/star")
|
||||
@Operation(summary = "关注用户")
|
||||
@Log(title = "关注用户", businessType = BusinessType.OTHER, isSaveDb = true)
|
||||
public R<Void> star(@RequestBody StarOrVisitorReq starOrVisitorReq){
|
||||
public R<Void> star(@Validated @RequestBody StarOrVisitorReq starOrVisitorReq){
|
||||
userFollowService.star(starOrVisitorReq);
|
||||
return R.ok();
|
||||
}
|
||||
@@ -36,7 +37,7 @@ public class UserStartAppController {
|
||||
@PostMapping("/unstar")
|
||||
@Operation(summary = "取消关注用户")
|
||||
@Log(title = "取消关注用户", businessType = BusinessType.OTHER, isSaveDb = true)
|
||||
public R<Void> unStar(@RequestBody StarOrVisitorReq starOrVisitorReq){
|
||||
public R<Void> unStar(@Validated @RequestBody StarOrVisitorReq starOrVisitorReq){
|
||||
userFollowService.unStar(starOrVisitorReq);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package com.ruoyi.cai.dto.app.query;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@Schema(description = "入参模型")
|
||||
public class StarOrVisitorReq {
|
||||
@Schema(description = "目标用户ID")
|
||||
@NotNull(message = "参数异常")
|
||||
private Long toUserId;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class UserStarOrVisitorList extends UserBaseVo {
|
||||
|
||||
@Schema(description = "是否回关 0-否 1-是")
|
||||
private Integer callBackStar = 0;
|
||||
@Schema(description = "是否为VIP")
|
||||
@Schema(description = "是否为VIP 0-否 1-是")
|
||||
private Integer isVip = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@ public class UserFollowServiceImpl extends ServiceImpl<UserFollowMapper, UserFol
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean star(StarOrVisitorReq starOrVisitorReq) {
|
||||
Long fromUserId = LoginHelper.getUserId();
|
||||
if(starOrVisitorReq.getToUserId().equals(fromUserId)){
|
||||
throw new ServiceException("不能关注自己哦");
|
||||
}
|
||||
this.remove(Wrappers.lambdaQuery(UserFollow.class)
|
||||
.eq(UserFollow::getUserId,fromUserId)
|
||||
.eq(UserFollow::getFollowUser, starOrVisitorReq.getToUserId()));
|
||||
|
||||
@@ -14,11 +14,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="pageMyStarApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserStarOrVisitorList">
|
||||
select
|
||||
t1.create_time as happen_time,
|
||||
t2.id as user_id, t2.avatar,t2.gender,t2.city,t2.nickname,t2.usercode,t2.age
|
||||
t2.id as user_id, t2.avatar,t2.gender,t2.city_id,t2.city,t2.nickname,t2.usercode,t2.age
|
||||
from cai_user_follow t1
|
||||
join cai_user t2 on t1.follow_user = t2.id
|
||||
where t1.user_id = #{query.userId}
|
||||
order by create_time desc
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="pageMyFansApp" resultType="com.ruoyi.cai.dto.app.vo.user.UserStarOrVisitorList">
|
||||
@@ -28,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from cai_user_follow t1
|
||||
join cai_user t2 on t1.user_id = t2.id
|
||||
where t1.follow_user = #{query.userId}
|
||||
order by create_time desc
|
||||
order by t1.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user