Compare commits

..

1 Commits

Author SHA1 Message Date
zhaolongfei
a15537ef20 删除考试根据名称条件筛选 2024-08-27 16:59:40 +08:00
39 changed files with 459 additions and 1906 deletions

View File

@@ -20,7 +20,7 @@ import com.xboe.common.utils.StringUtil;
public class ElasticsearchConfig { public class ElasticsearchConfig {
@Value("${xboe.elasticsearch.server.ip}") @Value("${xboe.elasticsearch.server.ip}")
private String esIp="10.251.88.214"; private String esIp="127.0.0.1";
@Value("${xboe.elasticsearch.server.port}") @Value("${xboe.elasticsearch.server.port}")
private int esPort=9200; private int esPort=9200;

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@@ -16,38 +16,38 @@
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<spring-cloud.version>2021.0.5</spring-cloud.version> <spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version> <spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
<nacos-client.version>2.2.0</nacos-client.version> <nacos-client.version>2.2.0</nacos-client.version>
</properties> </properties>
<dependencies> <dependencies>
<!-- 引入Cloud --> <!-- 引入Cloud -->
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${spring-cloud-alibaba.version}</version> <version>${spring-cloud-alibaba.version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>com.alibaba.nacos</groupId> <groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId> <artifactId>nacos-client</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.alibaba.nacos</groupId> <groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId> <artifactId>nacos-client</artifactId>
<version>${nacos-client.version}</version> <version>${nacos-client.version}</version>
</dependency> </dependency>
<!-- end --> <!-- end -->
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId> <artifactId>poi-ooxml</artifactId>
<version>4.0.1</version> <version>4.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>5.8.16</version> <version>5.8.16</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.xboe</groupId> <groupId>com.xboe</groupId>
<artifactId>xboe-api</artifactId> <artifactId>xboe-api</artifactId>
@@ -58,7 +58,7 @@
<artifactId>xboe-module-scorm</artifactId> <artifactId>xboe-module-scorm</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.xboe</groupId> <groupId>com.xboe</groupId>
<artifactId>xboe-core</artifactId> <artifactId>xboe-core</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
@@ -84,6 +84,7 @@
<artifactId>xboe-module-es</artifactId> <artifactId>xboe-module-es</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>it.sauronsoftware</groupId> <groupId>it.sauronsoftware</groupId>
<artifactId>jave</artifactId> <artifactId>jave</artifactId>
@@ -92,9 +93,9 @@
<systemPath>${project.basedir}/src/main/resources/libs/jave-1.0.2.jar</systemPath> <systemPath>${project.basedir}/src/main/resources/libs/jave-1.0.2.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.auth0</groupId> <groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId> <artifactId>java-jwt</artifactId>
<version>3.18.3</version> <version>3.18.3</version>
</dependency> </dependency>
<!-- <!--
<dependency> <dependency>
@@ -109,8 +110,8 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
</dependency> </dependency>
<dependency> <dependency>
@@ -129,10 +130,10 @@
<groupId>org.springframework.session</groupId> <groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId> <artifactId>spring-session-data-redis</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
@@ -184,13 +185,13 @@
</dependency> </dependency>
<!-- aspose --> <!-- aspose -->
<dependency> <dependency>
<groupId>com.aspose</groupId> <groupId>com.aspose</groupId>
<artifactId>slides</artifactId> <artifactId>slides</artifactId>
<version>15.9.0</version> <version>15.9.0</version>
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/aspose/aspose.slides-15.9.0.jar</systemPath> <systemPath>${project.basedir}/src/main/resources/aspose/aspose.slides-15.9.0.jar</systemPath>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.aspose</groupId> <groupId>com.aspose</groupId>
<artifactId>words</artifactId> <artifactId>words</artifactId>
@@ -213,20 +214,20 @@
<version>3.0.3</version> <version>3.0.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.elasticsearch.client</groupId> <groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId> <artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.9.0</version> <version>7.9.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.elasticsearch</groupId> <groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId> <artifactId>elasticsearch</artifactId>
<version>7.9.0</version> <version>7.9.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.elasticsearch.client</groupId> <groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId> <artifactId>elasticsearch-rest-client</artifactId>
<version>7.9.0</version> <version>7.9.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.retry</groupId> <groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId> <artifactId>spring-retry</artifactId>
@@ -235,32 +236,32 @@
</dependencies> </dependencies>
<build> <build>
<resources> <resources>
<resource> <resource>
<filtering>true</filtering> <filtering>true</filtering>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<includes> <includes>
<include>application-${profileActive}.properties</include> <include>application-${profileActive}.properties</include>
<include>application.properties</include> <include>application.properties</include>
</includes> </includes>
</resource> </resource>
<resource> <resource>
<filtering>false</filtering> <filtering>false</filtering>
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<excludes> <excludes>
<exclude>*.properties</exclude> <exclude>*.properties</exclude>
</excludes> </excludes>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<!-- <version>3.8.0</version> --> <!-- <version>3.8.0</version> -->
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
@@ -271,8 +272,8 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</exclude> </exclude>
</excludes> </excludes>
<includeSystemScope>true</includeSystemScope> <includeSystemScope>true</includeSystemScope>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
@@ -295,12 +296,12 @@
<profileActive>test</profileActive> <profileActive>test</profileActive>
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>test135</id> <id>test135</id>
<properties> <properties>
<profileActive>test135</profileActive> <profileActive>test135</profileActive>
</properties> </properties>
</profile> </profile>
<profile> <profile>
<id>dev</id> <id>dev</id>
<properties> <properties>

View File

@@ -12,14 +12,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.system.ApplicationPid; import org.springframework.boot.system.ApplicationPid;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
@Configuration @Configuration
@SpringBootApplication @SpringBootApplication
@EnableCaching @EnableCaching
@EnableAsync @EnableAsync
@EnableRetry @EnableRetry
@EnableScheduling
public class BoeServerAllApplication { public class BoeServerAllApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@@ -16,9 +16,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@@ -234,38 +231,5 @@ public class ThirdApi {
} }
/**
* 获取案例浏览记录
*/
public UserDynamicResult getAllUserdynamicListOfCaseRead(UserdynamicParam userdynamicParam, String token) {
String s = buildFormData(userdynamicParam);
String resp = Optional.ofNullable(HttpRequest
.post(userdynamicListUrl)
.header("Content-Type", "application/x-www-form-urlencoded")
.body(s)
.header("XBOE-Access-Token", token)
.execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
DynamicBean dynamicBean = JSONUtil.toBean(resp, DynamicBean.class);
UserDynamicResult userdynamicResult = dynamicBean.getResult();
return userdynamicResult;
}
private String buildFormData(UserdynamicParam param) {
StringBuilder builder = new StringBuilder();
try {
builder.append("pageIndex=").append(URLEncoder.encode(param.getPageIndex().toString(), "UTF-8"));
builder.append("&pageSize=").append(URLEncoder.encode(param.getPageSize().toString(), "UTF-8"));
builder.append("&contentType=").append(URLEncoder.encode(param.getContentType().toString(), "UTF-8"));
builder.append("&aid=").append(URLEncoder.encode(param.getAid().toString(), "UTF-8"));
builder.append("&eventKey=").append(URLEncoder.encode("ReadCase", "UTF-8"));
if (param.getHidden() != null) {
builder.append("&hidden=").append(URLEncoder.encode(param.getHidden(), "UTF-8"));
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return builder.toString();
}
} }

View File

@@ -133,26 +133,4 @@ public interface CacheName {
* 字典缓存key * 字典缓存key
* */ * */
String KEY_DICT="dict"; String KEY_DICT="dict";
String STUDY_KEY = "StudyKey:";
/**
* 季度观看量排行key
* */
String CASE_RANK_VIEWS_QUARTER="case:rank:views:quarter";
/**
* 总观看排行key
* */
String CASE_RANK_VIEWS_ALL="case:rank:views:all";
/**
* 季度点赞排行key
* */
String CASE_RANK_PRAISE_QUARTER ="case:rank:praise:quarter";
/**
* 总点赞排行key
* */
String CASE_RANK_PRAISE_ALL="case:rank:praise:all";
} }

View File

@@ -1,26 +0,0 @@
package com.xboe.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import static com.xboe.constants.CacheName.*;
/**
* 案例排行榜类型
*/
@AllArgsConstructor
@Getter
public enum CasesRankEnum {
QUARTER_VIEWS(1,"季度观看量排行",CASE_RANK_VIEWS_QUARTER),
ALL_VIEWS(2,"总观看排行",CASE_RANK_VIEWS_ALL),
QUARTER_PRAISES(3,"季度点赞排行",CASE_RANK_PRAISE_QUARTER),
ALL_PRAISES(4,"总点赞排行",CASE_RANK_PRAISE_ALL),
;
private Integer type;
private String name;
private String cacheKey;
}

View File

@@ -1,29 +0,0 @@
package com.xboe.module.boecase.api;
import com.xboe.module.boecase.service.ICasesService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class CaseScheduledTasks {
@Resource
private ICasesService casesService;
@Scheduled(cron = "0 0 1 1 * ?") // 每月的第一天的1:00执行
public void refreshViewsRankOfMajor() {
casesService.refreshViewsRankOfMajor();
}
/**
* 季初执行cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月
*/
@Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
public void refreshLastQuarterStatistics() {
casesService.refreshLastQuarterStatistics();
}
}

View File

@@ -11,14 +11,18 @@ import com.xboe.module.boecase.dao.CasesMajorTypeDao;
import com.xboe.module.boecase.dto.*; import com.xboe.module.boecase.dto.*;
import com.xboe.module.boecase.entity.CasesMajorType; import com.xboe.module.boecase.entity.CasesMajorType;
import com.xboe.module.boecase.service.ICasesRecommendPushRecordService; import com.xboe.module.boecase.service.ICasesRecommendPushRecordService;
import com.xboe.module.boecase.vo.*; import com.xboe.module.boecase.vo.CaseExportVo;
import com.xboe.module.dict.entity.DictItem; import com.xboe.module.dict.entity.DictItem;
import com.xboe.module.excel.ExportsExcelSenderUtil; import com.xboe.module.excel.ExportsExcelSenderUtil;
import com.xboe.system.user.dao.UserDao; import com.xboe.system.user.dao.UserDao;
import com.xboe.system.user.entity.User; import com.xboe.system.user.entity.User;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
@@ -35,7 +39,6 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -124,12 +127,25 @@ public class CasesApi extends ApiBaseController {
@PostMapping("/queryListV2") @PostMapping("/queryListV2")
public JsonResponse<PageList<Cases>> queryCaseBreV2(@Validated @RequestBody CasePageVo req) { public JsonResponse<PageList<Cases>> queryCaseBreV2(@Validated @RequestBody CasePageVo req) {
String type = req.getType(); String type = req.getType();
req.setUserId(getCurrent().getAccountId()); PageList<Cases> subViews1;
PageList<Cases> subViews2;
PageList<Cases> views = null; PageList<Cases> views = null;
if (type.equals("recommend")) { req.setUserId(getCurrent().getAccountId());
views = casesService.queryRecommendPageCasesV2(req); if (StringUtils.isNotEmpty(type)) {
if ("recommend".equals(type)) {
views = casesService.queryRecommendPageCasesV2(req);
} else {
views = casesService.queryPageCasesV2(req);
}
} else { } else {
views = casesService.queryPageCasesV2(req); PageDto pageDto = new PageDto();
pageDto.setPageIndex(req.getPageIndex());
pageDto.setPageSize(req.getPageSize());
req.setPageSize(1000000);
req.setPageIndex(1);
subViews1 = casesService.queryRecommendPageCasesV2(req);
subViews2 = casesService.queryPageCasesV2(req);
views = merge(subViews1, subViews2, pageDto);
} }
if (views != null) { if (views != null) {
@@ -159,6 +175,24 @@ public class CasesApi extends ApiBaseController {
return success(views); return success(views);
} }
public static PageList<Cases> merge(PageList<Cases> pageList1, PageList<Cases> pageList2, PageDto pageDto) {
List<Cases> mergedCaseList = new ArrayList<>();
mergedCaseList.addAll(pageList1.getList());
mergedCaseList.addAll(pageList2.getList());
List<Cases> pageCaseList = mergedCaseList.stream()
.skip((long) (pageDto.getPageIndex() - 1) * pageDto.getPageSize())
.limit(pageDto.getPageSize())
.collect(Collectors.toList());
int totalCount = pageList1.getCount() + pageList2.getCount();
int pageSize = pageDto.getPageSize();
PageList<Cases> mergePageList = new PageList<>();
mergePageList.setList(pageCaseList);
mergePageList.setCount(totalCount);
mergePageList.setPageSize(pageSize);
return mergePageList;
}
@PostMapping("/caseYears") @PostMapping("/caseYears")
public JsonResponse<List<String>> caseYears() { public JsonResponse<List<String>> caseYears() {
List<String> result = casesService.getCaseYears(); List<String> result = casesService.getCaseYears();
@@ -612,8 +646,7 @@ public class CasesApi extends ApiBaseController {
if (ids.isEmpty()) { if (ids.isEmpty()) {
return badRequest("参数异常"); return badRequest("参数异常");
} }
String accountId = getCurrent().getAccountId(); List<Cases> cases = casesService.ids(ids);
List<Cases> cases = casesService.ids(ids,accountId);
return success(cases); return success(cases);
} }
@@ -621,7 +654,7 @@ public class CasesApi extends ApiBaseController {
* 设置/取消优秀案例 * 设置/取消优秀案例
*/ */
@PostMapping("/excellent") @PostMapping("/excellent")
public JsonResponse<Boolean> excellent(String id, Boolean excellent,String excellentReason) { public JsonResponse<Boolean> excellent(String id, Boolean excellent) {
if (StringUtil.isBlank(id)) { if (StringUtil.isBlank(id)) {
return badRequest("参数异常"); return badRequest("参数异常");
} }
@@ -629,145 +662,12 @@ public class CasesApi extends ApiBaseController {
excellent = false;//默认设置取消 excellent = false;//默认设置取消
} }
try { try {
casesService.excellent(id, excellent,excellentReason); casesService.excellent(id, excellent);
return success(true); return success(true);
} catch (Exception e) { } catch (Exception e) {
return error("设置或者取消失败", e.getMessage()); return error("设置或者取消失败", e.getMessage());
} }
} }
/**
* 不同专业分类下排行榜刷新
* 注意定时统计任务是在本月月初执行的而上榜时间是在上个月最后一天23:59:59
*/
@PostMapping("/refreshViewsRankOfMajor")
public JsonResponse<Boolean> refreshViewsRankOfMajor() {
casesService.refreshViewsRankOfMajor();
return success(true);
}
@PostMapping("/refreshLastQuarterStatistics")
public JsonResponse<Boolean> refreshLastQuarterStatistics() {
casesService.refreshLastQuarterStatistics();
return success(true);
}
/**
* 热度榜(当前季度、总榜) 按观看量排行
* @param pageSize
* @param rankType 1当前季度2总榜
* @return
*/
@SuppressWarnings("unchecked")
@GetMapping("/queryPopularity")
public JsonResponse<List<CaseRankingVo>> queryPopularity(@RequestParam(required = false) Integer pageSize,@RequestParam Integer rankType) {
List<CaseRankingVo> caseRankingVoList =casesService.queryRank(pageSize,rankType);
return success(caseRankingVoList);
}
/**
* 好评榜 (当前季度、总榜) 按点赞量排行
* @param pageSize
* @param rankType
* @return
*/
@SuppressWarnings("unchecked")
@GetMapping("/queryHighOpinion")
public JsonResponse<List<CaseRankingVo>> queryHighOpinion(@RequestParam(required = false) Integer pageSize,@RequestParam Integer rankType) {
List<CaseRankingVo> caseRankingVoList =casesService.queryRank(pageSize,rankType);
return success(caseRankingVoList);
}
/**
* 不同专业月热度榜 按观看量排行
*/
@SuppressWarnings("unchecked")
@GetMapping("/queryPopularityOfMajor")
public JsonResponse<List<Cases>> queryPopularityOfMajor(@RequestParam(required = false) Integer pageSize,
@RequestParam String majorId,
@RequestParam LocalDateTime rankMonth) {
String accountId = getCurrent().getAccountId();
List<Cases> caseRankingVoList =casesService.queryPopularityOfMajor(pageSize,majorId,rankMonth,accountId);
return success(caseRankingVoList);
}
/**
* 所有上榜的的(专业ID-时间), 用于下拉框.优化可将majorName一并查询返回为List<List<Entity>> todo by anyone
*/
@GetMapping("/queryAllTimePopularityOfMajor")
public JsonResponse<Map<String, List<String>>> queryAllTimePopularityOfMajor() {
Map<String, List<String>> time = casesService.queryAllTimePopularityOfMajor();
return success(time);
}
/**
* 查询推荐案例榜单
* @return
*/
@SuppressWarnings("unchecked")
@GetMapping("/queryRecommendRank")
public JsonResponse<List<CasesQueryRecommendRankVo>> queryRecommendRank(@RequestParam(required = false,defaultValue = "3") Integer pageSize) {
List<CasesQueryRecommendRankVo> list = casesService.queryRecommendRank(pageSize);
return success(list);
}
/**
* 案例上榜
*/
@SuppressWarnings("unchecked")
@PostMapping("/riseIntoRank")
public JsonResponse<Boolean> riseIntoRank(@RequestParam Long caseId) {
casesService.riseIntoRank(caseId,getCurrent());
return success(true);
}
/**
* 案例下榜
*/
@SuppressWarnings("unchecked")
@PostMapping("/cancelRiseIntoRank")
public JsonResponse<Boolean> cancelRiseIntoRank(@RequestParam Long caseId) {
casesService.cancelRiseIntoRank(caseId);
return success(true);
}
/**
* 推荐案例调整排名
*/
@SuppressWarnings("unchecked")
@PostMapping("/adjustRank")
public JsonResponse<Boolean> adjustRank(@RequestParam List<Long> caseIds) {
casesService.adjustRank(caseIds);
return success(true);
}
/**
* 查询收藏
* @param pageIndex
* @param pageSize
* @return
*/
@SuppressWarnings("unchecked")
@GetMapping("/queryFavoriteCaseOfIndex")
public JsonResponse<PageList<FavoriteCaseOfIndexVo>> queryFavoriteCaseOfIndex(@RequestParam(required = false,defaultValue = "1") Integer pageIndex,
@RequestParam(required = false,defaultValue = "5") Integer pageSize) {
String accountId = this.getCurrent().getAccountId();
PageList<FavoriteCaseOfIndexVo> casesList = casesService.queryFavoriteCaseOfIndex(pageIndex,pageSize,accountId);
return success(casesList);
}
@GetMapping("/browsingHistory")
public JsonResponse<PageList<CasesBrowsingHistoryVo>> browsingHistory(@RequestParam(required = false,defaultValue = "1") Integer pageIndex,
@RequestParam(required = false,defaultValue = "5") Integer pageSize,
HttpServletRequest request) {
String accountId = this.getCurrent().getAccountId();
PageList<CasesBrowsingHistoryVo> casesList = casesService.browsingHistory(pageIndex,pageSize,accountId,request);
return success(casesList);
}
} }

View File

@@ -1,24 +1,18 @@
package com.xboe.module.boecase.dao; package com.xboe.module.boecase.dao;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.xboe.common.OrderCondition; import com.xboe.common.OrderCondition;
import com.xboe.common.PageList; import com.xboe.common.PageList;
import com.xboe.core.orm.BaseDao; import com.xboe.core.orm.BaseDao;
import com.xboe.core.orm.FieldFilters;
import com.xboe.core.orm.IFieldFilter; import com.xboe.core.orm.IFieldFilter;
import com.xboe.module.boecase.entity.Cases; import com.xboe.module.boecase.entity.Cases;
import com.xboe.module.boecase.vo.CaseRankingVo; import com.xboe.core.orm.FieldFilters;
import lombok.extern.slf4j.Slf4j; import com.xboe.module.boecase.dto.CaseVo;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import static com.xboe.enums.CasesRankEnum.*;
@Repository @Repository
@Slf4j
public class CasesDao extends BaseDao<Cases> { public class CasesDao extends BaseDao<Cases> {
/** /**
@@ -41,106 +35,4 @@ public class CasesDao extends BaseDao<Cases> {
public Cases getByTitle(String title) { public Cases getByTitle(String title) {
return this.getGenericDao().findOne(Cases.class, FieldFilters.eq("title", title)); return this.getGenericDao().findOne(Cases.class, FieldFilters.eq("title", title));
} }
public HashMap<String, Object> findExcellentCount(List<String> authorIdList) {
String sql =
"SELECT author_id,COUNT(1) AS excellentCount\n" +
"FROM boe_cases \n" +
"WHERE excellent = 1 AND author_id IN (?1) AND deleted=0 \n" +
"GROUP BY author_id";
List<Object[]> list = this.sqlFindList(sql, authorIdList);
HashMap<String, Object> map = new HashMap<>();
list.forEach(objects -> {
String authorId = objects[0].toString();
int excellentCount = Integer.parseInt(objects[1].toString());
map.put(authorId, excellentCount);
});
return map;
}
private List<CaseRankingVo> handleCaseRank(List<Object[]> listFields) {
List<CaseRankingVo> list = new ArrayList<>();
for (Object[] o : listFields) {
CaseRankingVo dto = new CaseRankingVo();
dto.setCaseId(String.valueOf(o[0]));
dto.setCaseTitle((String) o[1]);
list.add(dto);
}
return list;
}
public List<CaseRankingVo> findPopularityOfAll(Integer pageSize) {
String sql =
"SELECT id,title\n" +
"FROM boe_cases \n" +
"WHERE deleted=0\n" +
"ORDER BY views DESC,sys_create_time DESC\n" +
"LIMIT ?1";
List<Object[]> listFields = this.sqlFindList(sql, pageSize);
List<CaseRankingVo> caseRankingVoList = handleCaseRank(listFields);
return caseRankingVoList;
}
public List<CaseRankingVo> findPopularityOfQuarter(Integer pageSize) {
String sql =
"SELECT id,title\n" +
"FROM boe_cases \n" +
"WHERE deleted=0\n" +
"ORDER BY (views-last_quarter_views) DESC,sys_create_time DESC \n" +
"LIMIT ?1";
List<Object[]> listFields = this.sqlFindList(sql, pageSize);
List<CaseRankingVo> caseRankingVoList = handleCaseRank(listFields);
return caseRankingVoList;
}
public List<CaseRankingVo> findHighOpinionOfAll(Integer pageSize) {
String sql =
"SELECT id,title\n" +
"FROM boe_cases \n" +
"WHERE deleted=0\n" +
"ORDER BY praises DESC,sys_create_time DESC \n" +
"LIMIT ?1";
List<Object[]> listFields = this.sqlFindList(sql, pageSize);
List<CaseRankingVo> caseRankingVoList = handleCaseRank(listFields);
return caseRankingVoList;
}
public List<CaseRankingVo> findHighOpinionOfQuarter(Integer pageSize) {
String sql =
"SELECT id,title\n" +
"FROM boe_cases \n" +
"WHERE deleted=0\n" +
"ORDER BY (praises-last_quarter_praises) DESC,sys_create_time DESC \n" +
"LIMIT ?1";
List<Object[]> listFields = this.sqlFindList(sql, pageSize);
List<CaseRankingVo> caseRankingVoList = handleCaseRank(listFields);
return caseRankingVoList;
}
public List<CaseRankingVo> findRank(Integer pageSize, Integer rankType) {
List<CaseRankingVo> popularityOfQuarter = Collections.emptyList();
if (rankType == QUARTER_VIEWS.getType()){
popularityOfQuarter = findPopularityOfQuarter(pageSize);
}
if (rankType == ALL_VIEWS.getType()){
popularityOfQuarter = findPopularityOfAll(pageSize);
}
if (rankType == QUARTER_PRAISES.getType()){
popularityOfQuarter = findHighOpinionOfQuarter(pageSize);
}
if (rankType == ALL_PRAISES.getType()){
popularityOfQuarter = findHighOpinionOfAll(pageSize);
}
return popularityOfQuarter;
}
} }

View File

@@ -1,87 +0,0 @@
package com.xboe.module.boecase.dao;
import com.xboe.core.orm.BaseDao;
import com.xboe.module.boecase.entity.CasesRank;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
@Repository
@Slf4j
public class CasesRankDao extends BaseDao<CasesRank> {
public List<CasesRank> findViewsRankRecordByCaseId(String caseId) {
String sql =
"SELECT bdmt.name,bcvr.rise_rank_time,bcvr.rank,bcvr.major_id \n" +
"FROM\n" +
" boe_cases_rank bcvr\n" +
"JOIN boe_dict_major_type bdmt \n" +
" ON bdmt.code = bcvr.major_id \n" +
"WHERE bcvr.case_id = ?1 AND bcvr.deleted=0 AND bdmt.deleted=0\n" +
"ORDER BY bcvr.sys_update_time DESC \n" +
"LIMIT 2;";
List<Object[]> list = this.sqlFindList(sql, caseId);
List<CasesRank> resultList = new ArrayList<>();
for (Object[] o : list) {
CasesRank casesRank = new CasesRank();
casesRank.setMajorName(o[0].toString());
casesRank.setRiseRankTime(((Timestamp) o[1]).toLocalDateTime());
casesRank.setRank(Integer.valueOf(o[2].toString()));
casesRank.setMajorId(o[3].toString());
resultList.add(casesRank);
}
return resultList;
}
public HashMap<String, Object> findViewTopCount(List<String> authorIdList) {
String sql=
"SELECT author_id,COUNT(1) as viewTopCount\n" +
"FROM boe_cases bc JOIN boe_cases_rank bcvr ON bcvr.case_id = bc.id\n" +
"WHERE bc.author_id IN (?1) \n" +
" AND bcvr.deleted = 0 \n" +
" AND bc.deleted = 0\n" +
"GROUP BY bc.author_id;";
List<Object[]> list = this.sqlFindList(sql, authorIdList);
HashMap<String, Object> map = new HashMap<>();
list.forEach(objects -> {
String authorId = objects[0].toString();
Integer viewTopCount = Integer.parseInt(objects[1].toString());
map.put(authorId, viewTopCount);
});
return map;
}
public List<HashMap<String, Object>> findPopularityOfMajor(Integer pageSize, LocalDateTime startTime, LocalDateTime endTime, String majorId) {
String sql =
"SELECT bcr.case_id,bcr.rank\n" +
"FROM boe_cases_rank bcr\n" +
"JOIN boe_cases bc on bcr.case_id = bc.id\n" +
"WHERE bcr.deleted=0 AND bc.deleted=0 AND bcr.rise_rank_time BETWEEN ?1 and ?2 AND major_id=?3\n" +
"ORDER BY rank\n" +
"LIMIT ?4";
List<Object[]> listFields = this.sqlFindList(sql, startTime, endTime,majorId,pageSize);
List<HashMap<String, Object>> collect = listFields.stream().map(item -> {
HashMap<String, Object> map = new HashMap<>();
map.put("caseId", item[0].toString());
map.put("rank", item[1].toString());
return map;
}).collect(Collectors.toList());
return collect;
}
}

View File

@@ -21,79 +21,50 @@ import java.util.List;
*/ */
@Repository @Repository
public interface CasesRecordDao extends JpaRepository<Cases, String>, JpaSpecificationExecutor<Cases> { public interface CasesRecordDao extends JpaRepository<Cases, String>, JpaSpecificationExecutor<Cases> {
@Query(nativeQuery = true, value = @Query(nativeQuery = true, value = "select c.* from ( select b.*" +
" SELECT c.* FROM ( " + " from boe_cases_recommend_push_record a left JOIN boe_cases b on a.case_id = b.id" +
" SELECT b.*,a.sys_create_time as recommendPushTime" + " where b.deleted=0 and a.push_status = 3 and a.deleted=0 and a.push_user_id= :#{#condition.userId}" +
" FROM boe_cases_recommend_push_record a " + " and if(IFNULL(:#{#condition.keyWord},'')!='',b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
" LEFT JOIN boe_cases b ON a.case_id = b.id " + " or b.author_name like CONCAT('%',:#{#condition.keyWord},'%')" +
" WHERE b.deleted = 0 " + " or b.keyword1 like CONCAT('%',:#{#condition.keyWord},'%')" +
" AND a.push_status = 3 " + " or b.keyword2 like CONCAT('%',:#{#condition.keyWord},'%')" +
" AND a.deleted = 0 " + " or b.keyword3 like CONCAT('%',:#{#condition.keyWord},'%')" +
" AND a.push_user_id = :#{#condition.userId} " + " or b.keyword4 like CONCAT('%',:#{#condition.keyWord},'%')" +
" AND IF(IFNULL(:#{#condition.keyWord}, '') != '', " + " or b.keyword5 like CONCAT('%',:#{#condition.keyWord},'%'),1=1)" +
" b.title LIKE CONCAT('%', :#{#condition.keyWord}, '%') " + " and if(:#{#condition.yearsEmpty},1=1, YEAR(b.sys_create_time) in (:#{#condition.years}))" +
" OR b.author_name LIKE CONCAT('%', :#{#condition.keyWord}, '%') " + " and if(:#{#condition.caseIdsEmpty}, 1=1, b.id in (:#{#condition.caseIds}))" +
" OR b.keyword1 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " + " and ("+
" OR b.keyword2 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " + " if(:#{#condition.allOrgEmpty}, 1=1, 1=2)" +
" OR b.keyword3 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " + " or if(:#{#condition.org1Empty}, 1=2, b.org_domain_parent in (:#{#condition.org1}))" +
" OR b.keyword4 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " + " or if(:#{#condition.org2Empty}, 1=2, b.org_domain_parent2 in (:#{#condition.org2}))" +
" OR b.keyword5 LIKE CONCAT('%', :#{#condition.keyWord}, '%'), " + " or if(:#{#condition.org3Empty}, 1=2, b.org_domain_parent3 in (:#{#condition.org3}))" +
" 1 = 1) " + ")" +
" AND IF(:#{#condition.yearsEmpty}, 1 = 1, YEAR(b.sys_create_time) IN (:#{#condition.years})) " + " and if(:#{#condition.isSysType1Empty} , 1=1, b.sys_type1 = :#{#condition.sysType1} )"+
" AND IF(:#{#condition.caseIdsEmpty}, 1 = 1, b.id IN (:#{#condition.caseIds})) " + " and if(:#{#condition.isSysType2Empty} , 1=1, b.sys_type2 = :#{#condition.sysType2} )"+
" AND ( " + " and if(:#{#condition.isSysType3Empty} , 1=1, b.sys_type3 = :#{#condition.sysType3} )"+
" IF(:#{#condition.allOrgEmpty}, 1 = 1, 1 = 2) " + " order by a.sys_create_time DESC, a.read_flag ASC) as c group by c.id",
" OR IF(:#{#condition.org1Empty}, 1 = 2, b.org_domain_parent IN (:#{#condition.org1})) " + countQuery = "select count(*) FROM (select c.* from ( select b.*" +
" OR IF(:#{#condition.org2Empty}, 1 = 2, b.org_domain_parent2 IN (:#{#condition.org2})) " + " from boe_cases_recommend_push_record a left JOIN boe_cases b on a.case_id = b.id " +
" OR IF(:#{#condition.org3Empty}, 1 = 2, b.org_domain_parent3 IN (:#{#condition.org3})) " + " where b.deleted=0 and a.push_status = 3 and a.deleted=0 and a.push_user_id= :#{#condition.userId}" +
" ) " + " and if(IFNULL(:#{#condition.keyWord},'')!='',b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
" AND IF(:#{#condition.isSysType1Empty}, 1 = 1, b.sys_type1 = :#{#condition.sysType1}) " + " or b.author_name like CONCAT('%',:#{#condition.keyWord},'%')" +
" AND IF(:#{#condition.isSysType2Empty}, 1 = 1, b.sys_type2 = :#{#condition.sysType2}) " + " or b.keyword1 like CONCAT('%',:#{#condition.keyWord},'%')" +
" AND IF(:#{#condition.isSysType3Empty}, 1 = 1, b.sys_type3 = :#{#condition.sysType3}) " + " or b.keyword2 like CONCAT('%',:#{#condition.keyWord},'%')" +
" ) AS c GROUP BY c.id " + " or b.keyword3 like CONCAT('%',:#{#condition.keyWord},'%')" +
" ORDER BY " + " or b.keyword4 like CONCAT('%',:#{#condition.keyWord},'%')" +
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=true,c.views, null) asc," + " or b.keyword5 like CONCAT('%',:#{#condition.keyWord},'%'),1=1)" +
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=false,c.views, null) desc," + " and if(:#{#condition.yearsEmpty},1=1, YEAR(b.sys_create_time) in (:#{#condition.years}))" +
" IF(:#{#condition.orderField}='sysCreateTime' and :#{#condition.orderAsc}=true ,c.sys_create_time,null) asc," + " and if(:#{#condition.caseIdsEmpty}, 1=1, b.id in (:#{#condition.caseIds}))" +
" IF(:#{#condition.orderField}='sysCreateTime' and :#{#condition.orderAsc}=false , c.sys_create_time,null) desc," + " and ("+
" IF(:#{#condition.orderField}='recommendPushTime', c.recommendPushTime,null) desc", " if(:#{#condition.allOrgEmpty}, 1=1, 1=2)" +
countQuery = " or if(:#{#condition.org1Empty}, 1=1, b.org_domain_parent in (:#{#condition.org1}))" +
" SELECT count(*) FROM ( " + " or if(:#{#condition.org2Empty}, 1=1, b.org_domain_parent2 in (:#{#condition.org2}))" +
" SELECT b.*,a.sys_create_time as recommendPushTime" + " or if(:#{#condition.org3Empty}, 1=1, b.org_domain_parent3 in (:#{#condition.org3}))" +
" FROM boe_cases_recommend_push_record a " + ")" +
" LEFT JOIN boe_cases b ON a.case_id = b.id " + " and if(:#{#condition.isSysType1Empty} , 1=1, b.sys_type1 = :#{#condition.sysType1} )"+
" WHERE b.deleted = 0 " + " and if(:#{#condition.isSysType2Empty} , 1=1, b.sys_type2 = :#{#condition.sysType2} )"+
" AND a.push_status = 3 " + " and if(:#{#condition.isSysType3Empty} , 1=1, b.sys_type3 = :#{#condition.sysType3} )"+
" AND a.deleted = 0 " + " order by a.sys_create_time DESC, a.read_flag ASC ) as c group by c.id) as d")
" AND a.push_user_id = :#{#condition.userId} " +
" AND IF(IFNULL(:#{#condition.keyWord}, '') != '', " +
" b.title LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
" OR b.author_name LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
" OR b.keyword1 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
" OR b.keyword2 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
" OR b.keyword3 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
" OR b.keyword4 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
" OR b.keyword5 LIKE CONCAT('%', :#{#condition.keyWord}, '%'), " +
" 1 = 1) " +
" AND IF(:#{#condition.yearsEmpty}, 1 = 1, YEAR(b.sys_create_time) IN (:#{#condition.years})) " +
" AND IF(:#{#condition.caseIdsEmpty}, 1 = 1, b.id IN (:#{#condition.caseIds})) " +
" AND ( " +
" IF(:#{#condition.allOrgEmpty}, 1 = 1, 1 = 2) " +
" OR IF(:#{#condition.org1Empty}, 1 = 2, b.org_domain_parent IN (:#{#condition.org1})) " +
" OR IF(:#{#condition.org2Empty}, 1 = 2, b.org_domain_parent2 IN (:#{#condition.org2})) " +
" OR IF(:#{#condition.org3Empty}, 1 = 2, b.org_domain_parent3 IN (:#{#condition.org3})) " +
" ) " +
" AND IF(:#{#condition.isSysType1Empty}, 1 = 1, b.sys_type1 = :#{#condition.sysType1}) " +
" AND IF(:#{#condition.isSysType2Empty}, 1 = 1, b.sys_type2 = :#{#condition.sysType2}) " +
" AND IF(:#{#condition.isSysType3Empty}, 1 = 1, b.sys_type3 = :#{#condition.sysType3}) " +
" ) AS c GROUP BY c.id " +
" ORDER BY " +
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=true,c.views, null) asc," +
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=false,c.views, null) desc," +
" IF(:#{#condition.orderField}='sysCreateTime' and :#{#condition.orderAsc}=true ,c.sys_create_time,null) asc," +
" IF(:#{#condition.orderField}='sysCreateTime' and :#{#condition.orderAsc}=false , c.sys_create_time,null) desc," +
" IF(:#{#condition.orderField}='recommendPushTime', c.recommendPushTime,null) desc"
)
Page<Cases> queryList(Pageable pageable, @Param("condition") CasePageVo casePage); Page<Cases> queryList(Pageable pageable, @Param("condition") CasePageVo casePage);

View File

@@ -3,7 +3,6 @@ package com.xboe.module.boecase.entity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.xboe.core.SysConstant; import com.xboe.core.SysConstant;
import com.xboe.core.orm.BaseEntity; import com.xboe.core.orm.BaseEntity;
import com.xboe.module.boecase.vo.CaseViewRankingItemVo;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@@ -249,7 +248,16 @@ public class Cases extends BaseEntity {
@Column(name = "case_value") @Column(name = "case_value")
private String caseValue; private String caseValue;
// 种类字段1
// 暂不上线
// @Column(name = "sys_type1")
// private String sysType1;
//种类字段2
// @Column(name = "sys_type2")
// private String sysType2;
//种类字段3
// @Column(name = "sys_type3")
// private String sysType3;
/** /**
* 最佳案例标识 * 最佳案例标识
@@ -264,48 +272,6 @@ public class Cases extends BaseEntity {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime excellentTime; private LocalDateTime excellentTime;
/**
* 最佳时间
* */
@Column(name = "excellent_reason")
private String excellentReason;
/**
* 上月浏览量
*/
@Column(name = "last_month_views")
private Integer lastMonthViews;
/**
* 上季度浏览量
*/
@Column(name = "last_quarter_views")
private Integer lastQuarterViews;
/**
* 上季度点赞量
*/
@Column(name = "last_quarter_praises")
private Integer lastQuarterPraises;
/**
* 推荐榜排序
* */
@Column(name = "recommend_rank")
private Integer recommendRank;
/**
* 推送用户名称
*/
@Column(name = "recommend_rank_push_user_name")
private String recommendRankPushUserName;
/**
* 推送时间
*/
@Column(name = "recommend_rank_push_time")
private LocalDateTime recommendRankPushTime;
/** /**
* type 种类 * type 种类
* 区分 案例/推荐案例 * 区分 案例/推荐案例
@@ -313,6 +279,11 @@ public class Cases extends BaseEntity {
@Transient @Transient
private String type; private String type;
/**
* id
*/
@Transient @Transient
private List<String> majorIds; private List<String> majorIds;
@@ -325,15 +296,6 @@ public class Cases extends BaseEntity {
@Transient @Transient
private String refId; private String refId;
@Transient
private String excellentTag;
@Transient
private List<CaseViewRankingItemVo> viewRankTags;
@Transient
private List<String> authorTags;
public String getRefId() { public String getRefId() {
return refId; return refId;
} }
@@ -418,7 +380,7 @@ public class Cases extends BaseEntity {
this.title=title; this.title=title;
} }
public Cases(String id,String title,String summary,String coverUrl,String authorId,String authorName,LocalDateTime sysCreateTime,Integer breCommend,Integer views,Integer comments,Integer praises,Integer shares,Integer favorites,Boolean deleted public Cases(String id,String title,String summary,String coverUrl,String authorId,String authorName,LocalDateTime sysCreateTime,Integer breCommend,Integer views,Integer comments,Integer praises,Integer shares,Integer favorites,Boolean deleted
,String sysCreateBy,String sysCreateAid){ ,String sysCreateBy,String sysCreateAid){
this.title=title; this.title=title;
super.setId(id); super.setId(id);
this.authorId=authorId; this.authorId=authorId;
@@ -436,6 +398,7 @@ public class Cases extends BaseEntity {
this.favorites=favorites; this.favorites=favorites;
super.setDeleted(deleted); super.setDeleted(deleted);
} }
public Cases(String title) { public Cases(String title) {
this.title = title; this.title = title;
} }
@@ -452,29 +415,4 @@ public class Cases extends BaseEntity {
this.authorName = authorName; this.authorName = authorName;
this.confidentialityLevel = confidentialityLevel; this.confidentialityLevel = confidentialityLevel;
} }
public Cases(String id,String title,String summary,String coverUrl,String authorId,String authorName,LocalDateTime sysCreateTime,Integer breCommend,Integer views,Integer comments,Integer praises,Integer shares,Integer favorites,Boolean deleted
,String sysCreateBy,String sysCreateAid,String keyword1,String keyword2,String keyword3,String keyword4,String keyword5){
this.title=title;
super.setId(id);
this.authorId=authorId;
this.authorName=authorName;
super.setSysCreateTime(sysCreateTime);
super.setSysCreateAid(sysCreateAid);
super.setSysCreateBy(sysCreateBy);
this.summary=summary;
this.coverUrl=coverUrl;
this.breCommend=breCommend;
this.views=views;
this.comments=comments;
this.praises=praises;
this.shares=shares;
this.favorites=favorites;
this.keyword1=keyword1;
this.keyword2=keyword2;
this.keyword3=keyword3;
this.keyword4=keyword4;
this.keyword5=keyword5;
super.setDeleted(deleted);
}
} }

View File

@@ -1,61 +0,0 @@
package com.xboe.module.boecase.entity;
import com.xboe.core.SysConstant;
import com.xboe.core.orm.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.time.LocalDateTime;
/**
* 案例推荐表
* @TableName boe_cases_rank
*/
@Data
@NoArgsConstructor
@Entity
@EqualsAndHashCode(callSuper = false)
@Table(name = SysConstant.TABLE_PRE+"cases_rank")
public class CasesRank extends BaseEntity {
/**
* 案例ID
*/
@Column(name = "case_id")
private Long caseId;
/**
* 专业ID
*/
@Column(name = "major_id")
private String majorId;
/**
* 排名
*/
@Column(name = "rank")
private Integer rank;
/**
* 浏览量每月增量
*/
@Column(name = "monthly_increment")
private Integer monthlyIncrement;
@Column(name = "rise_rank_time")
private LocalDateTime riseRankTime;
@Transient
private String majorName;
public CasesRank(String majorId, LocalDateTime riseRankTime) {
this.majorId = majorId;
this.riseRankTime = riseRankTime;
}
}

View File

@@ -54,15 +54,8 @@ public class CasesRecommend extends BaseEntity {
public CasesRecommend() { public CasesRecommend() {
} }
public CasesRecommend(String id, String recommendOrgName) { public CasesRecommend(String id, String recommendOrgName) {
this.setId(id); this.setId(id);
this.recommendOrgName = recommendOrgName; this.recommendOrgName = recommendOrgName;
} }
public CasesRecommend(String id, String recommendOrgName,LocalDateTime recommendTime) {
this.setId(id);
this.recommendOrgName = recommendOrgName;
this.recommendTime = recommendTime;
}
} }

View File

@@ -1,22 +1,14 @@
package com.xboe.module.boecase.service; package com.xboe.module.boecase.service;
import java.util.List;
import com.xboe.common.PageList; import com.xboe.common.PageList;
import com.xboe.core.CurrentUser; import com.xboe.core.CurrentUser;
import com.xboe.module.boecase.dto.*; import com.xboe.module.boecase.dto.*;
import com.xboe.module.boecase.entity.Cases; import com.xboe.module.boecase.entity.Cases;
import com.xboe.module.boecase.vo.CasesBrowsingHistoryVo;
import com.xboe.module.boecase.vo.CaseRankingVo;
import com.xboe.module.boecase.vo.CasesQueryRecommendRankVo;
import com.xboe.module.boecase.vo.FavoriteCaseOfIndexVo;
import com.xboe.module.dict.entity.DictItem; import com.xboe.module.dict.entity.DictItem;
import com.xboe.school.vo.CasesVo; import com.xboe.school.vo.CasesVo;
import javax.servlet.http.HttpServletRequest;
import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
public interface ICasesService{ public interface ICasesService{
/** /**
* 案例分页搜索,是否被推荐 * 案例分页搜索,是否被推荐
@@ -99,7 +91,7 @@ public interface ICasesService{
/** /**
* 用于二次查询 * 用于二次查询
* */ * */
List<Cases> ids(List<String> ids, String accountId); List<Cases> ids(List<String> ids);
/** /**
*二期 首页的推荐案例 *二期 首页的推荐案例
@@ -109,7 +101,7 @@ public interface ICasesService{
/** /**
* 设置或者取消优秀案例 * 设置或者取消优秀案例
* */ * */
void excellent(String id, Boolean excellent, String excellentReason); void excellent(String id,Boolean excellent);
PageList<Cases> queryRecommendPageCasesV2(CasePageVo req); PageList<Cases> queryRecommendPageCasesV2(CasePageVo req);
@@ -118,27 +110,5 @@ public interface ICasesService{
List<String> getCaseYears(); List<String> getCaseYears();
@Transactional
void refreshViewsRankOfMajor();
void refreshLastQuarterStatistics();
List<CasesQueryRecommendRankVo> queryRecommendRank(Integer pageSize);
void riseIntoRank(Long caseId, CurrentUser currentUser);
void cancelRiseIntoRank(Long caseId);
void adjustRank(List<Long> caseIdList);
List<CaseRankingVo> queryRank(Integer pageSize, Integer rankType);
List<Cases> queryPopularityOfMajor(Integer pageSize, String majorId, LocalDateTime month, String accountId);
PageList<FavoriteCaseOfIndexVo> queryFavoriteCaseOfIndex(Integer pageIndex, Integer pageSize, String accountId);
PageList<CasesBrowsingHistoryVo> browsingHistory(Integer pageIndex, Integer pageSize, String accountId, HttpServletRequest request);
Map<String, List<String>> queryAllTimePopularityOfMajor();
} }

View File

@@ -2,14 +2,8 @@ package com.xboe.module.boecase.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil; import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.xboe.api.ThirdApi;
import com.xboe.api.vo.UserDynamic;
import com.xboe.api.vo.UserDynamicResult;
import com.xboe.api.vo.UserdynamicParam;
import com.xboe.common.OrderCondition; import com.xboe.common.OrderCondition;
import com.xboe.common.OrderDirection; import com.xboe.common.OrderDirection;
import com.xboe.common.PageList; import com.xboe.common.PageList;
@@ -17,40 +11,29 @@ import com.xboe.common.utils.IDGenerator;
import com.xboe.common.utils.StringUtil; import com.xboe.common.utils.StringUtil;
import com.xboe.core.CurrentUser; import com.xboe.core.CurrentUser;
import com.xboe.core.orm.*; import com.xboe.core.orm.*;
import com.xboe.enums.CasesRankEnum;
import com.xboe.module.boecase.dao.*; import com.xboe.module.boecase.dao.*;
import com.xboe.module.boecase.dto.*; import com.xboe.module.boecase.dto.*;
import com.xboe.module.boecase.entity.*; import com.xboe.module.boecase.entity.Cases;
import com.xboe.module.boecase.entity.CasesMajorType;
import com.xboe.module.boecase.entity.CasesRecommend;
import com.xboe.module.boecase.entity.CasesRecommendPushRecord;
import com.xboe.module.boecase.service.ICasesService; import com.xboe.module.boecase.service.ICasesService;
import com.xboe.module.boecase.vo.*;
import com.xboe.module.dict.dao.SysDictionaryDao; import com.xboe.module.dict.dao.SysDictionaryDao;
import com.xboe.module.dict.entity.DictItem; import com.xboe.module.dict.entity.DictItem;
import com.xboe.module.interaction.entity.Favorites;
import com.xboe.orm.CustomFieldInFilter; import com.xboe.orm.CustomFieldInFilter;
import com.xboe.school.vo.CasesVo; import com.xboe.school.vo.CasesVo;
import com.xboe.standard.enums.BoedxResourceType;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.transaction.Transactional;
import java.lang.reflect.Array;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
@Slf4j @Slf4j
@Service @Service
@@ -78,15 +61,6 @@ public class CasesServiceImpl implements ICasesService {
@Autowired @Autowired
private CasesRecommendDao casesRecommendDao; private CasesRecommendDao casesRecommendDao;
@Resource
private CasesRankDao casesRankDao;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private ThirdApi thirdApi;
/** /**
* 案例分页查询,用于门户的查询 * 案例分页查询,用于门户的查询
*/ */
@@ -204,6 +178,12 @@ public class CasesServiceImpl implements ICasesService {
@Override @Override
public PageList<Cases> queryPageCasesV2(CasePageVo caseVo) { public PageList<Cases> queryPageCasesV2(CasePageVo caseVo) {
String type = caseVo.getType();
if (!StrUtil.equals(type,"excellent")) {
caseVo.setOrderField("");
caseVo.setOrderAsc(null);
}
String keyword = caseVo.getKeyWord(); String keyword = caseVo.getKeyWord();
QueryBuilder query = QueryBuilder.from(Cases.class); QueryBuilder query = QueryBuilder.from(Cases.class);
PageList<Cases> page = null; PageList<Cases> page = null;
@@ -316,16 +296,18 @@ public class CasesServiceImpl implements ICasesService {
filters.add(FieldFilters.eq("excellent", caseVo.getExcellent())); filters.add(FieldFilters.eq("excellent", caseVo.getExcellent()));
} }
OrderCondition order = null; OrderCondition order = null;
if (StringUtils.isNotBlank(caseVo.getOrderField()) && caseVo.getOrderAsc() != null && ("sysCreateTime".equals(caseVo.getOrderField()) || "views".equals(caseVo.getOrderField()))) { if (StringUtils.isNotBlank(caseVo.getOrderField())) {
if (caseVo.getOrderAsc()) { if (caseVo.getOrderAsc() == null || caseVo.getOrderAsc()) {
order = OrderCondition.asc(caseVo.getOrderField()); order = OrderCondition.asc(caseVo.getOrderField());
} else { } else {
order = OrderCondition.desc(caseVo.getOrderField()); order = OrderCondition.desc(caseVo.getOrderField());
} }
} else {
order = OrderCondition.desc("sysCreateTime");
} }
if (StrUtil.equals(type,"new")) {
order = OrderCondition.desc("sysCreateTime");
} else if (StrUtil.equals(type,"hot")) {
order = OrderCondition.desc("views");
}
if(Objects.nonNull(order)) { if(Objects.nonNull(order)) {
query.addOrder(order); query.addOrder(order);
} }
@@ -333,18 +315,53 @@ public class CasesServiceImpl implements ICasesService {
query.setPageIndex(caseVo.getPageIndex()); query.setPageIndex(caseVo.getPageIndex());
query.setPageSize(caseVo.getPageSize()); query.setPageSize(caseVo.getPageSize());
page = casesDao.findPage(query.builder()); page = casesDao.findPage(query.builder());
List<Cases> casesList = page.getList(); List<Cases> list = page.getList();
casesList.forEach(it->{ list.forEach(it->{
it.setBreCommend(0); it.setBreCommend(0);
}); });
casesList = caseListCommonHandle(casesList, caseVo.getUserId()); if (CollUtil.isNotEmpty(list) && StrUtil.isNotBlank(caseVo.getUserId())) {
page.setList(casesList); List<String> caseIds = list.stream().map(Cases::getId).collect(Collectors.toList());
QueryBuilder recommendCasesQuery = QueryBuilder.from(CasesRecommendPushRecord.class);
recommendCasesQuery.addField("new CasesRecommendPushRecord(id,recommendId,caseId)");
List<IFieldFilter> subFilters = new ArrayList<>();
subFilters.add(FieldFilters.eq("pushUserId", caseVo.getUserId()));
subFilters.add(FieldFilters.in("caseId", caseIds));
subFilters.add(FieldFilters.eq("pushStatus", 3));
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
.addOrder("sysCreateTime", OrderDirection.DESC)
.addGroupBy("caseId");
List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder());
if (CollUtil.isNotEmpty(pushRecords)) {
List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).distinct().collect(Collectors.toList());
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class);
builder.addField("new CasesRecommend(id,recommendOrgName)");
List<IFieldFilter> recommendFilters = new ArrayList<>();
recommendFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
recommendFilters.add(FieldFilters.in("id", rIds));
builder.addFilters(recommendFilters);
List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder());
if (CollUtil.isNotEmpty(recommands)) {
Map<String, String> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), v -> v.getRecommendOrgName()));
list.forEach(it -> {
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
if (Objects.nonNull(one)) {
String recommendOrgName = collect.get(one.getRecommendId());
it.setBreCommend(1);
it.setRecommendOrgName(recommendOrgName);
} else {
it.setBreCommend(0);
}
});
}
}
}
return page; return page;
} }
@Override @Override
public PageList<Cases> queryRecommendPageCasesV2(CasePageVo caseVo) { public PageList<Cases> queryRecommendPageCasesV2(CasePageVo caseVo) {
@@ -391,68 +408,37 @@ public class CasesServiceImpl implements ICasesService {
caseVo.setOrg2(level2); caseVo.setOrg2(level2);
caseVo.setOrg3(level3); caseVo.setOrg3(level3);
Set<String> validOrderFields = new HashSet<>();
validOrderFields.add("sysCreateTime");
validOrderFields.add("views");
validOrderFields.add("recommendPushTime");
if (StringUtils.isBlank(caseVo.getOrderField()) || caseVo.getOrderAsc() == null || !validOrderFields.contains(caseVo.getOrderField())) {
caseVo.setOrderField("recommendPushTime");
caseVo.setOrderAsc(false);
}
Page<Cases> cases = casesRecordDao.queryList(pageRequest,caseVo); Page<Cases> cases = casesRecordDao.queryList(pageRequest,caseVo);
PageList<Cases> pageList = new PageList<>(); PageList<Cases> pageList = new PageList<>();
pageList.setCount((int) cases.getTotalElements()); pageList.setCount((int) cases.getTotalElements());
pageList.setPageSize(cases.getSize()); pageList.setPageSize(cases.getSize());
List<Cases> content = cases.getContent(); List<Cases> content = cases.getContent();
List<String> caseIds = content.stream().map(Cases::getId).collect(Collectors.toList());
String userId = caseVo.getUserId();
if (CollUtil.isNotEmpty(caseIds)) {
QueryBuilder recommendCasesQuery = QueryBuilder.from(CasesRecommendPushRecord.class);
recommendCasesQuery.addField("new CasesRecommendPushRecord(id,recommendId,caseId)");
List<IFieldFilter> subFilters = new ArrayList<>();
subFilters.add(FieldFilters.eq("pushUserId", userId));
subFilters.add(FieldFilters.in("caseId", caseIds));
subFilters.add(FieldFilters.eq("pushStatus", 3));
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
caseListCommonHandle(content, caseVo.getUserId()); QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
pageList.setList(content);
return pageList;
}
private List<Cases> caseListCommonHandle(List<Cases> casesList, String accountId) {
if (CollUtil.isEmpty(casesList)) {
return casesList;
}
//1.推荐案例数据处理
recommendCasesDataHandle(casesList, accountId);
//2.标签处理,添加作者标签和新的案例标签
addAuthorTagAndCaseNewTag(casesList);
return casesList;
}
private void recommendCasesDataHandle(List<Cases> casesList, String accountId) {
if (StrUtil.isNotBlank(accountId)) {
List<String> caseIdList = casesList.stream().map(Cases::getId).collect(Collectors.toList());
QueryBuilder queryBuilder = QueryBuilder.from(CasesRecommendPushRecord.class)
.addField("new CasesRecommendPushRecord(id,recommendId,caseId)")
.addFilters(Arrays.asList(
FieldFilters.eq("pushUserId", accountId),
FieldFilters.in("caseId", caseIdList),
FieldFilters.eq("pushStatus", 3),
FieldFilters.eq("deleted", Boolean.FALSE)
))
.addOrder("sysCreateTime", OrderDirection.DESC) .addOrder("sysCreateTime", OrderDirection.DESC)
.addGroupBy("caseId"); .addGroupBy("caseId");
List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder()); List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder());
if (CollUtil.isNotEmpty(pushRecords)) { if (CollUtil.isNotEmpty(pushRecords)) {
List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).distinct().collect(Collectors.toList()); List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).distinct().collect(Collectors.toList());
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class) QueryBuilder builder = QueryBuilder.from(CasesRecommend.class);
.addField("new CasesRecommend(id,recommendOrgName,recommendTime)") List<IFieldFilter> recommendFilters = new ArrayList<>();
.addFilters(Arrays.asList( recommendFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
FieldFilters.eq("deleted", Boolean.FALSE), recommendFilters.add(FieldFilters.in("id", rIds));
FieldFilters.in("id", rIds) builder.addFilters(recommendFilters);
));
List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder()); List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder());
if (CollUtil.isNotEmpty(recommands)) { if (CollUtil.isNotEmpty(recommands)) {
Map<String, CasesRecommend> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), item -> item)); Map<String, CasesRecommend> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), item->item));
casesList.forEach(it -> { content.forEach(it -> {
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId())); CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
if (Objects.nonNull(one)) { if (Objects.nonNull(one)) {
CasesRecommend recommend = collect.get(one.getRecommendId()); CasesRecommend recommend = collect.get(one.getRecommendId());
@@ -460,76 +446,13 @@ public class CasesServiceImpl implements ICasesService {
it.setRefId(one.getId()); it.setRefId(one.getId());
it.setRecommendOrgName(recommend.getRecommendOrgName()); it.setRecommendOrgName(recommend.getRecommendOrgName());
it.setSysCreateTime(recommend.getRecommendTime()); it.setSysCreateTime(recommend.getRecommendTime());
} else {
it.setBreCommend(0);
} }
}); });
} }
} }
} }
} pageList.setList(content);
return pageList;
/**
* 添加案例标签、作者标签最佳案例N篇、上榜浏览量TOP榜单N次、案例标签xx分类浏览量TOP、最佳案例
*/
private void addAuthorTagAndCaseNewTag(List<Cases> caseList) {
if (CollUtil.isEmpty(caseList)) {
return;
}
List<String> authorIdList = caseList.stream().map(Cases::getAuthorId).distinct().collect(Collectors.toList());
HashMap<String, Object> excellentCountMap = casesDao.findExcellentCount(authorIdList);
HashMap<String, Object> viewTopCountMap = casesRankDao.findViewTopCount(authorIdList);
caseList.forEach(e -> {
// 获取最新的两个浏览量上榜记录
List<CasesRank> viewsRankRecords = casesRankDao.findViewsRankRecordByCaseId(e.getId());
if (CollUtil.isNotEmpty(viewsRankRecords)) {
// 拼接生成浏览量排行榜的标签
List<CaseViewRankingItemVo> viewRankTags = viewsRankRecords.stream().map(casesRank -> {
String pattern = casesRank.getRiseRankTime().getMonthValue() < 10 ? "yy年M月" : "yy年MM月";
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
String time = casesRank.getRiseRankTime().format(formatter);
// 2023年6月 经营管理类 浏览量 TOP1
String viewRankTag = time + casesRank.getMajorName() + "类浏览量TOP" + (casesRank.getRank() + 1);
CaseViewRankingItemVo caseViewRankingItemVo = new CaseViewRankingItemVo();
caseViewRankingItemVo.setMajorId(String.valueOf(casesRank.getMajorId()));
caseViewRankingItemVo.setMajorName(casesRank.getMajorName());
caseViewRankingItemVo.setTagName(viewRankTag);
caseViewRankingItemVo.setRiseRankTime(casesRank.getRiseRankTime());
return caseViewRankingItemVo;
}).collect(Collectors.toList());
e.setViewRankTags(viewRankTags);
}
// 拼接生成年度最佳标签
if (e.getExcellent()!=null && e.getExcellent()) {
if (e.getDraftingTime()!=null){
e.setExcellentTag(e.getDraftingTime().format(DateTimeFormatter.ofPattern("yy年"))+"度最佳");
} else {
e.setExcellentTag(e.getSysCreateTime().format(DateTimeFormatter.ofPattern("yy年"))+"度最佳");
}
}
List<String> authorTags = new ArrayList<>();
if (excellentCountMap.get(e.getAuthorId())!=null){
String authorTagOfExcellent = excellentCountMap.get(e.getAuthorId()) + "篇最佳案例";
authorTags.add(authorTagOfExcellent);
}
if (viewTopCountMap.get(e.getAuthorId())!=null){
String authorTagOfView = "上榜浏览量TOP榜单" + viewTopCountMap.get(e.getAuthorId()) + "";
authorTags.add(authorTagOfView);
}
e.setAuthorTags(authorTags);
});
} }
public static void main(String[] args) { public static void main(String[] args) {
@@ -1022,12 +945,11 @@ public class CasesServiceImpl implements ICasesService {
} }
@Override @Override
public List<Cases> ids(List<String> ids, String accountId) { public List<Cases> ids(List<String> ids) {
QueryBuilder builder = QueryBuilder.from(Cases.class); QueryBuilder builder = QueryBuilder.from(Cases.class);
builder.addFilter(FieldFilters.in("id", ids)); builder.addFilter(FieldFilters.in("id", ids));
builder.addFields("new Cases(id,title,summary,coverUrl,authorId,authorName,sysCreateTime,breCommend,views,comments,praises,shares,favorites,deleted,sysCreateBy,sysCreateAid,keyword1,keyword2,keyword3,keyword4,keyword5)"); builder.addFields("new Cases(id,title,summary,coverUrl,authorId,authorName,sysCreateTime,breCommend,views,comments,praises,shares,favorites,deleted,sysCreateBy,sysCreateAid)");
List<Cases> cases = casesDao.findList(builder.builder()); List<Cases> cases = casesDao.findList(builder.builder());
cases = caseListCommonHandle(cases, accountId);
return cases; return cases;
} }
@@ -1156,362 +1078,15 @@ public class CasesServiceImpl implements ICasesService {
} }
@Override @Override
public void excellent(String id, Boolean excellent, String excellentReason) { public void excellent(String id, Boolean excellent) {
//取消时,把时间清空 //取消时,把时间清空
if (excellent) { if (excellent) {
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", LocalDateTime.now()), UpdateBuilder.create("excellentReason", excellentReason)); casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", LocalDateTime.now()));
} else { } else {
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", null), UpdateBuilder.create("excellentReason", null)); casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", null));
} }
}
@Override
@Transactional(rollbackFor = Exception.class)
public void refreshViewsRankOfMajor(){
log.info("开始执行每月案例浏览量相关定时任务");
// 获取上个月的第一天的00:00
// LocalDateTime firstDayOfLastMonth = LocalDateTime.now().minusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).toLocalDate().atStartOfDay();
// 获取上个月的最后一天的23:59:59,将其设置为上榜时间。注意定时统计任务是在本月月初执行的而上榜时间是在上个月最后一天23:59:59
LocalDateTime lastDayOfLastMonth = LocalDateTime.now().minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).toLocalDate().atTime(23, 59, 59); // 设置为当天的几乎结束时刻
int count = casesRankDao.sqlCount("SELECT count(1) FROM boe_cases_rank WHERE deleted=0 AND rise_rank_time = ?1" , lastDayOfLastMonth);
if (count > 0){
log.info("已生成上个月排行榜数据,本次不执行");
throw new RuntimeException("已生成上个月排行榜数据,请将上月排行榜数据删除");
}
//获取案例当月排名
// String sql =
// "SELECT bc.id,bcmt.major_id,bc.views - COALESCE(bc.last_month_views, 0) AS increment\n" +
// "FROM boe_cases bc\n" +
// "JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views - COALESCE(bc.last_month_views, 0)!=0";
String sql =
"SELECT bc.id,bcmt.major_id,bc.views AS increment\n" +
"FROM boe_cases bc\n" +
"JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views !=0 and bc.views is not null";
List<Object> caseListOfObject = casesDao.sqlFindList(sql);
// 转为casesRank
List<CasesRank> casesRankList = caseListOfObject.stream()
.map(o -> {
CasesRank casesRank = new CasesRank();
casesRank.setCaseId(Long.valueOf(Array.get(o, 0).toString()));
casesRank.setMajorId(Array.get(o, 1).toString());
casesRank.setMonthlyIncrement(Integer.parseInt(Array.get(o, 2).toString()));
casesRank.setRiseRankTime(lastDayOfLastMonth);
return casesRank;
}).collect(Collectors.toList());
// 根据专业分类进行分组
Map<String, List<CasesRank>> casesRankMap = casesRankList.stream().collect(Collectors.groupingBy(CasesRank::getMajorId));
// 生成当前月不同分类的最新的浏览量排名
ArrayList<CasesRank> lastMonthRank = new ArrayList<>();
casesRankMap.forEach((majorId, caseList) -> {
List<CasesRank> sortedCaseList = caseList.stream()
.sorted(Comparator.comparingInt(CasesRank::getMonthlyIncrement).reversed()).limit(10)
.collect(Collectors.toList());
IntStream.range(0, sortedCaseList.size())
.forEach(i -> sortedCaseList.get(i).setRank(i));
lastMonthRank.addAll(sortedCaseList);
});
casesRankDao.saveList(lastMonthRank);
// 重置上月观看量last_month_views
int i = casesDao.sqlUpdate("update boe_cases set last_month_views=views where deleted=0");
log.info("每月案例浏览量相关定时任务执行完成boe_cases更新数据量为条数为"+i);
log.info("每月案例浏览量相关定时任务执行完成boe_cases_rank添加数据量为条数为"+lastMonthRank.size());
} }
@Override
public void refreshLastQuarterStatistics() {
log.info("开始执行每季案例相关定时任务");
int i = casesDao.sqlUpdate("update boe_cases set last_quarter_views=views,last_quarter_praise=praise where deleted=0");
log.info("每季案例相关定时任务执行完成boe_cases更新数据量为条数为"+i);
}
@Override
public List<CaseRankingVo> queryRank(Integer pageSize, Integer rankType) {
if (pageSize == null) {
pageSize = 3;
}
String cacheKey = "";
// 获取缓存key
for (CasesRankEnum enumValue : CasesRankEnum.values()) {
if (rankType == enumValue.getType()) {
// 格式如case:rank:praise:all3
cacheKey = enumValue.getCacheKey()+pageSize;
}
}
List<String> caseListOfJson = stringRedisTemplate.opsForList().range(cacheKey, 0, -1);
if (CollectionUtil.isNotEmpty(caseListOfJson)) {
// 缓存中存在数据
List<CaseRankingVo> casesList = caseListOfJson.stream().map(item -> JSONUtil.toBean(item, CaseRankingVo.class)).collect(Collectors.toList());
return casesList;
}
List<CaseRankingVo> casesList = casesDao.findRank(pageSize,rankType);
if (CollectionUtil.isNotEmpty(casesList)) {
// 缓存不存在数据,数据库中不存在数据,重建缓存
List<String> serializedCases = casesList.stream().map(item -> JSONUtil.toJsonStr(item)).collect(Collectors.toList());
stringRedisTemplate.opsForList().rightPushAll(cacheKey, serializedCases);
stringRedisTemplate.expire(cacheKey, 600, TimeUnit.SECONDS);
return casesList;
}
return Collections.emptyList();
}
@Override
public List<Cases> queryPopularityOfMajor(Integer pageSize, String majorId, LocalDateTime month, String accountId) {
if (pageSize == null) {
pageSize = 10;
}
LocalDateTime startTime = month.withDayOfMonth(1);
LocalDateTime endTime = month.plusMonths(1).withDayOfMonth(1).withMinute(0);
List<HashMap<String, Object>> popularityOfMajor = casesRankDao.findPopularityOfMajor(pageSize, startTime, endTime, majorId);
List<String> caseIdList = popularityOfMajor.stream().map(map -> map.get("caseId").toString()).collect(Collectors.toList());
Map<Object, Integer> collect = popularityOfMajor.stream().collect(Collectors.toMap(map -> map.get("caseId").toString(), map -> Integer.valueOf(map.get("rank").toString())));
QueryBuilder query = QueryBuilder.from(Cases.class);
query.addFilter(FieldFilters.in("id",caseIdList));
query.addFilter(FieldFilters.eq("deleted",false));
List<Cases> casesList = casesDao.findList(query.builder());
casesList = caseListCommonHandle(casesList, accountId);
Collections.sort(casesList, new Comparator<Cases>() {
@Override
public int compare(Cases c1, Cases c2) {
Integer order1 = collect.get(c1.getId());
Integer order2 = collect.get(c2.getId());
return Integer.compare(order1, order2);
}
});
return casesList;
}
@Override
public List<CasesQueryRecommendRankVo> queryRecommendRank(Integer pageSize) {
QueryBuilder queryBuilder = QueryBuilder.from(Cases.class);
queryBuilder.setPageSize(pageSize);
queryBuilder.addFilter(FieldFilters.eq("deleted",false));
queryBuilder.addFilter(FieldFilters.isNotNull("recommend_rank"));
queryBuilder.addOrder(OrderCondition.asc("recommend_rank"));
List<Cases> recommendRank = casesDao.findList(queryBuilder.builder());
List<CasesQueryRecommendRankVo> collect = recommendRank.stream().map(e -> {
CasesQueryRecommendRankVo casesQueryRecommendRankVo = new CasesQueryRecommendRankVo();
casesQueryRecommendRankVo.setCaseId(e.getId());
casesQueryRecommendRankVo.setCaseTitle(e.getTitle());
casesQueryRecommendRankVo.setCaseAuthor(e.getAuthorName());
casesQueryRecommendRankVo.setRecommendRankPushUserName(e.getRecommendRankPushUserName());
casesQueryRecommendRankVo.setRecommendRankPusTime(e.getRecommendRankPushTime());
return casesQueryRecommendRankVo;
}).collect(Collectors.toList());
return collect;
}
@Override
public void riseIntoRank(Long caseId, CurrentUser currentUser) {
Cases caseOfNewRise = casesDao.findOne(FieldFilters.eq("id", String.valueOf(caseId)),FieldFilters.isNull("recommend_rank"),FieldFilters.eq("deleted",false));
if (caseOfNewRise == null) {
log.error("案例不存在或已经在榜,不可上榜", caseId);
return;
}
int count = casesDao.sqlCount("select count(1) from boe_cases where deleted=0 and recommend_rank is not null order by recommend_rank asc limit 10");
if (count == 10){
log.error("已满10条无法添加");
throw new RuntimeException("已满10条无法添加");
}
caseOfNewRise.setRecommendRank(count);
caseOfNewRise.setRecommendRankPushUserName(currentUser.getLoginName());
caseOfNewRise.setRecommendRankPushTime(LocalDateTime.now());
casesDao.update(caseOfNewRise);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void cancelRiseIntoRank(Long caseId) {
Cases caseOfCancelRise = casesDao.findOne(FieldFilters.eq("id", String.valueOf(caseId)),FieldFilters.isNotNull("recommend_rank"),FieldFilters.eq("deleted",false));
if (caseOfCancelRise == null) {
log.error("案例不存在或已经在榜,不可下榜", caseId);
return;
}
QueryBuilder queryBuilder = QueryBuilder.from(Cases.class);
queryBuilder.setPageSize(10);
queryBuilder.addFilter(FieldFilters.eq("deleted",false));
queryBuilder.addOrder(OrderCondition.asc("recommend_rank"));
queryBuilder.addFilter(FieldFilters.gt("recommend_rank",caseOfCancelRise.getRecommendRank()));
List<Cases> recommendRank = casesDao.findList(queryBuilder.builder());
if (CollectionUtils.isEmpty(recommendRank)){
// 更新排序
for (int i = 0; i < recommendRank.size(); i++){
Integer currentSort = recommendRank.get(i).getRecommendRank();
recommendRank.get(i).setRecommendRank(currentSort - 1);
casesDao.update(recommendRank.get(i));
}
}
// 取消排序
caseOfCancelRise.setRecommendRank(null);
caseOfCancelRise.setRecommendRankPushTime(null);
caseOfCancelRise.setRecommendRankPushUserName(null);
casesDao.update(caseOfCancelRise);
}
@Override
public void adjustRank(List<Long> caseIdList) {
QueryBuilder queryBuilder = QueryBuilder.from(Cases.class);
queryBuilder.setPageSize(10);
queryBuilder.addFilter(FieldFilters.eq("deleted",false));
queryBuilder.addFilter(FieldFilters.isNotNull("recommend_rank"));
queryBuilder.addOrder(OrderCondition.asc("recommend_rank"));
List<Cases> recommendRank = casesDao.findList(queryBuilder.builder());
// 遍历排序后的案例列表,并根据 caseIdList 设置或重置 recommendRank
recommendRank.forEach(caseItem -> {
int index = caseIdList.indexOf(Long.valueOf(caseItem.getId()));
// 如果 ID 存在于 caseIdList 中,则设置推荐等级为该 ID 的索引位置,否则设置为 null
if (index != -1) {
caseItem.setRecommendRank(index);
} else {
caseItem.setRecommendRank(null);
caseItem.setRecommendRankPushTime(null);
caseItem.setRecommendRankPushUserName(null);
}
});
// 保存对案例排序的更改
recommendRank.forEach(casesDao::update);
}
@Override
public PageList<FavoriteCaseOfIndexVo> queryFavoriteCaseOfIndex(Integer pageIndex, Integer pageSize, String accountId) {
String from = Favorites.class.getSimpleName()+" f,"+ Cases.class.getSimpleName()+" c";
QueryBuilder builder = QueryBuilder.from(from);
builder.addFields("f.id","f.sysCreateTime","c");
builder.addFilter(FieldFilters.eqField("f.objId","c.id"));
builder.addFilter(FieldFilters.eq("f.objType", BoedxResourceType.Case.value()));
builder.addFilter(FieldFilters.eq("f.sysCreateAid",accountId));
builder.addFilter(FieldFilters.eq("c.deleted", false));
builder.addOrder(OrderCondition.desc("f.sysCreateTime"));
builder.setPageIndex(pageIndex);
builder.setPageSize(pageSize);
PageList<Object[]> pageFields=null;
try {
pageFields = casesDao.findPageFields(builder.builder());
} catch (Exception e) {
log.error("收藏案例查询错误",e);
}
List<Object[]> list = pageFields.getList();
// 提取出 Cases 对象,添加标签
List<Cases> casesList = list.stream().map(o -> {
Cases cases = (Cases) o[2];
FavoriteCaseOfIndexVo favoriteCaseOfIndexVo = new FavoriteCaseOfIndexVo();
BeanUtils.copyProperties(cases, favoriteCaseOfIndexVo);
favoriteCaseOfIndexVo.setFavoriteId(o[0].toString());
favoriteCaseOfIndexVo.setFavoriteTime(LocalDateTime.parse(o[1].toString()));
return favoriteCaseOfIndexVo;
}).collect(Collectors.toList());
casesList = caseListCommonHandle(casesList, accountId);
List<FavoriteCaseOfIndexVo> collect = casesList.stream().map(cases -> (FavoriteCaseOfIndexVo) cases).collect(Collectors.toList());
PageList<FavoriteCaseOfIndexVo> favoriteCaseOfIndexVoPageList = new PageList<>();
favoriteCaseOfIndexVoPageList.setList(collect);
favoriteCaseOfIndexVoPageList.setPageSize(pageSize);
favoriteCaseOfIndexVoPageList.setCount(pageFields.getCount());
return favoriteCaseOfIndexVoPageList;
}
@Override
public PageList<CasesBrowsingHistoryVo> browsingHistory(Integer pageIndex, Integer pageSize, String accountId, HttpServletRequest request) {
UserdynamicParam userdynamicParam = new UserdynamicParam();
userdynamicParam.setPageIndex(pageIndex);
userdynamicParam.setPageSize(pageSize);
userdynamicParam.setContentType(3);
userdynamicParam.setAid(Long.valueOf(accountId));
userdynamicParam.setHidden("");
String token = request.getHeader("Xboe-Access-Token");
if (StringUtils.isEmpty(token)) {
token = request.getHeader("token");
}
// 获取案例浏览记录
UserDynamicResult userDynamicResult = thirdApi.getAllUserdynamicListOfCaseRead(userdynamicParam, token);
List<UserDynamic> allUserdynamicList = userDynamicResult.getList();
List<String> collect = allUserdynamicList.stream().map(UserDynamic::getContentId).distinct().collect(Collectors.toList());
// 查询案例信息
List<Cases> caseList = this.ids(collect, accountId);
Map<String, Cases> map = caseList.stream().collect(Collectors.toMap(Cases::getId, cases -> cases));
// 组合案例信息与浏览记录
List<CasesBrowsingHistoryVo> batchHistoryVoList = allUserdynamicList.stream().map(userDynamic -> {
CasesBrowsingHistoryVo browsingHistoryVo = new CasesBrowsingHistoryVo();
browsingHistoryVo.setBrowsingHistoryId(userDynamic.getId());
browsingHistoryVo.setContentInfo(userDynamic.getContentInfo());
browsingHistoryVo.setEventTime(userDynamic.getEventTime());
browsingHistoryVo.setContentId(userDynamic.getContentId());
if (map.containsKey(userDynamic.getContentId())){
// 重名属性如IDcopy会出现覆盖。
BeanUtils.copyProperties(map.get(userDynamic.getContentId()),browsingHistoryVo);
}
return browsingHistoryVo;
}).collect(Collectors.toList());
PageList<CasesBrowsingHistoryVo> pageList = new PageList<>();
pageList.setList(batchHistoryVoList);
pageList.setCount(userDynamicResult.getCount());
pageList.setPageSize(userDynamicResult.getPageSize());
return pageList;
}
@Override
public Map<String, List<String>> queryAllTimePopularityOfMajor() {
QueryBuilder builder = QueryBuilder.from(CasesRank.class);
builder.addField("new CasesRank(majorId,riseRankTime)");
builder.addFilter(FieldFilters.eq("deleted",false));
builder.addGroupBy("majorId");
builder.addGroupBy("riseRankTime");
List<CasesRank> list = casesRankDao.findList(builder.builder());
// 定义日期时间的格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy-MM");
Map<String, List<String>> collect = list.stream().collect(Collectors.groupingBy
(CasesRank::getMajorId, Collectors.mapping(casesRank -> casesRank.getRiseRankTime().format(formatter), Collectors.toList())));
return collect;
}
} }

View File

@@ -1,17 +0,0 @@
package com.xboe.module.boecase.vo;
import lombok.Data;
@Data
public class CaseRankingVo {
/**
* 案例id
*/
private String caseId;
/**
* 案例标题
*/
private String caseTitle;
}

View File

@@ -1,29 +0,0 @@
package com.xboe.module.boecase.vo;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class CaseViewRankingItemVo {
/**
* 分类id
*/
private String majorId;
/**
* 分类名称
*/
private String majorName;
/**
* 上榜时间目前默认为一月中的最后一天的23:59:59
*/
private LocalDateTime riseRankTime;
/**
* 标签名称
*/
private String tagName;
}

View File

@@ -1,31 +0,0 @@
package com.xboe.module.boecase.vo;
import com.xboe.module.boecase.entity.Cases;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class CasesBrowsingHistoryVo extends Cases{
/**
* 浏览记录id
* */
private String browsingHistoryId;
/**
* 案例标题
* */
private String contentInfo;
/**
* 事件时间查看案例时有定时接口触发名为sendeventTime为该时间
* */
private LocalDateTime eventTime;
/**
* 案例ID
* */
private String contentId;
}

View File

@@ -1,37 +0,0 @@
package com.xboe.module.boecase.vo;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class CasesQueryRecommendRankVo {
/**
* 案例id
*/
private String caseId;
/**
* 案例标题
*/
private String caseTitle;
/**
* 案例作者
*/
private String caseAuthor;
/**
* 推送用户名称
*/
private String recommendRankPushUserName;
/**
* 推送时间
*/
private LocalDateTime recommendRankPusTime;
}

View File

@@ -1,23 +0,0 @@
package com.xboe.module.boecase.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xboe.module.boecase.entity.Cases;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class FavoriteCaseOfIndexVo extends Cases{
/**
* 收藏id
*/
private String favoriteId;
/**
* 收藏时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime favoriteTime;
}

View File

@@ -1,33 +1,21 @@
package com.xboe.module.course.api; package com.xboe.module.course.api;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.xboe.api.ThirdApi; import com.xboe.api.ThirdApi;
import com.xboe.core.orm.FieldFilters; import com.xboe.api.vo.AuditList;
import com.xboe.module.course.entity.*; import com.xboe.api.vo.AuditListParam;
import com.xboe.api.vo.UserDynamic;
import com.xboe.api.vo.UserdynamicParam;
import com.xboe.common.OrderCondition;
import com.xboe.core.JsonResponseStatus;
import com.xboe.module.course.vo.TeacherVo; import com.xboe.module.course.vo.TeacherVo;
import com.xboe.school.study.dao.StudyCourseDao; import com.xboe.module.usergroup.entity.UserGroupItem;
import com.xboe.school.study.entity.StudyHomeWork;
import com.xboe.school.study.service.IStudyHomeWorkService;
import com.xboe.school.study.service.IStudyService;
import com.xboe.system.user.entity.User;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
@@ -46,6 +34,11 @@ import com.xboe.core.api.ApiBaseController;
import com.xboe.module.course.dto.CourseQueryDto; import com.xboe.module.course.dto.CourseQueryDto;
import com.xboe.module.course.dto.CourseTeacherDto; import com.xboe.module.course.dto.CourseTeacherDto;
import com.xboe.module.course.dto.RankingDto; import com.xboe.module.course.dto.RankingDto;
import com.xboe.module.course.entity.Course;
import com.xboe.module.course.entity.CourseContent;
import com.xboe.module.course.entity.CourseCrowd;
import com.xboe.module.course.entity.CourseSection;
import com.xboe.module.course.entity.CourseTeacher;
import com.xboe.module.course.service.ICourseContentService; import com.xboe.module.course.service.ICourseContentService;
import com.xboe.module.course.service.ICourseSectionService; import com.xboe.module.course.service.ICourseSectionService;
import com.xboe.module.course.service.ICourseService; import com.xboe.module.course.service.ICourseService;
@@ -74,19 +67,19 @@ public class CoursePortalApi extends ApiBaseController{
@Resource @Resource
private ICourseService courseService; private ICourseService courseService;
@Resource @Resource
private ITeacherService teacherService; private ITeacherService teacherService;
@Resource @Resource
private ICourseContentService contentService; private ICourseContentService contentService;
@Resource @Resource
private ICourseSectionService sectionService; private ICourseSectionService sectionService;
@Resource @Resource
private ICourseTeacherService courseTeacherService; private ICourseTeacherService courseTeacherService;
@Autowired @Autowired
private IUserGroupService userGroupService; private IUserGroupService userGroupService;
@@ -96,15 +89,6 @@ public class CoursePortalApi extends ApiBaseController{
@Resource @Resource
private ThirdApi thirdApi; private ThirdApi thirdApi;
@Autowired
IStudyHomeWorkService shomeworkService;
@Autowired
IStudyService studyService;
@Autowired
StudyCourseDao studyCourseDao;
@Autowired @Autowired
StringRedisTemplate redisTemplate; StringRedisTemplate redisTemplate;
@@ -124,9 +108,9 @@ public class CoursePortalApi extends ApiBaseController{
Map<String,Object> list=courseService.findImages(cids); Map<String,Object> list=courseService.findImages(cids);
return success(list); return success(list);
} }
/** /**
* 人气榜 * 人气榜
* */ * */
@PostMapping("/ranking") @PostMapping("/ranking")
public JsonResponse<List<RankingDto>> Ranking(Integer type,Integer time){ public JsonResponse<List<RankingDto>> Ranking(Integer type,Integer time){
@@ -152,7 +136,7 @@ public class CoursePortalApi extends ApiBaseController{
return success(rankingDtos); return success(rankingDtos);
} }
/** /**
* 查询列表,数量,类型,最新,最热 * 查询列表,数量,类型,最新,最热
* @param num * @param num
@@ -178,7 +162,7 @@ public class CoursePortalApi extends ApiBaseController{
} }
dto.setDevice(device); dto.setDevice(device);
try { try {
List<Course> list=courseService.findList(num, dto); List<Course> list=courseService.findList(num, dto);
return success(list); return success(list);
}catch(Exception e) { }catch(Exception e) {
@@ -186,10 +170,10 @@ public class CoursePortalApi extends ApiBaseController{
return error("查询课程列表失败",e.getMessage()); return error("查询课程列表失败",e.getMessage());
} }
} }
@PostMapping("/pagelist-new") @PostMapping("/pagelist-new")
public JsonResponse<PageList<Course>> findNewPage(Pagination pager,CourseQueryDto dto){ public JsonResponse<PageList<Course>> findNewPage(Pagination pager,CourseQueryDto dto){
//只是查询已发布的 //只是查询已发布的
dto.setPublish(true); dto.setPublish(true);
@@ -211,9 +195,9 @@ public class CoursePortalApi extends ApiBaseController{
} }
} }
} }
return success(coursePageList); return success(coursePageList);
} }
/** /**
@@ -224,7 +208,7 @@ public class CoursePortalApi extends ApiBaseController{
*/ */
@PostMapping("/pagelist") @PostMapping("/pagelist")
public JsonResponse<PageList<Course>> findPage(Pagination pager,CourseQueryDto dto){ public JsonResponse<PageList<Course>> findPage(Pagination pager,CourseQueryDto dto){
//只是查询已发布的 //只是查询已发布的
dto.setPublish(true); dto.setPublish(true);
@@ -245,11 +229,11 @@ public class CoursePortalApi extends ApiBaseController{
} }
} }
} }
return success(coursePageList); return success(coursePageList);
} }
/** /**
* 获取详细信息 * 获取详细信息
* @param id * @param id
@@ -260,19 +244,19 @@ public class CoursePortalApi extends ApiBaseController{
if(StringUtils.isBlank(id)) { if(StringUtils.isBlank(id)) {
return badRequest("参数错误,未指定课程"); return badRequest("参数错误,未指定课程");
} }
//当前对于课程不增加浏览量,课程的意义并不是看过 //当前对于课程不增加浏览量,课程的意义并不是看过
// if(addView==null) { // if(addView==null) {
// addView=false; // addView=false;
// } // }
Map<String,Object> rs=new HashMap<String,Object>(); Map<String,Object> rs=new HashMap<String,Object>();
Course course=courseService.getAddView(id); Course course=courseService.getAddView(id);
if(course==null || course.getDeleted()){ if(course==null || course.getDeleted()){
return badRequest("课程不存在或已被删除"); return badRequest("课程不存在或已被删除");
} }
rs.put("course",course); rs.put("course",course);
List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(id); List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(id);
if(crowd!=null && crowd) { if(crowd!=null && crowd) {
rs.put("crowds",courseCrowdList); rs.put("crowds",courseCrowdList);
@@ -315,7 +299,7 @@ public class CoursePortalApi extends ApiBaseController{
List<CourseContent> cclist=contentService.getByCourseId(id); List<CourseContent> cclist=contentService.getByCourseId(id);
List<CourseSection> sectionlist=sectionService.getByCourseId(id); List<CourseSection> sectionlist=sectionService.getByCourseId(id);
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id); List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化 //获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
for(CourseTeacher ct : teachers) { for(CourseTeacher ct : teachers) {
@@ -335,7 +319,7 @@ public class CoursePortalApi extends ApiBaseController{
} }
} }
} }
} }
rs.put("isCrowd",pass); rs.put("isCrowd",pass);
@@ -344,7 +328,7 @@ public class CoursePortalApi extends ApiBaseController{
rs.put("teachers",teachers); rs.put("teachers",teachers);
//查询课程 //查询课程
return success(rs); return success(rs);
} }
private void getTeacherInfo(String token, List<String> teacherIds) { private void getTeacherInfo(String token, List<String> teacherIds) {
List<TeacherVo> teacherInfo = thirdApi.getTeacherInfo(teacherIds, token); List<TeacherVo> teacherInfo = thirdApi.getTeacherInfo(teacherIds, token);
@@ -363,102 +347,7 @@ public class CoursePortalApi extends ApiBaseController{
} }
} }
//作业导出
@GetMapping("/export")
public JsonResponse<String> export(String courseName,String courseId,String contentId,String name,Integer status) throws IOException {
Map<String, String>map=new HashMap<>();
List<String> userIds = studyCourseDao.findList(FieldFilters.eq("courseId", courseId)).stream().filter(Objects::nonNull).map(StudyCourse::getAid).collect(Collectors.toList());
if (userIds.isEmpty()){
return error("查询不到用户");
}
List<User>user=studyService.getUserNo(userIds);
try {//筛选出的人员
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
if(list.isEmpty()){
return success("暂无数据");
}
for (StudyCourseItem s : list) {
List<StudyHomeWork> studyHomeWorks = shomeworkService.getByStudyIdAndContentId(s.getStudyId(), contentId).stream().filter(e-> !Objects.equals(e.getFilePath(), "")).filter(e->e.getFilePath()!=null).collect(Collectors.toList());
if(studyHomeWorks.isEmpty()){
return success("暂无数据");
}
studyHomeWorks.forEach(e->{
user.forEach(u->{
if(u.getId().equals(s.getAid())){
//取后缀
int dotIndex = e.getFilePath().lastIndexOf('.'); // 查找最后一个'.'的位置
String extension = e.getFilePath().substring(dotIndex);
map.put(u.getName()+"-"+u.getUserNo()+extension,"/home/www/elearning/upload"+e.getFilePath());
}
});
});
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("导出异常"+e.getMessage());
}
long totalFileSize = map.values().stream()
.mapToLong(path -> new File(path).length())
.sum();
// 检查文件总大小是否超过 2GB
if (totalFileSize > 2L * 1024 * 1024 * 1024) {
return success("您要下载的作业过大,请分批下载或联系管理员!");
}
// String encodedFilename = URLEncoder.encode(courseName+"【作业】.zip")
// .replace("+", "%20") // 空格替换为"%20"
// .replace("%2F", "/"); // 解决斜杠问题
// StringBuilder contentDispositionValue = new StringBuilder();
// contentDispositionValue.append("attachment; filename=\"")
// .append(encodedFilename)
// .append("\"")
// .append("; filename*=utf-8''")
// .append(encodedFilename);
//
// // 设置响应类型和Content-Disposition头
// response.setContentType("application/zip");
// 创建一个临时文件用于存储ZIP文件
File tempZipFile = new File("/home/www/elearning/upload/temp.zip");
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tempZipFile))) {
for (Map.Entry<String, String> e : map.entrySet()) {
File fileToZip = new File(e.getValue());
// 添加 ZIP 条目
ZipEntry entry = new ZipEntry(e.getKey());
entry.setSize(fileToZip.length());
zos.putNextEntry(entry);
try (FileInputStream fis = new FileInputStream(fileToZip)) {
byte[] buffer = new byte[4096];
int len;
while ((len = fis.read(buffer)) > 0) {
zos.write(buffer, 0, len);
}
}
zos.closeEntry();
}
}
// 将临时文件移动到指定位置
Path source = tempZipFile.toPath();
//生成uuid
String uuid = UUID.randomUUID().toString();
Path destination = Paths.get("/home/www/elearning/upload/saveZip/" + uuid + ".zip");
// 删除目标文件如果已存在
if (Files.exists(destination)) {
Files.delete(destination);
}
// 移动文件
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
// 返回文件路径给前端
String filePath = destination.toAbsolutePath().toString();
return success(filePath);
}
@GetMapping("/detail-study") @GetMapping("/detail-study")
public JsonResponse<List<CourseStudyVo>> detailStudy(String courseId, String aid){ public JsonResponse<List<CourseStudyVo>> detailStudy(String courseId, String aid){
if(StringUtil.isBlank(courseId)){ if(StringUtil.isBlank(courseId)){
@@ -503,7 +392,7 @@ public class CoursePortalApi extends ApiBaseController{
cv.setStatus(9); cv.setStatus(9);
} }
} }
//音视频 //音视频
}else{ }else{
cv.setStatus(study.getStatus()); cv.setStatus(study.getStatus());

View File

@@ -166,231 +166,118 @@ public class ExamQuestionApi extends ApiBaseController {
return badRequest("请上传正确的试题文件"); return badRequest("请上传正确的试题文件");
} }
//获取表头 //获取表头
Row row ; Row row = sheetAt.getRow(1);
//从第二行开始获取数据 //从第二行开始获取数据
List<ExamQuestion> examQuestions1 = new ArrayList<>(); List<ExamQuestion> examQuestions1 = new ArrayList<>();
QuestionDto questionDto = new QuestionDto(); QuestionDto questionDto = new QuestionDto();
if(sheetAt.getRow(1).getCell(0).getStringCellValue().equals("标题(*)")){
row = sheetAt.getRow(1);
for (int i = 2;i<sheetAt.getPhysicalNumberOfRows();i++) {
//获取每一行
Row row1 = sheetAt.getRow(i); for (int i=2;i<sheetAt.getPhysicalNumberOfRows();i++) {
if(row1==null || row1.getCell(0)==null){ //获取每一行
break;
}
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
break;
}
ExamQuestion examQuestion = new ExamQuestion();
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
if(row1.getCell(1).getStringCellValue().equals("单选题")){
examQuestion.setType(1);
}
if(row1.getCell(1).getStringCellValue().equals("多选题")){
examQuestion.setType(2);
}
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
}
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
}
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}
Cell cell = row1.getCell(4);
cell.setCellType(CellType.STRING);
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue())); Row row1 = sheetAt.getRow(i);
if(row1==null || row1.getCell(0)==null){
//单选 break;
if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
for (int j=7;j<=13;j++) {
if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption();
// 截取表头
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(6).getStringCellValue().contains(substring)) {
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
} else {
examOption.setIsAnswer(false);
}
if (examOption.getIsAnswer()) {
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=7;j<=13;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-7]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
} }
}else { if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
row = sheetAt.getRow(2); break;
for (int i = 3;i<sheetAt.getPhysicalNumberOfRows();i++) { }
//获取每一行 ExamQuestion examQuestion = new ExamQuestion();
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
Row row1 = sheetAt.getRow(i); if(row1.getCell(1).getStringCellValue().equals("单选题")){
if(row1==null || row1.getCell(0)==null){ examQuestion.setType(1);
break; }
} if(row1.getCell(1).getStringCellValue().equals("多选题")){
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){ examQuestion.setType(2);
break; }
} examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
ExamQuestion examQuestion = new ExamQuestion(); if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setTitle(row1.getCell(0).getStringCellValue()); examQuestion.setDifficulty(2f);
if(row1.getCell(1).getStringCellValue().equals("单选题")){ }
examQuestion.setType(1); if(row1.getCell(3).getStringCellValue().equals("")){
} examQuestion.setDifficulty(3f);
if(row1.getCell(1).getStringCellValue().equals("多选题")){ }
examQuestion.setType(2); if(row1.getCell(3).getStringCellValue().equals("")){
} examQuestion.setDifficulty(1f);
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue()); }
if(row1.getCell(3).getStringCellValue().equals("")){ Cell cell = row1.getCell(4);
examQuestion.setDifficulty(2f); cell.setCellType(CellType.STRING);
}
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
}
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}
Cell cell = row1.getCell(4);
cell.setCellType(CellType.STRING);
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue())); // examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
//单选 //单选
if (!cell.getStringCellValue().contains(",")){ if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(6).getStringCellValue()); examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue())); examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK); Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING); cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue()); examQuestion.setAnalysis(cell1.getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>(); List<ExamOption> examOptions = new ArrayList<>();
for (int j=7;j<=13;j++) { for (int j=7;j<=13;j++) {
if(row1.getCell(j)!=null) { if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption(); ExamOption examOption = new ExamOption();
// 截取表头 // 截取表头
String substring = row.getCell(j).getStringCellValue().substring(3, 4); String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(6).getStringCellValue().contains(substring)) { if (row1.getCell(6).getStringCellValue().contains(substring)) {
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
} else {
examOption.setIsAnswer(false);
}
if (examOption.getIsAnswer()) {
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=7;j<=13;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true); examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-7])); examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){ } else {
examOptions.add(examOption); examOption.setIsAnswer(false);
} }
if (examOption.getIsAnswer()) {
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
} }
} }
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
} }
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=7;j<=13;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-7]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
} }
} }
//判断题 只存在试题表中 //判断题 只存在试题表中

View File

@@ -142,9 +142,6 @@ public class AloneExamServiceImpl implements IAloneExamService{
if(StringUtils.isNotBlank(aea.getTestId())) { if(StringUtils.isNotBlank(aea.getTestId())) {
query.addFilter(FieldFilters.eq("testId",aea.getTestId())); query.addFilter(FieldFilters.eq("testId",aea.getTestId()));
} }
if(StringUtils.isNotBlank(aea.getTestName())) {
query.addFilter(FieldFilters.eq("testName",aea.getTestName()));
}
if(StringUtils.isNotBlank(aea.getAid())) { if(StringUtils.isNotBlank(aea.getAid())) {
query.addFilter(FieldFilters.eq("aid",aea.getAid())); query.addFilter(FieldFilters.eq("aid",aea.getAid()));
} }

View File

@@ -12,7 +12,6 @@ public class FavoriteCaseDto {
private String id; private String id;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime time; private LocalDateTime time;
/** /**

View File

@@ -3,11 +3,13 @@ package com.xboe.school.study.api;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter; import cn.hutool.core.util.ArrayUtil;
import com.xboe.api.ThirdApi; import com.xboe.api.ThirdApi;
import com.xboe.constants.CacheName; import com.xboe.api.vo.*;
import com.xboe.module.course.vo.TeacherVo; import com.xboe.module.course.vo.TeacherVo;
import com.xboe.module.usergroup.entity.UserGroupItem;
import com.xboe.module.usergroup.service.IUserGroupService; import com.xboe.module.usergroup.service.IUserGroupService;
import com.xboe.school.study.dao.StudyCourseDao; import com.xboe.school.study.dao.StudyCourseDao;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@@ -64,7 +66,9 @@ import javax.servlet.http.HttpServletRequest;
@RestController @RestController
@RequestMapping(value="/xboe/school/study/course") @RequestMapping(value="/xboe/school/study/course")
public class StudyCourseApi extends ApiBaseController{ public class StudyCourseApi extends ApiBaseController{
@Autowired @Autowired
IStudyCourseService service; IStudyCourseService service;
@@ -323,32 +327,17 @@ public class StudyCourseApi extends ApiBaseController{
//检查是否已存在 //检查是否已存在
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId()); StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
if(item!=null) { if(item!=null) {
String studyKey = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + item.getCourseId()+":"+cuser.getAccountId()+":"+item.getContentId(); //如果记录存在但是进度不100无成情况就更新进度一期不会有这种情况
String studyKey2 = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + sci.getCourseId()+":"+cuser.getAccountId()+":"+sci.getContentId(); if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
redisTemplate.opsForValue().set(studyKey, studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
String.valueOf(item.getProgress()), 2, TimeUnit.HOURS);
String progressStr = redisTemplate.opsForValue().get(studyKey2);
if (progressStr != null && !progressStr.isEmpty()) {
// 尝试将 Redis 中的字符串转换为整数
int redisProgress = Integer.parseInt(progressStr);
// 假设 item.getProgress() 返回的是 int 类型
int sciProgress = sci.getProgress();
if (redisProgress < sciProgress && redisProgress < 100) {
// 执行一些操作
// if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
// }
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
}
} }
//追加学习时长 //追加学习时长
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration()); studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token); List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
log.info("在线课学习记录"+allUserList); log.info("在线课学习记录"+allUserList);
return success(item.getId()); return success(item.getId());
//如果记录存在但是进度不100无成情况就更新进度一期不会有这种情况
} }
if(StringUtils.isBlank(sci.getCourseId())){ if(StringUtils.isBlank(sci.getCourseId())){
return error("无课程信息"); return error("无课程信息");
} }
@@ -707,9 +696,10 @@ public class StudyCourseApi extends ApiBaseController{
return error("查询失败",e.getMessage()); return error("查询失败",e.getMessage());
} }
} }
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST}) @RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId){ public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId, HttpServletRequest request){
if(StringUtils.isBlank(studyId)){ if(StringUtils.isBlank(studyId)){
return error("无学习信息"); return error("无学习信息");
} }

View File

@@ -1,6 +1,5 @@
package com.xboe.school.study.service; package com.xboe.school.study.service;
import java.util.Collection;
import java.util.List; import java.util.List;
import com.xboe.school.study.entity.StudyHomeWork; import com.xboe.school.study.entity.StudyHomeWork;
@@ -30,6 +29,4 @@ public interface IStudyHomeWorkService {
* @return * @return
*/ */
List<StudyHomeWork> getByStudyIdAndContentId(String studyId,String contentId); List<StudyHomeWork> getByStudyIdAndContentId(String studyId,String contentId);
List<StudyHomeWork>getByStudnetNameAndContentId(List<String> studentName, String contentId);
} }

View File

@@ -7,7 +7,6 @@ import com.xboe.common.PageList;
import com.xboe.school.study.dto.StudyContentDto; import com.xboe.school.study.dto.StudyContentDto;
import com.xboe.school.study.entity.StudyCourseItem; import com.xboe.school.study.entity.StudyCourseItem;
import com.xboe.school.study.entity.StudyTime; import com.xboe.school.study.entity.StudyTime;
import com.xboe.system.user.entity.User;
/** /**
* 学习情况处理,比较综合一个处理类 * 学习情况处理,比较综合一个处理类
@@ -96,8 +95,4 @@ public interface IStudyService {
* @return * @return
*/ */
PageList<StudyCourseItem> findItemPage(int pageIndex, int pageSize, String contentId, String courseId, String name, Integer status); PageList<StudyCourseItem> findItemPage(int pageIndex, int pageSize, String contentId, String courseId, String name, Integer status);
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
List<User> getUserNo(List<String> userIds);
} }

View File

@@ -89,9 +89,4 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
return dao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId)); return dao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
} }
@Override
public List<StudyHomeWork> getByStudnetNameAndContentId(List<String> studentName, String contentId) {
return dao.findList(FieldFilters.in("student_name", studentName),FieldFilters.eq("contentId", contentId));
}
} }

View File

@@ -1,5 +1,6 @@
package com.xboe.school.study.service.impl; package com.xboe.school.study.service.impl;
import java.math.BigInteger;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
@@ -7,12 +8,12 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource;
import javax.transaction.Transactional; import javax.transaction.Transactional;
import com.xboe.module.article.entity.Article; import com.xboe.module.article.entity.Article;
import com.xboe.module.interaction.entity.Shares; import com.xboe.module.interaction.entity.Shares;
import com.xboe.school.study.entity.StudyCourse; import com.xboe.school.study.entity.StudyCourse;
import com.xboe.system.user.entity.User;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -97,12 +98,8 @@ public class StudyServiceImpl implements IStudyService{
//sci.setProgress(100);//直接设置为学习完成 //sci.setProgress(100);//直接设置为学习完成
sci.setLastTime(ldt); sci.setLastTime(ldt);
scItemDao.saveOrUpdate(sci); scItemDao.saveOrUpdate(sci);
if (sci.getId() != null){
dto.setStudyItemId(sci.getId()); dto.setStudyItemId(sci.getId());
}else {
log.info("学习记录插入失败"+sci.getId());
throw new IllegalArgumentException("学习记录插入失败");
}
//检查是否全部学习完成 //检查是否全部学习完成
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal(),token); scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal(),token);
@@ -271,39 +268,6 @@ public class StudyServiceImpl implements IStudyService{
} }
@Override
public List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status) {
QueryBuilder query=QueryBuilder.from(StudyCourseItem.class);
OrderCondition oc=OrderCondition.desc("id");
query.addOrder(oc);
if(StringUtils.isNotBlank(contentId)) {
query.addFilter(FieldFilters.eq("contentId",contentId));
}
if(StringUtils.isNotBlank(courseId)) {
query.addFilter(FieldFilters.eq("courseId",courseId));
}
if(status!=null) {
if(status==1) {
query.addFilter(FieldFilters.eq("progress", 0));
}else {
query.addFilter(FieldFilters.eq("progress",100));
}
}
if(StringUtils.isNotBlank(name)) {
query.addFilter(FieldFilters.eq("aname", name));
}
return scItemDao.findList(query.builder());
}
@Override
public List<User> getUserNo(List<String> userIds) {
return userDao.findList(FieldFilters.in("id", userIds));
}
@Override @Override
@Transactional @Transactional
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) { public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) {

View File

@@ -1,9 +1,9 @@
# cloud nacos config # cloud nacos config
spring.cloud.nacos.discovery.server-addr=10.251.113.100:8848 spring.cloud.nacos.discovery.server-addr=10.251.129.51:8848
## redis ## redis
spring.redis.database=1 spring.redis.database=1
spring.redis.host=10.251.88.213 spring.redis.host=10.251.129.122
spring.redis.password=qwert!W588 spring.redis.password=qwert!W588
spring.redis.port=6379 spring.redis.port=6379
@@ -16,7 +16,7 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver
#spring.datasource.url=jdbc:mysql://10.251.129.129:8066/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull #spring.datasource.url=jdbc:mysql://10.251.129.129:8066/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
#spring.datasource.username=admin #spring.datasource.username=admin
#spring.datasource.password=ocYMC>!{8G #spring.datasource.password=ocYMC>!{8G
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=admin spring.datasource.username=admin
spring.datasource.password=boeRds01 spring.datasource.password=boeRds01
@@ -53,7 +53,6 @@ xboe.externalinterface.url.system=http://127.0.0.1:9091
## ????????????? ## ?????????????
xboe.old.base.url=https://u.boe.com xboe.old.base.url=https://u.boe.com
## ???????api?? ## ???????api??
xboe.stat.base.url=http://127.0.0.1:9080 xboe.stat.base.url=http://127.0.0.1:9080
xboe.server.userbasic.url=https://u.boe.com/userbasic xboe.server.userbasic.url=https://u.boe.com/userbasic
@@ -64,7 +63,7 @@ jasypt.encryptor.algorithm=PBEWithMD5AndDES
jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
# elasticsearch config # elasticsearch config
xboe.elasticsearch.server.ip=10.251.88.218 xboe.elasticsearch.server.ip=10.251.129.21
xboe.elasticsearch.server.port=9200 xboe.elasticsearch.server.port=9200
xboe.elasticsearch.server.user= xboe.elasticsearch.server.user=
xboe.elasticsearch.server.password= xboe.elasticsearch.server.password=

View File

@@ -56,7 +56,7 @@ logging.config=classpath:log/logback-@profileActive@.xml
# config.id.generator.datacenter.num=1 # config.id.generator.datacenter.num=1
#boe.domain=https://pretest.zcwytd.com #boe.domain=https://pretest.zcwytd.com
boe.domain=http://127.0.0.1 boe.domain=https://u.boe.com
#boe.domain=http://localhost:30001 #boe.domain=http://localhost:30001
orgTree.orgTreeList=${boe.domain}/userbasic/org/list orgTree.orgTreeList=${boe.domain}/userbasic/org/list
# ????id???????????? # ????id????????????

View File

@@ -1,6 +1,6 @@
## redis ## redis
spring.redis.database=3 spring.redis.database=3
spring.redis.host=10.251.88.213 spring.redis.host=10.251.129.122
spring.redis.password=qwert!W588 spring.redis.password=qwert!W588
spring.redis.port=6379 spring.redis.port=6379
@@ -14,7 +14,7 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# 当前数据库 basic 对应的数据库 # 当前数据库 basic 对应的数据库
spring.datasource.db1.driverClassName=com.mysql.jdbc.Driver spring.datasource.db1.driverClassName=com.mysql.jdbc.Driver
spring.datasource.db1.jdbc-url=jdbc:mysql://10.251.88.216:3306/boe_basic?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.db1.jdbc-url=jdbc:mysql://10.251.129.126:3306/boe_basic?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db1.username=admin spring.datasource.db1.username=admin
spring.datasource.db1.password=boeRds01 spring.datasource.db1.password=boeRds01
@@ -23,7 +23,7 @@ spring.datasource.db1.password=boeRds01
# 主数据库 all 对应的数据库 # 主数据库 all 对应的数据库
spring.datasource.db2.driverClassName=com.mysql.jdbc.Driver spring.datasource.db2.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.db2.jdbc-url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.db2.jdbc-url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db2.username=admin spring.datasource.db2.username=admin
spring.datasource.db2.password=boeRds01 spring.datasource.db2.password=boeRds01
@@ -48,7 +48,6 @@ xboe.upload.file.http_path=https://u.boe.com/upload
## 新系统的内部地址可以不通过nginx调用 ## 新系统的内部地址可以不通过nginx调用
xboe.inner.data.sync.baseurl=http://127.0.0.1:9090 xboe.inner.data.sync.baseurl=http://127.0.0.1:9090
#加密盐 #加密盐
#jasypt.encryptor.password=jasypt #jasypt.encryptor.password=jasypt
jasypt.encryptor.algorithm=PBEWithMD5AndDES jasypt.encryptor.algorithm=PBEWithMD5AndDES

View File

@@ -1,15 +1,15 @@
## redis ## redis
spring.redis.database=2 spring.redis.database=2
spring.redis.host=10.251.88.214 spring.redis.host=127.0.0.1
spring.redis.password=qwert!W588 spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
spring.redis.port=6379 spring.redis.port=6379
## datasource config ## datasource config
spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql:/10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=admin spring.datasource.username=root
spring.datasource.password=boeRds01 spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)
logging.level.org.hibernate.SQL=ERROR logging.level.org.hibernate.SQL=ERROR
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE # logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

View File

@@ -1,6 +1,6 @@
## redis ## redis
spring.redis.database=2 spring.redis.database=2
spring.redis.host=10.251.88.214 spring.redis.host=127.0.0.1
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+) spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
spring.redis.port=6379 spring.redis.port=6379
@@ -8,7 +8,7 @@ spring.redis.port=6379
spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.ddl-auto=none
spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==) spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)

View File

@@ -1,16 +1,16 @@
## redis ## redis
spring.redis.database=2 spring.redis.database=2
spring.redis.host=10.251.88.214 spring.redis.host=127.0.0.1
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+) spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
spring.redis.port=6379 spring.redis.port=6379
# cloud nacos config # cloud nacos config
spring.cloud.nacos.discovery.server-addr=10.251.113.100:8848 spring.cloud.nacos.discovery.server-addr=10.251.181.11:8848
## datasource config ## datasource config
spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==) spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)
@@ -33,6 +33,7 @@ xboe.upload.file.http_path=http://localhost:9090/cdn/upload
## 外部接口调用地址 旧系统机构及用户数据接口 ## 外部接口调用地址 旧系统机构及用户数据接口
xboe.externalinterface.url.system=http://localhost:9091 xboe.externalinterface.url.system=http://localhost:9091
#加密盐 #加密盐
#jasypt.encryptor.password=jasypt #jasypt.encryptor.password=jasypt
jasypt.encryptor.algorithm=PBEWithMD5AndDES jasypt.encryptor.algorithm=PBEWithMD5AndDES

View File

@@ -7,7 +7,7 @@ spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# 当前数据库 basic 对应的数据库 # 当前数据库 basic 对应的数据库
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=admin spring.datasource.username=admin
spring.datasource.password=boeRds01 spring.datasource.password=boeRds01

View File

@@ -7,7 +7,7 @@ spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# 当前数据库 basic 对应的数据库 # 当前数据库 basic 对应的数据库
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=admin spring.datasource.username=admin
spring.datasource.password=boeRds01 spring.datasource.password=boeRds01

View File

@@ -1,3 +1,4 @@
# datasource config # datasource config
# basic数据库 # basic数据库
spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.ddl-auto=none
@@ -8,7 +9,7 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# 原数据库 old 对应的数据库 # 原数据库 old 对应的数据库
spring.datasource.db1.driverClassName=com.mysql.jdbc.Driver spring.datasource.db1.driverClassName=com.mysql.jdbc.Driver
spring.datasource.db1.jdbc-url=jdbc:mysql://10.251.88.216:3306/elearninglms?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.db1.jdbc-url=jdbc:mysql://10.251.129.126:3306/elearninglms?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db1.username=admin spring.datasource.db1.username=admin
spring.datasource.db1.password=boeRds01 spring.datasource.db1.password=boeRds01
@@ -17,7 +18,7 @@ spring.datasource.db1.password=boeRds01
# 新主数据库 all 对应的数据库 # 新主数据库 all 对应的数据库
spring.datasource.db2.driverClassName=com.mysql.jdbc.Driver spring.datasource.db2.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver # spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.db2.jdbc-url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull spring.datasource.db2.jdbc-url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db2.username=admin spring.datasource.db2.username=admin
spring.datasource.db2.password=boeRds01 spring.datasource.db2.password=boeRds01