| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.account.api.model.UserPoint; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * Mapper 接口 |
| | |
| | | */ |
| | | public interface UserPointMapper extends BaseMapper<UserPoint> { |
| | | |
| | | List<UserPoint> findLatestUserPointByTypeForUser(Long userId); |
| | | } |
| | |
| | | @Override |
| | | public UserPointVO getUserPoint(Long userId) { |
| | | AppUser appUser = appUserService.getById(userId); |
| | | List<UserPoint> userPointList = list(new LambdaQueryWrapper<UserPoint>() |
| | | .eq(UserPoint::getAppUserId, userId)); |
| | | List<UserPoint> userPointList = this.baseMapper.findLatestUserPointByTypeForUser(userId); |
| | | |
| | | Map<Integer, Integer> userBalanceMap = userPointList.stream() |
| | | .collect(Collectors.toMap(UserPoint::getType, UserPoint::getBalance)); |
| | |
| | | <sql id="Base_Column_List"> |
| | | id, type, historical_point, variable_point, create_time, app_user_id, object_id |
| | | </sql> |
| | | <select id="findLatestUserPointByTypeForUser" resultType="com.ruoyi.account.api.model.UserPoint"> |
| | | SELECT |
| | | t1.* |
| | | FROM |
| | | t_user_point t1 |
| | | INNER JOIN ( SELECT type, MAX( create_time ) AS max_create_time FROM t_user_point WHERE app_user_id = 1864118151377129473 GROUP BY type ) t2 ON t1.type = t2.type |
| | | AND t1.create_time = t2.max_create_time |
| | | WHERE |
| | | t1.app_user_id = #{userId} |
| | | </select> |
| | | |
| | | </mapper> |