Merge branch 'test' into dev
This commit is contained in:
commit
05516d9db6
66
pom.xml
66
pom.xml
|
|
@ -23,7 +23,7 @@
|
|||
<mssql.version>4.0</mssql.version>
|
||||
<oracle.version>11.2.0.3</oracle.version>
|
||||
<druid.version>1.1.13</druid.version>
|
||||
<quartz.version>2.3.0</quartz.version>
|
||||
<!-- <quartz.version>2.3.0</quartz.version>-->
|
||||
<commons.lang.version>2.6</commons.lang.version>
|
||||
<commons.fileupload.version>1.2.2</commons.fileupload.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
|
|
@ -53,6 +53,26 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>dytnsapi20200217</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-openapi</artifactId>
|
||||
<version>0.3.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-console</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-util</artifactId>
|
||||
<version>0.2.23</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.volcengine</groupId>
|
||||
|
|
@ -65,17 +85,17 @@
|
|||
<artifactId>guava</artifactId>
|
||||
<version>19.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk</artifactId>
|
||||
<version>1.11.274</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>aws-java-sdk-simpleworkflow</artifactId>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.amazonaws</groupId>-->
|
||||
<!-- <artifactId>aws-java-sdk</artifactId>-->
|
||||
<!-- <version>1.11.274</version>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <artifactId>aws-java-sdk-simpleworkflow</artifactId>-->
|
||||
<!-- <groupId>com.amazonaws</groupId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-spring-boot-starter</artifactId>
|
||||
|
|
@ -305,17 +325,17 @@
|
|||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>${druid.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>${quartz.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.quartz-scheduler</groupId>-->
|
||||
<!-- <artifactId>quartz</artifactId>-->
|
||||
<!-- <version>${quartz.version}</version>-->
|
||||
<!-- <exclusions>-->
|
||||
<!-- <exclusion>-->
|
||||
<!-- <groupId>com.mchange</groupId>-->
|
||||
<!-- <artifactId>c3p0</artifactId>-->
|
||||
<!-- </exclusion>-->
|
||||
<!-- </exclusions>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -114,8 +115,13 @@ public class ApiAccessLimitUtil {
|
|||
String redisKey = generateRedisKey(key, id);
|
||||
Object countObj = redisUtils.get(redisKey);
|
||||
if (countObj == null) {
|
||||
// 根据不同时间周期设置过期时间并初始化访问次数为1
|
||||
long expireAt = calculateExpireAt(timeFormat);
|
||||
long expireAt;
|
||||
if (StrUtil.isBlank(timeFormat)) {
|
||||
expireAt = count;
|
||||
}else {
|
||||
// 根据不同时间周期设置过期时间并初始化访问次数为1
|
||||
expireAt = calculateExpireAt(timeFormat);
|
||||
}
|
||||
redisUtils.set(redisKey, 1, expireAt);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -127,6 +133,11 @@ public class ApiAccessLimitUtil {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void removeKey(String id, String key) {
|
||||
String redisKey = generateRedisKey(key, id);
|
||||
redisUtils.delete(redisKey);
|
||||
}
|
||||
|
||||
|
||||
public static<T> T runFunAndCheckKey(Supplier<T> supplier, String lockKey, Integer seconds) {
|
||||
try{
|
||||
|
|
|
|||
|
|
@ -1,101 +1,120 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页工具类
|
||||
*
|
||||
*/
|
||||
public class PageUtils implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private int totalCount;
|
||||
/**
|
||||
* 每页记录数
|
||||
*/
|
||||
private int pageSize;
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
private int totalPage;
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private int currPage;
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<?> list;
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 总记录数
|
||||
*/
|
||||
private int totalCount;
|
||||
/**
|
||||
* 每页记录数
|
||||
*/
|
||||
private int pageSize;
|
||||
/**
|
||||
* 总页数
|
||||
*/
|
||||
private int totalPage;
|
||||
/**
|
||||
* 当前页数
|
||||
*/
|
||||
private int currPage;
|
||||
/**
|
||||
* 列表数据
|
||||
*/
|
||||
private List<?> list;
|
||||
private List<?> records;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param list 列表数据
|
||||
* @param totalCount 总记录数
|
||||
* @param pageSize 每页记录数
|
||||
* @param currPage 当前页数
|
||||
*/
|
||||
public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
|
||||
this.list = list;
|
||||
this.totalCount = totalCount;
|
||||
this.pageSize = pageSize;
|
||||
this.currPage = currPage;
|
||||
this.totalPage = (int)Math.ceil((double)totalCount/pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
public PageUtils(IPage<?> page) {
|
||||
this.list = page.getRecords();
|
||||
this.totalCount = (int)page.getTotal();
|
||||
this.pageSize = (int)page.getSize();
|
||||
this.currPage = (int)page.getCurrent();
|
||||
this.totalPage = (int)page.getPages();
|
||||
}
|
||||
public PageUtils() {
|
||||
}
|
||||
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
/**
|
||||
* 分页
|
||||
*
|
||||
* @param list 列表数据
|
||||
* @param totalCount 总记录数
|
||||
* @param pageSize 每页记录数
|
||||
* @param currPage 当前页数
|
||||
*/
|
||||
public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
|
||||
this.list = list;
|
||||
this.totalCount = totalCount;
|
||||
this.pageSize = pageSize;
|
||||
this.currPage = currPage;
|
||||
this.totalPage = (int) Math.ceil((double) totalCount / pageSize);
|
||||
}
|
||||
|
||||
public void setTotalCount(int totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
public static PageUtils page(PageInfo<?> page) {
|
||||
return page(page,false);
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
public static PageUtils page(PageInfo<?> page, boolean isRecords) {
|
||||
PageUtils pageUtils = new PageUtils();
|
||||
if (isRecords) {
|
||||
pageUtils.records = page.getList();
|
||||
} else {
|
||||
pageUtils.list = page.getList();
|
||||
}
|
||||
pageUtils.totalCount = (int) page.getTotal();
|
||||
pageUtils.pageSize = page.getSize();
|
||||
pageUtils.currPage = page.getPageNum();
|
||||
pageUtils.totalPage = page.getPages();
|
||||
return pageUtils;
|
||||
}
|
||||
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
public int getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
|
||||
public int getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
public void setTotalCount(int totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
|
||||
public void setTotalPage(int totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public int getCurrPage() {
|
||||
return currPage;
|
||||
}
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public void setCurrPage(int currPage) {
|
||||
this.currPage = currPage;
|
||||
}
|
||||
public int getTotalPage() {
|
||||
return totalPage;
|
||||
}
|
||||
|
||||
public List<?> getList() {
|
||||
return list;
|
||||
}
|
||||
public void setTotalPage(int totalPage) {
|
||||
this.totalPage = totalPage;
|
||||
}
|
||||
|
||||
public void setList(List<?> list) {
|
||||
this.list = list;
|
||||
}
|
||||
public int getCurrPage() {
|
||||
return currPage;
|
||||
}
|
||||
|
||||
public void setCurrPage(int currPage) {
|
||||
this.currPage = currPage;
|
||||
}
|
||||
|
||||
public List<?> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<?> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
public List<?> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(List<?> records) {
|
||||
this.records = records;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,68 +0,0 @@
|
|||
package com.sqx.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.common.xss.SQLFilter;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
*
|
||||
*/
|
||||
public class Query<T> {
|
||||
|
||||
public IPage<T> getPage(Map<String, Object> params) {
|
||||
return this.getPage(params, null, false);
|
||||
}
|
||||
|
||||
public IPage<T> getPage(Map<String, Object> params, String defaultOrderField, boolean isAsc) {
|
||||
//分页参数
|
||||
long curPage = 1;
|
||||
long limit = 10;
|
||||
|
||||
if(params.get(Constant.PAGE) != null){
|
||||
curPage = Long.parseLong(String.valueOf(params.get(Constant.PAGE)));
|
||||
}
|
||||
if(params.get(Constant.LIMIT) != null){
|
||||
limit = Long.parseLong(String.valueOf(params.get(Constant.LIMIT)));
|
||||
}
|
||||
|
||||
//分页对象
|
||||
Page<T> page = new Page<>(curPage, limit);
|
||||
|
||||
//分页参数
|
||||
params.put(Constant.PAGE, page);
|
||||
|
||||
//排序字段
|
||||
//防止SQL注入(因为sidx、order是通过拼接SQL实现排序的,会有SQL注入风险)
|
||||
String orderField = SQLFilter.sqlInject((String)params.get(Constant.ORDER_FIELD));
|
||||
String order = (String)params.get(Constant.ORDER);
|
||||
|
||||
|
||||
//前端字段排序
|
||||
if(StringUtils.isNotEmpty(orderField) && StringUtils.isNotEmpty(order)){
|
||||
if(Constant.ASC.equalsIgnoreCase(order)) {
|
||||
return page.addOrder(OrderItem.asc(orderField));
|
||||
}else {
|
||||
return page.addOrder(OrderItem.desc(orderField));
|
||||
}
|
||||
}
|
||||
|
||||
//没有排序字段,则不排序
|
||||
if(StringUtils.isBlank(defaultOrderField)){
|
||||
return page;
|
||||
}
|
||||
|
||||
//默认排序
|
||||
if(isAsc) {
|
||||
page.addOrder(OrderItem.asc(defaultOrderField));
|
||||
}else {
|
||||
page.addOrder(OrderItem.desc(defaultOrderField));
|
||||
}
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,11 @@ public class SpringContextUtils implements ApplicationContextAware {
|
|||
return applicationContext.getBean(name);
|
||||
}
|
||||
|
||||
public static Object getSpringBean(Class<?> clazz) {
|
||||
return applicationContext == null ? null : applicationContext.getBean(clazz);
|
||||
}
|
||||
|
||||
|
||||
public static <T> T getBean(String name, Class<T> requiredType) {
|
||||
return applicationContext.getBean(name, requiredType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,31 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import com.sqx.modules.utils.InvitationCodeUtil;
|
||||
import com.sqx.sharding.MasterSlaveRules;
|
||||
import com.sqx.sharding.ShardingDataBase;
|
||||
import com.sqx.sharding.StandardShardingStrategyConf;
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shardingsphere.api.config.masterslave.MasterSlaveRuleConfiguration;
|
||||
import org.apache.shardingsphere.api.config.sharding.KeyGeneratorConfiguration;
|
||||
import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration;
|
||||
import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
|
||||
import org.apache.shardingsphere.api.config.sharding.strategy.InlineShardingStrategyConfiguration;
|
||||
import org.apache.shardingsphere.api.config.sharding.strategy.StandardShardingStrategyConfiguration;
|
||||
import org.apache.shardingsphere.core.strategy.route.standard.StandardShardingStrategy;
|
||||
import org.apache.shardingsphere.shardingjdbc.api.ShardingDataSourceFactory;
|
||||
import org.codehaus.groovy.util.StringUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +37,9 @@ import java.util.stream.Collectors;
|
|||
@ConfigurationProperties(prefix = "spring.shardingsphere")
|
||||
public class ShardingConfig {
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfile;
|
||||
|
||||
/**
|
||||
* 读取数据源信息
|
||||
*/
|
||||
|
|
@ -44,17 +53,56 @@ public class ShardingConfig {
|
|||
*/
|
||||
private String showSql;
|
||||
|
||||
/**
|
||||
* 广播表
|
||||
*/
|
||||
// private Set<String> broadcastTables;
|
||||
|
||||
/**
|
||||
* 中心库的节点
|
||||
*/
|
||||
private String centerTablesDataNode;
|
||||
|
||||
|
||||
/**
|
||||
* 中心表,不进行分库操作
|
||||
*/
|
||||
private List<String> centerTables;
|
||||
private Set<String> centerTables;
|
||||
|
||||
/**
|
||||
* 区域库的节点
|
||||
*/
|
||||
private String regionTablesDataNode;
|
||||
|
||||
/**
|
||||
* 区域表分库策略的字段
|
||||
*/
|
||||
private String regionTablesShardingDatabaseColumn;
|
||||
|
||||
/**
|
||||
* 区域表分库的算法
|
||||
*/
|
||||
private String regionTablesShardingDatabaseAlgorithm;
|
||||
|
||||
/**
|
||||
* 分库表,通过userId进行分库
|
||||
*/
|
||||
private Set<String> regionTables;
|
||||
|
||||
|
||||
/**
|
||||
* 区域表分库策略的字段
|
||||
*/
|
||||
private String courseDetailsShardingDatabaseColumn;
|
||||
|
||||
/**
|
||||
* 区域表分库的算法
|
||||
*/
|
||||
private String courseDetailsShardingDatabaseAlgorithm;
|
||||
|
||||
/**
|
||||
* 分库表,通过userId进行分库
|
||||
*/
|
||||
private Set<String> courseDetails;
|
||||
|
||||
/**
|
||||
* 配置sharding-jdbc数据源
|
||||
|
|
@ -66,9 +114,18 @@ public class ShardingConfig {
|
|||
// 配置数据库主从
|
||||
shardingRuleConfig.setMasterSlaveRuleConfigs(masterSlaveRuleConfigs());
|
||||
|
||||
// 配置广播表
|
||||
// shardingRuleConfig.setBroadcastTables(broadcastTables);
|
||||
|
||||
// 配置表的切分策略
|
||||
shardingRuleConfig.setTableRuleConfigs(addTableRuleConfigs());
|
||||
|
||||
// 配置表绑定规则
|
||||
List<Set<String>> sets = new ArrayList<>();
|
||||
sets.add(regionTables);
|
||||
shardingRuleConfig.setBindingTableGroups(bindingTableGroups(sets));
|
||||
|
||||
|
||||
// 配置是否显示sql
|
||||
Properties props = new Properties();
|
||||
props.put("sql.show", showSql);
|
||||
|
|
@ -88,15 +145,30 @@ public class ShardingConfig {
|
|||
String.format(centerTablesDataNode, centerTable));
|
||||
sets.add(tableRuleConfig);
|
||||
}
|
||||
|
||||
// // 定义区域表的分库规则
|
||||
// 定义区域表的分库规则
|
||||
StandardShardingStrategyConfiguration databaseShardingStrategyConfig = new StandardShardingStrategyConfiguration(
|
||||
regionTablesShardingDatabaseColumn, new StandardShardingStrategyConf());
|
||||
// InlineShardingStrategyConfiguration databaseShardingStrategyConfig = new InlineShardingStrategyConfiguration(
|
||||
// regionTablesShardingDatabaseColumn, regionTablesShardingDatabaseAlgorithm);
|
||||
// for (String regionTable : regionTables) {
|
||||
// TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration(regionTable, String.format(regionTablesDataNode, regionTable));
|
||||
// tableRuleConfig.setDatabaseShardingStrategyConfig(databaseShardingStrategyConfig);
|
||||
// sets.add(tableRuleConfig);
|
||||
// }
|
||||
for (String regionTable : regionTables) {
|
||||
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration(regionTable, String.format(regionTablesDataNode, regionTable));
|
||||
tableRuleConfig.setDatabaseShardingStrategyConfig(databaseShardingStrategyConfig);
|
||||
sets.add(tableRuleConfig);
|
||||
}
|
||||
|
||||
|
||||
// 定义区域表的分库规则
|
||||
StandardShardingStrategyConfiguration courseDetailsShardingStrategyConfig = new StandardShardingStrategyConfiguration(
|
||||
courseDetailsShardingDatabaseColumn, new StandardShardingStrategyConf());
|
||||
for (String regionTable : courseDetails) {
|
||||
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration(regionTable, String.format(regionTablesDataNode, regionTable));
|
||||
tableRuleConfig.setDatabaseShardingStrategyConfig(courseDetailsShardingStrategyConfig);
|
||||
// 设置区域表使用雪花算法生成主键
|
||||
KeyGeneratorConfiguration keyGeneratorConfig = new KeyGeneratorConfiguration("SNOWFLAKE", "id");
|
||||
tableRuleConfig.setKeyGeneratorConfig(keyGeneratorConfig);
|
||||
|
||||
sets.add(tableRuleConfig);
|
||||
}
|
||||
return sets;
|
||||
}
|
||||
|
||||
|
|
@ -136,4 +208,38 @@ public class ShardingConfig {
|
|||
});
|
||||
return sets;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定表的分片规则
|
||||
*/
|
||||
public static Set<String> bindingTableGroups(List<Set<String>> sets) {
|
||||
if (sets != null && !sets.isEmpty()) {
|
||||
Set<String> tableGroups = new HashSet<>();
|
||||
for (Set<String> set : sets) {
|
||||
String tableNames = bindingTable(set.toArray(new String[0]));
|
||||
if (StringUtils.isNotBlank(tableNames)) {
|
||||
tableGroups.add(tableNames);
|
||||
}
|
||||
}
|
||||
return tableGroups;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量绑定表规则
|
||||
*
|
||||
* @param tables 批量绑定的标规则
|
||||
* @return tableNames
|
||||
*/
|
||||
private static String bindingTable(String... tables) {
|
||||
StringBuilder tableNames = new StringBuilder();
|
||||
if (tables != null && tables.length != 0) {
|
||||
for (String table : tables) {
|
||||
tableNames.append(table).append(",");
|
||||
}
|
||||
tableNames.deleteCharAt(tableNames.length() - 1);
|
||||
}
|
||||
return tableNames.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
package com.sqx.config;
|
||||
|
||||
/**
|
||||
* 描述: Twitter的分布式自增ID雪花算法snowflake (Java版)
|
||||
**/
|
||||
public class SnowFlake {
|
||||
|
||||
/**
|
||||
* 起始的时间戳
|
||||
*/
|
||||
private final static long START_STMP = 1480166465631L;
|
||||
|
||||
/**
|
||||
* 每一部分占用的位数
|
||||
*/
|
||||
private final static long SEQUENCE_BIT = 12; //序列号占用的位数
|
||||
private final static long MACHINE_BIT = 5; //机器标识占用的位数
|
||||
private final static long DATACENTER_BIT = 5;//数据中心占用的位数
|
||||
|
||||
/**
|
||||
* 每一部分的最大值
|
||||
*/
|
||||
private final static long MAX_DATACENTER_NUM = ~(-1L << DATACENTER_BIT);
|
||||
private final static long MAX_MACHINE_NUM = ~(-1L << MACHINE_BIT);
|
||||
private final static long MAX_SEQUENCE = ~(-1L << SEQUENCE_BIT);
|
||||
|
||||
/**
|
||||
* 每一部分向左的位移
|
||||
*/
|
||||
private final static long MACHINE_LEFT = SEQUENCE_BIT;
|
||||
private final static long DATACENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT;
|
||||
private final static long TIMESTMP_LEFT = DATACENTER_LEFT + DATACENTER_BIT;
|
||||
|
||||
/**
|
||||
* 数据中心
|
||||
*/
|
||||
private long datacenterId;
|
||||
/**
|
||||
* 机器标识
|
||||
*/
|
||||
private long machineId;
|
||||
/**
|
||||
* 代表了一毫秒内生成的多个id的最新序号
|
||||
*/
|
||||
private long sequence = 10000L;
|
||||
/**
|
||||
* 上一次时间戳
|
||||
*/
|
||||
private long lastStmp = -1L;
|
||||
|
||||
public SnowFlake() {
|
||||
}
|
||||
|
||||
public SnowFlake(long datacenterId, long machineId) {
|
||||
if (datacenterId > MAX_DATACENTER_NUM || datacenterId < 0) {
|
||||
throw new IllegalArgumentException("datacenterId can't be greater than MAX_DATACENTER_NUM or less than 0");
|
||||
}
|
||||
if (machineId > MAX_MACHINE_NUM || machineId < 0) {
|
||||
throw new IllegalArgumentException("machineId can't be greater than MAX_MACHINE_NUM or less than 0");
|
||||
}
|
||||
this.datacenterId = datacenterId;
|
||||
this.machineId = machineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 产生下一个ID
|
||||
*
|
||||
* @param ifEvenNum 是否偶数 true 时间不连续全是偶数 时间连续 奇数偶数 false 时间不连续 奇偶都有 所以一般建议用false
|
||||
*/
|
||||
public synchronized long nextId(boolean ifEvenNum) {
|
||||
long currStmp = getNewstmp();
|
||||
if (currStmp < lastStmp) {
|
||||
throw new RuntimeException("Clock moved backwards. Refusing to generate id");
|
||||
}
|
||||
/**
|
||||
* 时间不连续出来全是偶数
|
||||
*/
|
||||
if (ifEvenNum) {
|
||||
if (currStmp == lastStmp) {
|
||||
//相同毫秒内,序列号自增
|
||||
sequence = (sequence + 1) & MAX_SEQUENCE;
|
||||
//同一毫秒的序列数已经达到最大
|
||||
if (sequence == 0L) {
|
||||
currStmp = getNextMill();
|
||||
}
|
||||
} else {
|
||||
//不同毫秒内,序列号置为0
|
||||
sequence = 0L;
|
||||
}
|
||||
} else {
|
||||
//相同毫秒内,序列号自增
|
||||
sequence = (sequence + 1) & MAX_SEQUENCE;
|
||||
}
|
||||
|
||||
lastStmp = currStmp;
|
||||
|
||||
return (currStmp - START_STMP) << TIMESTMP_LEFT //时间戳部分
|
||||
| datacenterId << DATACENTER_LEFT //数据中心部分
|
||||
| machineId << MACHINE_LEFT //机器标识部分
|
||||
| sequence; //序列号部分
|
||||
}
|
||||
|
||||
private long getNextMill() {
|
||||
long mill = getNewstmp();
|
||||
while (mill <= lastStmp) {
|
||||
mill = getNewstmp();
|
||||
}
|
||||
return mill;
|
||||
}
|
||||
|
||||
private long getNewstmp() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package com.sqx.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class SnowFlakeConfig {
|
||||
/**
|
||||
* 数据中心
|
||||
*/
|
||||
@Value("${snowflake.datacenterId}")
|
||||
private String datacenterId;
|
||||
/**
|
||||
* 机器标识
|
||||
*/
|
||||
@Value("${snowflake.machineId}")
|
||||
private String machineId;
|
||||
|
||||
@Bean(name = "snowFlake")
|
||||
public SnowFlake snowFlake() {
|
||||
return new SnowFlake(Long.parseLong(datacenterId), Long.parseLong(machineId));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.sqx.modules.announcement.controller;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.announcement.service.AnnouncementService;
|
||||
import com.sqx.modules.common.dto.AddAnnouncementDTO;
|
||||
import com.sqx.modules.common.dto.DeleteAnnouncementDTO;
|
||||
import com.sqx.modules.common.dto.UpdateAnnouncementDTO;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/announcement")
|
||||
public class AnnouncementController {
|
||||
|
||||
private final AnnouncementService announcementService;
|
||||
|
||||
public AnnouncementController(AnnouncementService announcementService) {
|
||||
this.announcementService = announcementService;
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result list(@RequestParam(required = false) String title, @RequestParam(required = false) Integer state, @RequestParam(required = false) Integer id) {
|
||||
return Result.success().put("data", announcementService.listInfo(title, state, id));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Result add(@RequestBody @Validated AddAnnouncementDTO announcementDTO) {
|
||||
return Result.success().put("data", announcementService.add(announcementDTO));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Result update(@RequestBody @Validated UpdateAnnouncementDTO updateAnnouncementDTO) {
|
||||
return Result.success().put("data", announcementService.updateInfo(updateAnnouncementDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
public Result delete(@RequestBody @Validated DeleteAnnouncementDTO deleteAnnouncementDTO) {
|
||||
return Result.success().put("data", announcementService.removeById(deleteAnnouncementDTO.getId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.sqx.modules.announcement.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 公告表
|
||||
* @TableName announcement
|
||||
*/
|
||||
@TableName(value ="announcement")
|
||||
@Data
|
||||
public class Announcement implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// @TableId
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 状态0关闭 1打开
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Announcement other = (Announcement) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
|
||||
&& (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
|
||||
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
|
||||
result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
|
||||
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", title=").append(title);
|
||||
sb.append(", content=").append(content);
|
||||
sb.append(", state=").append(state);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.announcement.mapper;
|
||||
|
||||
import com.sqx.modules.announcement.entity.Announcement;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【announcement(公告表)】的数据库操作Mapper
|
||||
* @createDate 2025-01-02 14:33:44
|
||||
* @Entity com.sqx.modules.announcement.entity.Announcement
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnnouncementMapper extends BaseMapper<Announcement> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.sqx.modules.announcement.service;
|
||||
|
||||
import com.sqx.modules.announcement.entity.Announcement;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.modules.common.dto.AddAnnouncementDTO;
|
||||
import com.sqx.modules.common.dto.DeleteAnnouncementDTO;
|
||||
import com.sqx.modules.common.dto.UpdateAnnouncementDTO;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【announcement(公告表)】的数据库操作Service
|
||||
* @createDate 2025-01-02 14:33:44
|
||||
*/
|
||||
public interface AnnouncementService extends IService<Announcement> {
|
||||
|
||||
Object add(AddAnnouncementDTO announcementDTO);
|
||||
|
||||
Object updateInfo(UpdateAnnouncementDTO updateAnnouncementDTO);
|
||||
|
||||
Object listInfo(String title, Integer state, Integer id);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.sqx.modules.announcement.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.modules.announcement.entity.Announcement;
|
||||
import com.sqx.modules.announcement.service.AnnouncementService;
|
||||
import com.sqx.modules.announcement.mapper.AnnouncementMapper;
|
||||
import com.sqx.modules.common.dto.AddAnnouncementDTO;
|
||||
import com.sqx.modules.common.dto.UpdateAnnouncementDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【announcement(公告表)】的数据库操作Service实现
|
||||
* @createDate 2025-01-02 14:33:44
|
||||
*/
|
||||
@Service
|
||||
public class AnnouncementServiceImpl extends ServiceImpl<AnnouncementMapper, Announcement>
|
||||
implements AnnouncementService{
|
||||
|
||||
@Override
|
||||
public Object listInfo(String title, Integer state, Integer id) {
|
||||
LambdaQueryWrapper<Announcement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
boolean flag = false;
|
||||
if (StrUtil.isNotBlank(title)) {
|
||||
queryWrapper.like(Announcement::getTitle, title);
|
||||
flag = true;
|
||||
}
|
||||
if (state != null) {
|
||||
queryWrapper.eq(Announcement::getState, state);
|
||||
flag = true;
|
||||
}
|
||||
if (id != null) {
|
||||
queryWrapper.eq(Announcement::getId, id);
|
||||
}
|
||||
return flag ? list(queryWrapper) : list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object add(AddAnnouncementDTO announcementDTO) {
|
||||
Announcement announcement = new Announcement();
|
||||
BeanUtil.copyProperties(announcementDTO, announcement);
|
||||
announcement.setCreateTime(DateUtil.date());
|
||||
return save(announcement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object updateInfo(UpdateAnnouncementDTO updateAnnouncementDTO) {
|
||||
Announcement announcement = getById(updateAnnouncementDTO.getId());
|
||||
if (announcement == null) {
|
||||
throw new SqxException("公告不存在");
|
||||
}
|
||||
BeanUtil.copyProperties(updateAnnouncementDTO, announcement);
|
||||
announcement.setUpdateTime(DateUtil.date());
|
||||
return updateById(announcement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.entity.App;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
|
|
@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
|
|
@ -30,8 +32,10 @@ public class AppUpgradeController {
|
|||
@ApiOperation("管理平台升级详情")
|
||||
@ResponseBody
|
||||
public Result list(Integer page,Integer limit) {
|
||||
IPage<App> pages =new Page<>(page,limit);
|
||||
return Result.success().put("data",iAppService.page(pages));
|
||||
PageHelper.startPage(page,limit);
|
||||
List<App> list = iAppService.list();
|
||||
PageInfo<App> pageInfo = new PageInfo<>(list);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo, true));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.entity.UserEntity;
|
||||
|
|
@ -270,9 +270,8 @@ public class UserController {
|
|||
@GetMapping("/courseMessage")
|
||||
@ApiOperation("短剧分析")
|
||||
public Result courseMessage(Long page, Long limit, String date, int type, Long sysUserId) {
|
||||
Page<Map<String, Object>> iPage = new Page<>(page, limit);
|
||||
IPage<Map<String, Object>> mapIPage = userService.queryCourseOrder(iPage, type, TimeCompleteUtils.completeStartTime(date), sysUserId);
|
||||
return Result.success().put("data", new PageUtils(mapIPage));
|
||||
PageUtils pageUtils = userService.queryCourseOrder(page, limit, type, TimeCompleteUtils.completeStartTime(date), sysUserId);
|
||||
return Result.success().put("data", pageUtils);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.sqx.modules.app.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
|
|
@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(value = "会员管理", tags = {"会员管理"})
|
||||
|
|
@ -89,7 +92,10 @@ public class VipDetailsController {
|
|||
@ApiParam("查询会员列表")
|
||||
@GetMapping("/selectVipDetailsList")
|
||||
public Result selectVipDetailsList(Integer page,Integer limit) {
|
||||
return Result.success().put("data",new PageUtils(vipDetailsService.page(new Page<>(page,limit))));
|
||||
PageHelper.startPage(page,limit);
|
||||
List<VipDetails> list = vipDetailsService.list();
|
||||
PageInfo<VipDetails> pageInfo = new PageInfo<>(list);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.announcement.entity.Announcement;
|
||||
import com.sqx.modules.announcement.service.AnnouncementService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/announcement")
|
||||
public class AppAnnouncementController {
|
||||
|
||||
private final AnnouncementService announcementService;
|
||||
|
||||
public AppAnnouncementController(AnnouncementService announcementService) {
|
||||
this.announcementService = announcementService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Result get() {
|
||||
PageHelper.startPage(1,1);
|
||||
List<Announcement> list = announcementService.list(new LambdaQueryWrapper<Announcement>()
|
||||
.eq(Announcement::getState, 1)
|
||||
.orderByDesc(Announcement::getCreateTime));
|
||||
return Result.success().put("data", list.isEmpty() ? null : list.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,17 +1,24 @@
|
|||
package com.sqx.modules.app.controller.app;
|
||||
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdcardUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.ApiAccessLimitUtil;
|
||||
import com.sqx.common.utils.DataLimitUtil;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.annotation.LoginUser;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.sqx.modules.app.service.AliService;
|
||||
import com.sqx.modules.app.service.AppService;
|
||||
import com.sqx.modules.app.service.UserInfoService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -21,6 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* APP登录授权
|
||||
|
|
@ -36,6 +44,13 @@ public class AppController {
|
|||
private AppService appService;
|
||||
@Autowired
|
||||
private CommonInfoService commonRepository;
|
||||
private final UserInfoService userInfoService;
|
||||
private final AliService aliService;
|
||||
|
||||
public AppController(UserInfoService userInfoService, AliService aliService) {
|
||||
this.userInfoService = userInfoService;
|
||||
this.aliService = aliService;
|
||||
}
|
||||
|
||||
@PostMapping("/authenticationRegister")
|
||||
@ApiOperation("认证创建账号")
|
||||
|
|
@ -79,43 +94,86 @@ public class AppController {
|
|||
@ApiOperation("用户修改个人信息")
|
||||
@ResponseBody
|
||||
@Debounce(interval = 3000, value = "#userId")
|
||||
public Result updateUserImageUrl(@RequestAttribute("userId") Long userId, String zhiFuBao, String zhiFuBaoName) {
|
||||
if (StrUtil.isEmpty(zhiFuBao) || StrUtil.isEmpty(zhiFuBaoName)) {
|
||||
return Result.error("支付宝账户及姓名不能为空!");
|
||||
public Result updateUserImageUrl(@RequestAttribute("userId") Long userId, @RequestParam(required = false) String zhiFuBao,
|
||||
@RequestParam String certName, @RequestParam(required = false) String certNum) {
|
||||
if (StrUtil.isAllBlank(zhiFuBao, certNum)) {
|
||||
return Result.error("支付宝账号或实名身份证号码必须传递一个");
|
||||
}
|
||||
if (!DataLimitUtil.isAccessAllowed(zhiFuBao+zhiFuBaoName, Integer.parseInt(commonRepository.findOne(924).getValue()), "month")) {
|
||||
return Result.error("修改失败,相同支付宝账号每月可绑定次数已用完");
|
||||
}
|
||||
int count = userService.count(new QueryWrapper<UserEntity>()
|
||||
.ne("user_id", userId)
|
||||
.eq("zhi_fu_bao_name", zhiFuBaoName)
|
||||
.eq("zhi_fu_bao", zhiFuBao));
|
||||
|
||||
if (count > 0) {
|
||||
return Result.error("一个支付宝账号仅可绑定一个用户");
|
||||
UserInfo userInfo = userInfoService.getByUserId(userId);
|
||||
UserEntity userEntity = userService.getById(userId);
|
||||
|
||||
String errMsg = null;
|
||||
if (StrUtil.isNotBlank(zhiFuBao) && !zhiFuBao.equals(userEntity.getZhiFuBao())) {
|
||||
int count = userService.count(new QueryWrapper<UserEntity>()
|
||||
.ne("user_id", userId)
|
||||
.eq("zhi_fu_bao_name", certName)
|
||||
.eq("zhi_fu_bao", zhiFuBao));
|
||||
if (count > 0) {
|
||||
errMsg = "支付宝信息修改失败: 一个支付宝账号仅可绑定一个用户";
|
||||
}
|
||||
if (StrUtil.isNotBlank(userInfo.getCertName()) && !certName.equals(userInfo.getCertName())) {
|
||||
errMsg = "支付宝信息修改失败: 姓名与实名认证信息不相符";
|
||||
}
|
||||
|
||||
if (!DataLimitUtil.isAccessAllowed(zhiFuBao+certName, Integer.parseInt(commonRepository.findOne(924).getValue()), "month")) {
|
||||
errMsg = "支付宝信息修改失败: 相同支付宝账号每月可绑定次数已用完";
|
||||
}
|
||||
|
||||
if (!ApiAccessLimitUtil.isAccessAllowed(userId.toString(), "updateZFB", Integer.parseInt(commonRepository.findOne(925).getValue()), "month")) {
|
||||
errMsg = "支付宝信息修改失败: 每月可修改次数已用完,请联系管理员";
|
||||
}
|
||||
|
||||
if (errMsg == null) {
|
||||
userEntity.setZhiFuBao(zhiFuBao);
|
||||
userEntity.setZhiFuBaoName(certName);
|
||||
userService.updateById(userEntity);
|
||||
}
|
||||
}
|
||||
if (!ApiAccessLimitUtil.isAccessAllowed(userId.toString(), "updateZFB", Integer.parseInt(commonRepository.findOne(925).getValue()), "month")) {
|
||||
return Result.error("每月可修改次数已用完,请联系管理员");
|
||||
|
||||
|
||||
if (StrUtil.isNotBlank(certNum) && !certNum.equals(userInfo.getCertNo())) {
|
||||
if (StrUtil.isNotBlank(userEntity.getZhiFuBaoName()) && !certName.equals(userEntity.getZhiFuBaoName())) {
|
||||
errMsg = "实名修改失败: 姓名与绑定支付宝信息不相符";
|
||||
}
|
||||
if (!IdcardUtil.isValidCard(certNum)) {
|
||||
errMsg = "实名修改失败: 身份证号码有误";
|
||||
}
|
||||
|
||||
Integer idCount = userInfoService.countCertCount(certName, certNum);
|
||||
if (idCount > 1) {
|
||||
errMsg = "实名修改失败: 此实名信息已存在";
|
||||
}
|
||||
|
||||
if (!ApiAccessLimitUtil.isAccessAllowed(String.valueOf(userId), "updateAuthCertInfo", 1, "month")) {
|
||||
errMsg = "实名修改失败: 每月可修改次数已用完,请联系管理员";
|
||||
}
|
||||
|
||||
try {
|
||||
aliService.authCertNo(certName, certNum);
|
||||
}catch (Exception e) {
|
||||
ApiAccessLimitUtil.removeKey(String.valueOf(userId), "updateAuthCertInfo");
|
||||
errMsg = "实名修改失败: 身份证信息不匹配";
|
||||
}
|
||||
|
||||
if (errMsg != null && errMsg.contains("实名修改失败")) {
|
||||
return Result.error(errMsg);
|
||||
}
|
||||
|
||||
userInfo.setCertName(certName);
|
||||
userInfo.setCertNo(certNum);
|
||||
userInfo.setUpdateTime(DateUtil.date());
|
||||
userInfoService.updateById(userInfo);
|
||||
}
|
||||
UserEntity old = userService.getById(userId);
|
||||
String accountNo = old.getZhiFuBao();
|
||||
String accountName = old.getZhiFuBaoName();
|
||||
boolean isFirstBind = false;
|
||||
if (StrUtil.isEmpty(accountNo) && StrUtil.isEmpty(accountName)) {
|
||||
isFirstBind = true;
|
||||
|
||||
if (errMsg != null) {
|
||||
return Result.error(errMsg);
|
||||
}
|
||||
UserEntity userEntity = new UserEntity();
|
||||
userEntity.setZhiFuBao(zhiFuBao);
|
||||
userEntity.setZhiFuBaoName(zhiFuBaoName);
|
||||
userEntity.setUserId(userId);
|
||||
old.setZhiFuBao(userEntity.getZhiFuBao());
|
||||
old.setZhiFuBaoName(userEntity.getZhiFuBaoName());
|
||||
boolean bool = userService.updateById(userEntity);
|
||||
return Result.success();
|
||||
// 去除首绑支付宝奖励
|
||||
// if (bool && isFirstBind) {
|
||||
// userService.firstBindAwardsMoney(old);
|
||||
// }
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -170,7 +228,10 @@ public class AppController {
|
|||
@ApiOperation("获取用户详细信息")
|
||||
@ResponseBody
|
||||
public Result selectUserById(@LoginUser UserEntity user) {
|
||||
return Result.success().put("data", user);
|
||||
UserInfo userInfo = userInfoService.getByUserId(user.getUserId());
|
||||
Map<String, Object> map = BeanUtil.beanToMap(user);
|
||||
map.putAll(BeanUtil.beanToMap(userInfo));
|
||||
return Result.success().put("data", map);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ package com.sqx.modules.app.controller.app;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sqx.common.annotation.Debounce;
|
||||
import com.sqx.common.utils.ApiAccessLimitUtil;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.app.dao.AuthCertNoDTO;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import com.sqx.modules.app.service.IAppleService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
|
|
@ -19,6 +22,7 @@ import io.swagger.annotations.ApiOperation;
|
|||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import weixin.popular.api.SnsAPI;
|
||||
import weixin.popular.bean.sns.SnsToken;
|
||||
|
|
@ -163,6 +167,16 @@ public class AppLoginController {
|
|||
return userService.sendMsg(phone, state,null);
|
||||
}
|
||||
|
||||
@Login
|
||||
@Debounce(value = "#authCertNoDTO.idNum")
|
||||
@PostMapping("/authCertNo")
|
||||
public Result authCertNo(@RequestBody @Validated AuthCertNoDTO authCertNoDTO, @RequestAttribute("userId") long userId) {
|
||||
if (!ApiAccessLimitUtil.isAccessAllowed(String.valueOf(userId), "updateAuthCertInfo", 1, "month")) {
|
||||
return Result.error("每月可修改次数已用完,请联系管理员");
|
||||
}
|
||||
return Result.success().put("data", userService.authCertNo(userId, authCertNoDTO));
|
||||
}
|
||||
|
||||
@ApiOperation("解密手机号")
|
||||
@RequestMapping(value = "/selectPhone",method = RequestMethod.POST)
|
||||
public Result getPhoneNumberBeanS5(@RequestBody WxPhone wxPhone) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class AuthCertNoDTO {
|
||||
@NotBlank
|
||||
private String name;
|
||||
@NotBlank
|
||||
private String idNum;
|
||||
}
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
package com.sqx.modules.app.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -17,7 +15,7 @@ import java.util.Map;
|
|||
public interface UserDao extends BaseMapper<UserEntity> {
|
||||
|
||||
|
||||
IPage<UserEntity> selectUserPage(@Param("page") Page<UserEntity> page, @Param("search") String search, @Param("sex") Integer sex, @Param("platform") String platform,
|
||||
List<UserEntity> selectUserPage(@Param("search") String search, @Param("sex") Integer sex, @Param("platform") String platform,
|
||||
@Param("sysPhone") String sysPhone, @Param("status") Integer status, @Param("member") Integer member,
|
||||
@Param("inviterCode") String inviterCode, @Param("userName") String userName,
|
||||
@Param("invitationCode") String invitationCode, @Param("startTime") String startTime,
|
||||
|
|
@ -31,13 +29,13 @@ public interface UserDao extends BaseMapper<UserEntity> {
|
|||
|
||||
Double queryPayMoney(@Param("type") int type, @Param("date") String date,String qdCode);
|
||||
|
||||
IPage<Map<String, Object>> queryCourseOrder(Page iPage,@Param("type") int type, @Param("start") String start, @Param("end") String end,Long sysUserId);
|
||||
List<Map<String, Object>> queryCourseOrder(@Param("type") int type, @Param("start") String start, @Param("end") String end,Long sysUserId);
|
||||
|
||||
int userMessage( String date, int type,String qdCode,Integer vipType);
|
||||
|
||||
int insertUser(UserEntity userEntity);
|
||||
|
||||
IPage<UserEntity> selectInviteUserList(Page<UserEntity> page,String userName,String phone);
|
||||
List<UserEntity> selectInviteUserList(String userName,String phone);
|
||||
|
||||
int selectUserOnLineCount(String qdCode);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Mapper
|
||||
public interface UserMoneyDao extends BaseMapper<UserMoney> {
|
||||
|
|
@ -14,4 +17,11 @@ public interface UserMoneyDao extends BaseMapper<UserMoney> {
|
|||
void updateSysMoney(@Param("type") Integer type, @Param("sysUserId")Long sysUserId, @Param("money") Double money);
|
||||
|
||||
void updateSysAmount(@Param("type") Integer type, @Param("sysUserId")Long sysUserId, @Param("amount") Double amount);
|
||||
|
||||
@Select("select sum(money) from user_money_details where user_id=#{userId} and classify in (6,1) and (content like '%额外奖励金币%' or content like '获取金币')")
|
||||
BigDecimal sumMoney(Long userId);
|
||||
|
||||
@Select("select sum(money) from user_money_details where user_id=#{userId} and classify=6 and content like '%额外奖励现金红包%'")
|
||||
BigDecimal sumMoney2(Long userId);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.sqx.modules.app.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -13,6 +15,7 @@ import java.io.Serializable;
|
|||
@TableName("app")
|
||||
public class App implements Serializable {
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String createAt;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
|
@ -23,18 +26,21 @@ public class InviteAchievement implements Serializable {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
* 邀请用户用户id -- 上级
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 上级邀请用户id
|
||||
* 下级被邀请用户id 当前达标用户id
|
||||
*/
|
||||
private Long sourceUserId;
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long targetUserId;
|
||||
|
||||
/**
|
||||
* 达标次数
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.sqx.modules.app.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -17,6 +19,7 @@ public class Msg implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String code;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -28,7 +30,8 @@ public class UserEntity implements Serializable {
|
|||
*/
|
||||
@Excel(name = "用户id", orderNum = "1")
|
||||
@ApiModelProperty("用户id")
|
||||
@TableId(type = IdType.AUTO, value = "user_id")
|
||||
@TableId(value = "user_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户名
|
||||
|
|
@ -199,5 +202,4 @@ public class UserEntity implements Serializable {
|
|||
@TableField(exist = false)
|
||||
private Integer vipType;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName user_info
|
||||
*/
|
||||
@TableName(value ="user_info")
|
||||
@Data
|
||||
public class UserInfo implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String certName;
|
||||
|
||||
/**
|
||||
* 身份证号码
|
||||
*/
|
||||
private String certNo;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
UserInfo other = (UserInfo) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
|
||||
&& (this.getCertName() == null ? other.getCertName() == null : this.getCertName().equals(other.getCertName()))
|
||||
&& (this.getCertNo() == null ? other.getCertNo() == null : this.getCertNo().equals(other.getCertNo()))
|
||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
|
||||
result = prime * result + ((getCertName() == null) ? 0 : getCertName().hashCode());
|
||||
result = prime * result + ((getCertNo() == null) ? 0 : getCertNo().hashCode());
|
||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", userId=").append(userId);
|
||||
sb.append(", certName=").append(certName);
|
||||
sb.append(", certNo=").append(certNo);
|
||||
sb.append(", updateTime=").append(updateTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
@ -23,7 +25,8 @@ public class UserMoney implements Serializable {
|
|||
* 主键id
|
||||
*/
|
||||
@ApiModelProperty("主键id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
|
@ -43,6 +46,7 @@ public class UserMoney implements Serializable {
|
|||
*/
|
||||
@ApiModelProperty("用户id")
|
||||
@TableField("user_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
|
|
@ -50,6 +54,10 @@ public class UserMoney implements Serializable {
|
|||
*/
|
||||
@ApiModelProperty("渠道用户id")
|
||||
@TableField("sys_user_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long sysUserId;
|
||||
|
||||
private BigDecimal inviteIncomeMoney;;
|
||||
private BigDecimal inviteIncomeCoin;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,18 @@
|
|||
package com.sqx.modules.app.entity;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.amazonaws.services.dynamodbv2.xspec.L;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
//import com.amazonaws.services.dynamodbv2.xspec.L;
|
||||
//import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
//import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -24,13 +26,15 @@ public class UserMoneyDetails implements Serializable {
|
|||
* 钱包详情id
|
||||
*/
|
||||
@ApiModelProperty("钱包详情id")
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField("user_id")
|
||||
@ApiModelProperty("用户id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
|
|
@ -38,8 +42,10 @@ public class UserMoneyDetails implements Serializable {
|
|||
*/
|
||||
@ApiModelProperty("渠道用户id")
|
||||
@TableField("sys_user_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long sysUserId;
|
||||
@ApiModelProperty("源id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long sourceId;
|
||||
|
||||
/**
|
||||
|
|
@ -47,6 +53,7 @@ public class UserMoneyDetails implements Serializable {
|
|||
*/
|
||||
@TableField("by_user_id")
|
||||
@ApiModelProperty("对应用户id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long byUserId;
|
||||
/**
|
||||
* 标题
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.app.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -24,10 +26,12 @@ public class UserPrizeExchange implements Serializable {
|
|||
* 奖品记录
|
||||
*/
|
||||
@TableId(type = IdType.ID_WORKER)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
/**
|
||||
* 奖品引用id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long foreignId;
|
||||
/**
|
||||
* 活动类型 task-任务奖励 spinning-大转盘
|
||||
|
|
@ -44,6 +48,7 @@ public class UserPrizeExchange implements Serializable {
|
|||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
/**
|
||||
* 用户名
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.sqx.modules.app.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -13,6 +15,7 @@ public class UserVip implements Serializable {
|
|||
* 用户会员ID
|
||||
*/
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long vipId;
|
||||
/**
|
||||
* 会员类型
|
||||
|
|
@ -21,6 +24,7 @@ public class UserVip implements Serializable {
|
|||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
|
@ -20,7 +22,8 @@ import java.math.BigDecimal;
|
|||
@ApiModel("会员详情")
|
||||
public class VipDetails implements Serializable {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("会员类型")
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import org.apache.ibatis.annotations.Update;
|
|||
@Mapper
|
||||
public interface InviteAchievementMapper extends BaseMapper<InviteAchievement> {
|
||||
|
||||
@Update("update invite_achievement set count = count + #{i}, update_time=now() where id = #{id}")
|
||||
int incrCount(Integer id, int i);
|
||||
@Update("update invite_achievement set count = count + #{i}, update_time=now() where id = #{id} and user_id = #{userId}")
|
||||
int incrCount(Long id, Long userId, int i);
|
||||
|
||||
@Insert("INSERT INTO invite_achievement (user_id, source_user_id, count, state, create_time)\n" +
|
||||
"SELECT #{userId}, #{sourceUserId}, #{count}, #{state}, #{createTime} " +
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.sqx.modules.app.mapper;
|
||||
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【user_info】的数据库操作Mapper
|
||||
* @createDate 2025-01-02 14:15:08
|
||||
* @Entity com.sqx.modules.app.entity.UserInfo
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserInfoMapper extends BaseMapper<UserInfo> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.sqx.modules.app.service;
|
||||
|
||||
|
||||
public interface AliService {
|
||||
void authCertNo(String name, String idCard);
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ public interface InviteAchievementService extends IService<InviteAchievement> {
|
|||
|
||||
InviteAchievement getByUserId(Long userId);
|
||||
|
||||
int incrCount(Integer id, int i);
|
||||
int incrCount(Long id, Long userId, int i);
|
||||
|
||||
boolean insertNotExists(InviteAchievement inviteAchievement);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package com.sqx.modules.app.service;
|
||||
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【user_info】的数据库操作Service
|
||||
* @createDate 2025-01-02 14:15:08
|
||||
*/
|
||||
public interface UserInfoService extends IService<UserInfo> {
|
||||
|
||||
UserInfo getByUserId(long userId);
|
||||
|
||||
Integer countCertCount(String name, String idNum);
|
||||
|
||||
}
|
||||
|
|
@ -16,5 +16,4 @@ public interface UserMoneyService extends IService<UserMoney> {
|
|||
void updateSysMoney(int i, Long userId, double money);
|
||||
|
||||
void updateSysAmount(int i, Long userId, double amount);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ package com.sqx.modules.app.service;
|
|||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.dao.AuthCertNoDTO;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -214,7 +214,7 @@ public interface UserService extends IService<UserEntity> {
|
|||
|
||||
Double queryPayMoney(int type,String qdCode);
|
||||
|
||||
IPage<Map<String, Object>> queryCourseOrder(Page<Map<String, Object>> iPage, int type, String date,Long sysUserId);
|
||||
PageUtils queryCourseOrder(Long page, Long limit, int type, String date,Long sysUserId);
|
||||
|
||||
int userMessage( String date, int type,String qdCode,Integer vipType);
|
||||
|
||||
|
|
@ -229,4 +229,8 @@ public interface UserService extends IService<UserEntity> {
|
|||
|
||||
void firstBindAwardsMoney(UserEntity entity);
|
||||
|
||||
/**
|
||||
* 二要素身份证认证
|
||||
*/
|
||||
Object authCertNo(long userId, AuthCertNoDTO authCertNoDTO);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
import com.aliyun.dytnsapi20200217.Client;
|
||||
import com.aliyun.dytnsapi20200217.models.CertNoTwoElementVerificationRequest;
|
||||
import com.aliyun.dytnsapi20200217.models.CertNoTwoElementVerificationResponse;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.modules.app.service.AliService;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AliServiceImpl implements AliService {
|
||||
private final CommonInfoService commonInfoService;
|
||||
private Client client;
|
||||
|
||||
public AliServiceImpl(CommonInfoService commonInfoService) {
|
||||
this.commonInfoService = commonInfoService;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() throws Exception {
|
||||
CommonInfo keyIdInfo = commonInfoService.findOne(85);
|
||||
CommonInfo securityInfo = commonInfoService.findOne(86);
|
||||
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
.setAccessKeyId(keyIdInfo.getValue())
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret(securityInfo.getValue());
|
||||
config.endpoint = "dytnsapi.aliyuncs.com";
|
||||
this.client = new Client(config);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void authCertNo(String name, String idCard) {
|
||||
log.info("阿里云二要素认证请求参数: {} {}", name, idCard);
|
||||
CertNoTwoElementVerificationRequest certNoTwoElementVerificationRequest = new com.aliyun.dytnsapi20200217.models.CertNoTwoElementVerificationRequest()
|
||||
.setAuthCode("t92K8i9ae6")
|
||||
.setCertName(name)
|
||||
.setCertNo(idCard);
|
||||
RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
try {
|
||||
CertNoTwoElementVerificationResponse resp = client.certNoTwoElementVerificationWithOptions(certNoTwoElementVerificationRequest, runtime);
|
||||
log.info("阿里云二要素认证响应参数: {}", resp);
|
||||
if (resp.getStatusCode() != 200) {
|
||||
throw new SqxException("请求失败");
|
||||
}
|
||||
|
||||
if (!"OK".equals(resp.getBody().getCode())) {
|
||||
throw new SqxException(resp.getBody().getMessage());
|
||||
}
|
||||
|
||||
if (!"1".equals(resp.getBody().getData().getIsConsistent())) {
|
||||
throw new SqxException("身份证信息不匹配,认证失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new SqxException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -25,12 +25,12 @@ public class InviteAchievementServiceImpl extends ServiceImpl<InviteAchievementM
|
|||
@Override
|
||||
public InviteAchievement getByUserId(Long userId) {
|
||||
return getOne(new LambdaQueryWrapper<InviteAchievement>()
|
||||
.eq(InviteAchievement::getUserId, userId));
|
||||
.eq(InviteAchievement::getTargetUserId, userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int incrCount(Integer id, int i) {
|
||||
return baseMapper.incrCount(id,i);
|
||||
public int incrCount(Long id, Long userId, int i) {
|
||||
return baseMapper.incrCount(id, userId,i);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -42,13 +42,13 @@ public class InviteAchievementServiceImpl extends ServiceImpl<InviteAchievementM
|
|||
public int countBySourceUserId(Long userId) {
|
||||
return count(new LambdaQueryWrapper<InviteAchievement>()
|
||||
.eq(InviteAchievement::getState, 1)
|
||||
.eq(InviteAchievement::getSourceUserId, userId));
|
||||
.eq(InviteAchievement::getUserId, userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countNum(Long userId, Integer signCount) {
|
||||
return count(new LambdaQueryWrapper<InviteAchievement>()
|
||||
.eq(InviteAchievement::getSourceUserId, userId)
|
||||
.eq(InviteAchievement::getUserId, userId)
|
||||
.ge(InviteAchievement::getCount, signCount));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.modules.app.entity.UserInfo;
|
||||
import com.sqx.modules.app.mapper.UserInfoMapper;
|
||||
import com.sqx.modules.app.service.UserInfoService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【user_info】的数据库操作Service实现
|
||||
* @createDate 2025-01-02 14:15:08
|
||||
*/
|
||||
@Service
|
||||
public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo>
|
||||
implements UserInfoService{
|
||||
|
||||
@Override
|
||||
public UserInfo getByUserId(long userId) {
|
||||
UserInfo userInfo = getOne(new LambdaQueryWrapper<UserInfo>()
|
||||
.eq(UserInfo::getUserId, userId));
|
||||
if (userInfo == null) {
|
||||
userInfo = new UserInfo();
|
||||
userInfo.setUserId(userId);
|
||||
save(userInfo);
|
||||
}
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countCertCount(String name, String idNum) {
|
||||
return count(new LambdaQueryWrapper<UserInfo>()
|
||||
.eq(UserInfo::getCertName, name)
|
||||
.eq(UserInfo::getCertNo, idNum));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,17 +1,19 @@
|
|||
package com.sqx.modules.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.dao.UserMoneyDetailsDao;
|
||||
import com.sqx.modules.app.entity.UserMoney;
|
||||
import com.sqx.modules.app.entity.UserMoneyDetails;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -21,7 +23,7 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
|
|||
@Override
|
||||
public Result queryUserMoneyDetails(Integer page, Integer limit, Long sysUserId, Long userId, Integer classify,
|
||||
Integer type, Integer moneyType, Integer viewType) {
|
||||
IPage<UserMoneyDetails> page1 = new Page(page, limit);
|
||||
PageHelper.startPage(page, limit);
|
||||
QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper();
|
||||
if (sysUserId != null) {
|
||||
queryWrapper.eq("sys_user_id", sysUserId);
|
||||
|
|
@ -45,7 +47,7 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
|
|||
queryWrapper.in("classify", arrayList);
|
||||
}
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return Result.success().put("data", baseMapper.selectPage(page1, queryWrapper));
|
||||
return Result.success().put("data", PageUtils.page(new PageInfo<>(baseMapper.selectList(queryWrapper)),true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -58,6 +60,7 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
|
|||
Double inviteMoney = baseMapper.queryUserInviteMoney(userId);
|
||||
Double inviteGoldMoney = baseMapper.queryUserInviteGoldMoney(userId);
|
||||
|
||||
|
||||
Map<String, Double> map = new HashMap<>(2);
|
||||
map.put("inviteMoney", inviteMoney == null ? 0 : inviteMoney);
|
||||
map.put("inviteGoldMoney", inviteGoldMoney == null ? 0 : inviteGoldMoney);
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ 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.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.Constant;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
|
|
@ -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;
|
||||
|
|
@ -100,8 +104,8 @@ public class UserPrizeExchangeServiceImpl extends ServiceImpl<UserPrizeExchangeD
|
|||
wrapper.orderByDesc(UserPrizeExchange::getId);
|
||||
long pageNum = proxy.getLong(Constant.PAGE, 1L);
|
||||
long pageSize = proxy.getLong(Constant.LIMIT, 10L);
|
||||
IPage<UserPrizeExchange> page = this.page(new Page<>(pageNum, pageSize), wrapper);
|
||||
return new PageUtils(page);
|
||||
PageHelper.startPage((int) pageNum, (int) pageSize);
|
||||
return PageUtils.page(new PageInfo<>(this.list(wrapper)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -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("中奖记录不存在");
|
||||
}
|
||||
|
|
@ -245,14 +252,14 @@ public class UserPrizeExchangeServiceImpl extends ServiceImpl<UserPrizeExchangeD
|
|||
}
|
||||
int count = userMoneyDetailsService.count(
|
||||
Wrappers.<UserMoneyDetails>lambdaQuery()
|
||||
.eq(UserMoneyDetails::getUserId, currentUserId)
|
||||
.eq(UserMoneyDetails::getUserId, currentUserId)
|
||||
.eq(UserMoneyDetails::getType, 1)
|
||||
.eq(UserMoneyDetails::getClassify, 7)
|
||||
.eq(UserMoneyDetails::getMoneyType, 1)
|
||||
.likeLeft(UserMoneyDetails::getTitle, "[连续签到")
|
||||
.likeRight(UserMoneyDetails::getTitle, "天]")
|
||||
);
|
||||
if(count > 0){
|
||||
if (count > 0) {
|
||||
throw new SqxException("已经领取过连续签到奖励,无需重复操作");
|
||||
}
|
||||
BigDecimal money = new BigDecimal(moneyStr);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ package com.sqx.modules.app.service.impl;
|
|||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.IdcardUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
|
|
@ -15,8 +17,9 @@ import com.aliyuncs.DefaultAcsClient;
|
|||
import com.aliyuncs.IAcsClient;
|
||||
import com.aliyuncs.http.MethodType;
|
||||
import com.aliyuncs.profile.DefaultProfile;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.getui.push.v2.sdk.ApiHelper;
|
||||
|
|
@ -31,17 +34,18 @@ import com.getui.push.v2.sdk.dto.req.message.android.GTNotification;
|
|||
import com.getui.push.v2.sdk.dto.req.message.ios.Alert;
|
||||
import com.getui.push.v2.sdk.dto.req.message.ios.Aps;
|
||||
import com.getui.push.v2.sdk.dto.req.message.ios.IosDTO;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.qcloudsms.SmsSingleSenderResult;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.dao.AuthCertNoDTO;
|
||||
import com.sqx.modules.app.dao.MsgDao;
|
||||
import com.sqx.modules.app.dao.UserDao;
|
||||
import com.sqx.modules.app.entity.*;
|
||||
import com.sqx.modules.app.service.UserMoneyDetailsService;
|
||||
import com.sqx.modules.app.service.UserMoneyService;
|
||||
import com.sqx.modules.app.service.UserService;
|
||||
import com.sqx.modules.app.service.UserVipService;
|
||||
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;
|
||||
|
|
@ -69,6 +73,7 @@ import org.apache.commons.codec.digest.DigestUtils;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import weixin.popular.api.SnsAPI;
|
||||
|
|
@ -117,12 +122,19 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
private DiscSpinningService discSpinningService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
private final AliService aliService;
|
||||
private final UserInfoService userInfoService;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profiles;
|
||||
|
||||
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
||||
|
||||
public UserServiceImpl(@Lazy AliService aliService, UserInfoService userInfoService) {
|
||||
this.aliService = aliService;
|
||||
this.userInfoService = userInfoService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result authenticationRegister(JSONObject jsonObject, HttpServletRequest request) {
|
||||
reentrantReadWriteLock.writeLock().lock();
|
||||
|
|
@ -959,6 +971,8 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
userInfo.setUpdateTime(sdf.format(new Date()));
|
||||
userInfo.setRate(new BigDecimal(commonInfoService.findOne(420).getValue()));
|
||||
userInfo.setTwoRate(new BigDecimal(commonInfoService.findOne(421).getValue()));
|
||||
Long snowFlakeId = InvitationCodeUtil.getSnowFlakeId();
|
||||
userInfo.setUserId(snowFlakeId);
|
||||
baseMapper.insert(userInfo);
|
||||
userInfo.setInvitationCode(InvitationCodeUtil.toSerialCode(userInfo.getUserId()));
|
||||
baseMapper.updateById(userInfo);
|
||||
|
|
@ -1348,9 +1362,11 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
public PageUtils selectUserPage(Integer page, Integer limit, String search, Integer sex, String platform,
|
||||
String sysPhone, Integer status, Integer member, String inviterCode, String userName,
|
||||
String invitationCode, String startTime, String endTime, String qdCode, String sysUserName, Integer vipType) {
|
||||
Page<UserEntity> pages = new Page<>(page, limit);
|
||||
return new PageUtils(baseMapper.selectUserPage(pages, search, sex, platform, sysPhone, status, member,
|
||||
inviterCode, userName, invitationCode, TimeCompleteUtils.completeStartTime(startTime), TimeCompleteUtils.completeEndTime(endTime), qdCode, sysUserName, vipType));
|
||||
PageHelper.startPage(page, limit);
|
||||
List<UserEntity> entities = baseMapper.selectUserPage(search, sex, platform, sysPhone, status, member,
|
||||
inviterCode, userName, invitationCode, TimeCompleteUtils.completeStartTime(startTime), TimeCompleteUtils.completeEndTime(endTime), qdCode, sysUserName, vipType);
|
||||
PageInfo<UserEntity> pageInfo = new PageInfo<>(entities);
|
||||
return PageUtils.page(pageInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1381,7 +1397,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public IPage<Map<String, Object>> queryCourseOrder(Page<Map<String, Object>> iPage, int type, String date, Long sysUserId) {
|
||||
public PageUtils queryCourseOrder(Long page, Long limit, int type, String date, Long sysUserId) {
|
||||
DateTime parse = DateUtil.parse(date, "yyyy-MM-dd");
|
||||
|
||||
String startTime = DateUtil.format(parse, "yyyy-MM-dd 00:00:00");
|
||||
|
|
@ -1393,7 +1409,12 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
startTime = DateUtil.format(DateUtil.beginOfYear(parse), "yyyy-MM-dd 00:00:00");
|
||||
endTime = DateUtil.format(DateUtil.endOfYear(parse), "yyyy-MM-dd 23:59:59");
|
||||
}
|
||||
return baseMapper.queryCourseOrder(iPage, type, startTime, endTime, sysUserId);
|
||||
|
||||
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);
|
||||
|
||||
return PageUtils.page(pageInfo, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1474,7 +1495,8 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
|
||||
@Override
|
||||
public Result selectInviteUserList(Integer page, Integer limit, String userName, String phone) {
|
||||
return Result.success().put("data", baseMapper.selectInviteUserList(new Page<>(page, limit), userName, phone));
|
||||
PageHelper.startPage(page,limit);
|
||||
return Result.success().put("data", PageUtils.page(new PageInfo<>(baseMapper.selectInviteUserList(userName, phone)),true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1535,4 +1557,35 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object authCertNo(long userId, AuthCertNoDTO authCertNoDTO) {
|
||||
authCertNoDTO.setName(StrUtil.trim(authCertNoDTO.getName()));
|
||||
authCertNoDTO.setIdNum(StrUtil.trim(authCertNoDTO.getIdNum()));
|
||||
if (!IdcardUtil.isValidCard(authCertNoDTO.getIdNum())) {
|
||||
throw new SqxException("身份证号码有误");
|
||||
}
|
||||
|
||||
UserEntity userEntity = baseMapper.selectById(userId);
|
||||
if (userEntity == null) {
|
||||
throw new SqxException("用户信息不存在");
|
||||
}
|
||||
|
||||
UserInfo userInfo = userInfoService.getByUserId(userId);
|
||||
if (userInfo.getCertName() != null) {
|
||||
throw new SqxException("此账号已认证");
|
||||
}
|
||||
|
||||
Integer count = userInfoService.countCertCount(authCertNoDTO.getName(), authCertNoDTO.getIdNum());
|
||||
if (count > 1) {
|
||||
throw new SqxException("此实名信息已存在");
|
||||
}
|
||||
|
||||
aliService.authCertNo(authCertNoDTO.getName(), authCertNoDTO.getIdNum());
|
||||
|
||||
userInfo.setCertName(authCertNoDTO.getName());
|
||||
userInfo.setCertNo(authCertNoDTO.getIdNum());
|
||||
userInfo.setUpdateTime(DateUtil.date());
|
||||
return userInfoService.updateById(userInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.banner.controller.app;
|
|||
|
||||
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.banner.entity.Banner;
|
||||
|
|
@ -13,6 +15,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/9
|
||||
|
|
@ -38,7 +42,10 @@ public class AppBannerController {
|
|||
@ApiOperation("查询所有banner图")
|
||||
@ResponseBody
|
||||
public Result selectBannerPage(Integer page,Integer limit,Integer classify) {
|
||||
return Result.success().put("data", new PageUtils(bannerService.page(new Page<>(page,limit),new QueryWrapper<Banner>().eq("classify",classify))));
|
||||
PageHelper.startPage(page,limit);
|
||||
List<Banner> classify1 = bannerService.list(new QueryWrapper<Banner>().eq("classify", classify));
|
||||
PageInfo<Banner> pageInfo = new PageInfo<>(classify1);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/clickBanner", method = RequestMethod.GET)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package com.sqx.modules.banner.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.banner.entity.Banner;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -21,6 +19,6 @@ public interface BannerDao extends BaseMapper<Banner> {
|
|||
|
||||
// List<Banner> selectList(@Param("classify") Integer classify);
|
||||
|
||||
IPage<Banner> selectBannerPage(Page<Banner> page,@Param("classify") Integer classify);
|
||||
List<Banner> selectBanner(@Param("classify") Integer classify);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.banner.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -14,6 +16,7 @@ import java.io.Serializable;
|
|||
@TableName("activity")
|
||||
public class Activity implements Serializable {
|
||||
@TableId(type = IdType.INPUT)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
private String createAt;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
|
@ -27,6 +29,7 @@ public class Banner implements Serializable {
|
|||
* banner图id
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
package com.sqx.modules.banner.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.banner.dao.BannerDao;
|
||||
import com.sqx.modules.banner.entity.Activity;
|
||||
import com.sqx.modules.banner.entity.Banner;
|
||||
import com.sqx.modules.banner.service.BannerService;
|
||||
import com.sqx.modules.course.dao.CourseDao;
|
||||
|
|
@ -53,8 +52,8 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
|||
|
||||
@Override
|
||||
public PageUtils selectBannerPage(Integer page, Integer limit, Integer classify) {
|
||||
Page<Banner> pages = new Page<>(page, limit);
|
||||
return new PageUtils(bannerDao.selectBannerPage(pages, classify));
|
||||
PageHelper.startPage(page, limit);
|
||||
return PageUtils.page(new PageInfo<>(bannerDao.selectBanner(classify)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -83,12 +82,13 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
|||
|
||||
@Override
|
||||
public Result clickBanner(Integer bannerId, int page, int limit) {
|
||||
Page<Course> page1 = new Page<>(page, limit);
|
||||
PageHelper.startPage(page, limit);
|
||||
QueryWrapper<Course> queryWrapper = new QueryWrapper();
|
||||
//查询banner 对应短剧
|
||||
queryWrapper.eq("banner_id", bannerId);
|
||||
IPage<Course> coursePage = courseDao.selectPage(page1, queryWrapper);
|
||||
return Result.success().put("data", coursePage);
|
||||
List<Course> coursePage = courseDao.selectList(queryWrapper);
|
||||
PageInfo<Course> pageInfo = new PageInfo<>(coursePage);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo, true));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -18,12 +21,14 @@ public class UniAdCallbackRecord implements Serializable {
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ public class UniAdCallbackRecordServiceImpl extends ServiceImpl<UniAdCallbackRec
|
|||
return respData;
|
||||
}
|
||||
|
||||
|
||||
UserEntity userEntity = userDao.selectById(callBackDTO.getUser_id());
|
||||
if (userEntity == null) {
|
||||
callbackRecord.setErrMsg("用户不存在");
|
||||
|
|
@ -106,16 +107,22 @@ public class UniAdCallbackRecordServiceImpl extends ServiceImpl<UniAdCallbackRec
|
|||
return respData;
|
||||
}
|
||||
|
||||
CommonInfo info = commonInfoDao.findOne(921);
|
||||
if (info == null || StrUtil.isBlank(info.getValue())){
|
||||
callbackRecord.setErrMsg("CommonInfo时长时间未配置");
|
||||
log.warn(getBaseErrInfo(callbackRecord));
|
||||
save(callbackRecord);
|
||||
respData.put("isValid", false);
|
||||
return respData;
|
||||
if (!callBackDTO.getExtra().contains("cash")) {
|
||||
CommonInfo info = commonInfoDao.findOne(921);
|
||||
if (info == null || StrUtil.isBlank(info.getValue())){
|
||||
callbackRecord.setErrMsg("CommonInfo时长时间未配置");
|
||||
log.warn(getBaseErrInfo(callbackRecord));
|
||||
save(callbackRecord);
|
||||
respData.put("isValid", false);
|
||||
return respData;
|
||||
}
|
||||
|
||||
redisService.setFreeWatchTime(callbackRecord.getUserId(), Integer.parseInt(info.getValue()) * 60, true);
|
||||
}else {
|
||||
redisService.setCanCashFlag(userEntity.getUserId(), callbackRecord.getId());
|
||||
}
|
||||
|
||||
redisService.setFreeWatchTime(callbackRecord.getUserId(), Integer.parseInt(info.getValue()) * 60, true);
|
||||
|
||||
save(callbackRecord);
|
||||
respData.put("isValid", true);
|
||||
return respData;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.sqx.modules.common.controller.app;
|
||||
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.annotation.Login;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -59,7 +58,19 @@ public class AppCommonController {
|
|||
return commonService.findByTypeAndCondition(condition);
|
||||
}
|
||||
|
||||
@GetMapping("getAppUseKv")
|
||||
@ApiOperation("获取APP使用的KV数据")
|
||||
@ResponseBody
|
||||
public Result getAppUseKv() {
|
||||
return Result.success().put("data",commonService.findAppKv());
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("cleanAppUseKv")
|
||||
@ApiOperation("清理APP使用的KV数据")
|
||||
@ResponseBody
|
||||
public Result clean() {
|
||||
commonService.cleanAppKv();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.sqx.modules.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class AddAnnouncementDTO {
|
||||
@NotBlank
|
||||
private String title;
|
||||
@NotBlank
|
||||
private String content;
|
||||
@NotNull
|
||||
private Integer state;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.sqx.modules.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AnnouncementDTO {
|
||||
private String title;
|
||||
private String content;
|
||||
private Integer state;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.sqx.modules.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class DeleteAnnouncementDTO {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.sqx.modules.common.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class UpdateAnnouncementDTO {
|
||||
@NotNull
|
||||
private Integer id;
|
||||
private String title;
|
||||
private String content;
|
||||
private Integer state;
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.common.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -15,11 +17,12 @@ import java.io.Serializable;
|
|||
public class CommonInfo implements Serializable {
|
||||
|
||||
@TableId(type = IdType.INPUT)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private long id;
|
||||
|
||||
private String createAt;
|
||||
|
||||
private Integer type; //1表示客服二维码 2表示公众号二维码 3表示全局佣金是否开启 4注册客服渠道id配置 5、佣金规则 6、
|
||||
//1表示客服二维码 2表示公众号二维码 3表示全局佣金是否开启 4注册客服渠道id配置 5、佣金规则 6、
|
||||
private Integer type;
|
||||
|
||||
private String value;
|
||||
|
||||
|
|
@ -29,5 +32,10 @@ public class CommonInfo implements Serializable {
|
|||
|
||||
private String conditionFrom;
|
||||
|
||||
/**
|
||||
* 是否在app中使用 1是,0否,默认0
|
||||
*/
|
||||
private Integer isAppUse;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.common.service;
|
|||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.common.entity.CommonInfo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
* @date 2020/7/8
|
||||
|
|
@ -40,4 +42,7 @@ public interface CommonInfoService {
|
|||
*/
|
||||
Result findByTypeAndCondition(String condition);
|
||||
|
||||
Map<Integer,String> findAppKv();
|
||||
|
||||
void cleanAppKv();
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.sqx.modules.common.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.common.dao.CommonInfoDao;
|
||||
|
|
@ -7,14 +9,18 @@ import com.sqx.modules.common.entity.CommonInfo;
|
|||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import com.sqx.modules.course.service.CourseService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author fang
|
||||
|
|
@ -29,6 +35,9 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
@Autowired
|
||||
private CourseService courseService;
|
||||
|
||||
@Autowired
|
||||
private CacheManager cacheManager;
|
||||
|
||||
|
||||
@CacheEvict(key = "#commonInfo.id")
|
||||
@Override
|
||||
|
|
@ -36,15 +45,15 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Date now = new Date();
|
||||
commonInfo.setCreateAt(sdf.format(now));
|
||||
if(commonInfo.getType()==820){
|
||||
if (commonInfo.getType() == 820) {
|
||||
Result result = courseService.setDyNotifyUrl(commonInfo.getValue());
|
||||
String code = String.valueOf(result.get("code"));
|
||||
if(!"0".equals(code)){
|
||||
if (!"0".equals(code)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
commonInfoDao.updateById(commonInfo);
|
||||
|
||||
cleanAppKv();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +66,7 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
@Override
|
||||
public Result delete(long id) {
|
||||
commonInfoDao.deleteById(id);
|
||||
cleanAppKv();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
|
@ -64,18 +74,34 @@ public class CommonInfoServiceImpl extends ServiceImpl<CommonInfoDao, CommonInfo
|
|||
@Override
|
||||
public Result updateBody(CommonInfo commonInfo) {
|
||||
commonInfoDao.updateById(commonInfo);
|
||||
cleanAppKv();
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findByType(Integer type) {
|
||||
return Result.success().put("data",commonInfoDao.findOne(type));
|
||||
return Result.success().put("data", commonInfoDao.findOne(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findByTypeAndCondition(String condition) {
|
||||
return Result.success().put("data",commonInfoDao.findByCondition(condition));
|
||||
return Result.success().put("data", commonInfoDao.findByCondition(condition));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable("commonInfoAppKv")
|
||||
public Map<Integer, String> findAppKv() {
|
||||
List<CommonInfo> list = commonInfoDao.selectList(Wrappers.<CommonInfo>lambdaQuery().eq(CommonInfo::getIsAppUse, 1).orderByAsc(CommonInfo::getType).orderByAsc(CommonInfo::getId));
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return new HashMap<>(0);
|
||||
}
|
||||
Map<Integer, String> data = list.stream().collect(Collectors.toMap(CommonInfo::getType, CommonInfo::getValue));
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanAppKv() {
|
||||
cacheManager.getCache("commonInfoAppKv").clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ import java.util.Date;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
|
|
@ -23,6 +25,7 @@ import lombok.Data;
|
|||
@ApiModel(value = "达标奖励表(邀请人员 几个人达标后的额外奖励) 实体类")
|
||||
public class CompletAward extends Model<CompletAward> {
|
||||
@ApiModelProperty("id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
@ApiModelProperty("人数")
|
||||
private Integer inviteCount;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.coupon.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -15,7 +17,8 @@ public class Coupon implements Serializable {
|
|||
/**
|
||||
* 优惠券d
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long couponId;
|
||||
/**
|
||||
* 优惠券名称
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.coupon.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -15,11 +17,13 @@ public class CouponUser implements Serializable {
|
|||
/**
|
||||
* 用户优惠券id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long couponUserId;
|
||||
/**
|
||||
*用户id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
/**
|
||||
* 优惠券金币
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.sqx.modules.coupon.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.coupon.dao.CouponDao;
|
||||
import com.sqx.modules.coupon.entity.Coupon;
|
||||
|
|
@ -34,13 +33,12 @@ public class CouponServiceImpl extends ServiceImpl<CouponDao, Coupon> implements
|
|||
|
||||
@Override
|
||||
public Result selectCoupon(Integer page, Integer limit, String couponName) {
|
||||
IPage<Coupon> pages = new Page<>(page, limit);
|
||||
PageHelper.startPage(page,limit);
|
||||
QueryWrapper<Coupon> queryWrapper1 = new QueryWrapper<>();
|
||||
if(couponName!=null){
|
||||
queryWrapper1.eq("coupon_name",couponName);
|
||||
}
|
||||
pages=baseMapper.selectPage(pages,queryWrapper1);
|
||||
return Result.success().put("data",pages.getRecords());
|
||||
return Result.success().put("data",baseMapper.selectList(queryWrapper1));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -33,5 +33,11 @@ public class AppCourseCollectController extends AbstractController {
|
|||
return courseCollectService.selectByUserId(page,limit,userId,classify);
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/collectVideoSummary")
|
||||
public Result collectVideoSummary(@RequestAttribute("userId") Long userId){
|
||||
return courseCollectService.collectVideoSummary(userId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,20 @@ public class AppCourseController extends AbstractController {
|
|||
null, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/courseSets")
|
||||
@ApiOperation("根据id查询短剧集数列表")
|
||||
public Result courseSets(@RequestAttribute("userId") Long userId, Long courseId) {
|
||||
return courseDetailsService.courseSets(userId, courseId);
|
||||
}
|
||||
|
||||
@Login
|
||||
@GetMapping("/courseDetails")
|
||||
@ApiOperation("查询短剧 内容")
|
||||
public Result courseDetails(@RequestAttribute("userId") Long userId, Long courseId, Integer sort) {
|
||||
return courseDetailsService.courseDetails(userId, courseId, sort);
|
||||
}
|
||||
|
||||
|
||||
@Login
|
||||
@GetMapping("/selectCourseDetailsById")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package com.sqx.modules.course.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.course.entity.CourseClassification;
|
||||
import com.sqx.modules.course.response.ClassificationResponse;
|
||||
import com.sqx.modules.course.response.CurriculumResponse;
|
||||
|
|
@ -14,10 +12,7 @@ import java.util.Map;
|
|||
|
||||
@Mapper
|
||||
public interface CourseClassificationDao extends BaseMapper<CourseClassification> {
|
||||
|
||||
IPage<Map<String, Object>> selectCourseClassificationPage(Page<Map<String, Object>> pages, @Param("classificationName") String classificationName);
|
||||
|
||||
IPage<Map<String, Object>> selectCourseClassificationList(@Param("classificationName") String classificationName);
|
||||
List<Map<String, Object>> selectCourseClassificationList(@Param("classificationName") String classificationName);
|
||||
|
||||
int updateDelete(@Param("id") Long id);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
package com.sqx.modules.course.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import com.sqx.modules.course.entity.CourseCollect;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface CourseCollectDao extends BaseMapper<CourseCollect> {
|
||||
|
||||
IPage<Course> selectCourseByCollect(Page<Course> page, @Param("userId") Long userId,@Param("classify") Integer classify);
|
||||
List<Course> selectCourseByCollect(@Param("userId") Long userId, @Param("classify") Integer classify);
|
||||
|
||||
|
||||
Map<String, Object> selectSummary(Long userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
package com.sqx.modules.course.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.course.entity.CourseComment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
|
|
@ -14,7 +13,7 @@ public interface CourseCommentDao extends BaseMapper<CourseComment> {
|
|||
|
||||
int updateCourseComment(@Param("type") Integer type, @Param("courseCommentId") Long courseCommentId);
|
||||
|
||||
IPage<CourseComment> selectCourseComment(Page<CourseComment> page, @Param("courseId") Long courseId,@Param("userId") Long userId);
|
||||
List<CourseComment> selectCourseComment(@Param("courseId") Long courseId, @Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 删除评论的点赞关联
|
||||
|
|
@ -23,7 +22,7 @@ public interface CourseCommentDao extends BaseMapper<CourseComment> {
|
|||
*/
|
||||
int deleteCommentGood(@Param("courseCommentId") Long courseCommentId);
|
||||
|
||||
IPage<Map<String,Object>> selectCourseCommentByUserId(Page<Map<String,Object>> page,@Param("userId") Long userId);
|
||||
List<Map<String,Object>> selectCourseCommentByUserId(@Param("userId") Long userId);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,30 @@
|
|||
package com.sqx.modules.course.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface CourseDao extends BaseMapper<Course> {
|
||||
|
||||
int updateDelete(@Param("id") Long id);
|
||||
|
||||
IPage<Map<String, Object>> selectCourse(Page<Map<String, Object>> pages, @Param("classifyId") Long classifyId,
|
||||
@Param("title") String title,@Param("isRecommend") Integer isRecommend,
|
||||
@Param("status") Integer status,@Param("bannerId") Long bannerId,
|
||||
@Param("sort") Integer sort,@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime,@Param("userId") Long userId,
|
||||
@Param("isPrice") Integer isPrice,@Param("over") Integer over,
|
||||
@Param("wxCourse") Integer wxCourse,@Param("dyCourse") Integer dyCourse,
|
||||
@Param("wxShow") Integer wxShow,@Param("dyShow") Integer dyShow);
|
||||
List<Map<String, Object>> selectCourse(@Param("classifyId") Long classifyId,
|
||||
@Param("title") String title, @Param("isRecommend") Integer isRecommend,
|
||||
@Param("status") Integer status, @Param("bannerId") Long bannerId,
|
||||
@Param("sort") Integer sort, @Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime, @Param("userId") Long userId,
|
||||
@Param("isPrice") Integer isPrice, @Param("over") Integer over,
|
||||
@Param("wxCourse") Integer wxCourse, @Param("dyCourse") Integer dyCourse,
|
||||
@Param("wxShow") Integer wxShow, @Param("dyShow") Integer dyShow);
|
||||
|
||||
IPage<Map<String, Object>> selectCourseAdmin(Page<Map<String, Object>> pages, @Param("classifyId") Long classifyId,
|
||||
List<Map<String, Object>> selectCourseAdmin(@Param("classifyId") Long classifyId,
|
||||
@Param("title") String title,@Param("isRecommend") Integer isRecommend,
|
||||
@Param("status") Integer status,@Param("bannerId") Long bannerId,
|
||||
@Param("sort") Integer sort,@Param("startTime") String startTime,
|
||||
|
|
@ -34,10 +35,8 @@ public interface CourseDao extends BaseMapper<Course> {
|
|||
|
||||
/**
|
||||
* 根据title 模糊查询短剧
|
||||
* @param pages
|
||||
* @param title
|
||||
* @return
|
||||
*/
|
||||
IPage<Map<String, Object>> selectCourseTitle(Page<Map<String, Object>> pages, @Param("title")String title);
|
||||
|
||||
List<Map<String, Object>> selectCourseTitle(@Param("title")String title);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,51 @@
|
|||
package com.sqx.modules.course.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.course.entity.CourseDetails;
|
||||
import com.sqx.modules.course.vo.CourseDetailsSetVo;
|
||||
import com.sqx.modules.course.vo.CourseDetailsVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
@CacheConfig
|
||||
public interface CourseDetailsDao extends BaseMapper<CourseDetails> {
|
||||
/**
|
||||
* @param courseId 剧的id
|
||||
* @param isPrice 是否收费 true 收费
|
||||
* @param price 全剧价格
|
||||
* @param wholesalePrice 10集价格
|
||||
*/
|
||||
@Cacheable(cacheNames = "courseSets" ,key = "#courseId")
|
||||
List<CourseDetailsSetVo> courseSets(@Param("courseId") Long courseId, Integer isPrice, BigDecimal price, BigDecimal wholesalePrice);
|
||||
|
||||
List<CourseDetails> findByCourseId(@Param("id") Long id,@Param("userId") Long userId);
|
||||
List<CourseDetailsVo> courseDetails(@Param("courseId") Long courseId, @Param("collect") Long collect,
|
||||
@Param("starSort") Integer starSort, @Param("endSort") Integer endSort);
|
||||
|
||||
IPage<CourseDetails> selectCoursePageByCourseId(Page<CourseDetails> page, @Param("id") Long id,@Param("good") Integer good);
|
||||
List<CourseDetails> findByCourseId(@Param("id") Long id, @Param("userId") Long userId);
|
||||
|
||||
List<CourseDetails> findByCourseIdNotUrl(@Param("id") Long id,@Param("userId") Long userId);
|
||||
List<CourseDetails> selectCoursePageByCourseId(@Param("id") Long id, @Param("good") Integer good);
|
||||
|
||||
List<CourseDetails> findByCourseIdNotUrl(@Param("id") Long id, @Param("userId") Long userId);
|
||||
|
||||
int deleteCourseDetails(String[] ids);
|
||||
|
||||
IPage<CourseDetails> selectCourseDetailsList(Page<CourseDetails> page,String randomNum,Integer wxShow,Integer dyShow);
|
||||
|
||||
/**
|
||||
* 播放数
|
||||
* 点赞数
|
||||
* 总集数
|
||||
*/
|
||||
Map<String, Object> countCourse(Long courseId);
|
||||
|
||||
@Cacheable(cacheNames = "courseCount" ,key = "#courseId")
|
||||
Integer countCourseByCourseId(Long courseId);
|
||||
|
||||
List<CourseDetails> countByCourseId();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,15 @@
|
|||
package com.sqx.modules.course.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import com.sqx.modules.course.entity.CourseUser;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface CourseUserDao extends BaseMapper<CourseUser> {
|
||||
|
||||
// IPage<Course> selectLatelyCourse(Page<Course> pages, @Param("userId") Long userId);
|
||||
|
||||
//子查询不能用
|
||||
// IPage<Course> selectCourseByCourseUser(Page<Course> pages, @Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 查询用户是否订购
|
||||
*
|
||||
|
|
@ -28,6 +20,8 @@ public interface CourseUserDao extends BaseMapper<CourseUser> {
|
|||
CourseUser selectCourseUser(@Param("id") Long id, @Param("userId") Long userId);
|
||||
|
||||
List<CourseUser> selectCourseUserList(@Param("id") Long id, @Param("userId") Long userId);
|
||||
//查询用户已购买的集
|
||||
Set<Long> selectUserCourseDetailsId(@Param("id") Long id, @Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.sqx.modules.course.entity;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -20,17 +22,20 @@ public class CommentGood implements Serializable {
|
|||
/**
|
||||
* 评论点赞id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long commentGoodId;
|
||||
|
||||
/**
|
||||
* 评论id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseCommentId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.sqx.modules.orders.entity.Orders;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -25,7 +27,8 @@ public class Course implements Serializable {
|
|||
/**
|
||||
* 短剧id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
|
|
@ -68,6 +71,7 @@ public class Course implements Serializable {
|
|||
* 分类
|
||||
*/
|
||||
@TableField("classify_id")
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long classifyId;
|
||||
/**
|
||||
* 短剧分类对象
|
||||
|
|
@ -332,6 +336,8 @@ public class Course implements Serializable {
|
|||
|
||||
@TableField(exist = false)
|
||||
private Integer isCollect;
|
||||
private Integer weekView;
|
||||
private Integer weekPay;
|
||||
|
||||
public Course() {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.sqx.modules.course.entity;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -19,7 +21,8 @@ public class CourseClassification implements Serializable {
|
|||
/**
|
||||
* 分类id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long classificationId;
|
||||
/**
|
||||
* 分类名称
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package com.sqx.modules.course.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.apache.ibatis.annotations.UpdateProvider;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
|
@ -25,22 +26,27 @@ public class CourseCollect implements Serializable {
|
|||
/**
|
||||
* 收藏id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseCollectId;
|
||||
|
||||
/**
|
||||
* 短剧id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 集id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseDetailsId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.sqx.modules.app.entity.UserEntity;
|
||||
import lombok.Data;
|
||||
|
||||
|
|
@ -24,12 +26,14 @@ public class CourseComment implements Serializable {
|
|||
/**
|
||||
* 短剧评论id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseCommentId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
@TableField(exist = false)
|
||||
private UserEntity userEntity;
|
||||
|
|
@ -49,6 +53,7 @@ public class CourseComment implements Serializable {
|
|||
/**
|
||||
* 短剧id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseId;
|
||||
/**
|
||||
* 短剧
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.sqx.modules.course.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -24,12 +23,15 @@ public class CourseDetails implements Serializable {
|
|||
/**
|
||||
* 短剧目录id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseDetailsId;
|
||||
|
||||
/**
|
||||
* 短剧id
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseId;
|
||||
|
||||
@TableField(exist = false)
|
||||
|
|
@ -136,11 +138,13 @@ public class CourseDetails implements Serializable {
|
|||
/**
|
||||
* 播放量
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long viewCount;
|
||||
|
||||
/**
|
||||
* 完播量
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long playCompleteCount;
|
||||
|
||||
@TableField(exist = false)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
package com.sqx.modules.course.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -23,17 +22,20 @@ public class CourseUser implements Serializable {
|
|||
/**
|
||||
* 我的短剧id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseUserId;
|
||||
|
||||
/**
|
||||
* 短剧id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 集数id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long courseDetailsId;
|
||||
|
||||
/**
|
||||
|
|
@ -44,11 +46,14 @@ public class CourseUser implements Serializable {
|
|||
/**
|
||||
* 订单id
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ public interface CourseCollectService extends IService<CourseCollect> {
|
|||
Result insertCourseCollect(CourseCollect courseCollect);
|
||||
|
||||
Result selectByUserId(Integer page, Integer limit, Long userId,Integer classify);
|
||||
Result collectVideoSummary(Long userId);
|
||||
|
||||
CourseCollect selectCourseCollectUserIdAnd(Long userId,Long courseId,Integer classify,Long courseDetailsId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,16 @@ public interface CourseDetailsService extends IService<CourseDetails> {
|
|||
|
||||
Result deleteCourseDetails(String ids);
|
||||
|
||||
/**
|
||||
* 集数列表
|
||||
* @param userId
|
||||
* @param courseId
|
||||
* @return
|
||||
*/
|
||||
Result courseSets(Long userId, Long courseId);
|
||||
|
||||
Result courseDetails(Long userId, Long courseId, Integer sort);
|
||||
|
||||
Result selectCourseDetailsById(Long id,String token,String courseDetailsId);
|
||||
|
||||
Result selectCourseDetailsList(Integer page,Integer limit,String token,String randomNum,Integer wxShow,Integer dyShow);
|
||||
|
|
|
|||
|
|
@ -63,4 +63,8 @@ public interface CourseService extends IService<Course> {
|
|||
|
||||
Result getRedEnvelopeTips(Long userId);
|
||||
|
||||
/**
|
||||
* 增加短剧周支付次数
|
||||
*/
|
||||
void incrWeekPayCount(Long courseId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,5 @@ public interface CourseUserService extends IService<CourseUser> {
|
|||
|
||||
void updateTime(Long courseId);
|
||||
|
||||
// Result selectCourseUser(Integer page, Integer limit, Long userId);
|
||||
|
||||
// Result selectLatelyCourse(Integer page, Integer limit, Long userId);
|
||||
|
||||
Result insertCourseUser(CourseUser courseUser);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
package com.sqx.modules.course.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.course.dao.CourseClassificationDao;
|
||||
|
|
@ -37,11 +38,16 @@ public class CourseClassificationServiceImpl extends ServiceImpl<CourseClassific
|
|||
|
||||
@Override
|
||||
public Result selectCourseClassification(Integer page, Integer limit, String classificationName) {
|
||||
if(page==null || limit==null){
|
||||
return Result.success().put("data", new PageUtils(baseMapper.selectCourseClassificationList( classificationName)));
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
Page<Map<String, Object>> pages = new Page<>(page, limit);
|
||||
return Result.success().put("data", new PageUtils(baseMapper.selectCourseClassificationPage(pages, classificationName)));
|
||||
if (limit == null) {
|
||||
limit = 10;
|
||||
}
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Map<String, Object>> list = baseMapper.selectCourseClassificationList(classificationName);
|
||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
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.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.course.dao.CourseClassificationDao;
|
||||
import com.sqx.modules.course.dao.CourseCollectDao;
|
||||
import com.sqx.modules.course.dao.CourseDao;
|
||||
import com.sqx.modules.course.dao.CourseDetailsDao;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import com.sqx.modules.course.entity.CourseCollect;
|
||||
import com.sqx.modules.course.entity.CourseDetails;
|
||||
|
|
@ -19,19 +24,26 @@ import org.springframework.cache.annotation.CachePut;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, CourseCollect> implements CourseCollectService {
|
||||
|
||||
private final CourseDao courseDao;
|
||||
@Autowired
|
||||
private CourseClassificationDao courseClassificationDao;
|
||||
@Autowired
|
||||
private CourseDetailsService courseDetailsService;
|
||||
|
||||
private ReentrantReadWriteLock reentrantReadWriteLock=new ReentrantReadWriteLock(true);
|
||||
private ReentrantReadWriteLock reentrantReadWriteLock = new ReentrantReadWriteLock(true);
|
||||
@Autowired
|
||||
private CourseDetailsDao courseDetailsDao;
|
||||
|
||||
public CourseCollectServiceImpl(CourseDao courseDao) {
|
||||
this.courseDao = courseDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = "app:courseCollect", key = "#courseCollect.userId")
|
||||
|
|
@ -42,15 +54,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);
|
||||
if (collect != null) {
|
||||
collect.setUpdateTime(DateUtils.format(new Date()));
|
||||
collect.setCourseCollectId(courseCollect.getCourseCollectId());
|
||||
baseMapper.updateById(collect);
|
||||
return Result.success("操作成功!");
|
||||
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())
|
||||
|
|
@ -61,37 +76,38 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||
baseMapper.insert(collect);
|
||||
return Result.success("操作成功!");
|
||||
}
|
||||
CourseCollect courseCollect1 = selectCourseCollectUserIdAnd(courseCollect.getUserId(), courseCollect.getCourseId(),courseCollect.getClassify(),courseCollect.getCourseDetailsId());
|
||||
CourseCollect courseCollect1 = selectCourseCollectUserIdAnd(courseCollect.getUserId(), courseCollect.getCourseId(),
|
||||
courseCollect.getClassify(), courseCollect.getClassify() == 1 ? null : courseCollect.getCourseDetailsId());
|
||||
if (courseCollect.getType() == 1) {
|
||||
if(courseCollect1==null){
|
||||
if (courseCollect1 == null) {
|
||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
courseCollect.setCreateTime(df.format(new Date()));
|
||||
courseCollect.setUpdateTime(courseCollect.getCreateTime());
|
||||
baseMapper.insert(courseCollect);
|
||||
if(courseCollect.getClassify()==2){
|
||||
if (courseCollect.getClassify() == 2) {
|
||||
CourseDetails courseDetails = courseDetailsService.getById(courseCollect.getCourseDetailsId());
|
||||
courseDetails.setGoodNum(courseDetails.getGoodNum()+1);
|
||||
courseDetails.setGoodNum(courseDetails.getGoodNum() + 1);
|
||||
courseDetailsService.updateById(courseDetails);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
courseCollect1.setUpdateTime(DateUtils.format(new Date()));
|
||||
baseMapper.updateById(courseCollect1);
|
||||
}
|
||||
} else {
|
||||
if(courseCollect1!=null){
|
||||
if (courseCollect1 != null) {
|
||||
baseMapper.deleteById(courseCollect1.getCourseCollectId());
|
||||
if(courseCollect.getClassify()==2){
|
||||
if (courseCollect.getClassify() == 2) {
|
||||
CourseDetails courseDetails = courseDetailsService.getById(courseCollect.getCourseDetailsId());
|
||||
courseDetails.setGoodNum(courseDetails.getGoodNum()-1);
|
||||
courseDetails.setGoodNum(courseDetails.getGoodNum() - 1);
|
||||
courseDetailsService.updateById(courseDetails);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success("操作成功!");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("收藏短剧出错了!"+e.getMessage());
|
||||
}finally {
|
||||
log.error("收藏短剧出错了!" + e.getMessage());
|
||||
} finally {
|
||||
reentrantReadWriteLock.writeLock().unlock();
|
||||
}
|
||||
return Result.error("系统繁忙,请稍后再试!");
|
||||
|
|
@ -99,22 +115,55 @@ public class CourseCollectServiceImpl extends ServiceImpl<CourseCollectDao, Cour
|
|||
|
||||
@Override
|
||||
@CachePut(value = "app:courseCollect", key = "#userId")
|
||||
public Result selectByUserId(Integer page, Integer limit, Long userId,Integer classify) {
|
||||
Page<Course> pages=new Page<>(page,limit);
|
||||
IPage<Course> courseIPage = baseMapper.selectCourseByCollect(pages, userId,classify);
|
||||
List<Course> courses = courseIPage.getRecords();
|
||||
if (courses != null && courses.size() > 0) {
|
||||
public Result selectByUserId(Integer page, Integer limit, Long userId, Integer classify) {
|
||||
PageHelper.startPage(page, limit);
|
||||
List<CourseCollect> courseCollectList = baseMapper.selectList(new LambdaQueryWrapper<CourseCollect>()
|
||||
.eq(CourseCollect::getUserId, userId)
|
||||
.eq(CourseCollect::getClassify, classify)
|
||||
.isNotNull(CourseCollect::getCourseId)
|
||||
.select(CourseCollect::getCourseId, CourseCollect::getUserId, CourseCollect::getCourseDetailsId));
|
||||
|
||||
Set<Long> courseIdList = new HashSet<>();
|
||||
HashMap<Long, CourseCollect> courseCollectHashMap = new HashMap<>();
|
||||
for (CourseCollect courseCollect : courseCollectList) {
|
||||
courseIdList.add(courseCollect.getCourseId());
|
||||
courseCollectHashMap.put(courseCollect.getCourseId(), courseCollect);
|
||||
}
|
||||
|
||||
List<Course> courseList = courseIdList.isEmpty() ? new ArrayList<>() : courseDao.selectList(new LambdaQueryWrapper<Course>().in(Course::getCourseId, courseIdList));
|
||||
// List<Course> courseList = baseMapper.selectCourseByCollect(userId, classify);
|
||||
Set<Long> detailIdList = courseCollectList.stream().map(CourseCollect::getCourseDetailsId).collect(Collectors.toSet());
|
||||
Map<Long, CourseDetails> courseDetailsMap = detailIdList.isEmpty() ? new HashMap<>() : courseDetailsService.list(new LambdaQueryWrapper<CourseDetails>()
|
||||
.in(CourseDetails::getCourseDetailsId, detailIdList)).stream()
|
||||
.collect(Collectors.toMap(CourseDetails::getCourseDetailsId, item->item));
|
||||
|
||||
Map<Long, Integer> countMap = courseDetailsDao.countByCourseId().stream().collect(Collectors.toMap(CourseDetails::getCourseId, CourseDetails::getCourseDetailsCount));
|
||||
|
||||
PageInfo<Course> pageInfo = new PageInfo<>(courseList);
|
||||
if (CollectionUtil.isNotEmpty(courseList)) {
|
||||
List<Course> courses = pageInfo.getList();
|
||||
for (Course course : courses) {
|
||||
course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
||||
CourseCollect courseCollect = courseCollectHashMap.get(course.getCourseId());
|
||||
CourseDetails courseDetails = courseCollect == null ? null : courseDetailsMap.get(courseCollect.getCourseDetailsId());
|
||||
course.setCourseDetailsCount(courseCollect == null ? 0 :countMap.get(courseCollect.getCourseId()));
|
||||
if (courseDetails != null) {
|
||||
course.setCourseDetailsName(courseDetails.getCourseDetailsName());
|
||||
course.setCourseDetailsId(courseDetails.getCourseDetailsId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.success().put("data",courseIPage);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result collectVideoSummary(Long userId) {
|
||||
return Result.success().put("data", baseMapper.selectSummary(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CourseCollect selectCourseCollectUserIdAnd(Long userId,Long courseId,Integer classify,Long courseDetailsId){
|
||||
return baseMapper.selectOne(new QueryWrapper<CourseCollect>().eq(courseDetailsId!=null,"course_details_id",courseDetailsId).eq("user_id",userId).eq("classify",classify).eq("course_id",courseId));
|
||||
public CourseCollect selectCourseCollectUserIdAnd(Long userId, Long courseId, Integer classify, Long courseDetailsId) {
|
||||
return baseMapper.selectOne(new QueryWrapper<CourseCollect>().eq(courseDetailsId != null, "course_details_id", courseDetailsId).eq("user_id", userId).eq("classify", classify).eq("course_id", courseId));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.sqx.modules.course.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
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.course.dao.CourseCommentDao;
|
||||
|
|
@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
|
|
@ -62,9 +64,11 @@ public class CourseCommentServiceImpl extends ServiceImpl<CourseCommentDao, Cour
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result selectCourseComment(Integer page, Integer limit, Long courseId,Long userId) {
|
||||
Page<CourseComment> courseCommentPage = new Page<>(page, limit);
|
||||
return Result.success().put("data", new PageUtils(baseMapper.selectCourseComment(courseCommentPage, courseId,userId)));
|
||||
public Result selectCourseComment(Integer page, Integer limit, Long courseId, Long userId) {
|
||||
PageHelper.startPage(page, limit);
|
||||
List<CourseComment> commentList = baseMapper.selectCourseComment(courseId, userId);
|
||||
PageInfo<CourseComment> pageInfo = new PageInfo<>(commentList);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -77,8 +81,10 @@ public class CourseCommentServiceImpl extends ServiceImpl<CourseCommentDao, Cour
|
|||
}
|
||||
|
||||
@Override
|
||||
public Result selectCourseCommentUser(Integer page, Integer limit,Long userId) {
|
||||
Page<Map<String,Object>> pages=new Page(page,limit);
|
||||
return Result.success().put("data",new PageUtils(baseMapper.selectCourseCommentByUserId(pages,userId)));
|
||||
public Result selectCourseCommentUser(Integer page, Integer limit, Long userId) {
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Map<String, Object>> list = baseMapper.selectCourseCommentByUserId(userId);
|
||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,20 @@
|
|||
package com.sqx.modules.course.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.exception.SqxException;
|
||||
import com.sqx.common.utils.ApiAccessLimitUtil;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
|
|
@ -29,6 +33,8 @@ import com.sqx.modules.course.entity.CourseDetails;
|
|||
import com.sqx.modules.course.entity.CourseUser;
|
||||
import com.sqx.modules.course.service.CourseDetailsService;
|
||||
import com.sqx.modules.course.vo.CourseDetailsIn;
|
||||
import com.sqx.modules.course.vo.CourseDetailsSetVo;
|
||||
import com.sqx.modules.course.vo.CourseDetailsVo;
|
||||
import com.sqx.modules.orders.dao.OrdersDao;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.redisService.impl.RedisServiceImpl;
|
||||
|
|
@ -40,13 +46,14 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -75,6 +82,7 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = {"courseSets", "courseCount"}, key = "#courseDetails.courseId")
|
||||
public Result insert(CourseDetails courseDetails) {
|
||||
if (courseDetails.getGoodNum() == null) {
|
||||
courseDetails.setGoodNum(0);
|
||||
|
|
@ -84,6 +92,7 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = {"courseSets", "courseCount"}, key = "#courseDetails.courseId")
|
||||
public Result updateCourseDetails(CourseDetails courseDetails) {
|
||||
baseMapper.updateById(courseDetails);
|
||||
return Result.success();
|
||||
|
|
@ -130,6 +139,121 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
|
||||
}
|
||||
|
||||
//更新 播放量 周播放量
|
||||
private void setCourseView(Course course) {
|
||||
if (course.getViewCounts() == null) {
|
||||
course.setViewCounts(1);
|
||||
} else {
|
||||
course.setViewCounts(course.getViewCounts() + 1);
|
||||
}
|
||||
if (ApiAccessLimitUtil.isAccessAllowed("setCourseView:" + course.getCourseId(), "updateAuthCertInfo", 1, 600)) {
|
||||
int courseViewCount = redisServiceImpl.getCourseWeekViewCount(course.getCourseId());
|
||||
course.setWeekView(courseViewCount);
|
||||
}
|
||||
courseDao.updateById(course);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result courseSets(Long userId, Long courseId) {
|
||||
CourseCollect courseCollect = courseCollectDao.selectOne(new QueryWrapper<CourseCollect>().eq("course_id", courseId)
|
||||
.eq("user_id", userId).eq("classify", 3).last("limit 1"));
|
||||
Course bean = courseDao.selectById(courseId);
|
||||
//查询用户是否购买了整集
|
||||
CourseUser courseUser = courseUserDao.selectCourseUser(courseId, userId);
|
||||
// 每天购买超过上限,获得免费时间段资格
|
||||
boolean freeWatch = checkFreeWatchPayCount(userId);
|
||||
List<CourseDetailsSetVo> courseDetailsSetVos;
|
||||
if (freeWatch || courseUser != null) {
|
||||
courseDetailsSetVos = baseMapper.courseSets(courseId, 2, null, null);
|
||||
} else {
|
||||
// courseDetailsSetVos = baseMapper.courseSets(courseId, 1, bean.getPrice(), bean.getWholesalePrice());
|
||||
courseDetailsSetVos = baseMapper.courseSets(courseId, 2, bean.getPrice(), bean.getWholesalePrice());
|
||||
//查询用户是否单独购买了集
|
||||
Set<Long> detailsId = courseUserDao.selectUserCourseDetailsId(courseId, userId);
|
||||
if (courseCollect != null) {
|
||||
for (CourseDetailsSetVo s : courseDetailsSetVos) {
|
||||
if (s.getCourseDetailsId().equals(courseCollect.getCourseDetailsId())) {
|
||||
s.setCurrent(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
courseDetailsSetVos.get(0).setCurrent(1);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(detailsId)) {
|
||||
courseDetailsSetVos = courseDetailsSetVos.stream()
|
||||
.peek(s -> {
|
||||
if (detailsId.contains(s.getCourseDetailsId())) {
|
||||
s.setIsPrice(2);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("title", bean.getTitle());
|
||||
map.put("list", courseDetailsSetVos);
|
||||
return new Result().put("data", map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result courseDetails(Long userId, Long courseId, Integer sort) {
|
||||
Course bean = courseDao.selectById(courseId);
|
||||
Integer detailCount = baseMapper.countCourseByCourseId(courseId);
|
||||
if (detailCount == null || detailCount.equals(0)) {
|
||||
return Result.error("暂无可看剧集,请观看其它影片。");
|
||||
}
|
||||
int startSort = 0;
|
||||
int endSort = 5;
|
||||
if (sort == null) {
|
||||
CourseCollect courseCollect = courseCollectDao.selectOne(new QueryWrapper<CourseCollect>().eq("course_id", courseId)
|
||||
.eq("user_id", userId).eq("classify", 3).last("limit 1"));
|
||||
if (courseCollect != null) {
|
||||
CourseDetails courseDetails = baseMapper.selectOne(new QueryWrapper<CourseDetails>()
|
||||
.eq("course_details_id", courseCollect.getCourseDetailsId()).eq("course_id", courseCollect.getCourseId()).last("limit 1"));
|
||||
sort = courseDetails.getSort();
|
||||
}
|
||||
}
|
||||
if (sort != null && sort > 2) {
|
||||
startSort = sort - 3;
|
||||
endSort = sort + 3;
|
||||
if (detailCount < endSort) {
|
||||
startSort = detailCount - 5;
|
||||
endSort = detailCount + 1;
|
||||
}
|
||||
}
|
||||
//查询用户是否购买了整集
|
||||
CourseUser courseUser = courseUserDao.selectCourseUser(courseId, userId);
|
||||
boolean freeWatch = true;
|
||||
if (courseUser == null) {
|
||||
// 每天购买超过上限,获得免费时间段资格
|
||||
freeWatch = checkFreeWatchPayCount(userId);
|
||||
}
|
||||
Integer collect = courseCollectDao.selectCount(new QueryWrapper<CourseCollect>()
|
||||
.eq("user_id", userId).eq("course_id", courseId)
|
||||
.eq("classify", 1).last("limit 1"));
|
||||
Set<Long> detailsId = new HashSet<>();
|
||||
//全剧免费
|
||||
if ((!freeWatch)) {
|
||||
detailsId = courseUserDao.selectUserCourseDetailsId(courseId, userId);
|
||||
}
|
||||
List<CourseDetailsVo> courseDetailsVos = baseMapper.courseDetails(courseId, collect == null ? 0L : 1L, startSort, endSort);
|
||||
Set<Long> finalDetailsId = detailsId;
|
||||
courseDetailsVos.stream().forEach(s -> {
|
||||
// 不免费 3集以后 (已买的不为空 并不在已买的包含)
|
||||
// if (!freeWatch && s.getSort() > 3 && (CollectionUtil.isEmpty(finalDetailsId) || !finalDetailsId.contains(s.getCourseDetailsId()))) {
|
||||
// s.setVideoUrl(null);
|
||||
// }
|
||||
CourseCollect isGood = courseCollectDao.selectOne(new QueryWrapper<CourseCollect>()
|
||||
.eq("user_id", userId).eq("course_details_id", s.getCourseDetailsId()).eq("classify", 2).last("limit 1"));
|
||||
s.setIsGood(isGood == null ? 0 : 1);
|
||||
});
|
||||
ThreadUtil.execAsync(() -> {
|
||||
setCourseView(bean);
|
||||
});
|
||||
return new Result().put("data", courseDetailsVos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result selectCourseDetailsById(Long id, String token, String courseDetailsId) {
|
||||
Course bean = courseDao.selectById(id);
|
||||
|
|
@ -139,6 +263,9 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
bean.setViewCounts(bean.getViewCounts() + 1);
|
||||
}
|
||||
courseDao.updateById(bean);
|
||||
|
||||
setCourseView(bean);
|
||||
|
||||
Long userId = null;
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
Claims claims = jwtUtils.getClaimByToken(token);
|
||||
|
|
@ -213,13 +340,14 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
.orderByDesc(CourseCollect::getUpdateTime).last("limit 1")
|
||||
);
|
||||
if (courseCollect != null && courseCollect.getCourseDetailsId() != null) {
|
||||
CourseDetails courseDetails = courseDetailsDao.selectById(courseCollect.getCourseDetailsId());
|
||||
CourseDetails courseDetails = courseDetailsDao.selectOne(new LambdaQueryWrapper<CourseDetails>().eq(CourseDetails::getCourseId, id)
|
||||
.eq(CourseDetails::getCourseDetailsId, courseCollect.getCourseDetailsId()));
|
||||
if (courseDetails != null) {
|
||||
bean.setCourseDetailsId(courseDetails.getCourseDetailsId());
|
||||
bean.setCourseDetailsName(courseDetails.getCourseDetailsName());
|
||||
bean.setCourseDetailsCount(courseDetails.getCourseDetailsCount());
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
//默认取第一集
|
||||
CourseDetails courseDetails = courseDetailsDao.selectOne(Wrappers.<CourseDetails>lambdaQuery().eq(CourseDetails::getCourseId, id)
|
||||
.orderByAsc(CourseDetails::getSort).last(" limit 1"));
|
||||
|
|
@ -241,24 +369,30 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
|
|||
userId = Long.parseLong(claims.getSubject());
|
||||
}
|
||||
}
|
||||
if(!Validator.isNumber(randomNum)){
|
||||
if (!Validator.isNumber(randomNum)) {
|
||||
throw new SqxException("随机码必须是数字");
|
||||
};
|
||||
IPage<CourseDetails> courseDetailsIPage = baseMapper.selectCourseDetailsList(new Page<>(page, limit), randomNum, wxShow, dyShow);
|
||||
|
||||
if (userId != null) {
|
||||
List<CourseDetails> records = courseDetailsIPage.getRecords();
|
||||
for (CourseDetails courseDetails : records) {
|
||||
courseDetails.setIsCollect(courseCollectDao.selectCount(new QueryWrapper<CourseCollect>()
|
||||
.eq("user_id", userId).eq("course_details_id", courseDetails.getCourseDetailsId()).eq("classify", 1)));
|
||||
courseDetails.setIsGood(courseCollectDao.selectCount(new QueryWrapper<CourseCollect>()
|
||||
.eq("user_id", userId).eq("course_details_id", courseDetails.getCourseDetailsId()).eq("classify", 2)));
|
||||
courseDetails.setCourse(courseDao.selectById(courseDetails.getCourseId()));
|
||||
courseDetails.setTitle(courseDetails.getCourse().getTitle());
|
||||
courseDetails.setCourseDetailsCount(baseMapper.selectCount(new QueryWrapper<CourseDetails>().eq("course_id", courseDetails.getCourseId())));
|
||||
}
|
||||
}
|
||||
return Result.success().put("data", new PageUtils(courseDetailsIPage));
|
||||
Integer detailCount = baseMapper.selectCount(new QueryWrapper<>());
|
||||
if (detailCount != null) {
|
||||
PageHelper.startPage(RandomUtil.randomInt(1, detailCount / 10), 10);
|
||||
}
|
||||
List<CourseDetails> list = baseMapper.selectList(new QueryWrapper<>());
|
||||
|
||||
PageInfo<CourseDetails> pageInfo = new PageInfo<>(list);
|
||||
|
||||
// if (userId != null) {
|
||||
// List<CourseDetails> records = pageInfo.getList();
|
||||
// for (CourseDetails courseDetails : records) {
|
||||
// courseDetails.setIsCollect(courseCollectDao.selectCount(new QueryWrapper<CourseCollect>()
|
||||
// .eq("user_id", userId).eq("course_details_id", courseDetails.getCourseDetailsId()).eq("classify", 1)));
|
||||
// courseDetails.setIsGood(courseCollectDao.selectCount(new QueryWrapper<CourseCollect>()
|
||||
// .eq("user_id", userId).eq("course_details_id", courseDetails.getCourseDetailsId()).eq("classify", 2)));
|
||||
// courseDetails.setCourse(courseDao.selectById(courseDetails.getCourseId()));
|
||||
// courseDetails.setTitle(courseDetails.getCourse().getTitle());
|
||||
// courseDetails.setCourseDetailsCount(baseMapper.selectCount(new QueryWrapper<CourseDetails>().eq("course_id", courseDetails.getCourseId())));
|
||||
// }
|
||||
// }
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -9,17 +9,21 @@ import cn.hutool.crypto.SecureUtil;
|
|||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.sqx.common.utils.*;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.RedisUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.app.entity.InviteAchievement;
|
||||
import com.sqx.modules.app.service.InviteAchievementService;
|
||||
import com.sqx.modules.app.utils.JwtUtils;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
|
|
@ -33,7 +37,9 @@ import com.sqx.modules.course.entity.CourseUser;
|
|||
import com.sqx.modules.course.service.CourseService;
|
||||
import com.sqx.modules.course.service.CourseUserService;
|
||||
import com.sqx.modules.course.vo.CourseIn;
|
||||
import com.sqx.modules.orders.dao.OrdersDao;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import com.sqx.modules.redisService.RedisService;
|
||||
import com.sqx.modules.search.service.AppSearchService;
|
||||
import com.sqx.modules.utils.EasyPoi.ExcelUtils;
|
||||
import com.sqx.modules.utils.HttpClientUtil;
|
||||
|
|
@ -43,6 +49,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
|
@ -69,18 +76,22 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
@Autowired
|
||||
private OrdersService ordersService;
|
||||
@Autowired
|
||||
private OrdersDao ordersDao;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
@Autowired
|
||||
private JwtUtils jwtUtils;
|
||||
@Autowired
|
||||
private CourseUserService courseUserService;
|
||||
private final RedisService redisService;
|
||||
private final InviteAchievementService inviteAchievementService;
|
||||
|
||||
|
||||
@Resource
|
||||
private RedisUtils redisUtils;
|
||||
|
||||
public CourseServiceImpl(InviteAchievementService inviteAchievementService) {
|
||||
public CourseServiceImpl(RedisService redisService, InviteAchievementService inviteAchievementService) {
|
||||
this.redisService = redisService;
|
||||
this.inviteAchievementService = inviteAchievementService;
|
||||
}
|
||||
|
||||
|
|
@ -139,6 +150,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(cacheNames = {"courseSets", "courseCount"}, key = "#course.courseId")
|
||||
public Result updateCourse(Course course) {
|
||||
baseMapper.updateById(course);
|
||||
return Result.success("操作成功!");
|
||||
|
|
@ -163,7 +175,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
}
|
||||
}
|
||||
}
|
||||
Page<Map<String, Object>> pages = new Page<>(page, limit);
|
||||
// 一周的第一天
|
||||
DateTime begin = DateUtil.beginOfWeek(new Date());
|
||||
String startTime = begin.toString();
|
||||
|
|
@ -177,30 +188,47 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
Map<String, Object> data = JSONUtil.toBean(cache, Map.class);
|
||||
return Result.success().put("data", data);
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, limit);
|
||||
if (admin == null) {
|
||||
IPage<Map<String, Object>> mapIPage = baseMapper.selectCourse(pages, classifyId, title, isRecommend, status, bannerId,
|
||||
List<Map<String, Object>> map = baseMapper.selectCourse(classifyId, title, isRecommend, status, bannerId,
|
||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||
List<Map<String, Object>> records = mapIPage.getRecords();
|
||||
for (Map<String, Object> map : records) {
|
||||
map.put("courseDetailsId", null);
|
||||
map.put("courseDetailsName", "");
|
||||
map.put("dyEpisodeId", "");
|
||||
map.put("wxCourseDetailsId", "");
|
||||
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")));
|
||||
m.put("courseDetailsCount", i == null ? 0 : i);
|
||||
m.put("courseDetailsId", null);
|
||||
m.put("courseDetailsName", "");
|
||||
m.put("dyEpisodeId", "");
|
||||
m.put("wxCourseDetailsId", "");
|
||||
}
|
||||
setCache(cacheKey, JSONUtil.toJsonStr(new PageUtils(mapIPage)));
|
||||
return Result.success().put("data", new PageUtils(mapIPage));
|
||||
PageUtils pageUtils = PageUtils.page(pageInfo);
|
||||
setCache(cacheKey, JSONUtil.toJsonStr(pageUtils));
|
||||
return Result.success().put("data", pageUtils);
|
||||
}
|
||||
IPage<Map<String, Object>> mapIPage = baseMapper.selectCourseAdmin(pages, classifyId, title, isRecommend, status, bannerId,
|
||||
|
||||
// 无用 ifnull(tt.isRecommend,0) as isRecommend
|
||||
// left join (select course_id,count(*) as isRecommend from course_details where good=1 group by course_id) tt on tt.course_id = c.course_id
|
||||
|
||||
List<Map<String, Object>> list = baseMapper.selectCourseAdmin(classifyId, title, isRecommend, status, bannerId,
|
||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||
List<Map<String, Object>> records = mapIPage.getRecords();
|
||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
||||
List<Map<String, Object>> records = pageInfo.getList();
|
||||
for (Map<String, Object> map : records) {
|
||||
long courseId = Convert.toLong(map.get("courseId"));
|
||||
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.putAll(countMap);
|
||||
}
|
||||
setCache(cacheKey, JSONUtil.toJsonStr(new PageUtils(mapIPage)));
|
||||
return Result.success().put("data", new PageUtils(mapIPage));
|
||||
PageUtils pageUtils = PageUtils.page(pageInfo);
|
||||
// setCache(cacheKey, JSONUtil.toJsonStr(pageUtils));
|
||||
return Result.success().put("data", pageUtils);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
|
|
@ -233,8 +261,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
|
||||
@Override
|
||||
public Result selectCourseById(Integer page, Integer limit, Long id, Integer good) {
|
||||
Page<CourseDetails> pages = new Page<>(page, limit);
|
||||
return Result.success().put("data", new PageUtils(courseDetailsDao.selectCoursePageByCourseId(pages, id, good)));
|
||||
PageHelper.startPage(page, limit);
|
||||
List<CourseDetails> details = courseDetailsDao.selectCoursePageByCourseId(id, good);
|
||||
PageInfo<CourseDetails> pageInfo = new PageInfo<>(details);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -245,15 +275,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
//记录或更新搜索内容
|
||||
appSearchService.insetAppSearch(title, userId);
|
||||
}
|
||||
//拼接模糊查询
|
||||
String title1 = null;
|
||||
if (StringUtils.isNotBlank(title)) {
|
||||
title1 = "%" + title + "%";
|
||||
return Result.success().put("data", new PageUtils(baseMapper.selectCourseTitle(pages, title1)));
|
||||
} else {
|
||||
if (StringUtils.isEmpty(title)) {
|
||||
return Result.error("请输入要搜索的内容!");
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, limit);
|
||||
List<Map<String, Object>> list = baseMapper.selectCourseTitle(title);
|
||||
PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1288,4 +1317,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
|||
|
||||
return Result.success().put("data", data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrWeekPayCount(Long courseId) {
|
||||
if (ApiAccessLimitUtil.isAccessAllowed("setWeekPayCount", courseId.toString(), 1, 600)) {
|
||||
int count = redisService.getCourseWeekPayCount(courseId);
|
||||
update(null, new LambdaUpdateWrapper<Course>()
|
||||
.eq(Course::getCourseId, courseId)
|
||||
.set(Course::getWeekPay, count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,17 +2,12 @@ package com.sqx.modules.course.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
import com.sqx.modules.course.dao.CourseClassificationDao;
|
||||
import com.sqx.modules.course.dao.CourseUserDao;
|
||||
import com.sqx.modules.course.entity.Course;
|
||||
import com.sqx.modules.course.entity.CourseUser;
|
||||
import com.sqx.modules.course.service.CourseUserService;
|
||||
import com.sqx.modules.orders.entity.Orders;
|
||||
import com.sqx.modules.orders.service.OrdersService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -20,7 +15,6 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -42,41 +36,6 @@ public class CourseUserServiceImpl extends ServiceImpl<CourseUserDao, CourseUser
|
|||
baseMapper.update(bean, updateWrapper);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Result selectCourseUser(Integer page, Integer limit, Long userId) {
|
||||
// Page<Course> courseUserPage = new Page<>(page, limit);
|
||||
// IPage<Course> iPage = baseMapper.selectCourseByCourseUser(courseUserPage, userId);
|
||||
//
|
||||
// List<Course> courses = iPage.getRecords();
|
||||
// if (courses != null && courses.size() > 0) {
|
||||
// for (Course course : courses) {
|
||||
// Orders orders = ordersService.selectOrdersByCourseIdAndUserId(userId, course.getCourseId());
|
||||
// if(orders!=null){
|
||||
// course.setOrders(orders);
|
||||
// }
|
||||
// course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
||||
// }
|
||||
// }
|
||||
// return Result.success().put("data", new PageUtils(iPage));
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public Result selectLatelyCourse(Integer page, Integer limit, Long userId) {
|
||||
// Page<Course> pages = new Page<>(page, limit);
|
||||
// IPage<Course> iPage = baseMapper.selectLatelyCourse(pages, userId);
|
||||
// List<Course> courses = iPage.getRecords();
|
||||
// if (courses != null && courses.size() > 0) {
|
||||
// for (Course course : courses) {
|
||||
// Orders orders = ordersService.selectOrdersByCourseIdAndUserId(userId, course.getCourseId());
|
||||
// if(orders!=null){
|
||||
// course.setOrders(orders);
|
||||
// }
|
||||
// course.setCourseClassification(courseClassificationDao.selectById(course.getClassifyId()));
|
||||
// }
|
||||
// }
|
||||
// return Result.success().put("data", new PageUtils(iPage));
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
public Result insertCourseUser(CourseUser courseUser) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.sqx.modules.course.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class CourseDetailsSetVo {
|
||||
private Long courseId;
|
||||
private Long courseDetailsId;
|
||||
private String courseDetailsName;
|
||||
private Integer current = 0;
|
||||
private Integer isPrice;
|
||||
private BigDecimal price;
|
||||
private BigDecimal wholesalePrice;
|
||||
private BigDecimal countPrice;
|
||||
private Integer sort;
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.sqx.modules.course.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CourseDetailsVo {
|
||||
private Long courseId;
|
||||
private Long courseDetailsId;
|
||||
private String courseDetailsName;
|
||||
/**
|
||||
* 封面图
|
||||
*/
|
||||
private String titleImg;
|
||||
/**
|
||||
* 视频地址
|
||||
*/
|
||||
private String videoUrl;
|
||||
/**
|
||||
* 点赞数
|
||||
*/
|
||||
private Integer goodNum;
|
||||
/**
|
||||
* 是否已追
|
||||
*/
|
||||
private Long isCollect;
|
||||
/**
|
||||
* 是否点赞
|
||||
*/
|
||||
private Integer isGood;
|
||||
private Integer sort;
|
||||
}
|
||||
|
|
@ -2,7 +2,8 @@ package com.sqx.modules.discSpinning.controller;
|
|||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.annotation.Debounce;
|
||||
import com.sqx.common.exception.CzgException;
|
||||
import com.sqx.common.utils.*;
|
||||
|
|
@ -27,7 +28,9 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
|
@ -126,8 +129,10 @@ public class DiscSpinningController {
|
|||
})
|
||||
@ApiOperation("查询大转盘")
|
||||
public Result selectDiscSpinning(@RequestParam(required = false, defaultValue = "1") Integer source) {
|
||||
return Result.success().put("data", discSpinningService.page(new Page<>(1, 20),
|
||||
new QueryWrapper<DiscSpinning>().eq("disc_type", source).orderByAsc("disc_type", "odds")));
|
||||
PageHelper.startPage(1,20);
|
||||
return Result.success().put("data", PageUtils.page(new PageInfo<>(discSpinningService.list(
|
||||
new QueryWrapper<DiscSpinning>().eq("disc_type", source).orderByAsc("disc_type", "odds"))),true)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = {"大转盘抽奖记录"})
|
||||
|
|
@ -33,8 +38,11 @@ public class DiscSpinningRecordController {
|
|||
@Login
|
||||
@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")));
|
||||
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"));
|
||||
PageInfo<DiscSpinningRecord> pageInfo = new PageInfo<>(list);
|
||||
PageUtils pageUtils = PageUtils.page(pageInfo, true);
|
||||
return Result.success().put("data", pageUtils);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
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 com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -16,10 +20,13 @@ import java.math.BigDecimal;
|
|||
@TableName("disc_spinning_record")
|
||||
public class DiscSpinningRecord extends Model<DiscSpinningRecord> {
|
||||
//主键
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long id;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long sourceId;
|
||||
|
||||
@TableField(updateStrategy = FieldStrategy.NEVER)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long userId;
|
||||
private String imgUrl;
|
||||
//描述
|
||||
|
|
@ -30,7 +37,7 @@ public class DiscSpinningRecord extends Model<DiscSpinningRecord> {
|
|||
private BigDecimal number;
|
||||
//流向 1 提现 2 存入余额 3 兑换
|
||||
private String target;
|
||||
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long targetId;
|
||||
//抽奖日期
|
||||
private String drawDay;
|
||||
|
|
|
|||
|
|
@ -101,10 +101,11 @@ public class DiscSpinningServiceImpl extends ServiceImpl<DiscSpinningDao, DiscSp
|
|||
userMoneyService.updateAmount(1, receive.getUserId(), receive.getNumber().doubleValue());
|
||||
|
||||
|
||||
if (receive.getNumber().compareTo(new BigDecimal("0.1")) > 0 && StringUtils.isNotBlank(userInfo.getZhiFuBao()) && StringUtils.isNotBlank(userInfo.getZhiFuBaoName())) {
|
||||
//提现
|
||||
withdraw(userInfo, receive.getNumber().doubleValue());
|
||||
}
|
||||
// 去除自动提现
|
||||
// if (receive.getNumber().compareTo(new BigDecimal("0.1")) > 0 && StringUtils.isNotBlank(userInfo.getZhiFuBao()) && StringUtils.isNotBlank(userInfo.getZhiFuBaoName())) {
|
||||
// //提现
|
||||
// withdraw(userInfo, receive.getNumber().doubleValue());
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ package com.sqx.modules.file;
|
|||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.model.CannedAccessControlList;
|
||||
import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||
//import com.amazonaws.services.s3.AmazonS3;
|
||||
//import com.amazonaws.services.s3.model.CannedAccessControlList;
|
||||
//import com.amazonaws.services.s3.model.ObjectMetadata;
|
||||
import com.qcloud.cos.COSClient;
|
||||
import com.qcloud.cos.ClientConfig;
|
||||
import com.qcloud.cos.auth.BasicCOSCredentials;
|
||||
|
|
@ -56,12 +56,14 @@ public class AliFileUploadController {
|
|||
|
||||
|
||||
private final CommonInfoService commonRepository;
|
||||
private AmazonS3 amazonS3;
|
||||
// private AmazonS3 amazonS3;
|
||||
|
||||
@Autowired
|
||||
public AliFileUploadController(CommonInfoService commonRepository, AmazonS3 amazonS3) {
|
||||
public AliFileUploadController(CommonInfoService commonRepository
|
||||
// , AmazonS3 amazonS3
|
||||
) {
|
||||
this.commonRepository = commonRepository;
|
||||
this.amazonS3 = amazonS3;
|
||||
// this.amazonS3 = amazonS3;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/getCredentials")
|
||||
|
|
@ -164,24 +166,24 @@ public class AliFileUploadController {
|
|||
cosclient.shutdown();
|
||||
}
|
||||
}else if("3".equals(value)){
|
||||
String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
|
||||
// 上传文件流。
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream =new ByteArrayInputStream(file.getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String completePath=getPath(suffix);
|
||||
String bucket=commonRepository.findOne(810).getValue();
|
||||
com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest = new com.amazonaws.services.s3.model.PutObjectRequest(bucket, completePath, inputStream, new ObjectMetadata());
|
||||
|
||||
putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
|
||||
|
||||
com.amazonaws.services.s3.model.PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
|
||||
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
return Result.success().put("data",commonRepository.findOne(811).getValue()+"/"+completePath);
|
||||
// String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
|
||||
// // 上传文件流。
|
||||
// InputStream inputStream = null;
|
||||
// try {
|
||||
// inputStream =new ByteArrayInputStream(file.getBytes());
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// String completePath=getPath(suffix);
|
||||
// String bucket=commonRepository.findOne(810).getValue();
|
||||
// com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest = new com.amazonaws.services.s3.model.PutObjectRequest(bucket, completePath, inputStream, new ObjectMetadata());
|
||||
//
|
||||
// putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
|
||||
//
|
||||
// com.amazonaws.services.s3.model.PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
|
||||
//
|
||||
// IOUtils.closeQuietly(inputStream);
|
||||
// return Result.success().put("data",commonRepository.findOne(811).getValue()+"/"+completePath);
|
||||
}else if("4".equals(value)){
|
||||
String endpoint = "tos-cn-beijing.volces.com";
|
||||
String region = "cn-beijing";
|
||||
|
|
@ -301,24 +303,24 @@ public class AliFileUploadController {
|
|||
cosclient.shutdown();
|
||||
}
|
||||
}else if("3".equals(value)){
|
||||
String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
|
||||
// 上传文件流。
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
inputStream =new ByteArrayInputStream(file.getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String completePath=getPath(suffix);
|
||||
String bucket=commonRepository.findOne(810).getValue();
|
||||
com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest = new com.amazonaws.services.s3.model.PutObjectRequest(bucket, completePath, inputStream, new ObjectMetadata());
|
||||
|
||||
putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
|
||||
|
||||
com.amazonaws.services.s3.model.PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
|
||||
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
return commonRepository.findOne(811).getValue()+"/"+completePath;
|
||||
// String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
|
||||
// // 上传文件流。
|
||||
// InputStream inputStream = null;
|
||||
// try {
|
||||
// inputStream =new ByteArrayInputStream(file.getBytes());
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// String completePath=getPath(suffix);
|
||||
// String bucket=commonRepository.findOne(810).getValue();
|
||||
// com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest = new com.amazonaws.services.s3.model.PutObjectRequest(bucket, completePath, inputStream, new ObjectMetadata());
|
||||
//
|
||||
// putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
|
||||
//
|
||||
// com.amazonaws.services.s3.model.PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
|
||||
//
|
||||
// IOUtils.closeQuietly(inputStream);
|
||||
// return commonRepository.findOne(811).getValue()+"/"+completePath;
|
||||
}else if("4".equals(value)){
|
||||
String endpoint = "tos-cn-beijing.volces.com";
|
||||
String region = "cn-beijing";
|
||||
|
|
|
|||
|
|
@ -1,91 +1,91 @@
|
|||
package com.sqx.modules.file;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.model.*;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class S3Service {
|
||||
|
||||
@Autowired
|
||||
private AmazonS3 amazonS3;
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
|
||||
private PutObjectResult upload(String filePath, String uploadKey) throws FileNotFoundException {
|
||||
return upload(new FileInputStream(filePath), uploadKey);
|
||||
}
|
||||
|
||||
private PutObjectResult upload(InputStream inputStream, String uploadKey) {
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(commonInfoService.findOne(810).getValue(), uploadKey, inputStream, new ObjectMetadata());
|
||||
|
||||
putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
|
||||
|
||||
PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
|
||||
|
||||
IOUtils.closeQuietly(inputStream);
|
||||
|
||||
return putObjectResult;
|
||||
}
|
||||
|
||||
public List<PutObjectResult> upload(MultipartFile[] multipartFiles) {
|
||||
List<PutObjectResult> putObjectResults = new ArrayList<>();
|
||||
|
||||
Arrays.stream(multipartFiles)
|
||||
.filter(multipartFile -> !StringUtils.isEmpty(multipartFile.getOriginalFilename()))
|
||||
.forEach(multipartFile -> {
|
||||
try {
|
||||
putObjectResults.add(upload(multipartFile.getInputStream(), multipartFile.getOriginalFilename()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
return putObjectResults;
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> download(String key) throws IOException {
|
||||
GetObjectRequest getObjectRequest = new GetObjectRequest(commonInfoService.findOne(810).getValue(), key);
|
||||
|
||||
S3Object s3Object = amazonS3.getObject(getObjectRequest);
|
||||
|
||||
S3ObjectInputStream objectInputStream = s3Object.getObjectContent();
|
||||
|
||||
byte[] bytes = IOUtils.toByteArray(objectInputStream);
|
||||
|
||||
String fileName = URLEncoder.encode(key, "UTF-8").replaceAll("\\+", "%20");
|
||||
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
httpHeaders.setContentLength(bytes.length);
|
||||
httpHeaders.setContentDispositionFormData("attachment", fileName);
|
||||
|
||||
return new ResponseEntity<>(bytes, httpHeaders, HttpStatus.OK);
|
||||
}
|
||||
|
||||
public List<S3ObjectSummary> list() {
|
||||
ObjectListing objectListing = amazonS3.listObjects(new ListObjectsRequest().withBucketName(commonInfoService.findOne(810).getValue()));
|
||||
|
||||
List<S3ObjectSummary> s3ObjectSummaries = objectListing.getObjectSummaries();
|
||||
|
||||
return s3ObjectSummaries;
|
||||
}
|
||||
}
|
||||
//package com.sqx.modules.file;
|
||||
//
|
||||
//import com.amazonaws.services.s3.AmazonS3;
|
||||
//import com.amazonaws.services.s3.model.*;
|
||||
//import com.sqx.modules.common.service.CommonInfoService;
|
||||
//import org.apache.commons.io.IOUtils;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.http.HttpHeaders;
|
||||
//import org.springframework.http.HttpStatus;
|
||||
//import org.springframework.http.MediaType;
|
||||
//import org.springframework.http.ResponseEntity;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//import org.springframework.util.StringUtils;
|
||||
//import org.springframework.web.multipart.MultipartFile;
|
||||
//
|
||||
//import java.io.FileInputStream;
|
||||
//import java.io.FileNotFoundException;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStream;
|
||||
//import java.net.URLEncoder;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//
|
||||
//@Service
|
||||
//public class S3Service {
|
||||
//
|
||||
// @Autowired
|
||||
// private AmazonS3 amazonS3;
|
||||
// @Autowired
|
||||
// private CommonInfoService commonInfoService;
|
||||
//
|
||||
// private PutObjectResult upload(String filePath, String uploadKey) throws FileNotFoundException {
|
||||
// return upload(new FileInputStream(filePath), uploadKey);
|
||||
// }
|
||||
//
|
||||
// private PutObjectResult upload(InputStream inputStream, String uploadKey) {
|
||||
// PutObjectRequest putObjectRequest = new PutObjectRequest(commonInfoService.findOne(810).getValue(), uploadKey, inputStream, new ObjectMetadata());
|
||||
//
|
||||
// putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
|
||||
//
|
||||
// PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
|
||||
//
|
||||
// IOUtils.closeQuietly(inputStream);
|
||||
//
|
||||
// return putObjectResult;
|
||||
// }
|
||||
//
|
||||
// public List<PutObjectResult> upload(MultipartFile[] multipartFiles) {
|
||||
// List<PutObjectResult> putObjectResults = new ArrayList<>();
|
||||
//
|
||||
// Arrays.stream(multipartFiles)
|
||||
// .filter(multipartFile -> !StringUtils.isEmpty(multipartFile.getOriginalFilename()))
|
||||
// .forEach(multipartFile -> {
|
||||
// try {
|
||||
// putObjectResults.add(upload(multipartFile.getInputStream(), multipartFile.getOriginalFilename()));
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return putObjectResults;
|
||||
// }
|
||||
//
|
||||
// public ResponseEntity<byte[]> download(String key) throws IOException {
|
||||
// GetObjectRequest getObjectRequest = new GetObjectRequest(commonInfoService.findOne(810).getValue(), key);
|
||||
//
|
||||
// S3Object s3Object = amazonS3.getObject(getObjectRequest);
|
||||
//
|
||||
// S3ObjectInputStream objectInputStream = s3Object.getObjectContent();
|
||||
//
|
||||
// byte[] bytes = IOUtils.toByteArray(objectInputStream);
|
||||
//
|
||||
// String fileName = URLEncoder.encode(key, "UTF-8").replaceAll("\\+", "%20");
|
||||
//
|
||||
// HttpHeaders httpHeaders = new HttpHeaders();
|
||||
// httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
// httpHeaders.setContentLength(bytes.length);
|
||||
// httpHeaders.setContentDispositionFormData("attachment", fileName);
|
||||
//
|
||||
// return new ResponseEntity<>(bytes, httpHeaders, HttpStatus.OK);
|
||||
// }
|
||||
//
|
||||
// public List<S3ObjectSummary> list() {
|
||||
// ObjectListing objectListing = amazonS3.listObjects(new ListObjectsRequest().withBucketName(commonInfoService.findOne(810).getValue()));
|
||||
//
|
||||
// List<S3ObjectSummary> s3ObjectSummaries = objectListing.getObjectSummaries();
|
||||
//
|
||||
// return s3ObjectSummaries;
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
package com.sqx.modules.file.config;
|
||||
|
||||
import com.amazonaws.auth.AWSCredentials;
|
||||
import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
||||
import com.amazonaws.auth.BasicAWSCredentials;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
||||
import com.sqx.modules.common.service.CommonInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Configuration
|
||||
@Component
|
||||
public class AWSConfiguration {
|
||||
|
||||
@Autowired
|
||||
private CommonInfoService commonInfoService;
|
||||
|
||||
@Bean
|
||||
public BasicAWSCredentials basicAWSCredentials() {
|
||||
return new BasicAWSCredentials(commonInfoService.findOne(807).getValue(), commonInfoService.findOne(808).getValue());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AmazonS3 amazonS3Client(AWSCredentials awsCredentials) {
|
||||
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
|
||||
builder.withCredentials(new AWSStaticCredentialsProvider(awsCredentials));
|
||||
builder.setRegion(commonInfoService.findOne(809).getValue());
|
||||
AmazonS3 amazonS3 = builder.build();
|
||||
return amazonS3;
|
||||
}
|
||||
}
|
||||
//package com.sqx.modules.file.config;
|
||||
//
|
||||
//import com.amazonaws.auth.AWSCredentials;
|
||||
//import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
||||
//import com.amazonaws.auth.BasicAWSCredentials;
|
||||
//import com.amazonaws.services.s3.AmazonS3;
|
||||
//import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
||||
//import com.sqx.modules.common.service.CommonInfoService;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Configuration
|
||||
//@Component
|
||||
//public class AWSConfiguration {
|
||||
//
|
||||
// @Autowired
|
||||
// private CommonInfoService commonInfoService;
|
||||
//
|
||||
// @Bean
|
||||
// public BasicAWSCredentials basicAWSCredentials() {
|
||||
// return new BasicAWSCredentials(commonInfoService.findOne(807).getValue(), commonInfoService.findOne(808).getValue());
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public AmazonS3 amazonS3Client(AWSCredentials awsCredentials) {
|
||||
// AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
|
||||
// builder.withCredentials(new AWSStaticCredentialsProvider(awsCredentials));
|
||||
// builder.setRegion(commonInfoService.findOne(809).getValue());
|
||||
// AmazonS3 amazonS3 = builder.build();
|
||||
// return amazonS3;
|
||||
// }
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.sqx.modules.helpCenter.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.sqx.common.utils.DateUtils;
|
||||
import com.sqx.common.utils.PageUtils;
|
||||
import com.sqx.common.utils.Result;
|
||||
|
|
@ -32,7 +32,7 @@ public class HelpWordController {
|
|||
|
||||
@PostMapping("/insertHelpClassify")
|
||||
@ApiOperation("添加帮助分类")
|
||||
public Result insertHelpClassify(@RequestBody HelpClassify helpClassify){
|
||||
public Result insertHelpClassify(@RequestBody HelpClassify helpClassify) {
|
||||
helpClassify.setCreateTime(DateUtils.format(new Date()));
|
||||
helpClassifyService.save(helpClassify);
|
||||
return Result.success();
|
||||
|
|
@ -40,14 +40,14 @@ public class HelpWordController {
|
|||
|
||||
@PostMapping("/updateHelpClassify")
|
||||
@ApiOperation("修改帮助分类")
|
||||
public Result updateHelpClassify(@RequestBody HelpClassify helpClassify){
|
||||
public Result updateHelpClassify(@RequestBody HelpClassify helpClassify) {
|
||||
helpClassifyService.updateById(helpClassify);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/deleteHelpClassify")
|
||||
@ApiOperation("删除帮助分类")
|
||||
public Result deleteHelpClassify(Long helpClassifyId){
|
||||
public Result deleteHelpClassify(Long helpClassifyId) {
|
||||
helpClassifyService.removeById(helpClassifyId);
|
||||
return Result.success();
|
||||
}
|
||||
|
|
@ -55,27 +55,28 @@ public class HelpWordController {
|
|||
|
||||
@GetMapping("/selectHelpClassifyList")
|
||||
@ApiOperation("查询帮助分类")
|
||||
public Result selectHelpClassifyList(Integer page,Integer limit,Long parentId,Integer types,String helpClassifyName){
|
||||
if(page==null || limit==null){
|
||||
List<HelpClassify> page1 = helpClassifyService.list(
|
||||
new QueryWrapper<HelpClassify>()
|
||||
.eq(types!=null,"types",types)
|
||||
.eq(StringUtils.isNotBlank(helpClassifyName), "help_classify_name", helpClassifyName)
|
||||
.eq(parentId != null, "parent_id", parentId).orderByAsc("sort"));
|
||||
return Result.success().put("data",page1);
|
||||
public Result selectHelpClassifyList(Integer page, Integer limit, Long parentId, Integer types, String helpClassifyName) {
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
IPage<HelpClassify> page1 = helpClassifyService.page(new Page<>(page, limit),
|
||||
new QueryWrapper<HelpClassify>()
|
||||
.eq(types!=null,"types",types)
|
||||
.eq(StringUtils.isNotBlank(helpClassifyName), "help_classify_name", helpClassifyName)
|
||||
.eq(parentId != null, "parent_id", parentId).orderByAsc("sort"));
|
||||
return Result.success().put("data",new PageUtils(page1));
|
||||
if (limit == null) {
|
||||
limit = 10;
|
||||
}
|
||||
|
||||
PageHelper.startPage(page, limit);
|
||||
List<HelpClassify> list = helpClassifyService.list(new QueryWrapper<HelpClassify>()
|
||||
.eq(types != null, "types", types)
|
||||
.eq(StringUtils.isNotBlank(helpClassifyName), "help_classify_name", helpClassifyName)
|
||||
.eq(parentId != null, "parent_id", parentId).orderByAsc("sort"));
|
||||
|
||||
PageInfo<HelpClassify> pageInfo = new PageInfo<>(list);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/insertHelpWord")
|
||||
@ApiOperation("添加帮助文档")
|
||||
public Result insertHelpWord(@RequestBody HelpWord helpWord){
|
||||
public Result insertHelpWord(@RequestBody HelpWord helpWord) {
|
||||
helpWord.setCreateTime(DateUtils.format(new Date()));
|
||||
helpWordService.save(helpWord);
|
||||
return Result.success();
|
||||
|
|
@ -83,14 +84,14 @@ public class HelpWordController {
|
|||
|
||||
@PostMapping("/updateHelpWord")
|
||||
@ApiOperation("修改帮助文档")
|
||||
public Result updateHelpWord(@RequestBody HelpWord helpWord){
|
||||
public Result updateHelpWord(@RequestBody HelpWord helpWord) {
|
||||
helpWordService.updateById(helpWord);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@PostMapping("/deleteHelpWord")
|
||||
@ApiOperation("删除帮助文档")
|
||||
public Result deleteHelpWord(Long helpWordId){
|
||||
public Result deleteHelpWord(Long helpWordId) {
|
||||
helpWordService.removeById(helpWordId);
|
||||
return Result.success();
|
||||
}
|
||||
|
|
@ -98,15 +99,16 @@ public class HelpWordController {
|
|||
|
||||
@GetMapping("/selectHelpWordList")
|
||||
@ApiOperation("查询帮助文档")
|
||||
public Result selectHelpWordList(Integer page,Integer limit,Long helpClassifyId,String helpWordTitle){
|
||||
IPage<HelpWord> page1 = helpWordService.page(new Page<>(page, limit), new QueryWrapper<HelpWord>()
|
||||
public Result selectHelpWordList(Integer page, Integer limit, Long helpClassifyId, String helpWordTitle) {
|
||||
PageHelper.startPage(page, limit);
|
||||
|
||||
List<HelpWord> page1 = helpWordService.list(new QueryWrapper<HelpWord>()
|
||||
.eq(helpClassifyId != null, "help_classify_id", helpClassifyId)
|
||||
.eq(StringUtils.isNotBlank(helpWordTitle), "help_word_title", helpWordTitle).orderByAsc("sort"));
|
||||
return Result.success().put("data",new PageUtils(page1));
|
||||
|
||||
PageInfo<HelpWord> pageInfo = new PageInfo<>(page1);
|
||||
return Result.success().put("data", PageUtils.page(pageInfo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class HelpClassify implements Serializable {
|
|||
/**
|
||||
* 帮助中心分类
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
private Long helpClassifyId;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue