|
@@ -1,113 +0,0 @@
|
|
|
-package com.gis.cms.service.impl;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.gis.cms.entity.dto.SortPageDto;
|
|
|
-import com.gis.cms.entity.dto.MusicDto;
|
|
|
-import com.gis.cms.entity.po.MusicEntity;
|
|
|
-import com.gis.cms.mapper.MusicMapper;
|
|
|
-import com.gis.cms.service.MusicService;
|
|
|
-import com.gis.common.base.service.impl.IBaseService;
|
|
|
-import com.gis.common.util.BaseUtil;
|
|
|
-import com.gis.common.util.FileUtils;
|
|
|
-import com.gis.common.util.Result;
|
|
|
-import com.gis.common.util.StrUtils;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
-
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * Created by owen on 2020/3/11 0011 16:16
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Service
|
|
|
-public class MusicServiceImpl extends ServiceImpl<MusicMapper, MusicEntity> implements MusicService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- FileUtils fileUtils;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- IBaseService iBaseService;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result search(SortPageDto param) {
|
|
|
- BaseUtil.startPage(param);
|
|
|
- IPage<MusicEntity> page = new Page<>(param.getPageNum() , param.getPageSize());
|
|
|
- IPage<MusicEntity> result = getBaseMapper().search(param, page);
|
|
|
- return Result.success(result);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void setVisit(Long id) {
|
|
|
- getBaseMapper().setVisit(id);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void setDisplay(Long id, Integer display) {
|
|
|
- getBaseMapper().setDisplay(id, display);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void setSort(Long id, Integer sort) {
|
|
|
- getBaseMapper().setSort(id, sort);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result saveEntity(MusicDto param) {
|
|
|
- Long id = param.getId();
|
|
|
-
|
|
|
- // 校验富文本内容长度
|
|
|
- StrUtils.checkStrLength(param.getDescription(), 10000);
|
|
|
-
|
|
|
- MusicEntity entity = null;
|
|
|
- if (id == null){
|
|
|
- entity = new MusicEntity();
|
|
|
- entity.setCreatorId(iBaseService.getUserId());
|
|
|
- } else {
|
|
|
- entity = this.getById(id);
|
|
|
- if (entity == null){
|
|
|
- String msg = "对象id不存在 ";
|
|
|
- log.error(msg + id);
|
|
|
- return Result.failure(msg);
|
|
|
- }
|
|
|
- // 判断图片
|
|
|
- String thumb = entity.getThumb();
|
|
|
- if (StringUtils.isNotBlank(thumb) && !StringUtils.equals(param.getThumb(), thumb)){
|
|
|
- fileUtils.del(thumb);
|
|
|
- }
|
|
|
-
|
|
|
- String fileUrl = entity.getFilePath();
|
|
|
- if (StringUtils.isNotBlank(fileUrl) && !StringUtils.equals(param.getFilePath(), fileUrl)){
|
|
|
- fileUtils.del(fileUrl);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- BeanUtils.copyProperties(param, entity);
|
|
|
- this.saveOrUpdate(entity);
|
|
|
- return Result.success();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result upload(MultipartFile file) {
|
|
|
- Map<String, Object> map = fileUtils.uploadMap(file, "/music/thumb", false);
|
|
|
- return Result.success(map);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Result fileUpload(MultipartFile file, String type) {
|
|
|
- Map<String, Object> map = fileUtils.uploadMap(file, "/music/"+type, false);
|
|
|
- return Result.success(map);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|