Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
a15d317e77
5
pom.xml
5
pom.xml
|
|
@ -53,6 +53,11 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.brainlag</groupId>
|
||||
<artifactId>nsq-client</artifactId>
|
||||
<version>1.0.0.RC4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dytnsapi20200217</artifactId>
|
||||
|
|
|
|||
|
|
@ -23,13 +23,12 @@ public class AppAnnouncementController {
|
|||
}
|
||||
|
||||
@GetMapping
|
||||
public Result get(@RequestParam Integer type) {
|
||||
PageHelper.startPage(1,1);
|
||||
public Result get(@RequestParam(defaultValue = "0") Integer type) {
|
||||
List<Announcement> list = announcementService.list(new LambdaQueryWrapper<Announcement>()
|
||||
.eq(Announcement::getType, type)
|
||||
.eq(Announcement::getState, 1)
|
||||
.orderByDesc(Announcement::getCreateTime));
|
||||
return Result.success().put("data", list.isEmpty() ? null : list.get(0));
|
||||
return Result.success().put("data", list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,4 +22,5 @@ public class CourseOrderResponse implements Serializable {
|
|||
* 售卖金币
|
||||
*/
|
||||
private Double coursemoney;
|
||||
private Long courseId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,11 +47,14 @@ import com.sqx.modules.app.dto.AuthDTO;
|
|||
import com.sqx.modules.app.dto.AuthRespDTO;
|
||||
import com.sqx.modules.app.entity.*;
|
||||
import com.sqx.modules.app.mapper.TbUserBlacklistMapper;
|
||||
import com.sqx.modules.app.response.CourseOrderResponse;
|
||||
import com.sqx.modules.app.service.*;
|
||||
import com.sqx.modules.app.utils.JwtUtils;
|
||||
import com.sqx.modules.app.utils.UserConstantInterface;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.course.dao.CourseDao;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import com.sqx.modules.discSpinning.service.DiscSpinningService;
|
||||
import com.sqx.modules.file.utils.Md5Utils;
|
||||
import com.sqx.modules.invite.service.InviteService;
|
||||
|
|
@ -130,6 +133,8 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
|
||||
|
||||
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
||||
@Autowired
|
||||
private CourseDao courseDao;
|
||||
|
||||
public UserServiceImpl(@Lazy AliService aliService, UserInfoService userInfoService, UserVipDao userVipDao, InviteAchievementService inviteAchievementService) {
|
||||
this.aliService = aliService;
|
||||
|
|
@ -1423,8 +1428,21 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
}
|
||||
|
||||
PageHelper.startPage(page.intValue(), limit.intValue());
|
||||
List<Map<String, Object>> list = baseMapper.queryCourseOrder(type, startTime, endTime, sysUserId);
|
||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
||||
List<CourseOrderResponse> courseList = courseDao.selectGroupCourseId(startTime, endTime);
|
||||
Set<Long> collect = courseList.stream().map(CourseOrderResponse::getCourseId).collect(Collectors.toSet());
|
||||
if (!collect.isEmpty()) {
|
||||
Map<Long, Course> courseMap = courseDao.selectList(new LambdaQueryWrapper<Course>().in(Course::getCourseId, collect).select(Course::getCourseId, Course::getTitle))
|
||||
.stream().collect(Collectors.toMap(Course::getCourseId, item -> item));
|
||||
courseList.forEach(item -> {
|
||||
Course course = courseMap.get(item.getCourseId());
|
||||
if (course != null) {
|
||||
item.setCoursename(course.getTitle());
|
||||
}
|
||||
});
|
||||
}
|
||||
PageInfo<CourseOrderResponse> pageInfo = new PageInfo<>(courseList);
|
||||
// List<Map<String, Object>> list = baseMapper.queryCourseOrder(type, startTime, endTime, sysUserId);
|
||||
// PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
||||
|
||||
return PageUtils.page(pageInfo, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class AppCourseController extends AbstractController {
|
|||
|
||||
@GetMapping("/selectCourseDetailsList")
|
||||
@ApiOperation("查询推荐视频")
|
||||
public Result selectCourseDetailsList(@RequestHeader("token") String token) {
|
||||
public Result selectCourseDetailsList(@RequestHeader(value = "token", required= false) String token) {
|
||||
return courseDetailsService.selectCourseDetailsList(token);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.sqx.modules.course.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sqx.modules.app.response.CourseOrderResponse;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -39,4 +40,6 @@ public interface CourseDao extends BaseMapper<Course> {
|
|||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> selectCourseTitle(@Param("title")String title);
|
||||
|
||||
List<CourseOrderResponse> selectGroupCourseId(@Param("start")String startTime, @Param("end") String endTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,8 +241,7 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
map.put("list", courseDetailsSetVos);
|
||||
return new Result().put("data", map);
|
||||
} catch (Exception e) {
|
||||
log.error("请求剧集异常打印:");
|
||||
e.printStackTrace();
|
||||
log.error("请求剧集异常打印:",e);
|
||||
return Result.error("请求剧集失败");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,17 +192,19 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
|
||||
PageHelper.startPage(page, limit);
|
||||
if (admin == null) {
|
||||
List<Map<String, Object>> map = baseMapper.selectCourse(classifyId, title, isRecommend, status, bannerId,
|
||||
List<Map<String, Object>> map = baseMapper.selectCourse(classifyId, title, isRecommend, 1, bannerId,
|
||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(map);
|
||||
List<Map<String, Object>> records = pageInfo.getList();
|
||||
for (Map<String, Object> m : records) {
|
||||
Integer i = courseDetailsDao.selectCount(new QueryWrapper<CourseDetails>().eq("course_id", m.get("courseId")));
|
||||
if (i != null && i.equals(0)) {
|
||||
baseMapper.update(null, new LambdaUpdateWrapper<Course>()
|
||||
.eq(Course::getCourseId, m.get("courseId"))
|
||||
.set(Course::getUpdateTime, DateUtil.now())
|
||||
.set(Course::getStatus, 2));
|
||||
}
|
||||
m.put("courseDetailsCount", i == null ? 0 : i);
|
||||
m.put("courseDetailsId", null);
|
||||
m.put("courseDetailsName", "");
|
||||
m.put("dyEpisodeId", "");
|
||||
m.put("wxCourseDetailsId", "");
|
||||
m.put("courseId", m.get("courseId").toString());
|
||||
}
|
||||
PageUtils pageUtils = PageUtils.page(pageInfo);
|
||||
|
|
@ -222,10 +224,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
Map<String, Object> countMap = courseDetailsDao.countCourse(courseId);
|
||||
BigDecimal payMoney = ordersDao.sumPayByCourseId(courseId);
|
||||
map.put("payMoney", payMoney == null ? BigDecimal.ZERO : payMoney);
|
||||
map.put("courseDetailsId", null);
|
||||
map.put("courseDetailsName", "");
|
||||
map.put("dyEpisodeId", "");
|
||||
map.put("wxCourseDetailsId", "");
|
||||
// map.put("courseDetailsId", null);
|
||||
// map.put("courseDetailsName", "");
|
||||
// map.put("dyEpisodeId", "");
|
||||
// map.put("wxCourseDetailsId", "");
|
||||
map.putAll(countMap);
|
||||
map.put("courseId", map.get("courseId").toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package com.sqx.nsqChannel;
|
||||
|
||||
import com.sqx.nsqChannel.channels.Print2MessageHandlerAdapter;
|
||||
import com.sqx.nsqChannel.channels.PrintMessageHandlerAdapter;
|
||||
import com.sqx.nsqChannel.config.NSQConsumers;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class NsqConfig {
|
||||
// /**
|
||||
// * 端口号
|
||||
// */
|
||||
// @Value("${nsq.port}")
|
||||
// private int port;
|
||||
//
|
||||
// @Value("${nsq.address}")
|
||||
// private String address;
|
||||
//
|
||||
// @PostConstruct
|
||||
// public void startNSQChannel() {
|
||||
// new NSQConsumers(address, port, "test", "ch1", new Print2MessageHandlerAdapter());
|
||||
// new NSQConsumers(address, port, "test", "ch2", new PrintMessageHandlerAdapter());
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.sqx.nsqChannel.channels;
|
||||
|
||||
import com.sqx.nsqChannel.config.NSQMessageHandlerAdapter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class Print2MessageHandlerAdapter extends NSQMessageHandlerAdapter {
|
||||
@Override
|
||||
public void handleMessage(byte[] message) {
|
||||
System.out.println("Print2MessageHandlerAdapter message: " + new String(message));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.sqx.nsqChannel.channels;
|
||||
|
||||
import com.sqx.nsqChannel.config.NSQMessageHandlerAdapter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class PrintMessageHandlerAdapter extends NSQMessageHandlerAdapter {
|
||||
|
||||
@Override
|
||||
public void handleMessage(byte[] message) {
|
||||
System.out.println("PrintMessageHandlerAdapter message: " + new String(message));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.sqx.nsqChannel.config;
|
||||
|
||||
import com.github.brainlag.nsq.NSQConsumer;
|
||||
import com.github.brainlag.nsq.lookup.DefaultNSQLookup;
|
||||
import com.github.brainlag.nsq.lookup.NSQLookup;
|
||||
|
||||
public class NSQConsumers {
|
||||
|
||||
private final String nsqLookupAddress;
|
||||
private final int nsqLookupPort;
|
||||
private final String topics;
|
||||
private final String channelName;
|
||||
private final NSQMessageHandlerAdapter handlerAdapter;
|
||||
private NSQConsumer consumer;
|
||||
|
||||
public NSQConsumers(String nsqLookupAddress, int nsqLookupPort,String topics, String channelName, NSQMessageHandlerAdapter handlerAdapter) {
|
||||
this.nsqLookupAddress = nsqLookupAddress;
|
||||
this.nsqLookupPort = nsqLookupPort;
|
||||
this.topics = topics;
|
||||
this.channelName = channelName;
|
||||
this.handlerAdapter = handlerAdapter;
|
||||
start();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
try {
|
||||
NSQLookup lookup = new DefaultNSQLookup();
|
||||
lookup.addLookupAddress(nsqLookupAddress, nsqLookupPort);
|
||||
|
||||
consumer = new NSQConsumer(lookup, topics, channelName, (message) -> {
|
||||
handlerAdapter.handleMessage(message.getMessage());
|
||||
message.finished();
|
||||
});
|
||||
consumer.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (consumer != null) {
|
||||
consumer.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.sqx.nsqChannel.config;
|
||||
|
||||
public abstract class NSQMessageHandlerAdapter {
|
||||
public abstract void handleMessage(byte[] message);
|
||||
|
||||
}
|
||||
|
|
@ -8,6 +8,10 @@ pay:
|
|||
server:
|
||||
port: 8100
|
||||
|
||||
nsq:
|
||||
address: 47.122.26.160
|
||||
port: 4161
|
||||
|
||||
# 数据源的一些配置
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 最小空闲连接,默认值10,小于0或大于maximum-pool-size,都会重置为maximum-pool-size
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ pay:
|
|||
server:
|
||||
port: 8200
|
||||
|
||||
nsq:
|
||||
address: 47.122.26.160
|
||||
port: 4161
|
||||
|
||||
# 数据源的一些配置
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 最小空闲连接,默认值10,小于0或大于maximum-pool-size,都会重置为maximum-pool-size
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ pay:
|
|||
server:
|
||||
port: 8100
|
||||
|
||||
nsq:
|
||||
address: 127.0.0.1
|
||||
port: 4161
|
||||
|
||||
# 数据源的一些配置
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 最小空闲连接,默认值10,小于0或大于maximum-pool-size,都会重置为maximum-pool-size
|
||||
|
|
|
|||
|
|
@ -11,41 +11,17 @@
|
|||
c.classify_id AS classifyId,
|
||||
c.course_id AS courseId,
|
||||
c.course_label AS courseLabel,
|
||||
c.create_time AS createTime,
|
||||
c.details,
|
||||
c.img,
|
||||
c.banner_img AS bannerImg,
|
||||
c.status,
|
||||
c.is_delete AS isDelete,
|
||||
c.msg_type AS msgType,
|
||||
c.msg_url AS msgUrl,
|
||||
c.pay_num AS payNum,
|
||||
c.price,
|
||||
c.wholesale_price AS wholesalePrice,
|
||||
c.is_over AS isOver,
|
||||
c.title,
|
||||
c.is_price AS isPrice,
|
||||
c.title_img AS titleImg,
|
||||
c.update_time AS updateTime,
|
||||
c.course_type AS courseType,
|
||||
c.banner_id AS bannerId
|
||||
FROM
|
||||
course AS c
|
||||
WHERE
|
||||
c.is_delete = 0
|
||||
|
||||
<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>
|
||||
<if test='null != title'>
|
||||
and c.title LIKE CONCAT('%', #{title}, '%')
|
||||
</if>
|
||||
|
|
@ -67,15 +43,6 @@
|
|||
<if test="status!=null and status!=0">
|
||||
and c.status=#{status}
|
||||
</if>
|
||||
<if test="isPrice!=null">
|
||||
and c.is_price=#{isPrice}
|
||||
</if>
|
||||
<if test="wxCourse!=null">
|
||||
and c.wx_course_id is not null
|
||||
</if>
|
||||
<if test="dyCourse!=null">
|
||||
and c.dy_status=4
|
||||
</if>
|
||||
<if test="sort==null">
|
||||
order by c.sort asc,c.create_time desc
|
||||
</if>
|
||||
|
|
@ -236,5 +203,13 @@
|
|||
</if>
|
||||
order by create_time desc
|
||||
</select>
|
||||
<select id="selectGroupCourseId" resultType="com.sqx.modules.app.response.CourseOrderResponse">
|
||||
select sum(o.pay_money) as 'coursemoney' ,count(*) as 'coursenum', o.course_id as courseId
|
||||
from orders o
|
||||
where o.status=1 and o.orders_type=1
|
||||
and o.create_time between #{start} and #{end}
|
||||
group by o.course_id
|
||||
order by coursenum desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue