| | |
| | | package com.yeshi.fanli.service.impl.homemodule;
|
| | |
|
| | | import java.io.InputStream;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.transaction.Transactional;
|
| | |
|
| | | import org.apache.commons.beanutils.PropertyUtils;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.HomeNavbarMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SuperHomeNavbarMapper;
|
| | |
| | | import com.yeshi.fanli.entity.system.System;
|
| | | import com.yeshi.fanli.service.inter.config.SystemService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.HomeNavbarService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | |
|
| | | @Service
|
| | |
| | | @Transactional
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) {
|
| | | superHomeNavbarMapper.deleteBatchByNavbarIds(list);
|
| | | for (Long id: list) {
|
| | | HomeNavbar homeNavbar = homeNavbarMapper.selectByPrimaryKey(id);
|
| | | if (homeNavbar !=null) {
|
| | | // 删除已存在图片 /
|
| | | String picture = homeNavbar.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(picture)) {
|
| | | COSManager.getInstance().deleteFile(picture);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | return homeNavbarMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HomeNavbar> getChangeOrder(Long id, Integer type, Integer order) {
|
| | | return homeNavbarMapper.getChangeOrder(id, type, order);
|
| | | public List<HomeNavbar> getChangeOrder(Integer type, Integer order) {
|
| | | return homeNavbarMapper.getChangeOrder(type, order);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | @Override
|
| | | public void uploadPicture(MultipartFile file, HomeNavbar homeNavbar) throws Exception {
|
| | | |
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl="HomeNavbar/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | |
| | | /* 修改图片时,先删除已存在图片 */
|
| | | String picture = homeNavbar.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(picture)) {
|
| | | COSManager.getInstance().deleteFile(picture);
|
| | | }
|
| | | |
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | | /* 更新数据库信息 */
|
| | | if (!StringUtil.isNullOrEmpty(uploadFilePath)) {
|
| | | homeNavbar.setUpdatetime(new Date());
|
| | | homeNavbar.setPicture(uploadFilePath);
|
| | | updateByPrimaryKeySelective(homeNavbar);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|