|
|
@@ -2,14 +2,20 @@ package com.fdkankan.manage.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.fdkankan.common.constant.CommonStatus;
|
|
|
+import com.fdkankan.common.constant.TbStatus;
|
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
import com.fdkankan.manage.entity.News;
|
|
|
import com.fdkankan.manage.mapper.INewsMapper;
|
|
|
import com.fdkankan.manage.service.INewsService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fdkankan.manage.vo.BaseParamVO;
|
|
|
import com.fdkankan.manage.vo.NewsDisplayParamVO;
|
|
|
+import com.fdkankan.manage.vo.NewsPublicParamVO;
|
|
|
+import com.fdkankan.manage.vo.NewsPutTopParamVO;
|
|
|
import com.fdkankan.manage.vo.PageNewsParamVO;
|
|
|
import com.fdkankan.manage.vo.PageNewsVO;
|
|
|
+import java.util.Calendar;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
/**
|
|
|
@@ -31,10 +37,58 @@ public class NewsServiceImpl extends ServiceImpl<INewsMapper, News> implements I
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResultData display(NewsDisplayParamVO param) {
|
|
|
+ public ResultData display(Long userId, NewsDisplayParamVO param) {
|
|
|
this.update(new LambdaUpdateWrapper<News>()
|
|
|
.set(News::getDisplay, param.getDisplay())
|
|
|
+ .set(News::getUpdateTime, Calendar.getInstance().getTime())
|
|
|
+ .set(News::getUpdaterId, userId)
|
|
|
.eq(News::getId, param.getId()));
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData putTop(Long userId, NewsPutTopParamVO param) {
|
|
|
+
|
|
|
+ LambdaUpdateWrapper<News> updateWrapper = new LambdaUpdateWrapper<News>()
|
|
|
+ .set(News::getIsTop, param.getIsTop())
|
|
|
+ .set(News::getUpdateTime, Calendar.getInstance().getTime())
|
|
|
+ .set(News::getUpdaterId, userId)
|
|
|
+ .eq(News::getId, param.getId());
|
|
|
+ if(CommonStatus.YES.code() == param.getIsTop().byteValue()){
|
|
|
+ updateWrapper.set(News::getTopTime, Calendar.getInstance().getTime());
|
|
|
+ }
|
|
|
+ this.update(updateWrapper);
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData publicNews(Long userId, NewsPublicParamVO param) {
|
|
|
+ LambdaUpdateWrapper<News> updateWrapper = new LambdaUpdateWrapper<News>()
|
|
|
+ .set(News::getIsPublic, param.getIsPublic())
|
|
|
+ .set(News::getUpdateTime, Calendar.getInstance().getTime())
|
|
|
+ .set(News::getUpdaterId, userId)
|
|
|
+ .eq(News::getId, param.getId());
|
|
|
+ if(CommonStatus.YES.code() == param.getIsPublic().byteValue()){
|
|
|
+ updateWrapper.set(News::getPublicTime, Calendar.getInstance().getTime());
|
|
|
+ }
|
|
|
+ this.update(updateWrapper);
|
|
|
+
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultData delete(Long userId, BaseParamVO param) {
|
|
|
+ this.update(new LambdaUpdateWrapper<News>()
|
|
|
+ .set(News::getTbStatus, TbStatus.DELETE.code())
|
|
|
+ .set(News::getUpdateTime, Calendar.getInstance().getTime())
|
|
|
+ .set(News::getUpdaterId, userId)
|
|
|
+ .eq(News::getId, param.getId()));
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public News getNewsDetail(BaseParamVO param) {
|
|
|
+ return this.getById(param.getId());
|
|
|
+ }
|
|
|
}
|