Pārlūkot izejas kodu

菜品查询、菜品分类、app今日菜品、图片上传

he.dujuan 3 gadi atpakaļ
vecāks
revīzija
99e52930a5

+ 6 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/food/service/dto/DmFoodQueryCriteria.java

@@ -16,6 +16,8 @@
 package me.zhengjie.modules.dm.food.service.dto;
 
 import lombok.Data;
+
+import java.sql.Timestamp;
 import java.util.List;
 import me.zhengjie.annotation.Query;
 import me.zhengjie.modules.dm.foodCate.domain.DmFoodCate;
@@ -42,4 +44,8 @@ public class DmFoodQueryCriteria{
 
     @Query
     private String cateName;
+
+    /** 精确 */
+    @Query(type = Query.Type.BETWEEN)
+    private List<Timestamp> createTime;
 }

+ 24 - 4
eladmin-system/src/main/java/me/zhengjie/modules/dm/foodCate/domain/DmFoodCate.java

@@ -21,13 +21,13 @@ import io.swagger.annotations.ApiModelProperty;
 import io.swagger.models.auth.In;
 import lombok.Data;
 import me.zhengjie.base.BaseEntity;
+import me.zhengjie.domain.LocalStorage;
+import me.zhengjie.modules.system.domain.Menu;
 
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
+import javax.persistence.*;
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Objects;
 
 /**
 * @website https://el-admin.vip
@@ -57,6 +57,26 @@ public class DmFoodCate extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "分类菜品图片")
     private String picture;
 
+    @Column(name = "sub_count")
+    @ApiModelProperty(value = "子节点数目", hidden = true)
+    private Integer subCount = 0;
+
+    @Column(name = "url")
+    @ApiModelProperty(value = "url路径")
+    private Long url;
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        DmFoodCate dmFoodCate = (DmFoodCate) o;
+        return Objects.equals(id, dmFoodCate.id);
+    }
+
     public void copy(DmFoodCate source){
         BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
     }

+ 41 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/foodCate/repository/DmFoodCateRepository.java

@@ -17,8 +17,15 @@ package me.zhengjie.modules.dm.foodCate.repository;
 
 import io.swagger.models.auth.In;
 import me.zhengjie.modules.dm.foodCate.domain.DmFoodCate;
+import me.zhengjie.modules.system.domain.Menu;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import javax.persistence.criteria.CriteriaBuilder;
+import java.util.List;
+import java.util.Map;
 
 /**
 * @website https://el-admin.vip
@@ -26,4 +33,38 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
 * @date 2021-09-15
 **/
 public interface DmFoodCateRepository extends JpaRepository<DmFoodCate, Integer>, JpaSpecificationExecutor<DmFoodCate> {
+
+    @Query(value = "SELECT p.pcid,p.`name`,cate_id,c.cate_name,t.url,p.price FROM dm_day_pc p " +
+            "LEFT JOIN dm_food_cate c ON c.cate_id = p.cate LEFT JOIN tool_local_storage t ON " +
+            "c.url = t.storage_id WHERE date_format(date,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')",nativeQuery = true)
+    List<Map<String,Object>> foodApp();
+
+    /**
+     * 获取节点数量
+     * @param id /
+     * @return /
+     */
+    int countByPid(Integer id);
+
+    /**
+     * 更新节点数目
+     * @param count /
+     * @param cateId /
+     */
+    @Modifying
+    @Query(value = " update dm_food_cate set sub_count = ?1 where cate_id = ?2 ",nativeQuery = true)
+    void updateSubCntById(int count, Integer cateId);
+
+    /**
+     * 根据菜单的 PID 查询
+     * @param pid /
+     * @return /
+     */
+    List<DmFoodCate> findByPid(Integer pid);
+
+    /**
+     * 查询顶级菜单
+     * @return /
+     */
+    List<DmFoodCate> findByPidIsNull();
 }

+ 53 - 5
eladmin-system/src/main/java/me/zhengjie/modules/dm/foodCate/rest/DmFoodCateController.java

@@ -15,6 +15,7 @@
 */
 package me.zhengjie.modules.dm.foodCate.rest;
 
+import cn.hutool.core.collection.CollectionUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
@@ -22,7 +23,13 @@ import me.zhengjie.annotation.Log;
 import me.zhengjie.config.FileProperties;
 import me.zhengjie.modules.dm.foodCate.domain.DmFoodCate;
 import me.zhengjie.modules.dm.foodCate.service.DmFoodCateService;
+import me.zhengjie.modules.dm.foodCate.service.dto.DmFoodCateDto;
 import me.zhengjie.modules.dm.foodCate.service.dto.DmFoodCateQueryCriteria;
+import me.zhengjie.modules.dm.foodCate.service.mapstruct.DmFoodCateMapper;
+import me.zhengjie.modules.system.domain.Menu;
+import me.zhengjie.modules.system.service.dto.MenuDto;
+import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
+import me.zhengjie.utils.PageUtil;
 import org.springframework.data.domain.Pageable;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -32,6 +39,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.util.*;
 
 @RestController
 @RequiredArgsConstructor
@@ -40,6 +48,7 @@ import java.io.IOException;
 public class DmFoodCateController {
 
     private final DmFoodCateService dmFoodService;
+    private final DmFoodCateMapper dmFoodCateMapper;
 
     @Log("导出数据")
     @ApiOperation("导出数据")
@@ -49,12 +58,44 @@ public class DmFoodCateController {
         dmFoodService.download(dmFoodService.queryAll(criteria), response);
     }
 
+//    @GetMapping
+//    @Log("查询dmFoodCate")
+//    @ApiOperation("查询dmFoodCate")
+//    @PreAuthorize("@el.check('dmFoodCate:list')")
+//    public ResponseEntity<Object> query(DmFoodCateQueryCriteria criteria, Pageable pageable){
+//        return new ResponseEntity<>(dmFoodService.queryAll(criteria,pageable),HttpStatus.OK);
+//    }
+
     @GetMapping
     @Log("查询dmFoodCate")
     @ApiOperation("查询dmFoodCate")
     @PreAuthorize("@el.check('dmFoodCate:list')")
-    public ResponseEntity<Object> query(DmFoodCateQueryCriteria criteria, Pageable pageable){
-        return new ResponseEntity<>(dmFoodService.queryAll(criteria,pageable),HttpStatus.OK);
+    public ResponseEntity<Object> query(DmFoodCateQueryCriteria criteria, Pageable pageable) throws Exception {
+        return new ResponseEntity<>(dmFoodService.queryAll(criteria,true,pageable),HttpStatus.OK);
+    }
+
+    @ApiOperation("返回全部的菜品分类")
+    @Log("返回全部的菜品分类")
+    @GetMapping(value = "/lazy")
+    @PreAuthorize("@el.check('dmFoodCate:list')")
+    public ResponseEntity<Object> query(@RequestParam Integer pid){
+        return new ResponseEntity<>(dmFoodService.getMenus(pid),HttpStatus.OK);
+    }
+
+    @ApiOperation("查询菜品分类:根据ID获取同级与上级数据")
+    @Log("查询菜品分类:根据ID获取同级与上级数据")
+    @PostMapping("/superior")
+    @PreAuthorize("@el.check('dmFoodCate:list')")
+    public ResponseEntity<Object> getSuperior(@RequestBody List<Integer> ids) {
+        Set<DmFoodCateDto> foodCateDtos = new LinkedHashSet<>();
+        if(CollectionUtil.isNotEmpty(ids)){
+            for (Integer id : ids) {
+                DmFoodCateDto dto = dmFoodService.findById(id);
+                foodCateDtos.addAll(dmFoodService.getSuperior(dto, new ArrayList<>()));
+            }
+            return new ResponseEntity<>(dmFoodService.buildTree(new ArrayList<>(foodCateDtos)),HttpStatus.OK);
+        }
+        return new ResponseEntity<>(dmFoodService.getMenus(null),HttpStatus.OK);
     }
 
     @PostMapping
@@ -62,7 +103,8 @@ public class DmFoodCateController {
     @ApiOperation("新增dmFoodCate")
     @PreAuthorize("@el.check('dmFoodCate:add')")
     public ResponseEntity<Object> create(@Validated @RequestBody DmFoodCate resources){
-        return new ResponseEntity<>(dmFoodService.create(resources),HttpStatus.CREATED);
+        dmFoodService.create(resources);
+        return new ResponseEntity<>(HttpStatus.CREATED);
     }
 
     @PutMapping
@@ -78,8 +120,14 @@ public class DmFoodCateController {
     @ApiOperation("删除dmFoodCate")
     @PreAuthorize("@el.check('dmFoodCate:del')")
     @DeleteMapping
-    public ResponseEntity<Object> delete(@RequestBody Integer[] ids) {
-        dmFoodService.deleteAll(ids);
+    public ResponseEntity<Object> delete(@RequestBody Set<Integer> ids) {
+        Set<DmFoodCate> foodCateSet = new HashSet<>();
+        for (Integer id : ids) {
+            List<DmFoodCateDto> menuList = dmFoodService.getMenus(id);
+            foodCateSet.add(dmFoodService.findOne(id));
+            foodCateSet = dmFoodService.getChildMenus(dmFoodCateMapper.toEntity(menuList), foodCateSet);
+        }
+        dmFoodService.deleteAll(foodCateSet);
         return new ResponseEntity<>(HttpStatus.OK);
     }
 }

+ 47 - 2
eladmin-system/src/main/java/me/zhengjie/modules/dm/foodCate/service/DmFoodCateService.java

@@ -18,12 +18,16 @@ package me.zhengjie.modules.dm.foodCate.service;
 import me.zhengjie.modules.dm.foodCate.domain.DmFoodCate;
 import me.zhengjie.modules.dm.foodCate.service.dto.DmFoodCateDto;
 import me.zhengjie.modules.dm.foodCate.service.dto.DmFoodCateQueryCriteria;
+import me.zhengjie.modules.system.domain.Menu;
+import me.zhengjie.modules.system.service.dto.MenuDto;
+import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
 import org.springframework.data.domain.Pageable;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 /**
 * @website https://el-admin.vip
@@ -41,6 +45,15 @@ public interface DmFoodCateService {
     */
     Map<String,Object> queryAll(DmFoodCateQueryCriteria criteria, Pageable pageable);
 
+    /**
+     * 查询全部数据
+     * @param criteria 条件
+     * @param isQuery /
+     * @throws Exception /
+     * @return /
+     */
+    Map<String,Object> queryAll(DmFoodCateQueryCriteria criteria, Boolean isQuery, Pageable pageable) throws Exception;
+
     /**
     * 查询所有数据不分页
     * @param criteria 条件参数
@@ -55,12 +68,27 @@ public interface DmFoodCateService {
      */
     DmFoodCateDto findById(Integer id);
 
+    /**
+     * 根据ID获取同级与上级数据
+     * @param menuDto /
+     * @param objects /
+     * @return /
+     */
+    List<DmFoodCateDto> getSuperior(DmFoodCateDto menuDto, List<DmFoodCate> objects);
+
+    /**
+     * 构建菜单树
+     * @param menuDtos 原始数据
+     * @return /
+     */
+    List<DmFoodCateDto> buildTree(List<DmFoodCateDto> menuDtos);
+
     /**
     * 创建
     * @param resources /
     * @return DmFoodDto
     */
-    DmFoodCateDto create(DmFoodCate resources);
+    void create(DmFoodCate resources);
 
     /**
     * 编辑
@@ -72,7 +100,24 @@ public interface DmFoodCateService {
     * 多选删除
     * @param ids /
     */
-    void deleteAll(Integer[] ids);
+    void deleteAll(Set<DmFoodCate> ids);
+
+    List<DmFoodCateDto> getMenus(Integer pid);
+
+    /**
+     * 根据ID查询
+     * @param id /
+     * @return /
+     */
+    DmFoodCate findOne(Integer id);
+
+    /**
+     * 获取所有子节点,包含自身ID
+     * @param menuList /
+     * @param menuSet /
+     * @return /
+     */
+    Set<DmFoodCate> getChildMenus(List<DmFoodCate> menuList, Set<DmFoodCate> menuSet);
 
     /**
     * 导出数据

+ 30 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/foodCate/service/dto/DmFoodCateDto.java

@@ -19,8 +19,12 @@ import com.alibaba.fastjson.annotation.JSONField;
 import com.alibaba.fastjson.serializer.ToStringSerializer;
 import lombok.Data;
 import me.zhengjie.base.BaseDTO;
+import me.zhengjie.domain.LocalStorage;
+import me.zhengjie.modules.system.service.dto.MenuDto;
 
 import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
 
 /**
 * @website https://el-admin.vip
@@ -40,4 +44,30 @@ public class DmFoodCateDto extends BaseDTO implements Serializable {
     private String cateName;
 
     private String picture;
+
+    private Integer subCount;
+
+    private Long url;
+
+    private List<DmFoodCateDto> children;
+
+    public Boolean getHasChildren() {
+        return subCount > 0;
+    }
+
+    public Boolean getLeaf() {
+        return subCount <= 0;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        DmFoodCateDto dto = (DmFoodCateDto) o;
+        return Objects.equals(id, dto.id);
+    }
 }

+ 8 - 0
eladmin-system/src/main/java/me/zhengjie/modules/dm/foodCate/service/dto/DmFoodCateQueryCriteria.java

@@ -18,6 +18,9 @@ package me.zhengjie.modules.dm.foodCate.service.dto;
 import lombok.Data;
 import me.zhengjie.annotation.Query;
 
+import java.sql.Timestamp;
+import java.util.List;
+
 /**
 * @website https://el-admin.vip
 * @author sunmz
@@ -25,5 +28,10 @@ import me.zhengjie.annotation.Query;
 **/
 @Data
 public class DmFoodCateQueryCriteria {
+    @Query
+    private Integer pid;
+
+    @Query(type = Query.Type.IS_NULL, propName = "pid")
+    private Boolean pidIsNull;
 
 }

+ 146 - 22
eladmin-system/src/main/java/me/zhengjie/modules/dm/foodCate/service/impl/DmFoodCateServiceImpl.java

@@ -17,28 +17,31 @@ package me.zhengjie.modules.dm.foodCate.service.impl;
 
 import cn.hutool.core.lang.Snowflake;
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
 import lombok.RequiredArgsConstructor;
+import me.zhengjie.exception.BadRequestException;
 import me.zhengjie.modules.dm.foodCate.domain.DmFoodCate;
 import me.zhengjie.modules.dm.foodCate.repository.DmFoodCateRepository;
 import me.zhengjie.modules.dm.foodCate.service.DmFoodCateService;
 import me.zhengjie.modules.dm.foodCate.service.dto.DmFoodCateDto;
 import me.zhengjie.modules.dm.foodCate.service.dto.DmFoodCateQueryCriteria;
 import me.zhengjie.modules.dm.foodCate.service.mapstruct.DmFoodCateMapper;
-import me.zhengjie.utils.FileUtil;
-import me.zhengjie.utils.PageUtil;
-import me.zhengjie.utils.QueryHelp;
-import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.modules.system.domain.Menu;
+import me.zhengjie.modules.system.domain.Role;
+import me.zhengjie.modules.system.domain.User;
+import me.zhengjie.modules.system.service.dto.MenuDto;
+import me.zhengjie.utils.*;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.lang.reflect.Field;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
 * @website https://el-admin.vip
@@ -50,50 +53,163 @@ import java.util.Map;
 @RequiredArgsConstructor
 public class DmFoodCateServiceImpl implements DmFoodCateService {
 
-    private final DmFoodCateRepository dmFoodRepository;
-    private final DmFoodCateMapper dmFoodMapper;
+    private final DmFoodCateRepository dmFoodCateRepository;
+    private final DmFoodCateMapper dmFoodCateMapper;
 
     @Override
     public Map<String,Object> queryAll(DmFoodCateQueryCriteria criteria, Pageable pageable){
-        Page<DmFoodCate> page = dmFoodRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
-        return PageUtil.toPage(page.map(dmFoodMapper::toDto));
+        Page<DmFoodCate> page = dmFoodCateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(dmFoodCateMapper::toDto));
+    }
+
+    @Override
+    public Map<String,Object> queryAll(DmFoodCateQueryCriteria criteria, Boolean isQuery, Pageable pageable) throws Exception {
+//        Sort sort = new Sort(Sort.Direction.ASC, "dmFoodCateSort");
+        if(isQuery){
+            criteria.setPidIsNull(true);
+            List<Field> fields = QueryHelp.getAllFields(criteria.getClass(), new ArrayList<>());
+            for (Field field : fields) {
+                //设置对象的访问权限,保证对private的属性的访问
+                field.setAccessible(true);
+                Object val = field.get(criteria);
+                if("pidIsNull".equals(field.getName())){
+                    continue;
+                }
+                if (ObjectUtil.isNotNull(val)) {
+                    criteria.setPidIsNull(null);
+                    break;
+                }
+            }
+        }
+        Page<DmFoodCate> page = dmFoodCateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(dmFoodCateMapper::toDto));
     }
 
     @Override
     public List<DmFoodCateDto> queryAll(DmFoodCateQueryCriteria criteria){
-        return dmFoodMapper.toDto(dmFoodRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+        return dmFoodCateMapper.toDto(dmFoodCateRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
     }
 
     @Override
     @Transactional
     public DmFoodCateDto findById(Integer id) {
-        DmFoodCate dmFood = dmFoodRepository.findById(id).orElseGet(DmFoodCate::new);
+        DmFoodCate dmFood = dmFoodCateRepository.findById(id).orElseGet(DmFoodCate::new);
         ValidationUtil.isNull(dmFood.getId(),"DmFood","id",id);
-        return dmFoodMapper.toDto(dmFood);
+        return dmFoodCateMapper.toDto(dmFood);
+    }
+
+    @Override
+    public List<DmFoodCateDto> getSuperior(DmFoodCateDto dto, List<DmFoodCate> objects) {
+        if(dto.getPid() == null){
+            objects.addAll(dmFoodCateRepository.findByPidIsNull());
+            return dmFoodCateMapper.toDto(objects);
+        }
+        objects.addAll(dmFoodCateRepository.findByPid(dto.getPid()));
+        return getSuperior(findById(dto.getPid()), objects);
+    }
+
+    @Override
+    public List<DmFoodCateDto> buildTree(List<DmFoodCateDto> menuDtos) {
+        List<DmFoodCateDto> trees = new ArrayList<>();
+        Set<Integer> ids = new HashSet<>();
+        for (DmFoodCateDto menuDTO : menuDtos) {
+            if (menuDTO.getPid() == null) {
+                trees.add(menuDTO);
+            }
+            for (DmFoodCateDto it : menuDtos) {
+                if (menuDTO.getId().equals(it.getPid())) {
+                    if (menuDTO.getChildren() == null) {
+                        menuDTO.setChildren(new ArrayList<>());
+                    }
+                    menuDTO.getChildren().add(it);
+                    ids.add(it.getId());
+                }
+            }
+        }
+        if(trees.size() == 0){
+            trees = menuDtos.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
+        }
+        return trees;
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public DmFoodCateDto create(DmFoodCate resources) {
+    public void create(DmFoodCate resources) {
 //        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
 //        resources.setId((int) snowflake.nextId());
-        return dmFoodMapper.toDto(dmFoodRepository.save(resources));
+        if(resources.getPid().equals(0)){
+            resources.setPid(null);
+        }
+        dmFoodCateRepository.save(resources);
+        // 计算子节点数目
+        resources.setSubCount(0);
+        // 更新父节点菜单数目
+        updateSubCnt(resources.getPid());
     }
 
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void update(DmFoodCate resources) {
-        DmFoodCate dmFood = dmFoodRepository.findById(resources.getId()).orElseGet(DmFoodCate::new);
+        if(resources.getId().equals(resources.getPid())) {
+            throw new BadRequestException("上级不能为自己");
+        }
+        DmFoodCate dmFood = dmFoodCateRepository.findById(resources.getId()).orElseGet(DmFoodCate::new);
         ValidationUtil.isNull( dmFood.getId(),"DmFood","id",resources.getId());
+
+        if(resources.getPid().equals(0)){
+            resources.setPid(null);
+        }
+
+        // 记录的父节点ID
+        Integer oldPid = dmFood.getPid();
+        Integer newPid = resources.getPid();
+
         dmFood.copy(resources);
-        dmFoodRepository.save(dmFood);
+        dmFoodCateRepository.save(dmFood);
+        // 计算父级菜单节点数目
+        updateSubCnt(oldPid);
+        updateSubCnt(newPid);
+    }
+
+    @Override
+    public void deleteAll(Set<DmFoodCate> dmFoodCates) {
+        for (DmFoodCate foodCate : dmFoodCates) {
+            dmFoodCateRepository.deleteById(foodCate.getId());
+            updateSubCnt(foodCate.getPid());
+        }
     }
 
     @Override
-    public void deleteAll(Integer[] ids) {
-        for (Integer id : ids) {
-            dmFoodRepository.deleteById(id);
+    public List<DmFoodCateDto> getMenus(Integer pid) {
+        List<DmFoodCate> dmFoodCates;
+        if (pid.equals(0)){
+            pid = null;
         }
+        if(pid != null && !pid.equals(0)){
+            dmFoodCates = dmFoodCateRepository.findByPid(pid);
+        } else {
+            dmFoodCates = dmFoodCateRepository.findByPidIsNull();
+        }
+        return dmFoodCateMapper.toDto(dmFoodCates);
+    }
+
+    @Override
+    public DmFoodCate findOne(Integer id) {
+        DmFoodCate menu = dmFoodCateRepository.findById(id).orElseGet(DmFoodCate::new);
+        ValidationUtil.isNull(menu.getId(),"DmFoodCate","id",id);
+        return menu;
+    }
+
+    @Override
+    public Set<DmFoodCate> getChildMenus(List<DmFoodCate> menuList, Set<DmFoodCate> menuSet) {
+        for (DmFoodCate menu : menuList) {
+            menuSet.add(menu);
+            List<DmFoodCate> menus = dmFoodCateRepository.findByPid(menu.getId());
+            if(menus!=null && menus.size()!=0){
+                getChildMenus(menus, menuSet);
+            }
+        }
+        return menuSet;
     }
 
     @Override
@@ -113,4 +229,12 @@ public class DmFoodCateServiceImpl implements DmFoodCateService {
         }
         FileUtil.downloadExcel(list, response);
     }
+
+    private void updateSubCnt(Integer cateId){
+        if(cateId != null){
+            int count = dmFoodCateRepository.countByPid(cateId);
+            dmFoodCateRepository.updateSubCntById(count, cateId);
+        }
+    }
+
 }

+ 5 - 2
eladmin-system/src/main/java/me/zhengjie/modules/thirdparty/v1/OpenApiController.java

@@ -16,6 +16,7 @@ import me.zhengjie.exception.BadRequestException;
 import me.zhengjie.modules.dm.daypc.domain.DmDayPc;
 import me.zhengjie.modules.dm.daypc.service.DmDayPcService;
 import me.zhengjie.modules.dm.daypc.service.dto.DmDayPcQueryCriteria;
+import me.zhengjie.modules.dm.foodCate.repository.DmFoodCateRepository;
 import me.zhengjie.modules.dm.foodPj.domain.DmFoodPj;
 import me.zhengjie.modules.dm.foodPj.service.DmFoodPjService;
 import me.zhengjie.modules.dm.order.domain.DmOrderItem;
@@ -53,13 +54,15 @@ public class OpenApiController {
     private final LocalStorageService localStorageService;
     private final DmOrderRecordRepository dmOrderRecordRepository;
     private final DmOrderItemRepository orderItemRepository;
+    private final DmFoodCateRepository dmFoodCateRepository;
 
     @Log("获取今日菜品-App")
     @ApiOperation("获取今日菜品-App")
     @AnonymousPostMapping(value = "/foodRepository")
-    public BaseResponse<Object> foodRepository(@RequestBody QueryPageParams<DmDayPcQueryCriteria> criteria, Pageable pageable){
+    public BaseResponse<Object> foodRepository(@RequestBody QueryPageParams<DmDayPcQueryCriteria> criteria){
         SecurityUtils.CheckApiAuth(criteria);
-        return new BaseResponse<>(dmDayPcService.foodRepository());
+//        dmDayPcService.foodRepository();
+        return new BaseResponse<>(dmFoodCateRepository.foodApp());
     }
 
     @AnonymousPostMapping(value = "/createApp")

+ 4 - 2
eladmin-system/src/main/resources/config/application-dev.yml

@@ -113,8 +113,10 @@ file:
     path: ~/file/
     avatar: ~/avatar/
   linux:
-    path: /home/eladmin/file/
-    avatar: /home/eladmin/avatar/
+#    path: /home/eladmin/file/
+#    avatar: /home/eladmin/avatar/
+    path: /app/static/zhcyres
+    avatar: /app/static/zhcyres
   windows:
     path: C:\eladmin\file\
     avatar: C:\eladmin\avatar\

+ 5 - 1
eladmin-tools/src/main/java/me/zhengjie/domain/LocalStorage.java

@@ -52,17 +52,21 @@ public class LocalStorage extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "路径")
     private String path;
 
+    @ApiModelProperty(value = "网络路径")
+    private String url;
+
     @ApiModelProperty(value = "类型")
     private String type;
 
     @ApiModelProperty(value = "大小")
     private String size;
 
-    public LocalStorage(String realName,String name, String suffix, String path, String type, String size) {
+    public LocalStorage(String realName,String name, String suffix, String path,String url, String type, String size) {
         this.realName = realName;
         this.name = name;
         this.suffix = suffix;
         this.path = path;
+        this.url = url;
         this.type = type;
         this.size = size;
     }

+ 2 - 0
eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java

@@ -79,6 +79,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
         if(ObjectUtil.isNull(file)){
             throw new BadRequestException("上传失败");
         }
+        String url = "https://smartpark.caih.com/static/zhcyres/"+file.getName();
         try {
             name = StringUtils.isBlank(name) ? FileUtil.getFileNameNoEx(multipartFile.getOriginalFilename()) : name;
             LocalStorage localStorage = new LocalStorage(
@@ -86,6 +87,7 @@ public class LocalStorageServiceImpl implements LocalStorageService {
                     name,
                     suffix,
                     file.getPath(),
+                    url,
                     type,
                     FileUtil.getSize(multipartFile.getSize())
             );