Browse Source

Merge remote-tracking branch 'origin/main' into main

pengzhenggao 2 tuần trước cách đây
mục cha
commit
47fe5802e5
17 tập tin đã thay đổi với 649 bổ sung131 xóa
  1. 13 0
      fuintBackend/fuint-application/pom.xml
  2. 2 2
      fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/IngredientDto.java
  3. 3 0
      fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/MtPurchaseOrderDto.java
  4. 1 1
      fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/VersionDto.java
  5. 3 3
      fuintBackend/fuint-application/src/main/java/com/fuint/common/service/IngredientService.java
  6. 1 1
      fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/CartServiceImpl.java
  7. 91 21
      fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/IngredientServiceImpl.java
  8. 94 10
      fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/VersionServiceImpl.java
  9. 139 0
      fuintBackend/fuint-application/src/main/java/com/fuint/common/util/HuaweiObsUtil.java
  10. 1 1
      fuintBackend/fuint-application/src/main/java/com/fuint/common/vo/IngredientVo.java
  11. 19 0
      fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendAccountController.java
  12. 1 4
      fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendDutyController.java
  13. 264 77
      fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendFileController.java
  14. 7 6
      fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendIngredientController.java
  15. 1 1
      fuintBackend/fuint-framework/src/main/java/com/fuint/framework/exception/GlobalExceptionHandler.java
  16. 1 1
      fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtIngredient.java
  17. 8 3
      fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtVersion.java

+ 13 - 0
fuintBackend/fuint-application/pom.xml

@@ -157,6 +157,19 @@
             <artifactId>commons-lang3</artifactId>
             <version>3.12.0</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.huaweicloud</groupId>
+            <artifactId>esdk-obs-java</artifactId>
+            <version>3.20.4</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.huaweicloud</groupId>
+            <artifactId>esdk-obs-java-bundle</artifactId>
+            <version>3.23.9</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 2 - 2
fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/IngredientDto.java

@@ -21,7 +21,7 @@ import java.util.Date;
 @Setter
 @TableName("mt_ingredient")
 @ApiModel(value = "ingredient表对象", description = "ingredient表对象")
-public class IngredientDto implements Serializable {
+public class IngredientDto extends Page implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
@@ -45,7 +45,7 @@ public class IngredientDto implements Serializable {
     private Long id;
 
     @ApiModelProperty("材料id")
-    private Integer materialId;
+    private String materialId;
 
     @ApiModelProperty("项目标识")
     private String project;

+ 3 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/MtPurchaseOrderDto.java

@@ -35,6 +35,9 @@ public class MtPurchaseOrderDto extends Page implements Serializable {
     @ApiModelProperty("创建时间")
     private Date createTime;
 
+    @ApiModelProperty("创建时间截止时间")
+    private Date endTime;
+
     @ApiModelProperty("创建用户id")
     private String createUserId;
 

+ 1 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/common/dto/VersionDto.java

@@ -21,7 +21,7 @@ import java.util.Date;
 @Setter
 @TableName("mt_version")
 @ApiModel(value = "version表对象", description = "version表对象")
-public class VersionDto implements Serializable {
+public class VersionDto extends Page implements Serializable {
 
     private static final long serialVersionUID = 1L;
 

+ 3 - 3
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/IngredientService.java

@@ -25,16 +25,16 @@ public interface IngredientService extends IService<MtIngredient> {
      * @param ingredientDto
      * @return
      */
-    PageResult<IngredientDto> queryIngredientPageList(IngredientDto ingredientDto);
+    PageResult<IngredientVo> queryIngredientPageList(IngredientDto ingredientDto);
 
     /**
      * 添加菜品配料表
      *
-     * @param  ingredientDto
+     * @param  ingredientDtoList
      * @throws BusinessCheckException
      * @return
      */
-    IngredientVo addIngredient(IngredientDto ingredientDto) throws BusinessCheckException;
+    void addIngredientForGoods(List<IngredientDto> ingredientDtoList) throws BusinessCheckException;
 
     /**
      * 根据ID获取菜品配料表信息

+ 1 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/CartServiceImpl.java

@@ -210,7 +210,7 @@ public class CartServiceImpl extends ServiceImpl<MtCartMapper, MtCart> implement
            return;
         }
         for (int i = 0; i < ids.length; i++) {
-            MtCart mtCart = mtCartMapper.selectById(Integer.parseInt(ids[i].trim()));
+            MtCart mtCart = mtCartMapper.selectById(Long.parseLong(ids[i].trim()));
             if (mtCart != null) {
                 mtCartMapper.deleteById(mtCart.getId());
             }

+ 91 - 21
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/IngredientServiceImpl.java

@@ -1,34 +1,34 @@
 package com.fuint.common.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Assert;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.IngredientDto;
 import com.fuint.common.util.AuthUserUtil;
 import com.fuint.common.vo.IngredientVo;
-import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
-import com.fuint.framework.pagination.PaginationRequest;
-import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.framework.web.PageResult;
+import com.fuint.repository.mapper.MtGoodsMapper;
+import com.fuint.repository.mapper.MtMaterialMapper;
+import com.fuint.repository.mapper.MtStoreMapper;
+import com.fuint.repository.model.MtGoods;
 import com.fuint.repository.model.MtIngredient;
 import com.fuint.common.service.IngredientService;
-import com.fuint.common.enums.StatusEnum;
 import com.fuint.repository.mapper.MtIngredientMapper;
-import com.github.pagehelper.PageHelper;
+import com.fuint.repository.model.MtMaterial;
 import lombok.AllArgsConstructor;
-import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.github.pagehelper.Page;
-import org.springframework.data.domain.PageImpl;
-import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 菜品配料表服务接口
@@ -44,8 +44,11 @@ public class IngredientServiceImpl extends ServiceImpl<MtIngredientMapper, MtIng
 
     private MtIngredientMapper mtIngredientMapper;
 
+    private MtStoreMapper mtStoreMapper;
 
+    private MtGoodsMapper mtGoodsMapper;
 
+    private MtMaterialMapper mtMaterialMapper;
 
     /**
      * 根据条件搜索菜品配料分页列表
@@ -55,24 +58,50 @@ public class IngredientServiceImpl extends ServiceImpl<MtIngredientMapper, MtIng
      * @return
      * */
     @Override
-    public PageResult<IngredientDto> queryIngredientPageList(IngredientDto ingredientDto) {
+    public PageResult<IngredientVo> queryIngredientPageList(IngredientDto ingredientDto) {
         AccountInfo accountInfo = AuthUserUtil.get();
         Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
-        Assert.isTrue(accountInfo.getStoreId()!=0, "暂无该餐厅权限");
-        return null;
+
+        IPage page = new Page(ingredientDto.getPageNo(), ingredientDto.getPageSize());
+        IPage<MtIngredient> ingredientIPage = mtIngredientMapper.selectPage(page, new LambdaQueryWrapper<MtIngredient>()
+                .eq(MtIngredient::getGoodsId, ingredientDto.getGoodsId()));
+        List<IngredientVo> ingredientVos = new ArrayList<>();
+        if (ObjectUtils.isNotEmpty(ingredientIPage.getRecords())){
+            ingredientVos = BeanUtil.copyToList(ingredientIPage.getRecords(), IngredientVo.class);
+        }
+        return PageResult.<IngredientVo>builder().data(ingredientVos).currentPage((int) ingredientIPage.getCurrent()).total((int) ingredientIPage.getTotal()).build();
     }
 
 
     /**
-     * 添加菜品配料表
+     * 给菜品添加配料表
      *
-     * @param ingredientDto 菜品配料表信息
+     * @param ingredientDtoList 菜品配料表信息
      * @return
      */
 
     @Override
-    public IngredientVo addIngredient(IngredientDto ingredientDto) throws BusinessCheckException {
-        return null;
+    @Transactional(rollbackFor = Exception.class)
+    public void addIngredientForGoods(List<IngredientDto> ingredientDtoList){
+
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(ingredientDtoList), "参数不能为空");
+
+        Set<String> goodIdSet = ingredientDtoList.stream().map(IngredientDto::getGoodsId).collect(Collectors.toSet());
+        Assert.isFalse(goodIdSet.size()!=1, "请选择同一个菜品");
+
+        List<String> materialIdList = ingredientDtoList.stream().map(IngredientDto::getMaterialId).collect(Collectors.toList());
+        materialIdList.forEach(materialId -> {
+            Assert.isTrue(ObjectUtils.isNotEmpty(materialId), "请选择菜品配料");
+        });
+        Integer selectCount = mtIngredientMapper.selectCount(new LambdaQueryWrapper<MtIngredient>().in(MtIngredient::getMaterialId, materialIdList));
+        Assert.isFalse(selectCount!=ingredientDtoList.size(), "包含不存在的材料");
+
+        List<MtIngredient> ingredientList = BeanUtil.copyToList(ingredientDtoList, MtIngredient.class);
+        boolean b = this.saveBatch(ingredientList);
+        Assert.isTrue(b, "保存失败");
     }
 
 
@@ -83,8 +112,16 @@ public class IngredientServiceImpl extends ServiceImpl<MtIngredientMapper, MtIng
      * @return
      */
     @Override
-    public IngredientVo queryIngredientById(Long id) throws BusinessCheckException {
-        return null;
+    public IngredientVo queryIngredientById(Long id){
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(id), "参数不能为空");
+
+        MtIngredient mtIngredient = mtIngredientMapper.selectById(id);
+        Assert.isTrue(ObjectUtils.isNotEmpty(mtIngredient),"该配料不存在");
+
+        return BeanUtil.copyProperties(mtIngredient,IngredientVo.class);
     }
 
 
@@ -96,8 +133,32 @@ public class IngredientServiceImpl extends ServiceImpl<MtIngredientMapper, MtIng
      * @return
      */
     @Override
-    public IngredientVo updateIngredient(IngredientDto ingredientDto) throws BusinessCheckException {
-        return null;
+    @Transactional(rollbackFor = Exception.class)
+    public IngredientVo updateIngredient(IngredientDto ingredientDto){
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(ingredientDto), "参数不能为空");
+        Assert.isTrue(ObjectUtils.isNotEmpty(ingredientDto.getGoodsId()),"请选择菜品");
+        Assert.isTrue(ObjectUtils.isNotEmpty(ingredientDto.getMaterialId()),"请选择材料");
+
+        MtIngredient mtIngredient1 = mtIngredientMapper.selectById(ingredientDto.getId());
+        Assert.isTrue(ObjectUtils.isNotEmpty(mtIngredient1),"该配料不存在");
+
+        MtGoods mtGoods = mtGoodsMapper.selectById(ingredientDto.getGoodsId());
+        Assert.isTrue(ObjectUtils.isNotEmpty(mtGoods),"所选菜品不存在");
+
+        MtMaterial mtMaterial = mtMaterialMapper.selectById(ingredientDto.getMaterialId());
+        Assert.isTrue(ObjectUtils.isNotEmpty(mtMaterial),"所选材料不存在");
+
+        MtIngredient mtIngredient = BeanUtil.copyProperties(ingredientDto, MtIngredient.class);
+        mtIngredient.setUpdateTime(new Date());
+        mtIngredient.setUpdateUserId(accountInfo.getId().toString());
+
+        int i = mtIngredientMapper.updateById(mtIngredient);
+        Assert.isFalse(i!=1, "更新失败");
+        return BeanUtil.copyProperties(mtIngredient,IngredientVo.class);
+
     }
 
 
@@ -110,7 +171,16 @@ public class IngredientServiceImpl extends ServiceImpl<MtIngredientMapper, MtIng
      */
     @Override
     public void deleteIngredientById(Long id) {
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(id), "参数不能为空");
+
+        MtIngredient mtIngredient1 = mtIngredientMapper.selectById(id);
+        Assert.isTrue(ObjectUtils.isNotEmpty(mtIngredient1),"该配料不存在");
 
+        int i = mtIngredientMapper.deleteById(id);
+        Assert.isFalse(i!=1, "删除失败");
     }
 
 

+ 94 - 10
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/VersionServiceImpl.java

@@ -1,15 +1,25 @@
 package com.fuint.common.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Assert;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.VersionDto;
+import com.fuint.common.util.AuthUserUtil;
+import com.fuint.common.vo.IngredientVo;
 import com.fuint.common.vo.VersionVo;
 import com.fuint.framework.annoation.OperationServiceLog;
 import com.fuint.framework.exception.BusinessCheckException;
 import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.framework.web.PageResult;
+import com.fuint.repository.model.MtIngredient;
 import com.fuint.repository.model.MtVersion;
 import com.fuint.common.service.VersionService;
 import com.fuint.common.enums.StatusEnum;
@@ -19,7 +29,6 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.github.pagehelper.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
@@ -47,8 +56,18 @@ public class VersionServiceImpl extends ServiceImpl<MtVersionMapper, MtVersion>
      * @return
      */
     @Override
-    public PageResult<VersionVo> queryVersionPageList(VersionDto versionDto) throws BusinessCheckException {
-        return null;
+    public PageResult<VersionVo> queryVersionPageList(VersionDto versionDto) {
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+
+        IPage page = new Page(versionDto.getPageNo(), versionDto.getPageSize());
+        IPage iPage = mtVersionMapper.selectPage(page, new LambdaQueryWrapper<MtVersion>());
+        List<VersionVo> versionVos = new ArrayList<>();
+        if (ObjectUtils.isNotEmpty(iPage.getRecords())){
+            versionVos = BeanUtil.copyToList(iPage.getRecords(), VersionVo.class);
+        }
+        return PageResult.<VersionVo>builder().data(versionVos).currentPage((int) iPage.getCurrent()).total((int) iPage.getTotal()).build();
     }
 
     /**
@@ -59,8 +78,24 @@ public class VersionServiceImpl extends ServiceImpl<MtVersionMapper, MtVersion>
      */
     @OperationServiceLog(description = "新增版本控制表")
     @Override
-    public VersionVo addVersion(VersionDto versionDto) throws BusinessCheckException {
-        return null;
+    @Transactional(rollbackFor = Exception.class)
+    public VersionVo addVersion(VersionDto versionDto) {
+
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(versionDto), "参数不能为空");
+        List<MtVersion> mtVersions = mtVersionMapper.selectList(new LambdaQueryWrapper<MtVersion>()
+                .eq(MtVersion::getName, versionDto.getName()));
+        Assert.isTrue(ObjectUtils.isEmpty(mtVersions), "版本名称已存在");
+        MtVersion mtVersion = BeanUtil.copyProperties(versionDto, MtVersion.class);
+//        mtVersion.setCreateTime(new Date());
+//        mtVersion.setCreateUserId(String.valueOf(accountInfo.getId()));
+
+        int insert = mtVersionMapper.insert(mtVersion);
+        Assert.isFalse(insert!=1, "添加失败");
+
+        return BeanUtil.copyProperties(mtVersion, VersionVo.class);
     }
 
     /**
@@ -70,7 +105,17 @@ public class VersionServiceImpl extends ServiceImpl<MtVersionMapper, MtVersion>
      * @return
      */
     @Override
-    public VersionVo queryVersionById(Long id) throws BusinessCheckException {
+    public VersionVo queryVersionById(Long id) {
+
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(id), "请选择版本");
+        MtVersion mtVersion = mtVersionMapper.selectById(id);
+        if (ObjectUtils.isNotEmpty(mtVersion)){
+            VersionVo versionVo = BeanUtil.copyProperties(mtVersion, VersionVo.class);
+            return versionVo;
+        }
         return null;
     }
 
@@ -84,8 +129,17 @@ public class VersionServiceImpl extends ServiceImpl<MtVersionMapper, MtVersion>
     @Override
     @Transactional(rollbackFor = Exception.class)
     @OperationServiceLog(description = "删除版本控制表")
-    public void deleteVersionById(Long id) throws BusinessCheckException {
+    public void deleteVersionById(Long id) {
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(id), "请选择版本");
+
+        MtVersion mtVersion = mtVersionMapper.selectById(id);
+        Assert.isTrue(ObjectUtils.isNotEmpty(mtVersion), "版本不存在");
 
+        int delete = mtVersionMapper.deleteById(id);
+        Assert.isFalse(delete!=1, "删除失败");
     }
 
 
@@ -99,9 +153,39 @@ public class VersionServiceImpl extends ServiceImpl<MtVersionMapper, MtVersion>
     @Override
     @Transactional(rollbackFor = Exception.class)
     @OperationServiceLog(description = "更新版本控制表")
-    public VersionVo updateVersion(VersionDto versionDto) throws BusinessCheckException {
-        return null;
-    }
+    public VersionVo updateVersion(VersionDto versionDto) {
+
+        AccountInfo accountInfo = AuthUserUtil.get();
+        Assert.isTrue(ObjectUtils.isNotEmpty(accountInfo), "请登录");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(versionDto), "参数不能为空");
+        Assert.isTrue(ObjectUtils.isNotEmpty(versionDto.getId()), "请选择版本");
+
+        MtVersion mtVersion = mtVersionMapper.selectById(versionDto.getId());
+        Assert.isTrue(ObjectUtils.isNotEmpty(mtVersion), "版本不存在");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(versionDto.getName()), "版本名称不能为空");
+
+        List<MtVersion> mtVersions = mtVersionMapper.selectList(new LambdaQueryWrapper<MtVersion>()
+                .eq(MtVersion::getName, versionDto.getName()));
+        Assert.isTrue(ObjectUtils.isEmpty(mtVersions), "版本名称已存在");
 
+        Assert.isTrue(mtVersion.getName().equals(versionDto.getName()), "不能修改版本名");
+
+        Assert.isTrue(ObjectUtils.isNotEmpty(versionDto.getStatus()), "请选择状态");
+
+        //只存在一个当前版本
+        if (versionDto.getStatus() == 1 && mtVersion.getStatus() != 1){
+            mtVersionMapper.update(MtVersion.builder().status(0).build(), new LambdaUpdateWrapper<MtVersion>().eq(MtVersion::getStatus, 1));
+        }
+
+//        versionDto.setUpdateTime(new Date());
+//        versionDto.setUpdateUserId(String.valueOf(accountInfo.getId()));
+
+        int i = mtVersionMapper.updateById(BeanUtil.copyProperties(versionDto, MtVersion.class));
+        Assert.isFalse(i!=1, "更新失败");
+
+        return BeanUtil.copyProperties(mtVersion, VersionVo.class);
+    }
 
 }

+ 139 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/util/HuaweiObsUtil.java

@@ -0,0 +1,139 @@
+package com.fuint.common.util;
+
+/**
+ * HuaweiObsUtil 类。
+ * <p>
+ * 描述:
+ *
+ * @author huangwenwen
+ * @date 2025/2/28
+ */
+
+
+
+
+import com.obs.services.ObsClient;
+import com.obs.services.exception.ObsException;
+import com.obs.services.model.DeleteObjectRequest;
+import com.obs.services.model.PutObjectRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Date;
+
+/**
+ * 华为云OBS存储工具
+ *
+ * Created by FSQ
+ * CopyRight https://www.fuint.cn
+ */
+public class HuaweiObsUtil {
+
+    private static final Logger logger = LoggerFactory.getLogger(HuaweiObsUtil.class);
+
+    /**
+     * 获取华为云OBS客户端对象
+     *
+     * @param accessKeyId 访问键值
+     * @param accessKeySecret 访问秘钥
+     * @param endpoint 存储endPoint
+     * @return obsClient
+     */
+    public static ObsClient getObsClient(String accessKeyId, String accessKeySecret, String endpoint) {
+        return new ObsClient(accessKeyId, accessKeySecret, endpoint);
+    }
+
+    /**
+     * 创建存储空间
+     *
+     * @param obsClient OBS连接
+     * @param bucketName 存储空间名称
+     * @return 存储空间名称
+     */
+    public static String createBucket(ObsClient obsClient, String bucketName) {
+        try {
+            if (!obsClient.headBucket(bucketName)) {
+                obsClient.createBucket(bucketName);
+                logger.info("创建存储空间成功");
+            }
+        } catch (ObsException e) {
+            logger.error("创建存储空间失败: " + e.getMessage(), e);
+        }
+        return bucketName;
+    }
+
+    /**
+     * 创建文件夹
+     *
+     * @param obsClient obs连接
+     * @param bucketName 存储bucket
+     * @param folder 文件夹路径
+     * @return 文件夹路径
+     */
+    public static String createFolder(ObsClient obsClient, String bucketName, String folder) {
+        String folderName = folder.endsWith("/") ? folder : folder + "/"; // 确保以"/"结尾
+        try {
+            if (!obsClient.doesObjectExist(bucketName, folderName)) {
+                InputStream emptyStream = new FileInputStream(new File(""));
+                obsClient.putObject(new PutObjectRequest(bucketName, folderName, emptyStream));
+                logger.info("创建文件夹成功");
+            }
+        } catch (ObsException e) {
+            logger.error("创建文件夹失败: " + e.getMessage(), e);
+        } catch (FileNotFoundException e) {
+            throw new RuntimeException(e);
+        }
+        return folderName;
+    }
+
+    /**
+     * 上传文件至OBS
+     *
+     * @param obsClient obs连接
+     * @param file 上传文件(文件全路径如:D:\\image\\cake.jpg)
+     * @param bucketName 存储空间
+     * @param folder 文件夹
+     * @return String 返回文件url
+     */
+    public static String upload(ObsClient obsClient, File file, String bucketName, String folder) {
+        String resultStr = null;
+
+        // 创建存储空间和文件夹
+        createBucket(obsClient, bucketName);
+        createFolder(obsClient, bucketName, folder);
+
+        try {
+            InputStream is = new FileInputStream(file);
+            String fileName = file.getName();
+            String date = DateUtil.formatDate(new Date(), "yyyyMMdd");
+            PutObjectRequest request = new PutObjectRequest(bucketName, folder + "/" + date + "/" + fileName, is);
+            obsClient.putObject(request);
+            resultStr = "/" + folder + "/" + date + "/" + fileName;
+        } catch (Exception e) {
+            logger.error("上传华为云OBS服务器异常: " + e.getMessage(), e);
+        }
+
+        return resultStr;
+    }
+
+    /**
+     * 根据key删除OBS上的文件
+     *
+     * @param obsClient obs连接
+     * @param bucketName 存储空间
+     * @param folder 文件夹
+     * @param key 文件路径(包括文件名,如 "uploads/cake.jpg")
+     */
+    public static void deleteFile(ObsClient obsClient, String bucketName, String folder, String key) {
+        try {
+            DeleteObjectRequest deleteObjectRequest = new DeleteObjectRequest(bucketName, folder + key);
+            obsClient.deleteObject(deleteObjectRequest);
+            logger.info("删除 " + bucketName + " 下的文件 " + folder + key + " 成功");
+        } catch (ObsException e) {
+            logger.error("删除文件失败: " + e.getMessage(), e);
+        }
+    }
+}

+ 1 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/common/vo/IngredientVo.java

@@ -45,7 +45,7 @@ public class IngredientVo implements Serializable {
     private Long id;
 
     @ApiModelProperty("材料id")
-    private Integer materialId;
+    private String materialId;
 
     @ApiModelProperty("项目标识")
     private String project;

+ 19 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendAccountController.java

@@ -287,6 +287,14 @@ public class BackendAccountController extends BaseController {
             return getFailureResult(1001, "请先登录");
         }
 
+        if (id == loginAccount.getId()) {
+            return getFailureResult(201, "不能修改自己的权限");
+        }
+
+        if ("admin".equals(loginAccount.getAccountName())){
+            return getFailureResult(201, "抱歉,不能修改超级管理员的信息");
+        }
+
         TAccount tAccount = tAccountService.getAccountInfoById(id);
         tAccount.setAcctId(id);
         tAccount.setRealName(realName);
@@ -346,12 +354,16 @@ public class BackendAccountController extends BaseController {
         if (accountInfo == null) {
             return getFailureResult(1001, "请先登录");
         }
+
         String ids[] = userIds.split(",");
         if (ids.length > 0) {
             for (int i = 0; i < ids.length; i++) {
                  if (StringUtil.isNotEmpty(ids[i])) {
                      Long userId = Long.parseLong(ids[i]);
                      TAccount tAccount = tAccountService.getAccountInfoById(userId);
+                     if (StringUtil.equals("admin", tAccount.getAccountName())) {
+                         return getFailureResult(201, "抱歉,不能删除超级管理员");
+                     }
                      if (tAccount == null) {
                          return getFailureResult(201, "账户不存在");
                      }
@@ -393,6 +405,13 @@ public class BackendAccountController extends BaseController {
         if (tAccount == null) {
             return getFailureResult(201, "账户不存在");
         }
+        if (StringUtil.equals(accountDto.getAccountName(), tAccount.getAccountName())) {
+            return getFailureResult(201, "您不能修改自己的状态");
+        }
+
+        if (StringUtil.equals("admin", tAccount.getAccountName())) {
+            return getFailureResult(201, "抱歉,不能修改超级管理员的状态");
+        }
 
         tAccount.setAccountStatus(status);
         tAccountService.updateAccount(tAccount);

+ 1 - 4
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendDutyController.java

@@ -241,10 +241,7 @@ public class BackendDutyController extends BaseController {
         // 获取角色所分配的菜单
         List<TSource> sources = null;
         if (!menuIds.isEmpty()) {
-            String[] sourceIds = new String[menuIds.size()];
-            for (int i = 0; i < sourceIds.length; i++) {
-                 sourceIds[i] = menuIds.get(i);
-            }
+            String[] sourceIds = menuIds.toArray(new String[0]);
             sources = tSourceService.findDatasByIds(sourceIds);
         }
 

+ 264 - 77
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendFileController.java

@@ -1,15 +1,207 @@
+//package com.fuint.module.backendApi.controller;
+//
+//import com.aliyun.oss.OSS;
+//import com.fuint.common.dto.AccountInfo;
+//import com.fuint.common.service.SettingService;
+//import com.fuint.common.util.AliyunOssUtil;
+//import com.fuint.common.util.CommonUtil;
+//import com.fuint.common.util.DateUtil;
+//import com.fuint.common.util.TokenUtil;
+//import com.fuint.framework.web.BaseController;
+//import com.fuint.framework.web.ResponseObject;
+//import com.fuint.utils.StringUtil;
+//import io.swagger.annotations.Api;
+//import io.swagger.annotations.ApiOperation;
+//import lombok.AllArgsConstructor;
+//import org.springframework.util.ResourceUtils;
+//import org.springframework.web.bind.annotation.CrossOrigin;
+//import org.springframework.web.bind.annotation.RequestMapping;
+//import org.springframework.web.bind.annotation.RequestMethod;
+//import org.springframework.web.bind.annotation.RestController;
+//import org.springframework.web.multipart.MultipartFile;
+//import org.springframework.web.multipart.MultipartHttpServletRequest;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.springframework.core.env.Environment;
+//import javax.servlet.http.HttpServletRequest;
+//import java.io.File;
+//import java.util.Date;
+//import java.util.HashMap;
+//import java.util.Map;
+//import java.util.UUID;
+//
+///**
+// * 文件上传管理控制类
+// *
+// * Created by FSQ
+// * CopyRight https://www.fuint.cn
+// */
+//@Api(tags="管理端-文件上传相关接口")
+//@RestController
+//@AllArgsConstructor
+//@RequestMapping(value = "/backendApi/file")
+//public class BackendFileController extends BaseController {
+//
+//    private static final Logger logger = LoggerFactory.getLogger(BackendFileController.class);
+//
+//    /**
+//     * 环境变量
+//     * */
+//    private Environment env;
+//
+//    /**
+//     * 系统设置服务接口
+//     * */
+//    private SettingService settingService;
+//
+//    /**
+//     * 后台上传文件
+//     *
+//     * @param request
+//     * @throws
+//     */
+//    @ApiOperation(value = "后台上传文件")
+//    @RequestMapping(value = "/upload", method = RequestMethod.POST)
+//    @CrossOrigin
+//    public ResponseObject uploadFileLocal(HttpServletRequest request) {
+//        String token = request.getHeader("Access-Token");
+//        String action = request.getParameter("action") == null ? "" : request.getParameter("action");
+//
+//        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+//        if (accountInfo == null) {
+//            return getFailureResult(1001, "请先登录");
+//        }
+//
+//        if (action.equals("config")) {
+//            Map<String, Object> outParams = new HashMap();
+//            outParams.put("imageActionName", "upload");
+//            outParams.put("fileActionName", "upload");
+//            outParams.put("fileFieldName", "file");
+//            outParams.put("imageFieldName", "file");
+//            outParams.put("fileUrlPrefix", "");
+//            outParams.put("imageUrlPrefix", "");
+//            return getSuccessResult(outParams);
+//        }
+//
+//        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+//        String sourcePic = request.getParameter("sourcePic");// 页面图片元素的ID
+//        MultipartFile file = multipartRequest.getFile(sourcePic);
+//
+//        if (file == null) {
+//            Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+//            if (fileMap.size() > 0) {
+//                file = fileMap.get("file");
+//            }
+//        }
+//
+//        Map<String, String> resultMap = new HashMap<>();
+//        String originalFilename = file.getOriginalFilename();
+//        if (StringUtil.isEmpty(originalFilename)) {
+//            return getFailureResult(201, "上传出错啦");
+//        }
+//
+//        String maxSizeStr = env.getProperty("images.upload.maxSize");
+//
+//        // 默认限制2M
+//        float maxSize = 2;
+//        try {
+//            maxSize = Float.parseFloat(maxSizeStr);
+//        } catch (NumberFormatException e) {
+//            logger.error("图片允许的大小设置不正确", e);
+//        }
+//        if (file.getSize() > (maxSize * 1024 * 1024)) {
+//            return getFailureResult(201, "上传的文件不能大于" + maxSize + "MB");
+//        }
+//
+//        String fileType = file.getContentType();
+//
+//        // 保存文件
+//        try {
+//            String fileName = saveFile(file);
+//            String baseImage = settingService.getUploadBasePath();
+//            String filePath = baseImage + fileName;
+//            String url = filePath;
+//
+//            // 上传阿里云oss
+//            String mode = env.getProperty("aliyun.oss.mode");
+//            if (mode.equals("1") && fileType.indexOf("image") >= 0) { // 检查是否开启上传
+//                String endpoint = env.getProperty("aliyun.oss.endpoint");
+//                String accessKeyId = env.getProperty("aliyun.oss.accessKeyId");
+//                String accessKeySecret = env.getProperty("aliyun.oss.accessKeySecret");
+//                String bucketName = env.getProperty("aliyun.oss.bucketName");
+//                String folder = env.getProperty("aliyun.oss.folder");
+//                String domain = env.getProperty("aliyun.oss.domain");
+//                OSS ossClient = AliyunOssUtil.getOSSClient(accessKeyId, accessKeySecret, endpoint);
+//                String pathRoot = env.getProperty("images.root");
+//                if (pathRoot == null || StringUtil.isEmpty(pathRoot)) {
+//                    pathRoot = ResourceUtils.getURL("classpath:").getPath();
+//                }
+//                File ossFile = new File(pathRoot + fileName);
+//                fileName = AliyunOssUtil.upload(ossClient, ossFile, bucketName, folder);
+//                filePath = domain + fileName;
+//                url = filePath;
+//            }
+//
+//            resultMap.put("status", "success");
+//            resultMap.put("domain", baseImage);
+//            resultMap.put("filePath", filePath);
+//            resultMap.put("fileName", fileName);
+//            resultMap.put("state", "SUCCESS");
+//            resultMap.put("original", file.getOriginalFilename());
+//            resultMap.put("size", file.getSize()+"");
+//            resultMap.put("title", fileName);
+//            resultMap.put("type", file.getContentType());
+//            resultMap.put("url", url);
+//            String ip = CommonUtil.getIPFromHttpRequest(request);
+//            logger.info("用户ip:{},上传文件url:{}", ip, url);
+//        } catch (Exception e) {
+//            return getFailureResult(201, "上传失败,请检查上传配置及权限");
+//        }
+//
+//        return getSuccessResult(resultMap);
+//    }
+//
+//    public String saveFile(MultipartFile file) throws Exception {
+//        String fileName = file.getOriginalFilename();
+//
+//        String imageName = fileName.substring(fileName.lastIndexOf("."));
+//
+//        String pathRoot = env.getProperty("images.root");
+//        if (pathRoot == null || StringUtil.isEmpty(pathRoot)) {
+//            pathRoot = ResourceUtils.getURL("classpath:").getPath();
+//        }
+//        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
+//
+//        String baseImage = env.getProperty("images.path");
+//        String filePath = baseImage + DateUtil.formatDate(new Date(), "yyyyMMdd")+"/";
+//
+//        String path = filePath + uuid + imageName;
+//
+//        try {
+//            File tempFile = new File(pathRoot + path);
+//            if (!tempFile.getParentFile().exists()) {
+//                tempFile.getParentFile().mkdirs();
+//            }
+//            CommonUtil.saveMultipartFile(file, pathRoot + path);
+//        } catch (Exception e) {
+//            throw new Exception("上传失败,请检查目录是否可写");
+//        }
+//
+//        return path;
+//    }
+//}
+
 package com.fuint.module.backendApi.controller;
 
-import com.aliyun.oss.OSS;
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.service.SettingService;
-import com.fuint.common.util.AliyunOssUtil;
 import com.fuint.common.util.CommonUtil;
 import com.fuint.common.util.DateUtil;
 import com.fuint.common.util.TokenUtil;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.ResponseObject;
 import com.fuint.utils.StringUtil;
+import com.obs.services.model.PutObjectRequest;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -19,16 +211,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.core.env.Environment;
-import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
+import com.obs.services.ObsClient;
 
 /**
  * 文件上传管理控制类
@@ -36,7 +227,7 @@ import java.util.UUID;
  * Created by FSQ
  * CopyRight https://www.fuint.cn
  */
-@Api(tags="管理端-文件上传相关接口")
+@Api(tags = "管理端-文件上传相关接口")
 @RestController
 @AllArgsConstructor
 @RequestMapping(value = "/backendApi/file")
@@ -46,143 +237,137 @@ public class BackendFileController extends BaseController {
 
     /**
      * 环境变量
-     * */
+     */
     private Environment env;
 
     /**
      * 系统设置服务接口
-     * */
+     */
     private SettingService settingService;
 
     /**
      * 后台上传文件
      *
-     * @param request
-     * @throws
+     * @param uploadFile
+     * @param token
+     * @return ResponseObject
      */
     @ApiOperation(value = "后台上传文件")
     @RequestMapping(value = "/upload", method = RequestMethod.POST)
     @CrossOrigin
-    public ResponseObject uploadFileLocal(HttpServletRequest request) {
-        String token = request.getHeader("Access-Token");
-        String action = request.getParameter("action") == null ? "" : request.getParameter("action");
+    public ResponseObject uploadFileLocal(MultipartFile uploadFile, String token) {
+//        // 验证 token 是否有效
+//        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
+//        if (accountInfo == null) {
+//            return getFailureResult(1001, "请先登录");
+//        }
 
-        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
-        if (accountInfo == null) {
-            return getFailureResult(1001, "请先登录");
+        // 校验上传的文件是否为空
+        if (uploadFile == null || uploadFile.isEmpty()) {
+            return getFailureResult(201, "上传的文件不能为空");
         }
 
-        if (action.equals("config")) {
-            Map<String, Object> outParams = new HashMap();
-            outParams.put("imageActionName", "upload");
-            outParams.put("fileActionName", "upload");
-            outParams.put("fileFieldName", "file");
-            outParams.put("imageFieldName", "file");
-            outParams.put("fileUrlPrefix", "");
-            outParams.put("imageUrlPrefix", "");
-            return getSuccessResult(outParams);
-        }
-
-        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
-        String sourcePic = request.getParameter("sourcePic");// 页面图片元素的ID
-        MultipartFile file = multipartRequest.getFile(sourcePic);
-
-        if (file == null) {
-            Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
-            if (fileMap.size() > 0) {
-                file = fileMap.get("file");
-            }
-        }
-
-        Map<String, String> resultMap = new HashMap<>();
-        String originalFilename = file.getOriginalFilename();
+        // 获取文件的原始文件名
+        String originalFilename = uploadFile.getOriginalFilename();
         if (StringUtil.isEmpty(originalFilename)) {
-            return getFailureResult(201, "上传出错啦");
+            return getFailureResult(201, "上传文件获取失败");
         }
 
+        // 获取上传文件的最大允许大小
         String maxSizeStr = env.getProperty("images.upload.maxSize");
-
-        // 默认限制2M
-        float maxSize = 2;
+        float maxSize = 2;  // 默认限制 2MB
         try {
             maxSize = Float.parseFloat(maxSizeStr);
         } catch (NumberFormatException e) {
             logger.error("图片允许的大小设置不正确", e);
         }
-        if (file.getSize() > (maxSize * 1024 * 1024)) {
-            return getFailureResult(201, "上传的文件不能大于" + maxSize + "MB");
+
+        // 判断文件大小
+        if (uploadFile.getSize() > (maxSize * 1024 * 1024)) {
+            return getFailureResult(201, "上传的文件不能大于 " + maxSize + "MB");
         }
 
-        String fileType = file.getContentType();
+        // 获取文件类型
+        String fileType = uploadFile.getContentType();
 
-        // 保存文件
+        // 保存文件并上传到华为云OBS
         try {
-            String fileName = saveFile(file);
+            String fileName = saveFile(uploadFile);
             String baseImage = settingService.getUploadBasePath();
             String filePath = baseImage + fileName;
             String url = filePath;
 
-            // 上传阿里云oss
-            String mode = env.getProperty("aliyun.oss.mode");
-            if (mode.equals("1") && fileType.indexOf("image") >= 0) { // 检查是否开启上传
-                String endpoint = env.getProperty("aliyun.oss.endpoint");
-                String accessKeyId = env.getProperty("aliyun.oss.accessKeyId");
-                String accessKeySecret = env.getProperty("aliyun.oss.accessKeySecret");
-                String bucketName = env.getProperty("aliyun.oss.bucketName");
-                String folder = env.getProperty("aliyun.oss.folder");
-                String domain = env.getProperty("aliyun.oss.domain");
-                OSS ossClient = AliyunOssUtil.getOSSClient(accessKeyId, accessKeySecret, endpoint);
+            // 上传到华为云OBS
+            String mode = env.getProperty("huaweicloud.obs.mode");
+            if (mode.equals("1") && fileType.indexOf("image") >= 0) { // 如果启用了华为云上传
+                String endpoint = env.getProperty("huaweicloud.obs.endpoint");
+                String accessKeyId = env.getProperty("huaweicloud.obs.accessKey");
+                String accessKeySecret = env.getProperty("huaweicloud.obs.secretKey");
+                String bucketName = env.getProperty("huaweicloud.obs.bucketName");
+                String folder = env.getProperty("huaweicloud.obs.folder");
+                String domain = env.getProperty("huaweicloud.obs.domain");
+
+                // 创建 OBS 客户端
+                ObsClient obsClient = new ObsClient(accessKeyId, accessKeySecret, endpoint);
                 String pathRoot = env.getProperty("images.root");
                 if (pathRoot == null || StringUtil.isEmpty(pathRoot)) {
                     pathRoot = ResourceUtils.getURL("classpath:").getPath();
                 }
-                File ossFile = new File(pathRoot + fileName);
-                fileName = AliyunOssUtil.upload(ossClient, ossFile, bucketName, folder);
-                filePath = domain + fileName;
+                File obsFile = new File(pathRoot + fileName);
+                fileName = folder + "/" + fileName; // 设置上传到 OBS 的路径
+                // 上传文件到 OBS
+                obsClient.putObject(new PutObjectRequest(bucketName, fileName, obsFile));
+
+                filePath = domain + "/" + fileName;
                 url = filePath;
             }
 
+            Map<String, String> resultMap = new HashMap<>();
             resultMap.put("status", "success");
             resultMap.put("domain", baseImage);
             resultMap.put("filePath", filePath);
             resultMap.put("fileName", fileName);
             resultMap.put("state", "SUCCESS");
-            resultMap.put("original", file.getOriginalFilename());
-            resultMap.put("size", file.getSize()+"");
+            resultMap.put("original", uploadFile.getOriginalFilename());
+            resultMap.put("size", uploadFile.getSize() + "");
             resultMap.put("title", fileName);
-            resultMap.put("type", file.getContentType());
+            resultMap.put("type", uploadFile.getContentType());
             resultMap.put("url", url);
-            String ip = CommonUtil.getIPFromHttpRequest(request);
+            String ip = CommonUtil.getIPFromHttpRequest(null);
             logger.info("用户ip:{},上传文件url:{}", ip, url);
+
+            return getSuccessResult(resultMap);
         } catch (Exception e) {
             return getFailureResult(201, "上传失败,请检查上传配置及权限");
         }
-
-        return getSuccessResult(resultMap);
     }
 
-    public String saveFile(MultipartFile file) throws Exception {
-        String fileName = file.getOriginalFilename();
-
-        String imageName = fileName.substring(fileName.lastIndexOf("."));
+    /**
+     * 保存文件到本地磁盘
+     *
+     * @param uploadFile
+     * @return 文件路径
+     * @throws Exception
+     */
+    public String saveFile(MultipartFile uploadFile) throws Exception {
+        String fileName = uploadFile.getOriginalFilename();
+        String fileExtension = fileName.substring(fileName.lastIndexOf("."));
+        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
 
         String pathRoot = env.getProperty("images.root");
         if (pathRoot == null || StringUtil.isEmpty(pathRoot)) {
             pathRoot = ResourceUtils.getURL("classpath:").getPath();
         }
-        String uuid = UUID.randomUUID().toString().replaceAll("-", "");
-
         String baseImage = env.getProperty("images.path");
-        String filePath = baseImage + DateUtil.formatDate(new Date(), "yyyyMMdd")+"/";
-
-        String path = filePath + uuid + imageName;
+        String filePath = baseImage + DateUtil.formatDate(new Date(), "yyyyMMdd") + "/";
+        String path = filePath + uuid + fileExtension;
 
         try {
             File tempFile = new File(pathRoot + path);
             if (!tempFile.getParentFile().exists()) {
                 tempFile.getParentFile().mkdirs();
             }
-            CommonUtil.saveMultipartFile(file, pathRoot + path);
+            CommonUtil.saveMultipartFile(uploadFile, pathRoot + path);
         } catch (Exception e) {
             throw new Exception("上传失败,请检查目录是否可写");
         }
@@ -190,3 +375,5 @@ public class BackendFileController extends BaseController {
         return path;
     }
 }
+
+

+ 7 - 6
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendIngredientController.java

@@ -22,6 +22,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import javax.servlet.http.HttpServletRequest;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -53,7 +54,7 @@ public class BackendIngredientController extends BaseController {
     @PreAuthorize("@pms.hasPermission('ingredient:list')")
     public ResponseObject list(HttpServletRequest request, IngredientDto ingredientDto) throws BusinessCheckException {
 
-        PageResult<IngredientDto> result = ingredientService.queryIngredientPageList(ingredientDto);
+        PageResult<IngredientVo> result = ingredientService.queryIngredientPageList(ingredientDto);
 
         return getSuccessResult(result);
     }
@@ -91,18 +92,18 @@ public class BackendIngredientController extends BaseController {
     }
 
     /**
-     * 保存菜品配料表
+     * 为菜品添加配料
      *
      * @param request HttpServletRequest对象
      * @return
      */
-    @ApiOperation(value = "保存菜品配料表")
-    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiOperation(value = "为菜品添加配料")
+    @RequestMapping(value = "/addIngredientForGoods", method = RequestMethod.POST)
     @CrossOrigin
     @PreAuthorize("@pms.hasPermission('ingredient:add')")
-    public ResponseObject saveHandler(HttpServletRequest request, @RequestBody IngredientDto ingredientDto) throws BusinessCheckException {
+    public ResponseObject addIngredientForGoods(HttpServletRequest request, @RequestBody List<IngredientDto > ingredientDtoList) throws BusinessCheckException {
 
-        ingredientService.addIngredient(ingredientDto);
+        ingredientService.addIngredientForGoods(ingredientDtoList);
 
         return getSuccessResult(true);
     }

+ 1 - 1
fuintBackend/fuint-framework/src/main/java/com/fuint/framework/exception/GlobalExceptionHandler.java

@@ -27,7 +27,7 @@ public class GlobalExceptionHandler {
     public ResponseObject handleHttpRequestMethodNotSupported(IllegalArgumentException e,HttpServletRequest request){
         String requestURI = request.getRequestURI();
         e.printStackTrace();
-        return new ResponseObject(400, e.getMessage(), null);
+        return new ResponseObject(201, e.getMessage(), null);
     }
 
     /**

+ 1 - 1
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtIngredient.java

@@ -44,7 +44,7 @@ public class MtIngredient implements Serializable {
     private Long id;
 
     @ApiModelProperty("材料id")
-    private Integer materialId;
+    private String materialId;
 
     @ApiModelProperty("项目标识")
     private String project;

+ 8 - 3
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtVersion.java

@@ -1,12 +1,12 @@
 package com.fuint.repository.model;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
+
 import java.io.Serializable;
 import java.util.Date;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Builder;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -18,6 +18,7 @@ import lombok.Setter;
  */
 @Getter
 @Setter
+@Builder
 @TableName("mt_version")
 @ApiModel(value = "version表对象", description = "version表对象")
 public class MtVersion implements Serializable {
@@ -25,9 +26,11 @@ public class MtVersion implements Serializable {
     private static final long serialVersionUID = 1L;
 
     @ApiModelProperty("创建时间")
+    @TableField(value = "create_time",fill = FieldFill.INSERT)
     private Date createTime;
 
     @ApiModelProperty("创建用户id")
+    @TableField(value = "create_user_id",fill = FieldFill.INSERT)
     private String createUserId;
 
     @ApiModelProperty("是否删除 0否 1是")
@@ -68,9 +71,11 @@ public class MtVersion implements Serializable {
     private String type;
 
     @ApiModelProperty("更新时间")
+//    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
     private Date updateTime;
 
     @ApiModelProperty("修改用户id")
+//    @TableField(value = "update_user_id",fill = FieldFill.INSERT_UPDATE)
     private String updateUserId;
 
 }