免费姓名评分测试打分生辰八字(免费姓名评分测试打分周易)

api

/**

* 查询推荐好友的缘分值

*

* @param userId 好友的id

* @param toUserId 我的id

* @return

*/

Double queryScore(Long userId, Long toUserId);

===========================================================

api impl

@Override

public Double queryScore(Long userId, Long toUserId) {

Query query = Query.query(Criteria.where("toUserId").is(toUserId)

.and("userId").is(userId));

RecommendUser recommendUser = this.mongoTemplate.findOne(query, RecommendUser.class);

if (null != recommendUser) {

return recommendUser.getScore();

}

return null;

}

============================================================

controller

import com.tanhua.server.service.TanHuaService;

import com.tanhua.server.vo.TodayBest;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.http.HttpStatus;

import org.springframework.http.ResponseEntity;

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

@RequestMapping("tanhua")

@RestController

public class TanHuaController {

@Autowired

private TanHuaService tanHuaService;

/**

* 查询个人主页的个人信息

*

* @param userId

* @return

*/

@GetMapping("{id}/personalInfo")

public ResponseEntity<TodayBest> queryUserInfo(@PathVariable("id") Long userId) {

try {

TodayBest todayBest = this.tanHuaService.queryUserInfo(userId);

return ResponseEntity.ok(todayBest);

} catch (Exception e) {

e.printStackTrace();

}

return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();

}

}

============================================================

service

import cn.hutool.core.convert.Convert;

import cn.hutool.core.util.ObjectUtil;

import cn.hutool.core.util.StrUtil;

import com.tanhua.common.pojo.User;

import com.tanhua.common.pojo.UserInfo;

import com.tanhua.common.utils.UserThreadLocal;

import com.tanhua.server.vo.TodayBest;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

@Service

public class TanHuaService {

@Autowired

private UserInfoService userInfoService;

@Autowired

private RecommendUserService recommendUserService;

public TodayBest queryUserInfo(Long userId) {

UserInfo userInfo = this.userInfoService.queryUserInfoByUserId(userId);

if(ObjectUtil.isEmpty(userInfo)){

return null;

}

TodayBest todayBest = new TodayBest();

todayBest.setId(userId);

todayBest.setAge(userInfo.getAge());

todayBest.setGender(userInfo.getSex().name().toLowerCase());

todayBest.setNickname(userInfo.getNickName());

todayBest.setTags(Convert.toStrArray(StrUtil.split(userInfo.getTags(),',')));

todayBest.setAvatar(userInfo.getLogo());

//缘分值

User user = UserThreadLocal.get();

todayBest.setFateValue(this.recommendUserService.queryScore(userId, user.getId()).longValue());

return todayBest;

}

}

======================================================

/**

* 查询推荐好友的缘分值 RecommendUserService

*

* @param userId

* @param toUserId

* @return

*/

public Double queryScore(Long userId, Long toUserId){

Double score = this.recommendUserApi.queryScore(userId, toUserId);

if(ObjectUtil.isNotEmpty(score)){

return score;

}

//默认值

return 98d;

}

本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 610798281@qq.com 举报,一经查实,本站将立刻删除。
如若转载,请注明出处:https://www.52mingliang.com/4850.html