|
|
@ -4,9 +4,9 @@ import api.PageResult;
|
|
|
|
import api.Result;
|
|
|
|
import api.Result;
|
|
|
|
import com.luoo.music.dao.*;
|
|
|
|
import com.luoo.music.dao.*;
|
|
|
|
import com.luoo.music.pojo.*;
|
|
|
|
import com.luoo.music.pojo.*;
|
|
|
|
import com.luoo.music.request.cms.ColumnAddModel;
|
|
|
|
import com.luoo.music.request.cms.JournalAddModel;
|
|
|
|
import com.luoo.music.request.cms.ColumnQueryModel;
|
|
|
|
import com.luoo.music.request.cms.JournalQueryModel;
|
|
|
|
import com.luoo.music.response.cms.ColumnVO;
|
|
|
|
import com.luoo.music.response.cms.JournalVO;
|
|
|
|
import com.luoo.music.response.cms.SongVO;
|
|
|
|
import com.luoo.music.response.cms.SongVO;
|
|
|
|
import com.luoo.music.util.CommonUtil;
|
|
|
|
import com.luoo.music.util.CommonUtil;
|
|
|
|
import com.luoo.music.util.UploadUtil;
|
|
|
|
import com.luoo.music.util.UploadUtil;
|
|
|
@ -34,20 +34,20 @@ import java.util.stream.Collectors;
|
|
|
|
* @author locust
|
|
|
|
* @author locust
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class CMSColumnService {
|
|
|
|
public class CMSJournalService {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ColumnTagDao columnTagDao;
|
|
|
|
private IdWorker idWorker;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ColumnDao columnDao;
|
|
|
|
private JournalTagDao journalTagDao;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IdWorker idWorker;
|
|
|
|
private JournalDao journalDao;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ColumnSongDao columnSongDao;
|
|
|
|
private JournalSongDao journalSongDao;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private TagDao tagDao;
|
|
|
|
private TagDao tagDao;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private CMSSongDao songDao;
|
|
|
|
private SongInfoDao songDao;
|
|
|
|
|
|
|
|
|
|
|
|
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
@ -59,30 +59,29 @@ public class CMSColumnService {
|
|
|
|
* @param size
|
|
|
|
* @param size
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Result<PageResult> search(ColumnQueryModel param, int page, int size) {
|
|
|
|
public Result<PageResult<JournalVO>> search(JournalQueryModel param, int page, int size) {
|
|
|
|
List<ColumnVO> result = new ArrayList<>();
|
|
|
|
List<JournalVO> result = new ArrayList<>();
|
|
|
|
Sort sort = new Sort(Sort.Direction.DESC, "createTime");
|
|
|
|
Sort sort = new Sort(Sort.Direction.DESC, "createTime");
|
|
|
|
PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
|
|
|
|
PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
|
|
|
|
Page<Column> columnPage;
|
|
|
|
Page<Journal> journalPage;
|
|
|
|
if (!Objects.isNull(param)) {
|
|
|
|
if (!Objects.isNull(param)) {
|
|
|
|
List<String> columnIdsByTags = null;
|
|
|
|
List<String> journalIdsByTags = null;
|
|
|
|
if (!CollectionUtils.isEmpty(param.getTags())) {
|
|
|
|
if (!CollectionUtils.isEmpty(param.getTags())) {
|
|
|
|
columnIdsByTags = columnTagDao.findColumnIdsByTags(param.getTags());
|
|
|
|
journalIdsByTags = journalTagDao.findJournalIdsByTags(param.getTags());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
param.setColumns(columnIdsByTags);
|
|
|
|
Specification<Journal> journalSpecification = buildSearchSpecification(param, journalIdsByTags);
|
|
|
|
Specification<Column> columnSpecification = buildSearchSpecification(param);
|
|
|
|
journalPage = journalDao.findAll(journalSpecification, pageRequest);
|
|
|
|
columnPage = columnDao.findAll(columnSpecification, pageRequest);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
columnPage = columnDao.findAll(pageRequest);
|
|
|
|
journalPage = journalDao.findAll(pageRequest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
long totalElements = columnPage.getTotalElements();
|
|
|
|
long totalElements = journalPage.getTotalElements();
|
|
|
|
List<Column> content = columnPage.getContent();
|
|
|
|
List<Journal> content = journalPage.getContent();
|
|
|
|
if (!CollectionUtils.isEmpty(content)) {
|
|
|
|
if (!CollectionUtils.isEmpty(content)) {
|
|
|
|
List<String> ids = content.stream().map(Column::getId).collect(Collectors.toList());
|
|
|
|
List<String> ids = content.stream().map(Journal::getId).collect(Collectors.toList());
|
|
|
|
Map<String, Long> songCountMap = songCountInfo(ids);
|
|
|
|
Map<String, Long> songCountMap = songCountInfo(ids);
|
|
|
|
Map<String, List<String>> columnTagMap = tagInfo(ids);
|
|
|
|
Map<String, List<String>> journalTagMap = tagInfo(ids);
|
|
|
|
for (Column item : content) {
|
|
|
|
for (Journal item : content) {
|
|
|
|
ColumnVO response = new ColumnVO();
|
|
|
|
JournalVO response = new JournalVO();
|
|
|
|
response.setId(item.getId());
|
|
|
|
response.setId(item.getId());
|
|
|
|
response.setNumber(item.getNumber());
|
|
|
|
response.setNumber(item.getNumber());
|
|
|
|
response.setName(item.getName());
|
|
|
|
response.setName(item.getName());
|
|
|
@ -96,7 +95,7 @@ public class CMSColumnService {
|
|
|
|
// TODO 编号文字转换
|
|
|
|
// TODO 编号文字转换
|
|
|
|
response.setUserId(item.getUserId());
|
|
|
|
response.setUserId(item.getUserId());
|
|
|
|
response.setSongCount(songCountMap.get(item.getId()));
|
|
|
|
response.setSongCount(songCountMap.get(item.getId()));
|
|
|
|
response.setTag(columnTagMap.get(item.getId()));
|
|
|
|
response.setTag(journalTagMap.get(item.getId()));
|
|
|
|
if (!"1".equals(param.getTab())) {
|
|
|
|
if (!"1".equals(param.getTab())) {
|
|
|
|
response.setPlayCount(0);
|
|
|
|
response.setPlayCount(0);
|
|
|
|
response.setCommentCount(0);
|
|
|
|
response.setCommentCount(0);
|
|
|
@ -116,8 +115,8 @@ public class CMSColumnService {
|
|
|
|
* @param param
|
|
|
|
* @param param
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Specification<Column> buildSearchSpecification(ColumnQueryModel param) {
|
|
|
|
private Specification<Journal> buildSearchSpecification(JournalQueryModel param, List<String> ids) {
|
|
|
|
return (Root<Column> root, CriteriaQuery<?> query, CriteriaBuilder builder) -> {
|
|
|
|
return (Root<Journal> root, CriteriaQuery<?> query, CriteriaBuilder builder) -> {
|
|
|
|
List<Predicate> predicateList = new ArrayList<Predicate>();
|
|
|
|
List<Predicate> predicateList = new ArrayList<Predicate>();
|
|
|
|
if("1".equals(param.getTab())) {
|
|
|
|
if("1".equals(param.getTab())) {
|
|
|
|
Predicate state = builder.equal(root.get("state"), "1");
|
|
|
|
Predicate state = builder.equal(root.get("state"), "1");
|
|
|
@ -136,8 +135,8 @@ public class CMSColumnService {
|
|
|
|
if (StringUtils.isNotBlank(param.getStart()) && StringUtils.isNotBlank(param.getEnd())) {
|
|
|
|
if (StringUtils.isNotBlank(param.getStart()) && StringUtils.isNotBlank(param.getEnd())) {
|
|
|
|
predicateList.add(builder.between(root.get("createTime"), param.getStart(), param.getEnd()));
|
|
|
|
predicateList.add(builder.between(root.get("createTime"), param.getStart(), param.getEnd()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!CollectionUtils.isEmpty(param.getColumns())) {
|
|
|
|
if (!CollectionUtils.isEmpty(ids)) {
|
|
|
|
predicateList.add(root.get("id").in(param.getColumns()));
|
|
|
|
predicateList.add(root.get("id").in(ids));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotBlank(param.getKeyword())) {
|
|
|
|
if(StringUtils.isNotBlank(param.getKeyword())) {
|
|
|
|
String likeExpression = "%" + param.getKeyword() + "%";
|
|
|
|
String likeExpression = "%" + param.getKeyword() + "%";
|
|
|
@ -157,8 +156,8 @@ public class CMSColumnService {
|
|
|
|
private Map<String, Long> songCountInfo(List<String> ids) {
|
|
|
|
private Map<String, Long> songCountInfo(List<String> ids) {
|
|
|
|
Map<String, Long> songCountMap = new HashMap<>();
|
|
|
|
Map<String, Long> songCountMap = new HashMap<>();
|
|
|
|
if (!CollectionUtils.isEmpty(ids)) {
|
|
|
|
if (!CollectionUtils.isEmpty(ids)) {
|
|
|
|
List<ColumnSongCount> columnSongCountList = columnSongDao.findSongCountByColumnIds(ids);
|
|
|
|
List<JournalSongCount> journalSongCountList = journalSongDao.findSongCountByJournalIds(ids);
|
|
|
|
songCountMap = columnSongCountList.stream().collect(Collectors.toMap(ColumnSongCount::getColumnId, ColumnSongCount::getSongCount));
|
|
|
|
songCountMap = journalSongCountList.stream().collect(Collectors.toMap(JournalSongCount::getJournalId, JournalSongCount::getSongCount));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return songCountMap;
|
|
|
|
return songCountMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -169,16 +168,16 @@ public class CMSColumnService {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private Map<String, List<String>> tagInfo(List<String> ids) {
|
|
|
|
private Map<String, List<String>> tagInfo(List<String> ids) {
|
|
|
|
Map<String, List<String>> columnTagMap = new HashMap<>();
|
|
|
|
Map<String, List<String>> journalTagMap = new HashMap<>();
|
|
|
|
List<ColumnTag> columnTagList = columnTagDao.findByColumnIds(ids);
|
|
|
|
List<JournalTag> journalTagList = journalTagDao.findByJournalIds(ids);
|
|
|
|
Set<String> tagIdSet = columnTagList.stream().map(ColumnTag::getTagId).collect(Collectors.toSet());
|
|
|
|
Set<String> tagIdSet = journalTagList.stream().map(JournalTag::getTagId).collect(Collectors.toSet());
|
|
|
|
List<Tag> tagList = tagDao.findByIdIn(tagIdSet);
|
|
|
|
List<Tag> tagList = tagDao.findByIdIn(tagIdSet);
|
|
|
|
Map<String, Tag> idTagMap = tagList.stream().collect(Collectors.toMap(Tag::getId, obj -> obj));
|
|
|
|
Map<String, Tag> idTagMap = tagList.stream().collect(Collectors.toMap(Tag::getId, obj -> obj));
|
|
|
|
List<String> list;
|
|
|
|
List<String> list;
|
|
|
|
for (ColumnTag item : columnTagList) {
|
|
|
|
for (JournalTag item : journalTagList) {
|
|
|
|
String columnId = item.getColumnId();
|
|
|
|
String journalId = item.getJournalId();
|
|
|
|
if (columnTagMap.containsKey(columnId)) {
|
|
|
|
if (journalTagMap.containsKey(journalId)) {
|
|
|
|
list = columnTagMap.get(columnId);
|
|
|
|
list = journalTagMap.get(journalId);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
list = new ArrayList<>();
|
|
|
|
list = new ArrayList<>();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -186,9 +185,9 @@ public class CMSColumnService {
|
|
|
|
if (StringUtils.isNotBlank(tag.getParentId())) {
|
|
|
|
if (StringUtils.isNotBlank(tag.getParentId())) {
|
|
|
|
list.add(tag.getNameCh());
|
|
|
|
list.add(tag.getNameCh());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
columnTagMap.put(columnId, list);
|
|
|
|
journalTagMap.put(journalId, list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return columnTagMap;
|
|
|
|
return journalTagMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -197,27 +196,27 @@ public class CMSColumnService {
|
|
|
|
* @param image
|
|
|
|
* @param image
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Result add(ColumnAddModel param, MultipartFile image) {
|
|
|
|
public Result add(JournalAddModel param, MultipartFile image) {
|
|
|
|
String imagePath = UploadUtil.upload(image, UploadUtil.IMAGE_DIR);
|
|
|
|
String imagePath = UploadUtil.upload(image, UploadUtil.IMAGE_DIR);
|
|
|
|
Column column = buildColumn(null, param);
|
|
|
|
Journal journal = buildJournal(null, param);
|
|
|
|
String id = String.valueOf(idWorker.nextId());
|
|
|
|
String id = String.valueOf(idWorker.nextId());
|
|
|
|
column.setId(id);
|
|
|
|
journal.setId(id);
|
|
|
|
column.setCoverPhoto(imagePath);
|
|
|
|
journal.setCoverPhoto(imagePath);
|
|
|
|
columnDao.save(column);
|
|
|
|
journalDao.save(journal);
|
|
|
|
batchSaveColumnRelatesInfo(id, param);
|
|
|
|
batchSaveJournalRelatesInfo(id, param);
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Column buildColumn(String id, ColumnAddModel param) {
|
|
|
|
private Journal buildJournal(String id, JournalAddModel param) {
|
|
|
|
Column column = new Column();
|
|
|
|
Journal journal = new Journal();
|
|
|
|
if (!StringUtils.isBlank(id)) {
|
|
|
|
if (!StringUtils.isBlank(id)) {
|
|
|
|
column.setId(id);
|
|
|
|
journal.setId(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
column.setNumber(param.getNumber());
|
|
|
|
journal.setNumber(param.getNumber());
|
|
|
|
column.setName(param.getName());
|
|
|
|
journal.setName(param.getName());
|
|
|
|
column.setUserId(param.getUserId());
|
|
|
|
journal.setUserId(param.getUserId());
|
|
|
|
column.setSummary(param.getSummary());
|
|
|
|
journal.setSummary(param.getSummary());
|
|
|
|
return column;
|
|
|
|
return journal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -225,27 +224,27 @@ public class CMSColumnService {
|
|
|
|
* @param id
|
|
|
|
* @param id
|
|
|
|
* @param param
|
|
|
|
* @param param
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void batchSaveColumnRelatesInfo(String id, ColumnAddModel param) {
|
|
|
|
private void batchSaveJournalRelatesInfo(String id, JournalAddModel param) {
|
|
|
|
if (!CollectionUtils.isEmpty(param.getTags())) {
|
|
|
|
if (!CollectionUtils.isEmpty(param.getTags())) {
|
|
|
|
List<ColumnTag> columnTagList = new ArrayList<>();
|
|
|
|
List<JournalTag> journalTagList = new ArrayList<>();
|
|
|
|
for (String item : param.getTags()) {
|
|
|
|
for (String item : param.getTags()) {
|
|
|
|
ColumnTag columnTag = new ColumnTag();
|
|
|
|
JournalTag journalTag = new JournalTag();
|
|
|
|
columnTag.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
journalTag.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
columnTag.setColumnId(id);
|
|
|
|
journalTag.setJournalId(id);
|
|
|
|
columnTag.setTagId(item);
|
|
|
|
journalTag.setTagId(item);
|
|
|
|
columnTagList.add(columnTag);
|
|
|
|
journalTagList.add(journalTag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
columnTagDao.saveAll(columnTagList);
|
|
|
|
journalTagDao.saveAll(journalTagList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!CollectionUtils.isEmpty(param.getSongs())) {
|
|
|
|
if (!CollectionUtils.isEmpty(param.getSongs())) {
|
|
|
|
List<ColumnSong> columnSongList = new ArrayList<>();
|
|
|
|
List<JournalSong> journalSongList = new ArrayList<>();
|
|
|
|
for (String item : param.getSongs()) {
|
|
|
|
for (String item : param.getSongs()) {
|
|
|
|
ColumnSong columnSong = new ColumnSong();
|
|
|
|
JournalSong journalSong = new JournalSong();
|
|
|
|
columnSong.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
journalSong.setId(String.valueOf(idWorker.nextId()));
|
|
|
|
columnSong.setColumnId(id);
|
|
|
|
journalSong.setJournalId(id);
|
|
|
|
columnSong.setSongId(item);
|
|
|
|
journalSong.setSongId(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
columnSongDao.saveAll(columnSongList);
|
|
|
|
journalSongDao.saveAll(journalSongList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -254,17 +253,17 @@ public class CMSColumnService {
|
|
|
|
* @param id
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Result<ColumnVO> findOne(String id) {
|
|
|
|
public Result<JournalVO> findOne(String id) {
|
|
|
|
Column column = columnDao.findById(id).get();
|
|
|
|
Journal journal = journalDao.findById(id).get();
|
|
|
|
ColumnVO response = new ColumnVO();
|
|
|
|
JournalVO response = new JournalVO();
|
|
|
|
response.setId(column.getId());
|
|
|
|
response.setId(journal.getId());
|
|
|
|
response.setNumber(column.getNumber());
|
|
|
|
response.setNumber(journal.getNumber());
|
|
|
|
response.setName(column.getName());
|
|
|
|
response.setName(journal.getName());
|
|
|
|
response.setTag(columnTagDao.findTagsByColumnId(id));
|
|
|
|
response.setTag(journalTagDao.findTagsByJournalId(id));
|
|
|
|
response.setUserId(column.getUserId());
|
|
|
|
response.setUserId(journal.getUserId());
|
|
|
|
response.setCoverPhoto(column.getCoverPhoto());
|
|
|
|
response.setCoverPhoto(journal.getCoverPhoto());
|
|
|
|
response.setSongs(songInfo(column.getId()));
|
|
|
|
response.setSongs(songInfo(journal.getId()));
|
|
|
|
response.setSummary(column.getSummary());
|
|
|
|
response.setSummary(journal.getSummary());
|
|
|
|
return Result.success(response);
|
|
|
|
return Result.success(response);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -275,14 +274,14 @@ public class CMSColumnService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private List<SongVO> songInfo(String id) {
|
|
|
|
private List<SongVO> songInfo(String id) {
|
|
|
|
List<SongVO> list = new ArrayList<>();
|
|
|
|
List<SongVO> list = new ArrayList<>();
|
|
|
|
List<ColumnSong> columnSongList = columnSongDao.findByColumnId(id);
|
|
|
|
List<JournalSong> journalSongList = journalSongDao.findByJournalId(id);
|
|
|
|
if (!CollectionUtils.isEmpty(columnSongList)) {
|
|
|
|
if (!CollectionUtils.isEmpty(journalSongList)) {
|
|
|
|
Set<String> songIdSet = columnSongList.stream().map(ColumnSong::getSongId).collect(Collectors.toSet());
|
|
|
|
Set<String> songIdSet = journalSongList.stream().map(JournalSong::getSongId).collect(Collectors.toSet());
|
|
|
|
List<CMSSong> songList = songDao.findByIdIn(songIdSet);
|
|
|
|
List<SongInfo> songList = songDao.findByIdIn(songIdSet);
|
|
|
|
Map<String, CMSSong> idTagMap = songList.stream().collect(Collectors.toMap(CMSSong::getId, obj -> obj));
|
|
|
|
Map<String, SongInfo> idTagMap = songList.stream().collect(Collectors.toMap(SongInfo::getId, obj -> obj));
|
|
|
|
for (ColumnSong item : columnSongList) {
|
|
|
|
for (JournalSong item : journalSongList) {
|
|
|
|
if (idTagMap.containsKey(item.getSongId())) {
|
|
|
|
if (idTagMap.containsKey(item.getSongId())) {
|
|
|
|
CMSSong song = idTagMap.get(item.getSongId());
|
|
|
|
SongInfo song = idTagMap.get(item.getSongId());
|
|
|
|
SongVO songVO = new SongVO();
|
|
|
|
SongVO songVO = new SongVO();
|
|
|
|
songVO.setId(song.getId());
|
|
|
|
songVO.setId(song.getId());
|
|
|
|
songVO.setPicture(song.getPicture());
|
|
|
|
songVO.setPicture(song.getPicture());
|
|
|
@ -305,17 +304,17 @@ public class CMSColumnService {
|
|
|
|
* @param image
|
|
|
|
* @param image
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Result update(String id, ColumnAddModel param, MultipartFile image) {
|
|
|
|
public Result update(String id, JournalAddModel param, MultipartFile image) {
|
|
|
|
Column column = buildColumn(id, param);
|
|
|
|
Journal journal = buildJournal(id, param);
|
|
|
|
Column oldColumn = columnDao.findById(id).get();
|
|
|
|
Journal oldJournal = journalDao.findById(id).get();
|
|
|
|
boolean bool = UploadUtil.fileHasChanged(oldColumn.getCoverPhoto(), image);
|
|
|
|
boolean bool = UploadUtil.fileHasChanged(oldJournal.getCoverPhoto(), image);
|
|
|
|
if (bool) {
|
|
|
|
if (bool) {
|
|
|
|
String imagePath = UploadUtil.upload(image, UploadUtil.IMAGE_DIR);
|
|
|
|
String imagePath = UploadUtil.upload(image, UploadUtil.IMAGE_DIR);
|
|
|
|
column.setCoverPhoto(imagePath);
|
|
|
|
journal.setCoverPhoto(imagePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
columnDao.save(column);
|
|
|
|
journalDao.save(journal);
|
|
|
|
batchDeleteColumnRelatesInfo(id);
|
|
|
|
batchDeleteJournalRelatesInfo(id);
|
|
|
|
batchSaveColumnRelatesInfo(id, param);
|
|
|
|
batchSaveJournalRelatesInfo(id, param);
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -323,9 +322,9 @@ public class CMSColumnService {
|
|
|
|
* 删除期刊的标签、音乐信息
|
|
|
|
* 删除期刊的标签、音乐信息
|
|
|
|
* @param id
|
|
|
|
* @param id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void batchDeleteColumnRelatesInfo(String id) {
|
|
|
|
private void batchDeleteJournalRelatesInfo(String id) {
|
|
|
|
columnTagDao.deleteByColumnId(id);
|
|
|
|
journalTagDao.deleteByJournalId(id);
|
|
|
|
columnSongDao.deleteByColumnId(id);
|
|
|
|
journalSongDao.deleteByJournalId(id);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -341,10 +340,10 @@ public class CMSColumnService {
|
|
|
|
if ("1".equals(scheduled)) {
|
|
|
|
if ("1".equals(scheduled)) {
|
|
|
|
if (StringUtils.isNotBlank(pubTimeStr)){
|
|
|
|
if (StringUtils.isNotBlank(pubTimeStr)){
|
|
|
|
pubTime = LocalDateTime.parse(pubTimeStr, formatter);
|
|
|
|
pubTime = LocalDateTime.parse(pubTimeStr, formatter);
|
|
|
|
columnDao.updateScheduledPubById(id, scheduled, pubTime);
|
|
|
|
journalDao.updateScheduledPubById(id, scheduled, pubTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
columnDao.updatePubById(id, pubTime);
|
|
|
|
journalDao.updatePubById(id, pubTime);
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -354,8 +353,8 @@ public class CMSColumnService {
|
|
|
|
* @param state
|
|
|
|
* @param state
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Result updateColumnState(String id, String state) {
|
|
|
|
public Result updateJournalState(String id, String state) {
|
|
|
|
columnDao.updateColumnState(id, state);
|
|
|
|
journalDao.updateJournalState(id, state);
|
|
|
|
return Result.success("更新成功");
|
|
|
|
return Result.success("更新成功");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -365,9 +364,8 @@ public class CMSColumnService {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Result deleteById(String id) {
|
|
|
|
public Result deleteById(String id) {
|
|
|
|
columnDao.deleteById(id);
|
|
|
|
journalDao.deleteById(id);
|
|
|
|
batchDeleteColumnRelatesInfo(id);
|
|
|
|
batchDeleteJournalRelatesInfo(id);
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|