| | |
| | | package com.yeshi.fanli.service.impl.homemodule;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import java.io.InputStream;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.transaction.Transactional;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SpecialMapper;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | |
|
| | | @Service
|
| | |
| | | public int updateByPrimaryKey(Special record) {
|
| | | return specialMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | @Transactional
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws Exception{
|
| | | |
| | | List<Special> listSpecial = specialMapper.queryByListPrimaryKey(list);
|
| | | for (Special special: listSpecial) {
|
| | | String src = special.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(src)) {
|
| | | COSManager.getInstance().deleteFile(src);
|
| | | }
|
| | | }
|
| | | |
| | | return specialMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | | |
| | | @Override
|
| | | public int deleteBatchByCardID(List<Long> list) throws Exception{
|
| | | List<Special> listSpecial = specialMapper.queryByListCardID(list);
|
| | | for (Special special: listSpecial) {
|
| | | String src = special.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(src)) {
|
| | | COSManager.getInstance().deleteFile(src);
|
| | | }
|
| | | }
|
| | | |
| | | return specialMapper.deleteBatchByCardID(list);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<Special> listQueryByCard(long start, int count, Long card, String key){
|
| | | return specialMapper.listQueryByCard(start, count, card, key);
|
| | | }
|
| | | |
| | | @Override
|
| | | public long countlistQueryByCard(Long card, String key) {
|
| | | return specialMapper.countlistQueryByCard(card, key);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<Special> getOrderByCardID(Long cardId, Integer type, Integer order) {
|
| | | return specialMapper.getOrderByCardID(cardId, type, order);
|
| | | }
|
| | | |
| | | @Override
|
| | | public int getMaxOrderByCard(Long card) {
|
| | | return specialMapper.getMaxOrderByCard(card);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "configCache", key = "'listBySystemAndCard-'+#card+'-'+#systemId")
|
| | | public List<Special> listBySystemAndCard( String card, Long systemId) {
|
| | | return specialMapper.listBySystemAndCard(card, systemId);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void uploadPicture(MultipartFile file, Special record, Long cardId) throws Exception {
|
| | | |
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl="SpecialPic/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | |
| | | /* 修改图片时,先删除已存在图片 */
|
| | | if (record != null) { |
| | | String src = record.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(src)) {
|
| | | COSManager.getInstance().deleteFile(src);
|
| | | }
|
| | | }
|
| | | |
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | | |
| | | /* 更新数据库信息 */
|
| | | if (!StringUtil.isNullOrEmpty(uploadFilePath)) {
|
| | | |
| | | if (record != null) {
|
| | | record.setUpdatetime(new Date());
|
| | | record.setPicture(uploadFilePath);
|
| | | updateByPrimaryKeySelective(record);
|
| | | } else {
|
| | | record = new Special();
|
| | | record.setPicture(uploadFilePath);
|
| | | record.setCreatetime(new Date());
|
| | | record.setUpdatetime(new Date());
|
| | | record.setCardId(cardId);
|
| | | record.setState(0L);
|
| | | |
| | | int maxOrder = getMaxOrderByCard(cardId);
|
| | | record.setOrderby(maxOrder + 1);
|
| | | record.setShowType("default");
|
| | | insertSelective(record);
|
| | | }
|
| | | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | }
|