分页 关联查询 等
This commit is contained in:
parent
4f6079dbb5
commit
c5f1456046
|
|
@ -1,5 +1,6 @@
|
|||
package com.sqx.modules.course.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -44,15 +45,18 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||
QueryWrapper<CourseCollect> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", courseCollect.getUserId()).eq("classify", 3).eq("course_id", courseCollect.getCourseId());
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
queryWrapper.last("limit 1");
|
||||
CourseCollect collect = baseMapper.selectOne(queryWrapper);
|
||||
PageHelper.startPage(1, 1);
|
||||
List<CourseCollect> courseCollects = baseMapper.selectList(queryWrapper);
|
||||
CourseCollect collect;
|
||||
if (CollectionUtil.isNotEmpty(courseCollects)) {
|
||||
collect = courseCollects.get(0);
|
||||
if (collect != null) {
|
||||
collect.setUpdateTime(DateUtils.format(new Date()));
|
||||
collect.setCourseCollectId(courseCollect.getCourseCollectId());
|
||||
baseMapper.updateById(collect);
|
||||
return Result.success("操作成功!");
|
||||
}
|
||||
|
||||
}
|
||||
collect = new CourseCollect()
|
||||
.setUserId(courseCollect.getUserId())
|
||||
.setCourseId(courseCollect.getCourseId())
|
||||
|
|
@ -105,8 +109,8 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||
PageHelper.startPage(page, limit);
|
||||
List<Course> courseList = baseMapper.selectCourseByCollect(userId, classify);
|
||||
PageInfo<Course> pageInfo = new PageInfo<>(courseList);
|
||||
if (CollectionUtil.isNotEmpty(courseList)) {
|
||||
List<Course> courses = pageInfo.getList();
|
||||
if (courses != null && courses.size() > 0) {
|
||||
for (Course course : courses) {
|
||||
course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,7 +247,6 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
|
||||
@Override
|
||||
public Result selectCourseDetailsList(Integer page, Integer limit, String token, String randomNum, Integer wxShow, Integer dyShow) {
|
||||
PageHelper.startPage(page, limit);
|
||||
Long userId = null;
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
Claims claims = jwtUtils.getClaimByToken(token);
|
||||
|
|
@ -258,6 +257,7 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
if(!Validator.isNumber(randomNum)){
|
||||
throw new SqxException("随机码必须是数字");
|
||||
};
|
||||
PageHelper.startPage(page, limit);
|
||||
List<CourseDetails> list = baseMapper.selectCourseDetailsList(randomNum, wxShow, dyShow);
|
||||
PageInfo<CourseDetails> pageInfo = new PageInfo<>(list);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ package com.sqx.modules.discSpinning.controller;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.discSpinning.entity.DiscSpinningRecord;
|
||||
|
|
@ -13,6 +16,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(value = "大转盘抽奖记录", tags = {"大转盘抽奖记录"})
|
||||
|
|
@ -34,7 +39,9 @@ public class DiscSpinningRecordController {
|
|||
@GetMapping("/selectDiscSpinningRecord")
|
||||
@ApiOperation("查询大转盘抽奖记录")
|
||||
public Result selectDiscSpinningRecord(Integer page, Integer limit, @RequestAttribute("userId") Long userId) {
|
||||
return Result.success().put("data", discSpinningRecordService.page(new Page<>(page, limit), new QueryWrapper<DiscSpinningRecord>().eq("user_id",userId).orderByDesc("create_time")));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.sqx.modules.discSpinning.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
|
@ -20,6 +22,7 @@ public class DiscSpinningRecord extends Model<DiscSpinningRecord> {
|
|||
|
||||
private Long sourceId;
|
||||
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
private Long userId;
|
||||
private String imgUrl;
|
||||
//描述
|
||||
|
|
|
|||
|
|
@ -57,20 +57,6 @@
|
|||
select cd.*,
|
||||
MD5(`course_details_id`) AS `uid`
|
||||
from course_details cd
|
||||
left join course c on c.course_id=cd.course_id
|
||||
where c.course_id is not null and c.is_delete=0 and cd.good=1
|
||||
<if test='null != wxShow and wxShow==1'>
|
||||
and c.wx_show = #{wxShow}
|
||||
</if>
|
||||
<if test='null != wxShow and wxShow==2'>
|
||||
and (c.wx_show = #{wxShow} or c.wx_show is null)
|
||||
</if>
|
||||
<if test='null != dyShow and dyShow==1'>
|
||||
and c.dy_show = #{dyShow}
|
||||
</if>
|
||||
<if test='null != dyShow and dyShow==2'>
|
||||
and (c.dy_show = #{dyShow} or c.dy_show is null)
|
||||
</if>
|
||||
order by SUBSTR(uid, ${randomNum}, 6)
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue