Commit 53dec052 authored by muhong's avatar muhong

修改 小程序足迹

parent 7b350b97
package com.wwdz.ch.db.dao;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.domain.Footprint;
import java.util.List;
......@@ -21,7 +22,7 @@ public interface FootPrintDao {
* @param size
* @return
*/
List<Footprint> pageByUserId(Long userId, Integer page, Integer size);
PageInfo<Footprint> pageByUserId(Long userId, Integer page, Integer size);
/**
* 通过用户id统计记录数
......
package com.wwdz.ch.db.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.db.dao.FootPrintDao;
import com.wwdz.ch.db.domain.Footprint;
import com.wwdz.ch.db.domain.FootprintExample;
......@@ -27,14 +28,15 @@ public class FootPrintDaoImpl implements FootPrintDao {
}
@Override
public List<Footprint> pageByUserId(Long userId, Integer page, Integer size) {
public PageInfo<Footprint> pageByUserId(Long userId, Integer page, Integer size) {
FootprintExample example = new FootprintExample();
FootprintExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andDeletedEqualTo(false);
example.orderBy("update_time desc");
PageHelper.startPage(page, size);
return footprintMapper.selectByExample(example);
List<Footprint> list = footprintMapper.selectByExample(example);
return new PageInfo<>(list);
}
@Override
......
......@@ -21,6 +21,12 @@ public class CacheCodeConstants {
*/
public static final String USER_UPDATE_SMS_KEY = "cjxc:wx:user:sms:update:{0}";
/**
* 缓存用户信息
* <p>{0}:用户id</p>
*/
public static final String USER_INFO_KEY = "cjxc:wx:user:info:{0}";
/**
* 短信验证码类型枚举
*/
......
package com.wwdz.ch.wx.impl;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.FavoritesItemsRelationDao;
......@@ -40,19 +41,21 @@ public class FootPrintServiceImpl implements FootPrintService {
@Override
public Result page(FootPrintRequestDto dto) {
try {
Map<String, Object> map = new HashMap<>();
map.put("pageNum", dto.getPage());
map.put("pageSize", dto.getSize());
map.put("total", 0);
map.put("list", new ArrayList<>());
PageInfo<AgentTranceResponseVo> result = new PageInfo<>();
result.setPageNum(dto.getPage());
result.setPageSize(dto.getSize());
result.setTotal(0L);
result.setList(new ArrayList<>());
result.setHasNextPage(false);
List<AgentTranceResponseVo> resultList = new ArrayList<>();
List<Footprint> list = footPrintDao.pageByUserId(dto.getUserId(), dto.getPage(), dto.getSize());
if (CollectionUtils.isEmpty(list)) {
return Result.success(map);
PageInfo<Footprint> page = footPrintDao.pageByUserId(dto.getUserId(), dto.getPage(), dto.getSize());
if (CollectionUtils.isEmpty(page.getList())) {
return Result.success(result);
}
map.put("total", footPrintDao.countByUserId(dto.getUserId()));
result.setTotal(page.getTotal());
result.setHasNextPage(page.isHasNextPage());
List<AgentTranceResponseVo> resultList = new ArrayList<>();
// 现在
Date now = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
......@@ -72,7 +75,7 @@ public class FootPrintServiceImpl implements FootPrintService {
calendar.setTime(now);
calendar.add(Calendar.MONTH, -1);
Date month = calendar.getTime();
for (Footprint footprint : list) {
for (Footprint footprint : page.getList()) {
ItemResponseVo itemResponseVo = new ItemResponseVo();
Item item = itemDao.findDetails(footprint.getItemId());
// 设置基本信息
......@@ -112,7 +115,7 @@ public class FootPrintServiceImpl implements FootPrintService {
agentTranceResponseVo.setDetail(itemResponseVo);
resultList.add(agentTranceResponseVo);
}
result.setList(resultList);
logger.info("【请求结束】用户足迹分页查询成功");
return Result.success(resultList);
} catch (Exception e) {
......
......@@ -426,4 +426,21 @@ public class UserServiceImpl implements UserService {
return Result.failed("修改手机号失败");
}
}
@Override
public Result userInfo(UserRequestDto dto) {
try {
User user = null;
// String key = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, dto.getUserId().toString());
// if (redisUtil.hasKey(key)) {
// user = (User) redisUtil.get(key);
// } else {
user = userDao.queryById(dto.getUserId());
// }
return Result.success(user);
} catch (Exception e) {
logger.error("查询用户信息失败", e);
return Result.failed("查询用户信息失败");
}
}
}
......@@ -71,4 +71,12 @@ public interface UserService {
* @return
*/
Result updateMobile(UserRequestDto dto);
/**
* 查询用户信息
*
* @param dto
* @return
*/
Result userInfo(UserRequestDto dto);
}
......@@ -155,4 +155,14 @@ public class WxUserController {
}
return userService.updateMobile(dto);
}
@ApiOperation(value = "用户信息")
@PostMapping("/userInfo")
public Result userInfo(@RequestBody UserRequestDto dto) {
logger.info("【请求开始】查询用户信息,请求参数:{}", JSON.toJSONString(dto));
if (Objects.isNull(dto.getUserId()) || dto.getUserId().equals(0L)) {
return Result.failed("用户id不能为空");
}
return userService.userInfo(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