Commit 2102337c authored by muhong's avatar muhong

修改 邀请码

parent 74255868
......@@ -46,6 +46,14 @@ public interface FavoritesDao {
*/
List<Favorites> listByUserId(Long userId);
/**
* 通过用户id查询记录数
*
* @param userId
* @return
*/
long countByUserId(Long userId);
/**
* 通过用户id分页查询
*
......
......@@ -115,6 +115,14 @@ public interface FavoritesItemsRelationDao {
*/
long countByFavoritesId(Long favoritesId);
/**
* 通过用户id统计记录数
*
* @param userId
* @return
*/
long countByUserId(Long userId);
/**
* 通过藏品id分组统计记录数量最多的20条记录
*
......
......@@ -53,6 +53,15 @@ public class FavoritesDaoImpl implements FavoritesDao {
return favoritesMapper.selectByExampleWithBLOBs(example);
}
@Override
public long countByUserId(Long userId) {
FavoritesExample example = new FavoritesExample();
FavoritesExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andDeletedEqualTo(false);
return favoritesMapper.countByExample(example);
}
@Override
public PageInfo<Favorites> pageByUserId(Long userId, int page, int size) {
FavoritesExample example = new FavoritesExample();
......
......@@ -124,6 +124,14 @@ public class FavoritesItemsRelationDaoImpl implements FavoritesItemsRelationDao
return favoritesItemsRelationMapper.countByExample(example);
}
@Override
public long countByUserId(Long userId) {
FavoritesItemsRelationExample example = new FavoritesItemsRelationExample();
FavoritesItemsRelationExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(userId, criteria::andUserIdEqualTo);
return favoritesItemsRelationMapper.countByExample(example);
}
@Override
public List<Map<String, Object>> findItemIdByCount() {
return favoritesItemsRelationMapper.selectItemIdByCount();
......
......@@ -197,6 +197,22 @@ public class FavoritesServiceImpl implements FavoritesService {
}
}
@Override
public Result favoritesNum(FavoritesRequestDto dto) {
try {
long itemNum = favoritesItemsRelationDao.countByUserId(dto.getUserId());
long favoritesNum = favoritesDao.countByUserId(dto.getUserId());
Map<String, Object> map = new HashMap<>();
map.put("itemNum", itemNum);
map.put("favoritesNum", favoritesNum);
logger.info("【请求结束】收藏品和收藏册数量查询成功");
return Result.success(map);
} catch (Exception e) {
logger.error("收藏品和收藏册数量查询失败,原因:" + e.getMessage(), e);
return Result.failed("收藏品和收藏册数量查询失败");
}
}
@Override
public Result itemList(FavoritesRequestDto dto) {
try {
......
......@@ -22,6 +22,7 @@ import com.wwdz.ch.wx.manager.AlipayLoginManager;
import com.wwdz.ch.wx.manager.TikTokLoginManager;
import com.wwdz.ch.wx.manager.UserTokenManager;
import com.wwdz.ch.wx.manager.WxLoginManager;
import com.wwdz.ch.wx.service.InviteRecordService;
import com.wwdz.ch.wx.service.UserService;
import com.wwdz.ch.wx.util.IpUtil;
import com.wwdz.ch.wx.util.RedisUtil;
......@@ -70,6 +71,9 @@ public class UserServiceImpl implements UserService {
@Autowired
private AliSmsSender aliSmsSender;
@Autowired
private InviteRecordService inviteRecordService;
@Override
public Result regCaptcha(UserRequestDto dto) {
......@@ -124,7 +128,7 @@ public class UserServiceImpl implements UserService {
}
// 获取登录结果
Map<String, Object> result = getLoginResult(dto.getMobile(), request);
result.put("isInvited", inviteRecordService.isExisted(dto.getMobile()).getData());
logger.info("【请求结束】手机号登录,响应结果:{}", JSONObject.toJSONString(result));
// 清除验证码缓存
redisUtil.del(key);
......@@ -179,7 +183,7 @@ public class UserServiceImpl implements UserService {
}
// 获取登录结果
Map<String, Object> result = getLoginResult(mobile, request);
result.put("isInvited", inviteRecordService.isExisted(dto.getMobile()).getData());
logger.info("【请求结束】快捷登录成功,响应结果:{}", JSONObject.toJSONString(result));
return Result.success(result);
} catch (Exception e) {
......
......@@ -66,15 +66,14 @@ public class LoginInterceptor implements HandlerInterceptor {
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.getWriter().write(JSON.toJSONString(map));
} else {
if (StringUtils.equals(url, "/wx/user/fillCode")) {
return true;
}
Integer loginType = 1;
if (StringUtils.isBlank(token)) {
loginType = 2;
}
if (StringUtils.isNotBlank(token)) {
} else {
if (userTokenManager.checkLogin(token)) {
if (StringUtils.equals(url, "/wx/user/fillCode")) {
return true;
}
User user = userDao.queryById(userTokenManager.getUserId(token));
if (!(Boolean) inviteRecordService.isExisted(user.getMobile()).getData()) {
loginType = 3;
......
......@@ -45,6 +45,14 @@ public interface FavoritesService {
*/
Result info(FavoritesRequestDto dto);
/**
* 收藏品和收藏册数量
*
* @param dto
* @return
*/
Result favoritesNum(FavoritesRequestDto dto);
/**
* 收藏册下藏品列表
*
......
......@@ -103,6 +103,16 @@ public class WxFavoritesController {
return favoritesService.info(dto);
}
@ApiOperation(value = "收藏品和收藏册数量")
@PostMapping("/favoritesNum")
public Result favoritesNum(@RequestBody FavoritesRequestDto dto) {
logger.info("【请求开始】收藏品和收藏册数量查询,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
return favoritesService.favoritesNum(dto);
}
@ApiOperation(value = "收藏册下藏品列表")
@PostMapping("/itemList")
public Result itemList(@RequestBody FavoritesRequestDto dto) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment