diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java index aa4f90018..38ff8e102 100644 --- a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysCustomerCaseController.java @@ -141,36 +141,37 @@ public class SysCustomerCaseController extends BaseController return getDataTable(list); } - /** - * 上传文件到OSS返回URL - */ - @PostMapping("/uploadCaseFile") - @PreAuthorize("@ss.hasPermi('custom:customerCase:list')") - public AjaxResult uploadCseFile(MultipartFile file) throws Exception { - try { - if(file == null){ - return AjaxResult.error("文件不存在"); - } - int fileNameLength = file.getOriginalFilename().length(); - if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) - { - throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); - } - FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); - - String fileUrl = AliyunOSSUtils.uploadFileInputSteam(AliyunOSSConfig.casePrefix, DateUtils.getDate()+"/"+file.getOriginalFilename(), file); - - AjaxResult ajax = null; - if(StringUtils.isNotEmpty(fileUrl)){ - ajax = AjaxResult.success(); - ajax.put("fileUrl", fileUrl); - ajax.put("fileName", file.getOriginalFilename()); - }else{ - ajax = AjaxResult.error("文件上传失败"); - } - return ajax; - } catch (Exception e) { - return AjaxResult.error("文件上传失败"); - } - } +// 转移到SysFileUploadController.java +// /** +// * 上传文件到OSS返回URL +// */ +// @PostMapping("/uploadCaseFile") +// @PreAuthorize("@ss.hasPermi('custom:customerCase:list')") +// public AjaxResult uploadCseFile(MultipartFile file) throws Exception { +// try { +// if(file == null){ +// return AjaxResult.error("文件不存在"); +// } +// int fileNameLength = file.getOriginalFilename().length(); +// if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) +// { +// throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); +// } +// FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); +// +// String fileUrl = AliyunOSSUtils.uploadFileInputSteam(AliyunOSSConfig.casePrefix, DateUtils.getDate()+"/"+file.getOriginalFilename(), file); +// +// AjaxResult ajax = null; +// if(StringUtils.isNotEmpty(fileUrl)){ +// ajax = AjaxResult.success(); +// ajax.put("fileUrl", fileUrl); +// ajax.put("fileName", file.getOriginalFilename()); +// }else{ +// ajax = AjaxResult.error("文件上传失败"); +// } +// return ajax; +// } catch (Exception e) { +// return AjaxResult.error("文件上传失败"); +// } +// } } \ No newline at end of file diff --git a/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysFileUploadController.java b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysFileUploadController.java new file mode 100644 index 000000000..2745957c1 --- /dev/null +++ b/stdiet-admin/src/main/java/com/stdiet/web/controller/custom/SysFileUploadController.java @@ -0,0 +1,54 @@ +package com.stdiet.web.controller.custom; + +import com.stdiet.common.core.controller.BaseController; +import com.stdiet.common.core.domain.AjaxResult; +import com.stdiet.common.exception.file.FileNameLengthLimitExceededException; +import com.stdiet.common.utils.DateUtils; +import com.stdiet.common.utils.StringUtils; +import com.stdiet.common.utils.file.FileUploadUtils; +import com.stdiet.common.utils.file.MimeTypeUtils; +import com.stdiet.common.utils.oss.AliyunOSSUtils; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +@RestController +@RequestMapping("/custom/fileUpload") +public class SysFileUploadController extends BaseController { + + /** + * 上传文件到OSS返回URL + */ + @PostMapping(value = "/{prefix}") + @PreAuthorize("@ss.hasPermi('custom:file:upload')") + public AjaxResult uploadCseFile(MultipartFile file, @PathVariable String prefix) throws Exception { + + try { + if (file == null) { + return AjaxResult.error("文件不存在"); + } + int fileNameLength = file.getOriginalFilename().length(); + if (fileNameLength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) { + throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH); + } + FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); + + String fileUrl = AliyunOSSUtils.uploadFileInputSteam(prefix + '/', DateUtils.getDate() + "/" + file.getOriginalFilename(), file); + + AjaxResult ajax = null; + if (StringUtils.isNotEmpty(fileUrl)) { + ajax = AjaxResult.success(); + ajax.put("fileUrl", fileUrl); + ajax.put("fileName", file.getOriginalFilename()); + } else { + ajax = AjaxResult.error("文件上传失败"); + } + return ajax; + } catch (Exception e) { + return AjaxResult.error("文件上传失败"); + } + } +} diff --git a/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java b/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java index 0f2199d0d..0b77da830 100644 --- a/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java +++ b/stdiet-common/src/main/java/com/stdiet/common/utils/oss/AliyunOSSUtils.java @@ -248,7 +248,7 @@ public class AliyunOSSUtils { /** * - * @param fileUrl + * @param fileUrlList * @return */ public static List generatePresignedUrl(List fileUrlList){ diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java new file mode 100644 index 000000000..ceab8eccd --- /dev/null +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredentFile.java @@ -0,0 +1,27 @@ +package com.stdiet.custom.domain; + +import lombok.Data; + +import java.util.Date; + +@Data +public class SysIngredentFile { + + Long id; + + Long igdId; + + String fileUrl; + + String fileName; + + Integer delFlag; + + Long createBy; + + Date createTime; + + Long updateBy; + + Date updateTime; +} diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java index c5cd66719..4f52f9902 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/domain/SysIngredient.java @@ -15,8 +15,6 @@ import java.util.Date; */ @Data public class SysIngredient { - private static final long serialVersionUID = 1L; - /** * id */ @@ -107,4 +105,9 @@ public class SysIngredient { private Long[] notRecIds; + /** + * 食材信息 + */ + private String info; + } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java index d1e8b9d9f..8ac25d4aa 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/mapper/SysIngredientMapper.java @@ -1,6 +1,8 @@ package com.stdiet.custom.mapper; import java.util.List; + +import com.stdiet.custom.domain.SysIngredentFile; import com.stdiet.custom.domain.SysIngredient; import com.stdiet.custom.domain.SysIngredientNotRec; import com.stdiet.custom.domain.SysIngredientRec; @@ -80,4 +82,6 @@ public interface SysIngredientMapper * @return */ public SysIngredient selectSysIngredientByName(@Param("name") String name); + + int batchInsertIngredientImage(List ingredentFiles); } \ No newline at end of file diff --git a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java index 2814d59bd..c37cf6f08 100644 --- a/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java +++ b/stdiet-custom/src/main/java/com/stdiet/custom/service/impl/SysIngredientServiceImpl.java @@ -60,6 +60,9 @@ public class SysIngredientServiceImpl implements ISysIngredientService { insertRecommand(sysIngredient); // insertNotRecommand(sysIngredient); + // + + return rows; } diff --git a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml index 68e4ab886..122e4bf06 100644 --- a/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml +++ b/stdiet-custom/src/main/resources/mapper/custom/SysIngredientMapper.xml @@ -5,21 +5,23 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + @@ -43,44 +45,44 @@ SELECT * FROM sys_ingredient igd RIGHT JOIN( - SELECT * FROM( - SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_rec - - - physical_signs_id in - - #{item} - - - - ) recId - LEFT JOIN ( - SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM( - SELECT physical_signs_id as id, ingredient_id - FROM sys_ingredient_rec - ) rec JOIN sys_physical_signs phy USING(id) - GROUP BY id - ) recM USING(id) - INNER JOIN ( - SELECT * FROM( - SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_not_rec - - - physical_signs_id in - - #{item} - - - - ) notRecId - LEFT JOIN ( - SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM( - SELECT physical_signs_id as id, ingredient_id - FROM sys_ingredient_not_rec - ) notRec JOIN sys_physical_signs phy USING(id) - GROUP BY id - ) notRecM USING(id) - ) notRecT USING(id) + SELECT * FROM( + SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_rec + + + physical_signs_id in + + #{item} + + + + ) recId + LEFT JOIN ( + SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') rec FROM( + SELECT physical_signs_id as id, ingredient_id + FROM sys_ingredient_rec + ) rec JOIN sys_physical_signs phy USING(id) + GROUP BY id + ) recM USING(id) + INNER JOIN ( + SELECT * FROM( + SELECT DISTINCT(ingredient_id) as id FROM sys_ingredient_not_rec + + + physical_signs_id in + + #{item} + + + + ) notRecId + LEFT JOIN ( + SELECT ingredient_id as id, GROUP_CONCAT(name SEPARATOR ',') not_rec FROM( + SELECT physical_signs_id as id, ingredient_id + FROM sys_ingredient_not_rec + ) notRec JOIN sys_physical_signs phy USING(id) + GROUP BY id + ) notRecM USING(id) + ) notRecT USING(id) ) recT USING(id) @@ -97,10 +99,10 @@ - and name like concat('%', #{name}, '%') - and type = #{type} - and area = #{area} - and review_status = #{reviewStatus} + and name like concat('%', #{name}, '%') + and type = #{type} + and area = #{area} + and review_status = #{reviewStatus} @@ -141,14 +143,14 @@ - + insert into sys_ingredient_rec(ingredient_id, physical_signs_id) values (#{item.ingredientId},#{item.recommandId}) - + insert into sys_ingredient_not_rec(ingredient_id, physical_signs_id) values (#{item.ingredientId},#{item.notRecommandId}) @@ -213,4 +215,28 @@ where name = #{name} limit 1 + + + insert into sys_ingredient_file(igd_id, file_url, file_name, create_by, create_time, update_by, update_time ) + values + + (#{item.ingredientId},#{item.fileUrl},#{item.fileName},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime}) + + + + + + + + + + + + + + + update sys_ingredent_file set del_flag=1 where id=#{id} + \ No newline at end of file diff --git a/stdiet-ui/src/components/FileUpload/DragUpload.vue b/stdiet-ui/src/components/FileUpload/DragUpload.vue index 46fedccf7..6a47e08a0 100644 --- a/stdiet-ui/src/components/FileUpload/DragUpload.vue +++ b/stdiet-ui/src/components/FileUpload/DragUpload.vue @@ -1,74 +1,81 @@ diff --git a/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue b/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue index 14da04c39..ed00da5b0 100644 --- a/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue +++ b/stdiet-ui/src/components/FileUpload/DragUploadEdit.vue @@ -1,41 +1,58 @@ diff --git a/stdiet-ui/src/views/custom/customerCase/index.vue b/stdiet-ui/src/views/custom/customerCase/index.vue index b1ec42819..53800dc9f 100644 --- a/stdiet-ui/src/views/custom/customerCase/index.vue +++ b/stdiet-ui/src/views/custom/customerCase/index.vue @@ -1,6 +1,12 @@ - + - + @@ -127,7 +161,11 @@ }} - + - +
- - - - - - - - - - - - - + + + + + + + + + + + + + - - - 选择所属客户 - - - - - - + + + + 选择所属客户 + + + + + +