Merge remote-tracking branch 'origin/main'

main
wangqing 9 months ago
commit 43a1af546b

@ -50,6 +50,7 @@ public class CMSJournalController {
@ApiOperation(value = "新增期刊", notes = "新增期刊")
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Result add(@ApiParam(value = "期刊信息", required = true) @Valid @RequestBody JournalAddModel addModel){
cacheChannel.evict("default", "journal_filter");
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE);
return journalService.add(addModel);
}
@ -86,6 +87,7 @@ public class CMSJournalController {
@ApiOperation(value = "删除单条期刊", notes = "物理删除")
@RequestMapping(value="/{id}", method= RequestMethod.DELETE)
public Result delete(@ApiParam(value = "期刊ID", required = true) @PathVariable String id){
cacheChannel.evict("default", "journal_filter");
cacheChannel.clear(Constants.J2CACHE_REGION_JOURNAL_QUERY_PAGE);
return journalService.deleteById(id);
}

@ -1,10 +1,8 @@
package com.luoo.music.controller;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@ -29,8 +27,6 @@ import org.springframework.web.bind.annotation.*;
import com.luoo.music.pojo.Journal;
import com.luoo.music.pojo.Tag;
import com.luoo.music.service.JournalService;
import com.luoo.music.service.SongInfoService;
import com.luoo.music.service.TagService;
import com.luoo.music.service.UserCollectInfoService;
import annotation.GlobalInterceptor;
import annotation.VerifyParam;
@ -41,7 +37,6 @@ import constants.Constants;
import dto.UserLoginDto;
import enums.CollectTypeEnum;
import util.JwtUtil;
import util.StringTools;
/**
*
@ -63,9 +58,6 @@ public class JournalController {
@Autowired
private SongController songController;
@Autowired
private TagService tagService;
@Autowired
private JwtUtil jwtUtil;
@ -78,9 +70,6 @@ public class JournalController {
@Autowired
private RedisTemplate redisTemplate;
private static final int JOURNAL_FILTER_NUMBER_RANGE=100;
private static final Map<String,JournalRespDTO> journalRespDTOMap=new HashMap<>();
@ApiOperation(value = "1.查询期刊信息", notes = "若authorization为空或authorization校验失败默认返回最新的10期期刊筛选条件对游客不可用")
@GetMapping("/list")
@GlobalInterceptor
@ -230,12 +219,7 @@ public class JournalController {
@GlobalInterceptor(checkAppUserLogin = true)
public Result<JournalFilterDTO> getFilterList(
@RequestHeader(value = "Authorization", required = false) String authorization) {
JournalFilterDTO journalFilterDTO=new JournalFilterDTO();
journalFilterDTO.setJournalNoList(journalService.getJournalNoList(JOURNAL_FILTER_NUMBER_RANGE));
journalFilterDTO.setLanguageList(tagService.getLanguageList().stream().map(this::getTagDTO).collect(Collectors.toList()));
journalFilterDTO.setStyleList(tagService.getStyleList().stream().map(this::getTagDTO).collect(Collectors.toList()));
return Result.success(journalFilterDTO);
return Result.success(journalService.getJournalFilterDTO());
}
@ApiOperation(value = "5.根据当前期刊的标签推荐6期类似期刊")
@ -259,12 +243,7 @@ public class JournalController {
return Result.success(list);
}
private TagDTO getTagDTO(Tag tag) {
TagDTO tagDTO=new TagDTO();
tagDTO.setName(tag.getNameCh());
tagDTO.setId(tag.getId());
return tagDTO;
}
@ApiOperation(value = "统计期刊的浏览数", notes = "APP端打开期刊调用一次统计接口")
@RequestMapping(value="/stat/visits/{id}", method= RequestMethod.PUT)
public Result statVisitsCount(@ApiParam(value = "期刊ID", required = true) @PathVariable String id) {

@ -14,13 +14,11 @@ import com.luoo.music.dto.response.SongRespDTO;
import io.swagger.annotations.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;
import com.luoo.music.pojo.Journal;
import com.luoo.music.pojo.JournalSong;
import com.luoo.music.pojo.Tag;
import com.luoo.music.service.JournalService;
import com.luoo.music.service.JournalSongService;
import com.luoo.music.service.SearchService;
@ -29,7 +27,6 @@ import annotation.GlobalInterceptor;
import annotation.VerifyParam;
import api.PageResult;
import api.Result;
import constants.Constants;
/**
*
@ -59,10 +56,7 @@ public class SearchController {
@GetMapping("/category")
@GlobalInterceptor
public Result<List<SearchCategoryDTO>> getCategory() {
List<Tag> tags = tagService.getCategoryTags();
List<SearchCategoryDTO> searchCategoryDTOs = tags.stream().map(this::getSearchCategoryDTO)
.collect(Collectors.toList());
return Result.success(searchCategoryDTOs);
return Result.success(tagService.getCategoryDTO());
}
@ApiOperation(value = "2.1 搜索歌曲", notes = "根据关键词模糊搜索歌曲")
@ -113,12 +107,4 @@ public class SearchController {
private int getLimit(Integer limit) {
return null == limit || 0 == limit ? DEFAULT_AUTO_COMPLETE_LIMIT : limit;
}
private SearchCategoryDTO getSearchCategoryDTO(Tag tag) {
SearchCategoryDTO searchCategoryDTO = new SearchCategoryDTO();
BeanUtils.copyProperties(tag, searchCategoryDTO);
searchCategoryDTO.setImage(Constants.TAG_RESOURCE_PREFIX + tag.getImage());
searchCategoryDTO.setThumbnail(Constants.TAG_RESOURCE_PREFIX + tag.getThumbnail());
return searchCategoryDTO;
}
}

@ -1,12 +1,14 @@
package com.luoo.music.dto.response;
import java.io.Serializable;
import java.util.List;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class JournalFilterDTO {
public class JournalFilterDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "风格筛选条件")
private List<TagDTO> styleList;
@ApiModelProperty(value = "语言筛选条件")

@ -1,10 +1,13 @@
package com.luoo.music.dto.response;
import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class SearchCategoryDTO {
public class SearchCategoryDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
private String id;
@ApiModelProperty(value = "中文名")

@ -1,10 +1,13 @@
package com.luoo.music.dto.response;
import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class TagDTO {
public class TagDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID")
private String id;
@ApiModelProperty(value = "中文名")

@ -41,8 +41,12 @@ import com.luoo.music.dao.JournalTagDao;
import com.luoo.music.dao.TagDao;
import com.luoo.music.dto.mapper.JournalMapper;
import com.luoo.music.dto.request.JournalQueryReq;
import com.luoo.music.dto.response.JournalFilterDTO;
import com.luoo.music.dto.response.JournalRespDTO;
import com.luoo.music.dto.response.SearchCategoryDTO;
import com.luoo.music.dto.response.TagDTO;
import com.luoo.music.pojo.Journal;
import com.luoo.music.pojo.Tag;
/**
*
@ -53,6 +57,7 @@ import com.luoo.music.pojo.Journal;
@Service
public class JournalService {
private static final Pattern NUMBER_PATTERN = Pattern.compile("[0-9]*");
private static final int JOURNAL_FILTER_NUMBER_RANGE=100;
@Autowired
private JournalDao journalDao;
@ -73,13 +78,9 @@ public class JournalService {
@Autowired
private CommentDao commentDao;
private Map<Integer,List<String>> JOURNAL_RANGE_MAP=new HashMap<>();
/*
* public void updateState(String id) { journalDao.updateState(id); }
*
*
* public void addThumbup(String id){ journalDao.addThumbup(id); }
*/
@Autowired
private TagService tagService;
/**
*
* @return
@ -270,10 +271,6 @@ public class JournalService {
public List<String> getJournalNoList(int journalFilterNumberRange) {
//获取最大的期刊号
int maxJournalNo=journalDao.getMaxJournalNo();
if(JOURNAL_RANGE_MAP.containsKey(maxJournalNo)) {
return JOURNAL_RANGE_MAP.get(maxJournalNo);
}
JOURNAL_RANGE_MAP.clear();
List<String> journalNoList=new ArrayList<>();
int i=1;
int start=1;
@ -292,7 +289,6 @@ public class JournalService {
i++;
}
Collections.reverse(journalNoList);
JOURNAL_RANGE_MAP.put(maxJournalNo, journalNoList);
return journalNoList;
}
@ -402,4 +398,23 @@ public class JournalService {
}
return JournalMapper.getJournalRespDTO(journal,mongoTemplate,redisTemplate,commentDao);
}
public JournalFilterDTO getJournalFilterDTO() {
return (JournalFilterDTO) this.cacheChannel.get("default", "journal_filter", key -> getJournalFilter(), false).getValue();
}
private JournalFilterDTO getJournalFilter() {
JournalFilterDTO journalFilterDTO=new JournalFilterDTO();
journalFilterDTO.setJournalNoList(getJournalNoList(JOURNAL_FILTER_NUMBER_RANGE));
journalFilterDTO.setLanguageList(tagService.getLanguageList().stream().map(this::getTagDTO).collect(Collectors.toList()));
journalFilterDTO.setStyleList(tagService.getStyleList().stream().map(this::getTagDTO).collect(Collectors.toList()));
return journalFilterDTO;
}
private TagDTO getTagDTO(Tag tag) {
TagDTO tagDTO=new TagDTO();
tagDTO.setName(tag.getNameCh());
tagDTO.setId(tag.getId());
return tagDTO;
}
}

@ -1,20 +1,28 @@
package com.luoo.music.service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.luoo.music.dao.TagDao;
import com.luoo.music.dto.response.JournalRespDTO;
import com.luoo.music.dto.response.SearchCategoryDTO;
import com.luoo.music.dto.response.TagDTO;
import com.luoo.music.pojo.Tag;
import api.Result;
import constants.Constants;
import net.oschina.j2cache.CacheChannel;
@Service
public class TagService {
@Autowired
private TagDao tagDao;
@Autowired
private CacheChannel cacheChannel;
public List<Tag> getLanguageList() {
return tagDao.getLanguageList();
@ -28,19 +36,26 @@ public class TagService {
return tagDao.getCategoryTags();
}
public Map<String, List<String>> getTagMap(List<String> journalIds) {
if (journalIds.isEmpty()) {
return Collections.emptyMap();
}
List<Object[]> pairs = tagDao.getJounralId2TagPairs(journalIds);
return pairs.stream().collect(Collectors.groupingBy(s -> s[0].toString(),
Collectors.mapping(s -> s[1].toString(), Collectors.toList())));
public List<String> getTagNameChByJournalId(String journalId) {
return tagDao.getTagNameChByJournalId(journalId);
}
@SuppressWarnings("unchecked")
public List<SearchCategoryDTO> getCategoryDTO() {
return (List<SearchCategoryDTO>) this.cacheChannel.get("default", "search_category", key -> getSearchCategoryDTO(), false).getValue();
}
public List<String> getTagNameChByJournalId(String journalId) {
return tagDao.getTagNameChByJournalId(journalId);
private List<SearchCategoryDTO> getSearchCategoryDTO() {
List<Tag> tags = getCategoryTags();
return tags.stream().map(this::getSearchCategoryDTO)
.collect(Collectors.toList());
}
private SearchCategoryDTO getSearchCategoryDTO(Tag tag) {
SearchCategoryDTO searchCategoryDTO = new SearchCategoryDTO();
BeanUtils.copyProperties(tag, searchCategoryDTO);
searchCategoryDTO.setImage(Constants.TAG_RESOURCE_PREFIX + tag.getImage());
searchCategoryDTO.setThumbnail(Constants.TAG_RESOURCE_PREFIX + tag.getThumbnail());
return searchCategoryDTO;
}
}

@ -210,6 +210,9 @@ public class UserInfoService {
user.setLastUseDeviceBrand(userInfo.getLastUseDeviceBrand());
user.setLastLoginIp(userInfo.getLastLoginIp());
}
if (!UserStatusEnum.ENABLE.getStatus().equals(userInfo.getStatus())) {
return null;
}
user.setLastLoginTime(new Date());
userInfoDao.save(user);
return Constants.TOKEN_PREFIX

Loading…
Cancel
Save