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 lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
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.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/oss/fileoss")
|
||||
@@ -32,4 +32,19 @@ public class OssController {
|
||||
String url = ossService.uploadFileAvatar(file);
|
||||
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;
|
||||
|
||||
import com.peanut.common.utils.R;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
public interface OssService {
|
||||
//上传头像到oss
|
||||
String uploadFileAvatar(MultipartFile file);
|
||||
|
||||
String uploadFileSchedule(MultipartFile file,String uid);
|
||||
|
||||
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.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.PutObjectRequest;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
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.web.multipart.MultipartFile;
|
||||
|
||||
@@ -17,51 +22,53 @@ import java.util.UUID;
|
||||
@Service
|
||||
public class OssServiceImpl implements OssService {
|
||||
|
||||
//上传头像到oss
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
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 accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
||||
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
||||
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
||||
|
||||
try {
|
||||
// 创建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;
|
||||
|
||||
//2 把文件按照日期进行分类
|
||||
//获取当前日期
|
||||
// 2019/11/12
|
||||
//2 把文件按照日期进行分类 拼接 2019/11/12/ewtqr313401.jpg
|
||||
String datePath = new DateTime().toString("yyyy/MM/dd");
|
||||
//拼接
|
||||
// 2019/11/12/ewtqr313401.jpg
|
||||
fileName = datePath+"/"+fileName;
|
||||
|
||||
//调用oss方法实现上传
|
||||
//第一个参数 Bucket名称
|
||||
//第二个参数 上传到oss文件路径和文件名称 aa/bb/1.jpg
|
||||
//第三个参数 上传文件输入流
|
||||
ossClient.putObject(bucketName,fileName , inputStream);
|
||||
|
||||
// 关闭OSSClient。
|
||||
ossClient.shutdown();
|
||||
|
||||
//把上传之后文件路径返回
|
||||
//需要把上传到阿里云oss路径手动拼接出来
|
||||
//把上传之后文件路径返回 需要把上传到阿里云oss路径手动拼接出来
|
||||
// https://edu-guli-1010.oss-cn-beijing.aliyuncs.com/01.jpg
|
||||
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;
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -76,48 +83,39 @@ public class OssServiceImpl implements OssService {
|
||||
String accessKeyId = ConstantPropertiesUtils.ACCESS_KEY_ID;
|
||||
String accessKeySecret = ConstantPropertiesUtils.ACCESS_KEY_SECRET;
|
||||
String bucketName = ConstantPropertiesUtils.BUCKET_NAME;
|
||||
|
||||
try {
|
||||
// 创建OSS实例。
|
||||
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());
|
||||
String fileName = name;
|
||||
//2 把文件按照日期进行分类
|
||||
//获取当前日期
|
||||
// 2019/11/12
|
||||
//2 把文件按照日期进行分类 获取当前日期 2019/11/12/ewtqr313401.jpg
|
||||
String datePath = new DateTime().toString("yyyy/MM/dd");
|
||||
//拼接
|
||||
// 2019/11/12/ewtqr313401.jpg
|
||||
fileName = datePath+"/"+fileName;
|
||||
|
||||
//调用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
|
||||
//把上传之后文件路径返回 需要把上传到阿里云oss路径手动拼接出来
|
||||
//https://edu-guli-1010.oss-cn-beijing.aliyuncs.com/01.jpg
|
||||
String url = "https://"+bucketName+"."+endpoint+"/"+fileName;
|
||||
|
||||
return url;
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
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")
|
||||
public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenDao, SysUserTokenEntity> implements SysUserTokenService {
|
||||
//10天后过期
|
||||
private final static int EXPIRE = 3600 * 12 * 10;
|
||||
private final static int EXPIRE = 3600 * 24 * 10;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -48,10 +48,12 @@ public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenDao, SysUse
|
||||
//保存token
|
||||
this.save(tokenEntity);
|
||||
}else{
|
||||
tokenEntity.setToken(token);
|
||||
if (tokenEntity.getExpireTime().getTime() > now.getTime()){
|
||||
token = tokenEntity.getToken();
|
||||
}
|
||||
tokenEntity.setToken(token);
|
||||
tokenEntity.setUpdateTime(now);
|
||||
tokenEntity.setExpireTime(expireTime);
|
||||
|
||||
//更新token
|
||||
this.updateById(tokenEntity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user