| | |
| | | }
|
| | |
|
| | | try {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | Date startTime = record.getStartTime();
|
| | | if (startTime != null) {
|
| | | record.setStartTime(format.parse(format.format(startTime)));
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
| | | |
| | | String startTime_str = record.getStartTime_str();
|
| | | if (startTime_str != null && startTime_str.trim().length() > 0) {
|
| | | startTime_str = startTime_str.replaceAll("T", " ");
|
| | | record.setStartTime(format.parse(startTime_str));
|
| | | }
|
| | |
|
| | | Date endTime = record.getEndTime();
|
| | | if (endTime != null) {
|
| | | record.setEndTime(format.parse(format.format(endTime)));
|
| | | String endTime_str = record.getEndTime_str();
|
| | | if (endTime_str != null && endTime_str.trim().length() > 0) {
|
| | | endTime_str = endTime_str.replaceAll("T", " ");
|
| | | record.setEndTime(format.parse(endTime_str));
|
| | | }
|
| | |
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 图片上传
|
| | | String picture = null;
|
| | | if (file != null) {
|
| | | picture = uploadPicture(file);
|
| | |
| | |
|
| | | Long id = record.getId();
|
| | | if (id == null) {
|
| | | int maxOrder = floatADMapper.countByPosition(position);
|
| | | int maxOrder = floatADMapper.getMaxOrderByPosition(position);
|
| | | record.setPicture(picture);
|
| | | Integer state = record.getState();
|
| | | if (state == null) {
|
| | | record.setState(0);
|
| | | }
|
| | | |
| | | record.setOrder(maxOrder + 1);
|
| | | record.setJumpNeedLogin(false);
|
| | | record.setCreateTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | floatADMapper.insert(record);
|
| | |
| | | }
|
| | |
|
| | | if (picture != null && picture.trim().length() > 0) {
|
| | | // 删除老图
|
| | | removePicture(resultObj.getPicture());
|
| | | // 存储新图
|
| | | record.setPicture(picture);
|
| | | // 删除已存在图片
|
| | | removePicture(resultObj);
|
| | | } else {
|
| | | record.setPicture(resultObj.getPicture());
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 上传图片
|
| | | * @param file
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public String uploadPicture(MultipartFile file) throws Exception {
|
| | | |
| | | // 文件解析 |
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | |
| | | // 文件路径
|
| | | String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | |
| | | return fileLink;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除图片-不更新数据库
|
| | | * @param record
|
| | | * @throws Exception
|
| | | */
|
| | | public void removePicture(String picture) throws Exception {
|
| | | if (picture != null && picture.trim().length() > 0) {
|
| | | COSManager.getInstance().deleteFile(picture);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | |
| | |
|
| | | // 删除已存在图片
|
| | | for (FloatAD floatAD: listSwiper) {
|
| | | removePicture(floatAD);
|
| | | removePicture(floatAD.getPicture());
|
| | | }
|
| | |
|
| | | return floatADMapper.deleteByPrimaryKeyList(list);
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 上传图片
|
| | | * @param file
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public String uploadPicture(MultipartFile file) throws Exception {
|
| | | |
| | | // 文件解析 |
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | |
| | | // 文件路径
|
| | | String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | |
| | | return fileLink;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除图片-不更新数据库
|
| | | * @param record
|
| | | * @throws Exception
|
| | | */
|
| | | public void removePicture(FloatAD record) throws Exception {
|
| | | String picture = record.getPicture();
|
| | | if (picture != null && picture.trim().length() > 0) {
|
| | | COSManager.getInstance().deleteFile(picture);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | for (FloatAD floatAD : listQuery) {
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
|
| | | Date startTime = floatAD.getStartTime();
|
| | | if (startTime == null) {
|
| | | floatAD.setStartTime_str("");
|
| | | } else {
|
| | | floatAD.setStartTime_str(sdf.format(startTime));
|
| | | }
|
| | | |
| | | Date endTime = floatAD.getEndTime();
|
| | | if (endTime == null) {
|
| | | floatAD.setEndTime_str("");
|
| | | } else {
|
| | | floatAD.setEndTime_str(sdf.format(endTime));
|
| | | }
|
| | | |
| | | String params = floatAD.getParams();
|
| | | if (params == null) {
|
| | | floatAD.setParams("");
|