返回数据

This commit is contained in:
GYJ
2025-01-03 21:00:47 +08:00
parent 4ab8f837d5
commit 404e7b663b
10 changed files with 27 additions and 19 deletions

View File

@@ -9,6 +9,7 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil;
import com.aliyun.tea.ValidateException;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
@@ -28,6 +29,7 @@ import com.sqx.modules.common.entity.CommonInfo;
import com.sqx.modules.common.service.CommonInfoService;
import com.sqx.modules.discSpinning.dao.DiscSpinningRecordDao;
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
import com.sqx.modules.discSpinning.service.DiscSpinningRecordService;
import com.sqx.modules.taskCenter.dao.TaskCenterRecordDao;
import com.sqx.modules.taskCenter.dao.TaskCenterRewardDao;
import com.sqx.modules.taskCenter.entity.TaskCenterRecord;
@@ -54,6 +56,8 @@ public class UserPrizeExchangeServiceImpl extends ServiceImpl<UserPrizeExchangeD
@Resource
private DiscSpinningRecordDao discSpinningRecordDao;
@Resource
private DiscSpinningRecordService discSpinningRecordService;
@Resource
private TaskCenterRecordDao taskCenterRecordDao;
@Resource
private TaskCenterRewardDao taskCenterRewardDao;
@@ -126,7 +130,10 @@ public class UserPrizeExchangeServiceImpl extends ServiceImpl<UserPrizeExchangeD
}
Dict dict = Dict.create();
if ("spinning".equals(dto.getForeignType())) {
DiscSpinningRecord record = discSpinningRecordDao.selectById(dto.getForeignId());
QueryWrapper<DiscSpinningRecord> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("id", dto.getForeignId());
queryWrapper.eq("user_id", currentUserId);
DiscSpinningRecord record = discSpinningRecordService.getOne(queryWrapper);
if (record == null) {
throw new SqxException("中奖记录不存在");
}

View File

@@ -120,7 +120,7 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
.eq(CourseCollect::getUserId, userId)
.eq(CourseCollect::getClassify, classify)
.isNotNull(CourseCollect::getCourseId)
.select(CourseCollect::getCourseId, CourseCollect::getUserId))
.select(CourseCollect::getCourseId, CourseCollect::getUserId).groupBy(CourseCollect::getCourseId))
.stream().map(CourseCollect::getCourseId).collect(Collectors.toSet());
// List<CourseCollect> collectList = baseMapper.selectByUserId(userId, classify);
// Set<Long> courseIdList = collectList.stream().map(CourseCollect::getCourseId).collect(Collectors.toSet());

View File

@@ -41,7 +41,8 @@ public class DiscSpinningRecordController {
public Result selectDiscSpinningRecord(Integer page, Integer limit, @RequestAttribute("userId") Long userId) {
PageHelper.startPage(page, limit);
List<DiscSpinningRecord> list = discSpinningRecordService.list(new QueryWrapper<DiscSpinningRecord>().eq("user_id", userId).orderByDesc("create_time"));
return Result.success().put("data", PageUtils.page(new PageInfo<>(list), true));
PageInfo<DiscSpinningRecord> pageInfo = new PageInfo<>(list);
PageUtils pageUtils = PageUtils.page(pageInfo, true);
return Result.success().put("data", pageUtils);
}
}

View File

@@ -86,7 +86,7 @@ public class SysLoginController extends AbstractController {
user.setIsChannel(1);
user.setQdRate(new BigDecimal("0.01"));
user.setStatus(1);
user.setRoleIdList(Collections.singletonList(4L));
user.setRoleIdList(Collections.singletonList("4"));
ValidatorUtils.validateEntity(user, AddGroup.class);
user.setUserId(InvitationCodeUtil.getSnowFlakeId());
sysUserService.saveUser(user);

View File

@@ -88,7 +88,7 @@ public class SysUserController extends AbstractController {
SysUserEntity user = sysUserService.getById(userId);
//获取用户所属的角色列表
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(userId);
List<String> roleIdList = sysUserRoleService.queryRoleIdList(userId);
user.setRoleIdList(roleIdList);
return Result.success().put("user", user);

View File

@@ -12,11 +12,11 @@ import java.util.List;
*/
@Mapper
public interface SysUserRoleDao extends BaseMapper<SysUserRoleEntity> {
/**
* 根据用户ID获取角色ID列表
*/
List<Long> queryRoleIdList(Long userId);
List<String> queryRoleIdList(Long userId);
/**

View File

@@ -72,7 +72,7 @@ public class SysUserEntity implements Serializable {
* 角色ID列表
*/
@TableField(exist=false)
private List<Long> roleIdList;
private List<String> roleIdList;
/**
* 创建者ID

View File

@@ -12,13 +12,13 @@ import java.util.List;
*
*/
public interface SysUserRoleService extends IService<SysUserRoleEntity> {
void saveOrUpdate(Long userId, List<Long> roleIdList);
void saveOrUpdate(Long userId, List<String> roleIdList);
/**
* 根据用户ID获取角色ID列表
*/
List<Long> queryRoleIdList(Long userId);
List<String> queryRoleIdList(Long userId);
/**
* 根据角色ID数组批量删除

View File

@@ -18,7 +18,7 @@ import java.util.List;
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleDao, SysUserRoleEntity> implements SysUserRoleService {
@Override
public void saveOrUpdate(Long userId, List<Long> roleIdList) {
public void saveOrUpdate(Long userId, List<String> roleIdList) {
if (roleIdList == null || roleIdList.isEmpty()) {
return;
}
@@ -27,17 +27,17 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleDao, SysUserR
this.removeByMap(new MapUtils().put("user_id", userId));
//保存用户与角色关系
for (Long roleId : roleIdList) {
for (String roleId : roleIdList) {
SysUserRoleEntity sysUserRoleEntity = new SysUserRoleEntity();
sysUserRoleEntity.setUserId(userId);
sysUserRoleEntity.setRoleId(roleId);
sysUserRoleEntity.setRoleId(Long.parseLong(roleId));
this.save(sysUserRoleEntity);
}
}
@Override
public List<Long> queryRoleIdList(Long userId) {
public List<String> queryRoleIdList(Long userId) {
return baseMapper.queryRoleIdList(userId);
}

View File

@@ -10,7 +10,7 @@
</foreach>
</delete>
<select id="queryRoleIdList" resultType="long">
<select id="queryRoleIdList" resultType="string">
select role_id from sys_user_role where user_id = #{value}
</select>
</mapper>
</mapper>