Merge remote-tracking branch 'origin/master' into wumedical/v1
# Conflicts: # src/main/java/com/peanut/modules/common/dao/ChineseMedicineResearchDao.java # src/main/java/com/peanut/modules/common/dao/GeneralArticleDao.java # src/main/java/com/peanut/modules/common/entity/ChineseMedicineResearch.java # src/main/java/com/peanut/modules/common/entity/GeneralArticle.java
This commit is contained in:
@@ -0,0 +1,71 @@
|
|||||||
|
package com.peanut.modules.book.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.book.entity.ChineseMedicineResearch;
|
||||||
|
import com.peanut.modules.book.service.ChineseMedicineResearchService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("book/chineseMedicineResearch")
|
||||||
|
public class ChineseMedicineResearchController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ChineseMedicineResearchService chineseMedicineResearchService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中医研究列表
|
||||||
|
*/
|
||||||
|
@RequestMapping(path = "/researchByType")
|
||||||
|
public R researchByType(String type) {
|
||||||
|
LambdaQueryWrapper<ChineseMedicineResearch> wrapper = new LambdaQueryWrapper();
|
||||||
|
if (StringUtils.isNotEmpty(type)){
|
||||||
|
wrapper.eq(ChineseMedicineResearch::getType,type);
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(ChineseMedicineResearch::getSort);
|
||||||
|
List<ChineseMedicineResearch> list = chineseMedicineResearchService.list(wrapper);
|
||||||
|
return R.ok().put("result", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中医研究列表
|
||||||
|
*/
|
||||||
|
@RequestMapping(path = "/researchByPage")
|
||||||
|
public R researchByPage(@RequestBody Map map) {
|
||||||
|
LambdaQueryWrapper<ChineseMedicineResearch> wrapper = new LambdaQueryWrapper();
|
||||||
|
if (map.containsKey("type")&&StringUtils.isNotEmpty(map.get("type").toString())){
|
||||||
|
wrapper.eq(ChineseMedicineResearch::getType,map.get("type"));
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(ChineseMedicineResearch::getSort);
|
||||||
|
Page<ChineseMedicineResearch> page = chineseMedicineResearchService.page(new Page<>(
|
||||||
|
Long.parseLong(map.get("current").toString()), Long.parseLong(map.get("limit").toString())),wrapper);
|
||||||
|
return R.ok().put("result", page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(path = "/getResearchById")
|
||||||
|
public R getResearchById(String id) {
|
||||||
|
return R.ok().put("result",chineseMedicineResearchService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(path = "/saveOrUpdateResearch")
|
||||||
|
public R saveOrUpdateResearch(@RequestBody ChineseMedicineResearch research) {
|
||||||
|
chineseMedicineResearchService.saveOrUpdate(research);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(path = "/delResearch")
|
||||||
|
public R delResearch(String id) {
|
||||||
|
chineseMedicineResearchService.removeById(id);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.peanut.modules.book.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.book.entity.GeneralArticle;
|
||||||
|
import com.peanut.modules.book.service.GeneralArticleService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("book/generalArticle")
|
||||||
|
public class GeneralArticleController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GeneralArticleService generalArticleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章列表分页
|
||||||
|
*/
|
||||||
|
@RequestMapping(path = "/articleByPage")
|
||||||
|
public R articleByPage(@RequestBody Map map) {
|
||||||
|
LambdaQueryWrapper<GeneralArticle> wrapper = new LambdaQueryWrapper();
|
||||||
|
if (StringUtils.isNotEmpty(map.get("type").toString())){
|
||||||
|
wrapper.eq(GeneralArticle::getType,map.get("type"));
|
||||||
|
}
|
||||||
|
wrapper.orderByAsc(GeneralArticle::getSort);
|
||||||
|
Page<GeneralArticle> page = generalArticleService.page(new Page<>(
|
||||||
|
Long.parseLong(map.get("current").toString()), Long.parseLong(map.get("limit").toString())),wrapper);
|
||||||
|
return R.ok().put("result", page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(path = "/getArticleById")
|
||||||
|
public R getArticleById(String id) {
|
||||||
|
return R.ok().put("result",generalArticleService.getById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(path = "/saveOrUpdateArticle")
|
||||||
|
public R saveOrUpdateArticle(@RequestBody GeneralArticle article) {
|
||||||
|
generalArticleService.saveOrUpdate(article);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(path = "/delArticle")
|
||||||
|
public R delArticle(String id) {
|
||||||
|
generalArticleService.removeById(id);
|
||||||
|
return R.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.peanut.modules.book.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.peanut.modules.book.entity.ChineseMedicineResearch;
|
||||||
|
|
||||||
|
public interface ChineseMedicineResearchService extends IService<ChineseMedicineResearch> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.peanut.modules.book.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.peanut.modules.book.entity.GeneralArticle;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public interface GeneralArticleService extends IService<GeneralArticle> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.peanut.modules.book.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.peanut.modules.book.dao.ChineseMedicineResearchDao;
|
||||||
|
import com.peanut.modules.book.entity.ChineseMedicineResearch;
|
||||||
|
import com.peanut.modules.book.service.ChineseMedicineResearchService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service("chineseMedicineResearchService")
|
||||||
|
public class ChineseMedicineResearchServiceImpl extends ServiceImpl<ChineseMedicineResearchDao, ChineseMedicineResearch> implements ChineseMedicineResearchService {
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.peanut.modules.book.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.peanut.modules.book.dao.GeneralArticleDao;
|
||||||
|
import com.peanut.modules.book.entity.GeneralArticle;
|
||||||
|
import com.peanut.modules.book.service.GeneralArticleService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GeneralArticleServiceImpl extends ServiceImpl<GeneralArticleDao, GeneralArticle> implements GeneralArticleService {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.peanut.modules.book.dao;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.peanut.modules.book.entity.ChineseMedicineResearch;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ChineseMedicineResearchDao extends MPJBaseMapper<ChineseMedicineResearch> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.peanut.modules.book.dao;
|
||||||
|
|
||||||
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
|
import com.peanut.modules.book.entity.GeneralArticle;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface GeneralArticleDao extends MPJBaseMapper<GeneralArticle> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.peanut.modules.book.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("chinese_medicine_research")
|
||||||
|
public class ChineseMedicineResearch implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标签(中医经典,中医基础,中医临床,针灸推拿,中药研究)
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 链接(公微链接)
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 照片
|
||||||
|
*/
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件地址
|
||||||
|
*/
|
||||||
|
private String file;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 期刊文章引用方式
|
||||||
|
*/
|
||||||
|
private String articleCitation;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.peanut.modules.book.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("general_article")
|
||||||
|
public class GeneralArticle implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 外链
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文章类型 1文章 2外链形式
|
||||||
|
*/
|
||||||
|
private Integer contentType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型 1学术思想 2学术平台
|
||||||
|
*/
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
@TableLogic
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,11 +7,11 @@ import io.swagger.annotations.Api;
|
|||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/oss/fileoss")
|
@RequestMapping("/oss/fileoss")
|
||||||
@@ -32,4 +32,19 @@ public class OssController {
|
|||||||
String url = ossService.uploadFileAvatar(file);
|
String url = ossService.uploadFileAvatar(file);
|
||||||
return R.ok().put("url",url);
|
return R.ok().put("url",url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/uploadFileSchedule")
|
||||||
|
@ApiOperation("上传带进度条")
|
||||||
|
public R uploadFileSchedule(@RequestParam("file") MultipartFile file,@RequestParam("uid") String uid) {
|
||||||
|
String url = ossService.uploadFileSchedule(file,uid);
|
||||||
|
return R.ok().put("url",url);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取进度条
|
||||||
|
@GetMapping("/getSchedule")
|
||||||
|
public R getSchedule(String uid){
|
||||||
|
return ossService.getSchedule(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package com.peanut.modules.oss.controller;
|
||||||
|
|
||||||
|
import com.aliyun.oss.event.ProgressEvent;
|
||||||
|
import com.aliyun.oss.event.ProgressEventType;
|
||||||
|
import com.aliyun.oss.event.ProgressListener;
|
||||||
|
import com.peanut.common.utils.SpringContextUtils;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class PutObjectProgressListener implements ProgressListener {
|
||||||
|
|
||||||
|
private long bytesWritten = 0;
|
||||||
|
private long totalBytes = 0;
|
||||||
|
private String uid = "";
|
||||||
|
private String url = "";
|
||||||
|
|
||||||
|
public PutObjectProgressListener() {
|
||||||
|
}
|
||||||
|
public PutObjectProgressListener(long fileSize,String uid,String url) {
|
||||||
|
this.totalBytes = fileSize;
|
||||||
|
this.uid = uid;
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void progressChanged(ProgressEvent progressEvent) {
|
||||||
|
long bytes = progressEvent.getBytes();
|
||||||
|
ProgressEventType eventType = progressEvent.getEventType();
|
||||||
|
StringRedisTemplate redisTemplate = (StringRedisTemplate)SpringContextUtils.getBean("stringRedisTemplate");
|
||||||
|
switch (eventType) {
|
||||||
|
case TRANSFER_STARTED_EVENT:
|
||||||
|
// System.out.println("Start to upload......");
|
||||||
|
// break;
|
||||||
|
case REQUEST_CONTENT_LENGTH_EVENT:
|
||||||
|
//因为传的是文件流,不走此路
|
||||||
|
// this.totalBytes = bytes;
|
||||||
|
// System.out.println(this.totalBytes + " bytes in total will be uploaded to OSS");
|
||||||
|
// break;
|
||||||
|
case REQUEST_BYTE_TRANSFER_EVENT:
|
||||||
|
this.bytesWritten += bytes;
|
||||||
|
int percent = (int)(this.bytesWritten * 100.0 / this.totalBytes);
|
||||||
|
// System.out.println(bytes + " bytes have been written at this time, upload progress: " + percent + "%(" + this.bytesWritten + "/" + this.totalBytes + ")");
|
||||||
|
redisTemplate.opsForValue().set(uid,percent+";"+url);
|
||||||
|
redisTemplate.expire(uid, 600, TimeUnit.SECONDS);
|
||||||
|
break;
|
||||||
|
case TRANSFER_COMPLETED_EVENT:
|
||||||
|
// this.succeed = true;
|
||||||
|
// System.out.println("Succeed to upload, " + this.bytesWritten + " bytes have been transferred in total");
|
||||||
|
// break;
|
||||||
|
case TRANSFER_FAILED_EVENT:
|
||||||
|
// System.out.println("Failed to upload, " + this.bytesWritten + " bytes have been transferred");
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
package com.peanut.modules.oss.service;
|
package com.peanut.modules.oss.service;
|
||||||
|
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
public interface OssService {
|
public interface OssService {
|
||||||
//上传头像到oss
|
//上传头像到oss
|
||||||
String uploadFileAvatar(MultipartFile file);
|
String uploadFileAvatar(MultipartFile file);
|
||||||
|
|
||||||
|
String uploadFileSchedule(MultipartFile file,String uid);
|
||||||
|
|
||||||
String uploadHtml(String html,String name);
|
String uploadHtml(String html,String name);
|
||||||
|
|
||||||
|
R getSchedule(String uid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,15 @@ package com.peanut.modules.oss.service.impl;
|
|||||||
|
|
||||||
import com.aliyun.oss.OSS;
|
import com.aliyun.oss.OSS;
|
||||||
import com.aliyun.oss.OSSClientBuilder;
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
import com.peanut.common.utils.ConstantPropertiesUtils;
|
import com.peanut.common.utils.ConstantPropertiesUtils;
|
||||||
|
import com.peanut.common.utils.R;
|
||||||
|
import com.peanut.modules.oss.controller.PutObjectProgressListener;
|
||||||
import com.peanut.modules.oss.service.OssService;
|
import com.peanut.modules.oss.service.OssService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@@ -17,51 +22,53 @@ import java.util.UUID;
|
|||||||
@Service
|
@Service
|
||||||
public class OssServiceImpl implements OssService {
|
public class OssServiceImpl implements OssService {
|
||||||
|
|
||||||
//上传头像到oss
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadFileAvatar(MultipartFile file) {
|
public String uploadFileAvatar(MultipartFile file) {
|
||||||
|
return uploadFile(file,"");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadFileSchedule(MultipartFile file,String uid) {
|
||||||
|
return uploadFile(file,uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String uploadFile(MultipartFile file,String uid){
|
||||||
// 工具类获取值
|
// 工具类获取值
|
||||||
String endpoint = ConstantPropertiesUtils.END_POIND;
|
String endpoint = ConstantPropertiesUtils.END_POIND;
|
||||||
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
||||||
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
||||||
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 创建OSS实例。
|
// 创建OSS实例。
|
||||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||||
|
|
||||||
|
|
||||||
//获取上传文件输入流
|
//获取上传文件输入流
|
||||||
InputStream inputStream = file.getInputStream();
|
InputStream inputStream = file.getInputStream();
|
||||||
//获取文件名称
|
//获取文件名称
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
//1 在文件名称里面添加随机唯一的值
|
//1 在文件名称里面添加随机唯一的值
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
||||||
// yuy76t5rew01.jpg
|
|
||||||
fileName = uuid+fileName;
|
fileName = uuid+fileName;
|
||||||
|
//2 把文件按照日期进行分类 拼接 2019/11/12/ewtqr313401.jpg
|
||||||
//2 把文件按照日期进行分类
|
|
||||||
//获取当前日期
|
|
||||||
// 2019/11/12
|
|
||||||
String datePath = new DateTime().toString("yyyy/MM/dd");
|
String datePath = new DateTime().toString("yyyy/MM/dd");
|
||||||
//拼接
|
|
||||||
// 2019/11/12/ewtqr313401.jpg
|
|
||||||
fileName = datePath+"/"+fileName;
|
fileName = datePath+"/"+fileName;
|
||||||
|
//把上传之后文件路径返回 需要把上传到阿里云oss路径手动拼接出来
|
||||||
//调用oss方法实现上传
|
|
||||||
//第一个参数 Bucket名称
|
|
||||||
//第二个参数 上传到oss文件路径和文件名称 aa/bb/1.jpg
|
|
||||||
//第三个参数 上传文件输入流
|
|
||||||
ossClient.putObject(bucketName,fileName , inputStream);
|
|
||||||
|
|
||||||
// 关闭OSSClient。
|
|
||||||
ossClient.shutdown();
|
|
||||||
|
|
||||||
//把上传之后文件路径返回
|
|
||||||
//需要把上传到阿里云oss路径手动拼接出来
|
|
||||||
// https://edu-guli-1010.oss-cn-beijing.aliyuncs.com/01.jpg
|
// https://edu-guli-1010.oss-cn-beijing.aliyuncs.com/01.jpg
|
||||||
String url = "https://"+bucketName+"."+endpoint+"/"+fileName;
|
String url = "https://"+bucketName+"."+endpoint+"/"+fileName;
|
||||||
|
//调用oss方法实现上传
|
||||||
|
if ("".equals(uid)){
|
||||||
|
ossClient.putObject(bucketName,fileName, inputStream);
|
||||||
|
}else {
|
||||||
|
//带进度条
|
||||||
|
long fileSize = file.getSize();
|
||||||
|
System.out.println(uid+ "" +url);
|
||||||
|
ossClient.putObject(new PutObjectRequest(bucketName,fileName, inputStream).
|
||||||
|
withProgressListener(new PutObjectProgressListener(fileSize,uid,url)));
|
||||||
|
}
|
||||||
|
// 关闭OSSClient。
|
||||||
|
ossClient.shutdown();
|
||||||
return url;
|
return url;
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -76,48 +83,39 @@ public class OssServiceImpl implements OssService {
|
|||||||
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
||||||
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
||||||
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 创建OSS实例。
|
// 创建OSS实例。
|
||||||
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||||
|
|
||||||
|
|
||||||
//获取上传文件输入流
|
|
||||||
// InputStream inputStream = file.getInputStream();
|
|
||||||
//获取文件名称
|
|
||||||
// String fileName = file.getOriginalFilename();
|
|
||||||
//1 在文件名称里面添加随机唯一的值
|
|
||||||
// String uuid = UUID.randomUUID().toString().replaceAll("-","");
|
|
||||||
// yuy76t5rew01.jpg
|
|
||||||
// fileName = uuid+fileName;
|
|
||||||
InputStream inputStream = new ByteArrayInputStream(html.getBytes());
|
InputStream inputStream = new ByteArrayInputStream(html.getBytes());
|
||||||
String fileName = name;
|
String fileName = name;
|
||||||
//2 把文件按照日期进行分类
|
//2 把文件按照日期进行分类 获取当前日期 2019/11/12/ewtqr313401.jpg
|
||||||
//获取当前日期
|
|
||||||
// 2019/11/12
|
|
||||||
String datePath = new DateTime().toString("yyyy/MM/dd");
|
String datePath = new DateTime().toString("yyyy/MM/dd");
|
||||||
//拼接
|
|
||||||
// 2019/11/12/ewtqr313401.jpg
|
|
||||||
fileName = datePath+"/"+fileName;
|
fileName = datePath+"/"+fileName;
|
||||||
|
|
||||||
//调用oss方法实现上传
|
//调用oss方法实现上传
|
||||||
//第一个参数 Bucket名称
|
|
||||||
//第二个参数 上传到oss文件路径和文件名称 aa/bb/1.jpg
|
|
||||||
//第三个参数 上传文件输入流
|
|
||||||
ossClient.putObject(bucketName,fileName , inputStream);
|
ossClient.putObject(bucketName,fileName , inputStream);
|
||||||
|
|
||||||
// 关闭OSSClient。
|
// 关闭OSSClient。
|
||||||
ossClient.shutdown();
|
ossClient.shutdown();
|
||||||
|
//把上传之后文件路径返回 需要把上传到阿里云oss路径手动拼接出来
|
||||||
//把上传之后文件路径返回
|
//https://edu-guli-1010.oss-cn-beijing.aliyuncs.com/01.jpg
|
||||||
//需要把上传到阿里云oss路径手动拼接出来
|
|
||||||
// https://edu-guli-1010.oss-cn-beijing.aliyuncs.com/01.jpg
|
|
||||||
String url = "https://"+bucketName+"."+endpoint+"/"+fileName;
|
String url = "https://"+bucketName+"."+endpoint+"/"+fileName;
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R getSchedule(String uid) {
|
||||||
|
R result = new R();
|
||||||
|
result.put("percent","");
|
||||||
|
result.put("url","");
|
||||||
|
String str = redisTemplate.opsForValue().get(uid);
|
||||||
|
if (str!=null&&str.contains(";")){
|
||||||
|
String[] strs = str.split(";");
|
||||||
|
result.put("percent",strs[0]);
|
||||||
|
result.put("url",strs[1]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import java.util.Date;
|
|||||||
@Service("sysUserTokenService")
|
@Service("sysUserTokenService")
|
||||||
public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenDao, SysUserTokenEntity> implements SysUserTokenService {
|
public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenDao, SysUserTokenEntity> implements SysUserTokenService {
|
||||||
//10天后过期
|
//10天后过期
|
||||||
private final static int EXPIRE = 3600 * 12 * 10;
|
private final static int EXPIRE = 3600 * 24 * 10;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,10 +48,12 @@ public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenDao, SysUse
|
|||||||
//保存token
|
//保存token
|
||||||
this.save(tokenEntity);
|
this.save(tokenEntity);
|
||||||
}else{
|
}else{
|
||||||
|
if (tokenEntity.getExpireTime().getTime() > now.getTime()){
|
||||||
|
token = tokenEntity.getToken();
|
||||||
|
}
|
||||||
tokenEntity.setToken(token);
|
tokenEntity.setToken(token);
|
||||||
tokenEntity.setUpdateTime(now);
|
tokenEntity.setUpdateTime(now);
|
||||||
tokenEntity.setExpireTime(expireTime);
|
tokenEntity.setExpireTime(expireTime);
|
||||||
|
|
||||||
//更新token
|
//更新token
|
||||||
this.updateById(tokenEntity);
|
this.updateById(tokenEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ wxpay:
|
|||||||
notifyUrl: https://testapi.nuttyreading.com/pay/payNotify
|
notifyUrl: https://testapi.nuttyreading.com/pay/payNotify
|
||||||
refundUrl: https://api.mch.weixin.qq.com/v3/refund/domestic/refunds
|
refundUrl: https://api.mch.weixin.qq.com/v3/refund/domestic/refunds
|
||||||
refundNotifyUrl: https://testapi.nuttyreading.com/pay/refundNotify
|
refundNotifyUrl: https://testapi.nuttyreading.com/pay/refundNotify
|
||||||
keyPemPath: D:/hs/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
keyPemPath: F:\ideaProject\peanutBook\src\main\resources\cent\apiclient_key.pem
|
||||||
serialNo: 679AECB2F7AC4183033F713828892BA640E4EEE3
|
serialNo: 679AECB2F7AC4183033F713828892BA640E4EEE3
|
||||||
apiV3Key: 4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
|
apiV3Key: 4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
|
||||||
wechatPayCertificateUrl: D:/hs/nuttyreading-java/src/main/resources/cent/wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
wechatPayCertificateUrl: F:\ideaProject\peanutBook\src\main\resources\cent\wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
||||||
privateKeyUrl: D:/hs/nuttyreading-java/src/main/resources/cent/apiclient_key.pem
|
privateKeyUrl: F:\ideaProject\peanutBook\src\main\resources\cent\apiclient_key.pem
|
||||||
|
|
||||||
|
|
||||||
redisAddress: redis://47.93.127.115:6379
|
redisAddress: redis://47.93.127.115:6379
|
||||||
|
|||||||
93
src/main/resources/application-dev1.yml
Normal file
93
src/main/resources/application-dev1.yml
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
spring:
|
||||||
|
redis:
|
||||||
|
open: false # 是否开启redis缓存 true开启 false关闭
|
||||||
|
database: 0
|
||||||
|
host: 47.93.127.115
|
||||||
|
port: 6379
|
||||||
|
password: Jgll2015 # 密码(默认为空)
|
||||||
|
timeout: 6000000ms # 连接超时时长(毫秒)
|
||||||
|
jedis:
|
||||||
|
pool:
|
||||||
|
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制)
|
||||||
|
max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||||
|
max-idle: 10 # 连接池中的最大空闲连接
|
||||||
|
min-idle: 5 # 连接池中的最小空闲连接
|
||||||
|
datasource:
|
||||||
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
|
druid:
|
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
|
url: jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/e_book_test
|
||||||
|
# username: root
|
||||||
|
# password: HSXY1234hsxy
|
||||||
|
# password: Jgll2023Nutty
|
||||||
|
username: nuttyreading
|
||||||
|
password: Wu751019!
|
||||||
|
initial-size: 10
|
||||||
|
max-active: 100
|
||||||
|
min-idle: 10
|
||||||
|
max-wait: 60000
|
||||||
|
pool-prepared-statements: true
|
||||||
|
max-pool-prepared-statement-per-connection-size: 20
|
||||||
|
time-between-eviction-runs-millis: 60000
|
||||||
|
min-evictable-idle-time-millis: 300000
|
||||||
|
#Oracle需要打开注释
|
||||||
|
#validation-query: SELECT 1 FROM DUAL
|
||||||
|
test-while-idle: true
|
||||||
|
test-on-borrow: false
|
||||||
|
test-on-return: false
|
||||||
|
stat-view-servlet:
|
||||||
|
enabled: true
|
||||||
|
url-pattern: /druid/*
|
||||||
|
#login-username: admin
|
||||||
|
#login-password: admin
|
||||||
|
filter:
|
||||||
|
stat:
|
||||||
|
log-slow-sql: true
|
||||||
|
slow-sql-millis: 1000
|
||||||
|
merge-sql: false
|
||||||
|
wall:
|
||||||
|
config:
|
||||||
|
multi-statement-allow: true
|
||||||
|
tomcat:
|
||||||
|
initSQL: SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci
|
||||||
|
|
||||||
|
rabbitmq:
|
||||||
|
host: 47.93.127.115
|
||||||
|
port: 5672
|
||||||
|
username: admin
|
||||||
|
password: 751019
|
||||||
|
virtualHost: /
|
||||||
|
aliyun:
|
||||||
|
oss:
|
||||||
|
file:
|
||||||
|
endpoint: oss-cn-beijing.aliyuncs.com
|
||||||
|
keyid: LTAIiSMeo8ztauV5
|
||||||
|
keysecret: pVIYAOIFSUGg61lYfE8cjg2ZNpnLJA
|
||||||
|
bucketname: ehh-private-01
|
||||||
|
sms:
|
||||||
|
accessKeyId: LTAI5tJbbw5fY97pnw635yq3
|
||||||
|
accessKeySecret: LTXQ9v3OYVwNVbDWWfVpbbcVDKErKi
|
||||||
|
singName: 疯子读书国际
|
||||||
|
templateCode: SMS_248840040
|
||||||
|
sTemplateCode: SMS_463780139
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 9200
|
||||||
|
|
||||||
|
|
||||||
|
wxpay:
|
||||||
|
appId: wx47134a8f15083734
|
||||||
|
mchId: 1612860909
|
||||||
|
payUrl: https://api.mch.weixin.qq.com/v3/pay/transactions/app
|
||||||
|
notifyUrl: https://testapi.nuttyreading.com/pay/payNotify
|
||||||
|
refundUrl: https://api.mch.weixin.qq.com/v3/refund/domestic/refunds
|
||||||
|
refundNotifyUrl: https://testapi.nuttyreading.com/pay/refundNotify
|
||||||
|
keyPemPath: D:\hs\nuttyreading-java\src\main\resources\cent\apiclient_key.pem
|
||||||
|
serialNo: 679AECB2F7AC4183033F713828892BA640E4EEE3
|
||||||
|
apiV3Key: 4aYFklzaULeGlr7oJPZ6rHWKcxjihZUF
|
||||||
|
wechatPayCertificateUrl: D:\hs\nuttyreading-java\src\main\resources\cent\wechatpay_7B5676E3CDF56680D0414A009CE501C844DBE2D6.pem
|
||||||
|
privateKeyUrl: D:\hs\nuttyreading-java\src\main\resources\cent\apiclient_key.pem
|
||||||
|
|
||||||
|
|
||||||
|
redisAddress: redis://47.93.127.115:6379
|
||||||
|
redisPassword: Jgll2015
|
||||||
@@ -9,9 +9,9 @@ server:
|
|||||||
|
|
||||||
connection-timeout: 6000000ms
|
connection-timeout: 6000000ms
|
||||||
spring:
|
spring:
|
||||||
# 环境 dev|test|prod
|
# 环境 dev/dev1|test|prod
|
||||||
profiles:
|
profiles:
|
||||||
active: dev
|
active: dev1
|
||||||
# jackson时间格式化
|
# jackson时间格式化
|
||||||
jackson:
|
jackson:
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
|
|||||||
@@ -186,7 +186,7 @@
|
|||||||
<!-- <!– 4. 最终的策略 –>-->
|
<!-- <!– 4. 最终的策略 –>-->
|
||||||
<!-- <!– 4.1 开发环境:打印控制台–>-->
|
<!-- <!– 4.1 开发环境:打印控制台–>-->
|
||||||
|
|
||||||
<springProfile name="dev">
|
<springProfile name="dev,dev1">
|
||||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||||
<!-- <logger name="org.springframework.web" level="DEBUG"/>-->
|
<!-- <logger name="org.springframework.web" level="DEBUG"/>-->
|
||||||
<!-- <logger name="org.springboot.sample" level="DEBUG" />-->
|
<!-- <logger name="org.springboot.sample" level="DEBUG" />-->
|
||||||
|
|||||||
Reference in New Issue
Block a user