|
@@ -5,7 +5,6 @@ import cn.com.ty.lift.quan.news.dao.entity.QuanNews;
|
|
import cn.com.ty.lift.quan.news.dao.mapper.QuanNewsMapper;
|
|
import cn.com.ty.lift.quan.news.dao.mapper.QuanNewsMapper;
|
|
import cn.com.ty.lift.quan.news.service.QuanNewsService;
|
|
import cn.com.ty.lift.quan.news.service.QuanNewsService;
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
-import com.aliyun.oss.model.PutObjectResult;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
@@ -85,23 +84,23 @@ public class QuanNewsServiceImpl extends ServiceImpl<QuanNewsMapper, QuanNews> i
|
|
//如果不是置顶新闻
|
|
//如果不是置顶新闻
|
|
return RestResponse.ok(null, "1", "不是置顶新闻");
|
|
return RestResponse.ok(null, "1", "不是置顶新闻");
|
|
}
|
|
}
|
|
- byId.setTopSerial(0);
|
|
|
|
List<QuanNews> tops = this.list(new QueryWrapper<QuanNews>().select("id", "top_serial").ne("top_serial", 0).ne("id", id));
|
|
List<QuanNews> tops = this.list(new QueryWrapper<QuanNews>().select("id", "top_serial").ne("top_serial", 0).ne("id", id));
|
|
//如果置顶新闻为0个
|
|
//如果置顶新闻为0个
|
|
if (tops.isEmpty()) {
|
|
if (tops.isEmpty()) {
|
|
|
|
+ byId.setTopSerial(0);
|
|
if (this.updateById(byId)) {
|
|
if (this.updateById(byId)) {
|
|
return RestResponse.ok(null, "1", "取消置顶成功");
|
|
return RestResponse.ok(null, "1", "取消置顶成功");
|
|
} else {
|
|
} else {
|
|
return RestResponse.ok(null, "0", "取消置顶失败");
|
|
return RestResponse.ok(null, "0", "取消置顶失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
//比这个新闻排序大的都 序号-1
|
|
//比这个新闻排序大的都 序号-1
|
|
tops.forEach(top -> {
|
|
tops.forEach(top -> {
|
|
if (top.getTopSerial() > byId.getTopSerial()) {
|
|
if (top.getTopSerial() > byId.getTopSerial()) {
|
|
top.setTopSerial(top.getTopSerial() - 1);
|
|
top.setTopSerial(top.getTopSerial() - 1);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ byId.setTopSerial(0);
|
|
if (this.updateById(byId) && this.updateBatchById(tops)) {
|
|
if (this.updateById(byId) && this.updateBatchById(tops)) {
|
|
return RestResponse.ok(null, "1", "取消置顶成功");
|
|
return RestResponse.ok(null, "1", "取消置顶成功");
|
|
} else {
|
|
} else {
|
|
@@ -127,7 +126,6 @@ public class QuanNewsServiceImpl extends ServiceImpl<QuanNewsMapper, QuanNews> i
|
|
}
|
|
}
|
|
|
|
|
|
public RestResponse addNew(QuanNews quanNews, MultipartFile videoFile, Integer isTop) {
|
|
public RestResponse addNew(QuanNews quanNews, MultipartFile videoFile, Integer isTop) {
|
|
-// String title, String content, MultipartFile videoFile, Integer isTop, Long releaseId, String releaseUser
|
|
|
|
//上传视频到Oss,获取视频地址
|
|
//上传视频到Oss,获取视频地址
|
|
//上传视频到Oss,获取视频地址
|
|
//上传视频到Oss,获取视频地址
|
|
//获取发布人名称
|
|
//获取发布人名称
|
|
@@ -224,8 +222,7 @@ public class QuanNewsServiceImpl extends ServiceImpl<QuanNewsMapper, QuanNews> i
|
|
String fileName = IdWorker.getIdStr() + "." + substring;
|
|
String fileName = IdWorker.getIdStr() + "." + substring;
|
|
new Thread(() -> {
|
|
new Thread(() -> {
|
|
try {
|
|
try {
|
|
- ////////////////需要判断是否成功
|
|
|
|
- new AliyunOSSUtil().putObject("temp15827479607", videoFile.getBytes(), fileName);
|
|
|
|
|
|
+ new AliyunOSSUtil().putObject("temp15827479607", videoFile.getBytes(), fileName);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|