Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
张松 2025-01-04 18:33:00 +08:00
commit cc978f44e8
14 changed files with 313 additions and 262 deletions

46
pom.xml
View File

@ -23,7 +23,7 @@
<mssql.version>4.0</mssql.version>
<oracle.version>11.2.0.3</oracle.version>
<druid.version>1.1.13</druid.version>
<quartz.version>2.3.0</quartz.version>
<!-- <quartz.version>2.3.0</quartz.version>-->
<commons.lang.version>2.6</commons.lang.version>
<commons.fileupload.version>1.2.2</commons.fileupload.version>
<commons.io.version>2.5</commons.io.version>
@ -85,17 +85,17 @@
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.274</version>
<exclusions>
<exclusion>
<artifactId>aws-java-sdk-simpleworkflow</artifactId>
<groupId>com.amazonaws</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.amazonaws</groupId>-->
<!-- <artifactId>aws-java-sdk</artifactId>-->
<!-- <version>1.11.274</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>aws-java-sdk-simpleworkflow</artifactId>-->
<!-- <groupId>com.amazonaws</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
@ -325,17 +325,17 @@
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
<exclusions>
<exclusion>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.quartz-scheduler</groupId>-->
<!-- <artifactId>quartz</artifactId>-->
<!-- <version>${quartz.version}</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>com.mchange</groupId>-->
<!-- <artifactId>c3p0</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>

View File

@ -153,24 +153,6 @@ public class ShardingConfig {
for (String regionTable : regionTables) {
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration(regionTable, String.format(regionTablesDataNode, regionTable));
tableRuleConfig.setDatabaseShardingStrategyConfig(databaseShardingStrategyConfig);
// // 设置区域表使用雪花算法生成主键
// switch (regionTable){
// case "orders":
// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "orders_id"));
// break;
//// case "course_collect":
//// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "course_collect_id"));
//// break;
// case "course_user":
// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "course_user_id"));
// break;
// case "tb_user":
// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "user_id"));
// break;
// default:
// tableRuleConfig.setKeyGeneratorConfig(new KeyGeneratorConfiguration("SNOWFLAKE", "id"));
// break;
// }
sets.add(tableRuleConfig);
}
@ -178,8 +160,6 @@ public class ShardingConfig {
// 定义区域表的分库规则
StandardShardingStrategyConfiguration courseDetailsShardingStrategyConfig = new StandardShardingStrategyConfiguration(
courseDetailsShardingDatabaseColumn, new StandardShardingStrategyConf());
// InlineShardingStrategyConfiguration courseDetailsShardingStrategyConfig = new InlineShardingStrategyConfiguration(
// courseDetailsShardingDatabaseColumn, courseDetailsShardingDatabaseAlgorithm);
for (String regionTable : courseDetails) {
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration(regionTable, String.format(regionTablesDataNode, regionTable));
tableRuleConfig.setDatabaseShardingStrategyConfig(courseDetailsShardingStrategyConfig);

View File

@ -1,8 +1,8 @@
package com.sqx.modules.app.entity;
import cn.hutool.core.date.DateUtil;
import com.amazonaws.services.dynamodbv2.xspec.L;
import com.baomidou.mybatisplus.annotation.IdType;
//import com.amazonaws.services.dynamodbv2.xspec.L;
//import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -12,7 +12,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
//import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;

View File

@ -6,14 +6,15 @@ import com.sqx.modules.course.vo.CourseDetailsSetVo;
import com.sqx.modules.course.vo.CourseDetailsVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Mapper
@CacheConfig
public interface CourseDetailsDao extends BaseMapper<CourseDetails> {
/**
* @param courseId 剧的id
@ -21,9 +22,10 @@ public interface CourseDetailsDao extends BaseMapper<CourseDetails> {
* @param price 全剧价格
* @param wholesalePrice 10集价格
*/
List<CourseDetailsSetVo> courseSets(@Param("courseId") Long courseId, boolean isPrice, BigDecimal price, BigDecimal wholesalePrice);
@Cacheable(cacheNames = "courseSets" ,key = "#courseId")
List<CourseDetailsSetVo> courseSets(@Param("courseId") Long courseId, Integer isPrice, BigDecimal price, BigDecimal wholesalePrice);
List<CourseDetailsVo> courseDetails(@Param("courseId") Long courseId, @Param("collect") Integer collect,
List<CourseDetailsVo> courseDetails(@Param("courseId") Long courseId, @Param("collect") Long collect,
@Param("starSort") Integer starSort, @Param("endSort") Integer endSort);
List<CourseDetails> findByCourseId(@Param("id") Long id, @Param("userId") Long userId);
@ -42,6 +44,7 @@ public interface CourseDetailsDao extends BaseMapper<CourseDetails> {
*/
Map<String, Object> countCourse(Long courseId);
@Cacheable(cacheNames = "courseCount" ,key = "#courseId")
Integer countCourseByCourseId(Long courseId);
List<CourseDetails> countByCourseId();

View File

@ -46,15 +46,13 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -84,6 +82,7 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
@Override
@CacheEvict(cacheNames = {"courseSets", "courseCount"}, key = "#courseDetails.courseId")
public Result insert(CourseDetails courseDetails) {
if (courseDetails.getGoodNum() == null) {
courseDetails.setGoodNum(0);
@ -93,6 +92,7 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
}
@Override
@CacheEvict(cacheNames = {"courseSets", "courseCount"}, key = "#courseDetails.courseId")
public Result updateCourseDetails(CourseDetails courseDetails) {
baseMapper.updateById(courseDetails);
return Result.success();
@ -164,26 +164,36 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
boolean freeWatch = checkFreeWatchPayCount(userId);
List<CourseDetailsSetVo> courseDetailsSetVos;
if (freeWatch || courseUser != null) {
courseDetailsSetVos = baseMapper.courseSets(courseId, false, null, null);
courseDetailsSetVos = baseMapper.courseSets(courseId, 2, null, null);
} else {
courseDetailsSetVos = baseMapper.courseSets(courseId, true, bean.getPrice(), bean.getWholesalePrice());
// courseDetailsSetVos = baseMapper.courseSets(courseId, 1, bean.getPrice(), bean.getWholesalePrice());
courseDetailsSetVos = baseMapper.courseSets(courseId, 2, bean.getPrice(), bean.getWholesalePrice());
//查询用户是否单独购买了集
Set<Long> detailsId = courseUserDao.selectUserCourseDetailsId(courseId, userId);
if (courseCollect != null) {
for (CourseDetailsSetVo s : courseDetailsSetVos) {
if (s.getCourseDetailsId().equals(courseCollect.getCourseDetailsId())) {
s.setCurrent(1);
break;
}
}
} else {
courseDetailsSetVos.get(0).setCurrent(1);
}
if (CollectionUtil.isNotEmpty(detailsId)) {
courseDetailsSetVos = courseDetailsSetVos.stream()
.peek(s -> {
if (s.getCourseDetailsId().equals(courseCollect.getCourseDetailsId())) {
s.setCurrent(1);
}
if (detailsId.contains(s.getCourseDetailsId())) {
s.setIsPrice(2);
}
})
.filter(s -> s.getCurrent() == 1 || s.getIsPrice() == 2)
.collect(Collectors.toList());
}
}
return new Result().put("data", courseDetailsSetVos);
Map<String, Object> map = new HashMap<>();
map.put("title", bean.getTitle());
map.put("list", courseDetailsSetVos);
return new Result().put("data", map);
}
@Override
@ -198,9 +208,11 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
if (sort == null) {
CourseCollect courseCollect = courseCollectDao.selectOne(new QueryWrapper<CourseCollect>().eq("course_id", courseId)
.eq("user_id", userId).eq("classify", 3).last("limit 1"));
CourseDetails courseDetails = baseMapper.selectOne(new QueryWrapper<CourseDetails>()
.eq("course_details_id", courseCollect.getCourseDetailsId()).eq("course_id", courseCollect.getCourseId()).last("limit 1"));
sort = courseDetails.getSort();
if (courseCollect != null) {
CourseDetails courseDetails = baseMapper.selectOne(new QueryWrapper<CourseDetails>()
.eq("course_details_id", courseCollect.getCourseDetailsId()).eq("course_id", courseCollect.getCourseId()).last("limit 1"));
sort = courseDetails.getSort();
}
}
if (sort != null && sort > 2) {
startSort = sort - 3;
@ -210,11 +222,28 @@ public class CourseDetailsServiceImpl extends ServiceImpl<CourseDetailsDao, Cour
endSort = detailCount + 1;
}
}
//查询用户是否购买了整集
CourseUser courseUser = courseUserDao.selectCourseUser(courseId, userId);
boolean freeWatch = true;
if (courseUser == null) {
// 每天购买超过上限获得免费时间段资格
freeWatch = checkFreeWatchPayCount(userId);
}
Integer collect = courseCollectDao.selectCount(new QueryWrapper<CourseCollect>()
.eq("user_id", userId).eq("course_id", courseId)
.eq("classify", 1).last("limit 1"));
List<CourseDetailsVo> courseDetailsVos = baseMapper.courseDetails(courseId, collect, startSort, endSort);
Set<Long> detailsId = new HashSet<>();
//全剧免费
if ((!freeWatch)) {
detailsId = courseUserDao.selectUserCourseDetailsId(courseId, userId);
}
List<CourseDetailsVo> courseDetailsVos = baseMapper.courseDetails(courseId, collect == null ? 0L : 1L, startSort, endSort);
Set<Long> finalDetailsId = detailsId;
courseDetailsVos.stream().forEach(s -> {
// 不免费 3集以后 (已买的不为空 并不在已买的包含)
// if (!freeWatch && s.getSort() > 3 && (CollectionUtil.isEmpty(finalDetailsId) || !finalDetailsId.contains(s.getCourseDetailsId()))) {
// s.setVideoUrl(null);
// }
CourseCollect isGood = courseCollectDao.selectOne(new QueryWrapper<CourseCollect>()
.eq("user_id", userId).eq("course_details_id", s.getCourseDetailsId()).eq("classify", 2).last("limit 1"));
s.setIsGood(isGood == null ? 0 : 1);

View File

@ -49,6 +49,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
@ -149,6 +150,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
}
@Override
@CacheEvict(cacheNames = {"courseSets", "courseCount"}, key = "#course.courseId")
public Result updateCourse(Course course) {
baseMapper.updateById(course);
return Result.success("操作成功!");

View File

@ -13,4 +13,6 @@ public class CourseDetailsSetVo {
private Integer isPrice;
private BigDecimal price;
private BigDecimal wholesalePrice;
private BigDecimal countPrice;
private Integer sort;
}

View File

@ -22,9 +22,10 @@ public class CourseDetailsVo {
/**
* 是否已追
*/
private Integer isCollect;
private Long isCollect;
/**
* 是否点赞
*/
private Integer isGood;
private Integer sort;
}

View File

@ -4,9 +4,9 @@ package com.sqx.modules.file;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.tea.TeaException;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.ObjectMetadata;
//import com.amazonaws.services.s3.AmazonS3;
//import com.amazonaws.services.s3.model.CannedAccessControlList;
//import com.amazonaws.services.s3.model.ObjectMetadata;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
@ -56,12 +56,14 @@ public class AliFileUploadController {
private final CommonInfoService commonRepository;
private AmazonS3 amazonS3;
// private AmazonS3 amazonS3;
@Autowired
public AliFileUploadController(CommonInfoService commonRepository, AmazonS3 amazonS3) {
public AliFileUploadController(CommonInfoService commonRepository
// , AmazonS3 amazonS3
) {
this.commonRepository = commonRepository;
this.amazonS3 = amazonS3;
// this.amazonS3 = amazonS3;
}
@GetMapping(value = "/getCredentials")
@ -164,24 +166,24 @@ public class AliFileUploadController {
cosclient.shutdown();
}
}else if("3".equals(value)){
String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
// 上传文件流
InputStream inputStream = null;
try {
inputStream =new ByteArrayInputStream(file.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
String completePath=getPath(suffix);
String bucket=commonRepository.findOne(810).getValue();
com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest = new com.amazonaws.services.s3.model.PutObjectRequest(bucket, completePath, inputStream, new ObjectMetadata());
putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
com.amazonaws.services.s3.model.PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
IOUtils.closeQuietly(inputStream);
return Result.success().put("data",commonRepository.findOne(811).getValue()+"/"+completePath);
// String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
// // 上传文件流
// InputStream inputStream = null;
// try {
// inputStream =new ByteArrayInputStream(file.getBytes());
// } catch (IOException e) {
// e.printStackTrace();
// }
// String completePath=getPath(suffix);
// String bucket=commonRepository.findOne(810).getValue();
// com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest = new com.amazonaws.services.s3.model.PutObjectRequest(bucket, completePath, inputStream, new ObjectMetadata());
//
// putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
//
// com.amazonaws.services.s3.model.PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
//
// IOUtils.closeQuietly(inputStream);
// return Result.success().put("data",commonRepository.findOne(811).getValue()+"/"+completePath);
}else if("4".equals(value)){
String endpoint = "tos-cn-beijing.volces.com";
String region = "cn-beijing";
@ -301,24 +303,24 @@ public class AliFileUploadController {
cosclient.shutdown();
}
}else if("3".equals(value)){
String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
// 上传文件流
InputStream inputStream = null;
try {
inputStream =new ByteArrayInputStream(file.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
String completePath=getPath(suffix);
String bucket=commonRepository.findOne(810).getValue();
com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest = new com.amazonaws.services.s3.model.PutObjectRequest(bucket, completePath, inputStream, new ObjectMetadata());
putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
com.amazonaws.services.s3.model.PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
IOUtils.closeQuietly(inputStream);
return commonRepository.findOne(811).getValue()+"/"+completePath;
// String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
// // 上传文件流
// InputStream inputStream = null;
// try {
// inputStream =new ByteArrayInputStream(file.getBytes());
// } catch (IOException e) {
// e.printStackTrace();
// }
// String completePath=getPath(suffix);
// String bucket=commonRepository.findOne(810).getValue();
// com.amazonaws.services.s3.model.PutObjectRequest putObjectRequest = new com.amazonaws.services.s3.model.PutObjectRequest(bucket, completePath, inputStream, new ObjectMetadata());
//
// putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
//
// com.amazonaws.services.s3.model.PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
//
// IOUtils.closeQuietly(inputStream);
// return commonRepository.findOne(811).getValue()+"/"+completePath;
}else if("4".equals(value)){
String endpoint = "tos-cn-beijing.volces.com";
String region = "cn-beijing";

View File

@ -1,91 +1,91 @@
package com.sqx.modules.file;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.*;
import com.sqx.modules.common.service.CommonInfoService;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Service
public class S3Service {
@Autowired
private AmazonS3 amazonS3;
@Autowired
private CommonInfoService commonInfoService;
private PutObjectResult upload(String filePath, String uploadKey) throws FileNotFoundException {
return upload(new FileInputStream(filePath), uploadKey);
}
private PutObjectResult upload(InputStream inputStream, String uploadKey) {
PutObjectRequest putObjectRequest = new PutObjectRequest(commonInfoService.findOne(810).getValue(), uploadKey, inputStream, new ObjectMetadata());
putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
IOUtils.closeQuietly(inputStream);
return putObjectResult;
}
public List<PutObjectResult> upload(MultipartFile[] multipartFiles) {
List<PutObjectResult> putObjectResults = new ArrayList<>();
Arrays.stream(multipartFiles)
.filter(multipartFile -> !StringUtils.isEmpty(multipartFile.getOriginalFilename()))
.forEach(multipartFile -> {
try {
putObjectResults.add(upload(multipartFile.getInputStream(), multipartFile.getOriginalFilename()));
} catch (IOException e) {
e.printStackTrace();
}
});
return putObjectResults;
}
public ResponseEntity<byte[]> download(String key) throws IOException {
GetObjectRequest getObjectRequest = new GetObjectRequest(commonInfoService.findOne(810).getValue(), key);
S3Object s3Object = amazonS3.getObject(getObjectRequest);
S3ObjectInputStream objectInputStream = s3Object.getObjectContent();
byte[] bytes = IOUtils.toByteArray(objectInputStream);
String fileName = URLEncoder.encode(key, "UTF-8").replaceAll("\\+", "%20");
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
httpHeaders.setContentLength(bytes.length);
httpHeaders.setContentDispositionFormData("attachment", fileName);
return new ResponseEntity<>(bytes, httpHeaders, HttpStatus.OK);
}
public List<S3ObjectSummary> list() {
ObjectListing objectListing = amazonS3.listObjects(new ListObjectsRequest().withBucketName(commonInfoService.findOne(810).getValue()));
List<S3ObjectSummary> s3ObjectSummaries = objectListing.getObjectSummaries();
return s3ObjectSummaries;
}
}
//package com.sqx.modules.file;
//
//import com.amazonaws.services.s3.AmazonS3;
//import com.amazonaws.services.s3.model.*;
//import com.sqx.modules.common.service.CommonInfoService;
//import org.apache.commons.io.IOUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity;
//import org.springframework.stereotype.Service;
//import org.springframework.util.StringUtils;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.FileInputStream;
//import java.io.FileNotFoundException;
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.URLEncoder;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.List;
//
//@Service
//public class S3Service {
//
// @Autowired
// private AmazonS3 amazonS3;
// @Autowired
// private CommonInfoService commonInfoService;
//
// private PutObjectResult upload(String filePath, String uploadKey) throws FileNotFoundException {
// return upload(new FileInputStream(filePath), uploadKey);
// }
//
// private PutObjectResult upload(InputStream inputStream, String uploadKey) {
// PutObjectRequest putObjectRequest = new PutObjectRequest(commonInfoService.findOne(810).getValue(), uploadKey, inputStream, new ObjectMetadata());
//
// putObjectRequest.setCannedAcl(CannedAccessControlList.PublicRead);
//
// PutObjectResult putObjectResult = amazonS3.putObject(putObjectRequest);
//
// IOUtils.closeQuietly(inputStream);
//
// return putObjectResult;
// }
//
// public List<PutObjectResult> upload(MultipartFile[] multipartFiles) {
// List<PutObjectResult> putObjectResults = new ArrayList<>();
//
// Arrays.stream(multipartFiles)
// .filter(multipartFile -> !StringUtils.isEmpty(multipartFile.getOriginalFilename()))
// .forEach(multipartFile -> {
// try {
// putObjectResults.add(upload(multipartFile.getInputStream(), multipartFile.getOriginalFilename()));
// } catch (IOException e) {
// e.printStackTrace();
// }
// });
//
// return putObjectResults;
// }
//
// public ResponseEntity<byte[]> download(String key) throws IOException {
// GetObjectRequest getObjectRequest = new GetObjectRequest(commonInfoService.findOne(810).getValue(), key);
//
// S3Object s3Object = amazonS3.getObject(getObjectRequest);
//
// S3ObjectInputStream objectInputStream = s3Object.getObjectContent();
//
// byte[] bytes = IOUtils.toByteArray(objectInputStream);
//
// String fileName = URLEncoder.encode(key, "UTF-8").replaceAll("\\+", "%20");
//
// HttpHeaders httpHeaders = new HttpHeaders();
// httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
// httpHeaders.setContentLength(bytes.length);
// httpHeaders.setContentDispositionFormData("attachment", fileName);
//
// return new ResponseEntity<>(bytes, httpHeaders, HttpStatus.OK);
// }
//
// public List<S3ObjectSummary> list() {
// ObjectListing objectListing = amazonS3.listObjects(new ListObjectsRequest().withBucketName(commonInfoService.findOne(810).getValue()));
//
// List<S3ObjectSummary> s3ObjectSummaries = objectListing.getObjectSummaries();
//
// return s3ObjectSummaries;
// }
//}

View File

@ -1,34 +1,34 @@
package com.sqx.modules.file.config;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.sqx.modules.common.service.CommonInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@Configuration
@Component
public class AWSConfiguration {
@Autowired
private CommonInfoService commonInfoService;
@Bean
public BasicAWSCredentials basicAWSCredentials() {
return new BasicAWSCredentials(commonInfoService.findOne(807).getValue(), commonInfoService.findOne(808).getValue());
}
@Bean
public AmazonS3 amazonS3Client(AWSCredentials awsCredentials) {
AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
builder.withCredentials(new AWSStaticCredentialsProvider(awsCredentials));
builder.setRegion(commonInfoService.findOne(809).getValue());
AmazonS3 amazonS3 = builder.build();
return amazonS3;
}
}
//package com.sqx.modules.file.config;
//
//import com.amazonaws.auth.AWSCredentials;
//import com.amazonaws.auth.AWSStaticCredentialsProvider;
//import com.amazonaws.auth.BasicAWSCredentials;
//import com.amazonaws.services.s3.AmazonS3;
//import com.amazonaws.services.s3.AmazonS3ClientBuilder;
//import com.sqx.modules.common.service.CommonInfoService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.stereotype.Component;
//
//@Configuration
//@Component
//public class AWSConfiguration {
//
// @Autowired
// private CommonInfoService commonInfoService;
//
// @Bean
// public BasicAWSCredentials basicAWSCredentials() {
// return new BasicAWSCredentials(commonInfoService.findOne(807).getValue(), commonInfoService.findOne(808).getValue());
// }
//
// @Bean
// public AmazonS3 amazonS3Client(AWSCredentials awsCredentials) {
// AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard();
// builder.withCredentials(new AWSStaticCredentialsProvider(awsCredentials));
// builder.setRegion(commonInfoService.findOne(809).getValue());
// AmazonS3 amazonS3 = builder.build();
// return amazonS3;
// }
//}

View File

@ -1,6 +1,9 @@
#logging:
# file:
# name: logs/duanju.log
# 日志配置
logging:
file:
name: logs/duanju.log
config: classpath:logback.xml
# Tomcat
server:
@ -27,25 +30,6 @@ pagehelper:
supportMethodsArguments: true
params:
count: countSql
#mybatis-plus:
# mapper-locations: classpath*:/mapper/**/*.xml
# #实体扫描多个package用逗号或者分号分隔
# typeAliasesPackage: com.sqx.modules.*.entity
# global-config:
# #数据库相关配置
# db-config:
# #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
# id-type: AUTO
# logic-delete-value: -1
# logic-not-delete-value: 0
# banner: false
# #原生配置
# configuration:
# map-underscore-to-camel-case: true
# cache-enabled: false
# call-setters-on-nulls: true
# jdbc-type-for-null: 'null'
## log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
sqx:
redis:

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>logback</contextName>
<!-- 打印控制台格式 -->
<!--%d表示日期%thread表示线程名%-5level级别从左显示5个字符宽度%msg日志消息%n是换行符-->
<property name="p_console"
value="%green(%d) | %highlight(%-5level) [%thread] %yellow(%c) %cyan([%L]) -| %X{messageId} %msg %n"/>
<!--写入文件格式-->
<property name="p_file" value="%d | %-5level [%thread] %c [%L] -| %X{messageId} %msg %n"/>
<!--输出到控制台-->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${p_console}</pattern>
</encoder>
</appender>
<!--按天生成日志-->
<appender name="logFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/duanju.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--生成日志文件名称-->
<fileNamePattern>logs/duanju.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<maxFileSize>100MB</maxFileSize>
</rollingPolicy>
<!-- 日志输出格式 -->
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>${p_file}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 配置一些第三方包的日志过滤级别,用于避免刷屏 -->
<!-- 日志级别排序为: TRACE < DEBUG < INFO < WARN < ERROR-->
<!-- WARN [main] org.mybatis.spring.mapper.ClassPathMapperScanner-->
<!-- INFO [main] org.apache.shardingsphere.core.log.ConfigurationLogger-->
<logger name="org.springframework.context.support" level="WARN"/>
<logger name="org.apache.shardingsphere" level="WARN"/>
<logger name="org.mybatis.spring.mapper.ClassPathMapperScanner" level="ERROR"/>
<logger name="com.zaxxer.hikari" level="WARN"/>
<!-- 输出日志 -->
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="logFile"/>
</root>
</configuration>

View File

@ -3,13 +3,14 @@
<mapper namespace="com.sqx.modules.course.dao.CourseDetailsDao">
<select id="courseSets" resultType="com.sqx.modules.course.vo.CourseDetailsSetVo">
select c.course_id as courseId
, c.course_details_id as courseDetailsId
, c.course_details_name as courseDetailsName
, c.price as countPrice
, ifnull(#{price}, 0, #{price}) as price
, ifnull(#{wholesalePrice}, 0, #{wholesalePrice}) as wholesalePrice
, IF(#{isPrice}, c.is_price, 2) AS isPrice
select c.course_id as courseId
, c.course_details_id as courseDetailsId
, c.course_details_name as courseDetailsName
, c.price as countPrice
, c.sort as sort
, ifnull(#{price}, 0) as price
, ifnull(#{wholesalePrice}, 0) as wholesalePrice
, IF(#{isPrice} = 1, c.is_price, 2) AS isPrice
from course_details c
where c.course_id = #{courseId}
order by c.sort asc
@ -22,7 +23,8 @@
, c.title_img as titleImg
, c.video_url as videoUrl
, c.good_num as goodNum
, ifnull(#{collect}, 0, 1) as isCollect
, c.sort as sort
, IF(#{collect} = 1, 1, 0) AS isCollect
from course_details c
where c.course_id = #{courseId}
and sort &gt; #{starSort}