单身推荐/新接口
This commit is contained in:
parent
cb966608f1
commit
fa3e5d2c0b
|
|
@ -1,13 +1,17 @@
|
||||||
package com.ruoyi.web.controller.app;
|
package com.ruoyi.web.controller.app;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.ruoyi.common.core.domain.Result;
|
import com.ruoyi.common.core.domain.Result;
|
||||||
|
import com.ruoyi.system.domain.TbUserFollow;
|
||||||
import com.ruoyi.system.domain.TbUserImg;
|
import com.ruoyi.system.domain.TbUserImg;
|
||||||
import com.ruoyi.system.domain.TbUserSingle;
|
import com.ruoyi.system.domain.TbUserSingle;
|
||||||
|
import com.ruoyi.system.service.ITbUserFollowService;
|
||||||
import com.ruoyi.system.service.ITbUserImgService;
|
import com.ruoyi.system.service.ITbUserImgService;
|
||||||
import com.ruoyi.system.service.ITbUserSingleService;
|
import com.ruoyi.system.service.ITbUserSingleService;
|
||||||
|
import com.ruoyi.web.request.UserSingleRecommendReq;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
|
@ -32,6 +36,9 @@ public class TbUserSingleAppController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITbUserImgService tbUserImgService;
|
private ITbUserImgService tbUserImgService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ITbUserFollowService tbUserFollowService;
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ApiOperation(value = "填写用户信息", httpMethod = "POST")
|
@ApiOperation(value = "填写用户信息", httpMethod = "POST")
|
||||||
|
|
@ -93,6 +100,46 @@ public class TbUserSingleAppController {
|
||||||
return Result.success(PageInfo.of(list));
|
return Result.success(PageInfo.of(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ResponseBody
|
||||||
|
@PostMapping("/recommendForSingle")
|
||||||
|
@ApiOperation(value = "单身获取推荐用户", httpMethod = "POST")
|
||||||
|
@ApiImplicitParams({ @ApiImplicitParam(name = "pageNum", value = "当前页码", required = true, dataType = "int"),
|
||||||
|
@ApiImplicitParam(name = "pageSize", value = "每页显示的条数", required = true, dataType = "int") })
|
||||||
|
public Result<PageInfo<TbUserSingle>> recommendForSingle(@RequestBody UserSingleRecommendReq recommendReq,
|
||||||
|
@RequestParam("pageNum") int pageNum,
|
||||||
|
@RequestParam("pageSize") int pageSize) {
|
||||||
|
Long notExcludeSex = null;
|
||||||
|
// 获取当前登陆人信息
|
||||||
|
TbUserSingle userSingle = tbUserSingleService.lambdaQuery().eq(TbUserSingle::getUserId, recommendReq.getUserId()).one();
|
||||||
|
if(userSingle != null){
|
||||||
|
notExcludeSex = userSingle.getSex();
|
||||||
|
}else {
|
||||||
|
notExcludeSex = recommendReq.getSex();
|
||||||
|
}
|
||||||
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
|
List<TbUserSingle> list = tbUserSingleService.lambdaQuery()
|
||||||
|
.ne(ObjectUtil.isNotEmpty(notExcludeSex), TbUserSingle::getSex, notExcludeSex)
|
||||||
|
.list();
|
||||||
|
list.forEach(model->{
|
||||||
|
//填充年纪
|
||||||
|
if(model.getBirthday() != null){
|
||||||
|
model.setAge(DateUtil.ageOfNow(model.getBirthday()));
|
||||||
|
}
|
||||||
|
// 填充用户图片
|
||||||
|
model.setTbUserImgList(tbUserImgService.lambdaQuery().eq(TbUserImg::getUserId, model.getUserId()).list());
|
||||||
|
// 填充是否已经关注
|
||||||
|
if(ObjectUtil.isNotEmpty(userSingle)){
|
||||||
|
long count = tbUserFollowService.lambdaQuery().eq(TbUserFollow::getFollowUserId, model.getUserId())
|
||||||
|
.eq(TbUserFollow::getUserId, userSingle.getUserId()).count();
|
||||||
|
if(count > 0){
|
||||||
|
model.setIsLike(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
return Result.success(PageInfo.of(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.ruoyi.web.request;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <P>单身用户推荐入参</P>
|
||||||
|
* @author clunt
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "单身用户推荐入参")
|
||||||
|
public class UserSingleRecommendReq {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "当前登陆用户userId")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "性别,当用户没有保存性别时使用")
|
||||||
|
private Long sex;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -152,4 +152,8 @@ public class TbUserSingle extends BaseEntity
|
||||||
@ApiModelProperty(value = "用户各图片附件信息")
|
@ApiModelProperty(value = "用户各图片附件信息")
|
||||||
private List<TbUserImg> tbUserImgList;
|
private List<TbUserImg> tbUserImgList;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@ApiModelProperty(value = "是否是已关注用户,单身推荐专用")
|
||||||
|
private Boolean isLike = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue