营养类别等相关接口改动
This commit is contained in:
parent
4d50b29254
commit
4015c6942f
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.canteen.core.menu.controller;
|
||||
|
||||
import com.bonus.canteen.core.menu.domain.MenuMaterial;
|
||||
import com.bonus.canteen.core.menu.dto.MenuDishesTypeAddDTO;
|
||||
import com.bonus.canteen.core.menu.service.MenuDishesTypeService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -41,4 +42,17 @@ public class MenuDishesTypeController extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增菜品类别")
|
||||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("menu:material:edit")
|
||||
@SysLog(title = "新增菜品类别", businessType = OperaType.UPDATE, logType = 1,module = "仓储管理->新增菜品类别")
|
||||
@PostMapping("/addMenuDishesType")
|
||||
public AjaxResult addMenuDishesType(@RequestBody MenuDishesTypeAddDTO content) {
|
||||
try {
|
||||
return success(menuDishesTypeService.addMenuDishesType(content));
|
||||
} catch (Exception e) {
|
||||
return error("系统错误, " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import java.util.List;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.bonus.canteen.core.menu.domain.MenuNutritionType;
|
||||
import com.bonus.canteen.core.menu.dto.MenuNutritionTypeDTO;
|
||||
import com.bonus.canteen.core.menu.service.IMenuNutritionTypeService;
|
||||
import com.bonus.canteen.core.menu.vo.NutritionTypeV2VO;
|
||||
import com.bonus.canteen.core.menu.vo.NutritionTypeVo;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -78,7 +80,7 @@ public class MenuNutritionTypeController extends BaseController {
|
|||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("menu:type:add")
|
||||
@SysLog(title = "营养基础类型", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增营养基础类型")
|
||||
@PostMapping
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@RequestBody MenuNutritionType menuNutritionType) {
|
||||
try {
|
||||
return toAjax(menuNutritionTypeService.insertMenuNutritionType(menuNutritionType));
|
||||
|
|
@ -110,16 +112,16 @@ public class MenuNutritionTypeController extends BaseController {
|
|||
//@PreventRepeatSubmit
|
||||
//@RequiresPermissions("menu:type:remove")
|
||||
@SysLog(title = "营养基础类型", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除营养基础类型")
|
||||
@PostMapping("/del/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(menuNutritionTypeService.deleteMenuNutritionTypeByIds(ids));
|
||||
@PostMapping("/del")
|
||||
public AjaxResult remove(@RequestBody MenuNutritionTypeDTO menuNutritionTypeDTO) {
|
||||
return toAjax(menuNutritionTypeService.deleteMenuNutritionTypeByIds(menuNutritionTypeDTO.getIds()));
|
||||
}
|
||||
|
||||
@PostMapping({"/nutritionTypeList"})
|
||||
@ApiOperation("获取所有食材类别")
|
||||
@SysLog(title = "营养基础类型", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除营养基础类型")
|
||||
public AjaxResult getNutritionTypeList() {
|
||||
List<NutritionTypeVo> nutritionTypeList = this.menuNutritionTypeService.getNutritionTypeList();
|
||||
List<NutritionTypeV2VO> nutritionTypeList = this.menuNutritionTypeService.getNutritionTypeList();
|
||||
return AjaxResult.success(nutritionTypeList);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
package com.bonus.canteen.core.menu.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("menu_dishes_type")
|
||||
@ApiModel("菜品类型信息")
|
||||
@Data
|
||||
public class MenuDishesType extends Model<MenuDishesType> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId
|
||||
@ApiModelProperty("主键id")
|
||||
private Long id;
|
||||
@ApiModelProperty("菜品类型id")
|
||||
private Long typeId;
|
||||
@ApiModelProperty("菜品类型名称")
|
||||
private String typeName;
|
||||
@ApiModelProperty("类别别称")
|
||||
private String aliasName;
|
||||
@ApiModelProperty("是否默认(1-默认,2-非默认)")
|
||||
private Integer defaultFlag;
|
||||
@ApiModelProperty("删除标识")
|
||||
private Integer delFlag;
|
||||
@ApiModelProperty("乐观锁")
|
||||
private Integer revision;
|
||||
@ApiModelProperty("创建人")
|
||||
private String crby;
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime crtime;
|
||||
@ApiModelProperty("更新人")
|
||||
private String upby;
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime uptime;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.canteen.core.menu.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -8,7 +10,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
|
|||
|
||||
/**
|
||||
* 营养基础类型对象 menu_nutrition_type
|
||||
*
|
||||
*
|
||||
* @author xsheng
|
||||
* @date 2025-04-03
|
||||
*/
|
||||
|
|
@ -35,5 +37,13 @@ public class MenuNutritionType extends BaseEntity {
|
|||
/** 删除标志(0代表存在 1代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
@ApiModelProperty(value = "上传人")
|
||||
private String createBy;
|
||||
@ApiModelProperty(value = "修改人")
|
||||
private String updateBy;
|
||||
|
||||
@ApiModelProperty(value = "层级")
|
||||
private String level;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.canteen.core.menu.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MenuDishesTypeAddDTO implements Serializable {
|
||||
@ApiModelProperty("菜品类型名称")
|
||||
private @NotBlank(
|
||||
message = "{menu_type_name_null}"
|
||||
) String typeName;
|
||||
@ApiModelProperty("类别别称")
|
||||
private String aliasName;
|
||||
|
||||
public String getTypeName() {
|
||||
return this.typeName;
|
||||
}
|
||||
|
||||
public String getAliasName() {
|
||||
return this.aliasName;
|
||||
}
|
||||
|
||||
public void setTypeName(final String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public void setAliasName(final String aliasName) {
|
||||
this.aliasName = aliasName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.bonus.canteen.core.menu.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MenuDishesTypeEditDTO implements Serializable {
|
||||
@ApiModelProperty("菜品类型id")
|
||||
private @NotNull(
|
||||
message = "{menu_type_id_null}"
|
||||
) Long typeId;
|
||||
@ApiModelProperty("菜品类型名称")
|
||||
private String typeName;
|
||||
@ApiModelProperty("类别别称")
|
||||
private String aliasName;
|
||||
|
||||
public Long getTypeId() {
|
||||
return this.typeId;
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return this.typeName;
|
||||
}
|
||||
|
||||
public String getAliasName() {
|
||||
return this.aliasName;
|
||||
}
|
||||
|
||||
public void setTypeId(final Long typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public void setTypeName(final String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
public void setAliasName(final String aliasName) {
|
||||
this.aliasName = aliasName;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.bonus.canteen.core.menu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author xliu
|
||||
* @date 2025/4/9 17:52
|
||||
*/
|
||||
@Data
|
||||
public class MenuNutritionTypeDTO {
|
||||
private Integer[] ids;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package com.bonus.canteen.core.menu.enums;
|
||||
|
||||
public enum MenuDishesTypeDefaultFlagEnum {
|
||||
DEFAULT(1, "默认"),
|
||||
NOT_DEFAULT(2, "非默认");
|
||||
|
||||
private final Integer key;
|
||||
private final String value;
|
||||
|
||||
private MenuDishesTypeDefaultFlagEnum(Integer key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static Integer getKey(String value) {
|
||||
MenuDishesTypeDefaultFlagEnum[] enums = values();
|
||||
MenuDishesTypeDefaultFlagEnum[] var2 = enums;
|
||||
int var3 = enums.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
MenuDishesTypeDefaultFlagEnum temp = var2[var4];
|
||||
if (temp.value().equals(value)) {
|
||||
return temp.key();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getValue(Integer key) {
|
||||
MenuDishesTypeDefaultFlagEnum[] enums = values();
|
||||
MenuDishesTypeDefaultFlagEnum[] var2 = enums;
|
||||
int var3 = enums.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
MenuDishesTypeDefaultFlagEnum temp = var2[var4];
|
||||
if (temp.key().equals(key)) {
|
||||
return temp.value();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Integer key() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
private static MenuDishesTypeDefaultFlagEnum[] $values() {
|
||||
return new MenuDishesTypeDefaultFlagEnum[]{DEFAULT, NOT_DEFAULT};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.canteen.core.menu.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.menu.domain.MenuDishesType;
|
||||
import com.bonus.canteen.core.menu.domain.MenuMaterial;
|
||||
import com.bonus.canteen.core.menu.vo.MenuDishesTypeAllVO;
|
||||
|
||||
|
|
@ -11,7 +13,7 @@ import java.util.List;
|
|||
* @author xsheng
|
||||
* @date 2025-04-03
|
||||
*/
|
||||
public interface MenuDishesTypeMapper {
|
||||
public interface MenuDishesTypeMapper extends BaseMapper<MenuDishesType> {
|
||||
|
||||
List<MenuDishesTypeAllVO> getAllMenuDishesTypeList();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.bonus.canteen.core.menu.mapper;
|
|||
import java.util.List;
|
||||
|
||||
import com.bonus.canteen.core.menu.domain.MenuNutritionType;
|
||||
import com.bonus.canteen.core.menu.vo.NutritionTypeV2VO;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 营养基础类型Mapper接口
|
||||
|
|
@ -57,9 +59,15 @@ public interface MenuNutritionTypeMapper {
|
|||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMenuNutritionTypeByIds(Long[] ids);
|
||||
public int deleteMenuNutritionTypeByIds(Integer[] ids);
|
||||
|
||||
List<String> selectBigTypeList();
|
||||
List<MenuNutritionType> selectBigTypeList();
|
||||
|
||||
List<NutritionTypeV2VO> selectLittleTypeList(String parentId);
|
||||
|
||||
|
||||
MenuNutritionType getOne(MenuNutritionType menuNutritionType);
|
||||
|
||||
MenuNutritionType getParentOne(MenuNutritionType menuNutritionType);
|
||||
|
||||
List<String> selectLittleTypeList(String bigType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.canteen.core.menu.service;
|
|||
import java.util.List;
|
||||
|
||||
import com.bonus.canteen.core.menu.domain.MenuNutritionType;
|
||||
import com.bonus.canteen.core.menu.vo.NutritionTypeV2VO;
|
||||
import com.bonus.canteen.core.menu.vo.NutritionTypeVo;
|
||||
|
||||
/**
|
||||
|
|
@ -50,7 +51,7 @@ public interface IMenuNutritionTypeService {
|
|||
* @param ids 需要删除的营养基础类型主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteMenuNutritionTypeByIds(Long[] ids);
|
||||
public int deleteMenuNutritionTypeByIds(Integer[] ids);
|
||||
|
||||
/**
|
||||
* 删除营养基础类型信息
|
||||
|
|
@ -60,5 +61,5 @@ public interface IMenuNutritionTypeService {
|
|||
*/
|
||||
public int deleteMenuNutritionTypeById(Long id);
|
||||
|
||||
List<NutritionTypeVo> getNutritionTypeList();
|
||||
List<NutritionTypeV2VO> getNutritionTypeList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.bonus.canteen.core.menu.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bonus.canteen.core.menu.domain.MenuDishesType;
|
||||
import com.bonus.canteen.core.menu.dto.MenuDishesTypeAddDTO;
|
||||
import com.bonus.canteen.core.menu.vo.MenuDishesTypeAllVO;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -8,8 +11,10 @@ import java.util.List;
|
|||
* @author xliu
|
||||
* @date 2025/4/8 19:16
|
||||
*/
|
||||
public interface MenuDishesTypeService {
|
||||
public interface MenuDishesTypeService extends IService<MenuDishesType> {
|
||||
|
||||
|
||||
List<MenuDishesTypeAllVO> getAllMenuDishesTypeList();
|
||||
|
||||
int addMenuDishesType(MenuDishesTypeAddDTO content);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,19 @@
|
|||
package com.bonus.canteen.core.menu.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bonus.canteen.core.menu.dto.MenuDishesTypeAddDTO;
|
||||
import com.bonus.canteen.core.menu.mapper.MenuDishesTypeMapper;
|
||||
import com.bonus.canteen.core.menu.service.MenuDishesTypeService;
|
||||
import com.bonus.canteen.core.menu.domain.MenuDishesType;
|
||||
import com.bonus.canteen.core.menu.vo.MenuDishesTypeAllVO;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.houqin.constant.DelFlagEnum;
|
||||
import com.bonus.common.houqin.i18n.I18n;
|
||||
import com.bonus.common.houqin.utils.id.Id;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -13,7 +24,7 @@ import java.util.List;
|
|||
* @date 2025/4/8 19:16
|
||||
*/
|
||||
@Service
|
||||
public class MenuDishesTypeServiceImpl implements MenuDishesTypeService {
|
||||
public class MenuDishesTypeServiceImpl extends ServiceImpl<MenuDishesTypeMapper, MenuDishesType> implements MenuDishesTypeService {
|
||||
|
||||
@Resource
|
||||
private MenuDishesTypeMapper menuDishesTypeMapper;
|
||||
|
|
@ -22,4 +33,22 @@ public class MenuDishesTypeServiceImpl implements MenuDishesTypeService {
|
|||
public List<MenuDishesTypeAllVO> getAllMenuDishesTypeList() {
|
||||
return menuDishesTypeMapper.getAllMenuDishesTypeList();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int addMenuDishesType(MenuDishesTypeAddDTO content) {
|
||||
List<MenuDishesType> cookList = this.baseMapper.selectList(Wrappers.lambdaQuery(MenuDishesType.class)
|
||||
.eq(MenuDishesType::getTypeName, content.getTypeName())
|
||||
.eq(MenuDishesType::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
|
||||
if (CollUtil.isNotEmpty(cookList)) {
|
||||
throw new ServiceException(I18n.getMessage("menu_type_name_repeat", new Object[0]));
|
||||
} else {
|
||||
String username = SecurityUtils.getUsername();
|
||||
MenuDishesType dishesType = new MenuDishesType();
|
||||
BeanUtil.copyProperties(content, dishesType, new String[0]);
|
||||
dishesType.setCrby(username);
|
||||
dishesType.setTypeId(Id.next());
|
||||
return this.baseMapper.insert(dishesType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,13 @@ import java.util.ArrayList;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hutool.system.UserInfo;
|
||||
import com.bonus.canteen.core.menu.mapper.MenuNutritionMapper;
|
||||
import com.bonus.canteen.core.menu.vo.NutritionTypeV2VO;
|
||||
import com.bonus.canteen.core.menu.vo.NutritionTypeVo;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.canteen.core.menu.mapper.MenuNutritionTypeMapper;
|
||||
|
|
@ -55,7 +58,21 @@ public class MenuNutritionTypeServiceImpl implements IMenuNutritionTypeService {
|
|||
*/
|
||||
@Override
|
||||
public int insertMenuNutritionType(MenuNutritionType menuNutritionType) {
|
||||
menuNutritionType.setCreateTime(DateUtils.getNowDate());
|
||||
menuNutritionType.setCreateBy(SecurityUtils.getUserId()+"");
|
||||
MenuNutritionType one = menuNutritionTypeMapper.getOne(menuNutritionType);
|
||||
if(one !=null ){
|
||||
throw new ServiceException("该营养基础类型已存在");
|
||||
}
|
||||
MenuNutritionType getParentOne = menuNutritionTypeMapper.getParentOne(menuNutritionType);
|
||||
if(getParentOne == null){
|
||||
throw new ServiceException("无效的父级节点");
|
||||
}else{
|
||||
if("2".equals(getParentOne.getLevel())){
|
||||
throw new ServiceException("不允许添加三级节点");
|
||||
}else{
|
||||
menuNutritionType.setLevel("2");
|
||||
}
|
||||
}
|
||||
try {
|
||||
return menuNutritionTypeMapper.insertMenuNutritionType(menuNutritionType);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -71,7 +88,11 @@ public class MenuNutritionTypeServiceImpl implements IMenuNutritionTypeService {
|
|||
*/
|
||||
@Override
|
||||
public int updateMenuNutritionType(MenuNutritionType menuNutritionType) {
|
||||
menuNutritionType.setUpdateTime(DateUtils.getNowDate());
|
||||
menuNutritionType.setCreateBy(SecurityUtils.getUserId()+"");
|
||||
MenuNutritionType one = menuNutritionTypeMapper.getOne(menuNutritionType);
|
||||
if(one !=null ){
|
||||
throw new ServiceException("该营养基础类型已存在");
|
||||
}
|
||||
try {
|
||||
return menuNutritionTypeMapper.updateMenuNutritionType(menuNutritionType);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -86,7 +107,7 @@ public class MenuNutritionTypeServiceImpl implements IMenuNutritionTypeService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteMenuNutritionTypeByIds(Long[] ids) {
|
||||
public int deleteMenuNutritionTypeByIds(Integer[] ids) {
|
||||
return menuNutritionTypeMapper.deleteMenuNutritionTypeByIds(ids);
|
||||
}
|
||||
|
||||
|
|
@ -103,20 +124,28 @@ public class MenuNutritionTypeServiceImpl implements IMenuNutritionTypeService {
|
|||
|
||||
|
||||
@Override
|
||||
public List<NutritionTypeVo> getNutritionTypeList() {
|
||||
List<String> bigTypeList =menuNutritionTypeMapper.selectBigTypeList();
|
||||
List<NutritionTypeVo> nutritionTypeVOList = new ArrayList();
|
||||
Iterator var3 = bigTypeList.iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
String bigType = (String)var3.next();
|
||||
NutritionTypeVo nutritionTypeVO = new NutritionTypeVo();
|
||||
List<String> littleTypeList = menuNutritionTypeMapper.selectLittleTypeList(bigType);
|
||||
nutritionTypeVO.setBigType(bigType);
|
||||
public List<NutritionTypeV2VO> getNutritionTypeList() {
|
||||
List<MenuNutritionType> bigTypeList =menuNutritionTypeMapper.selectBigTypeList();
|
||||
List<NutritionTypeV2VO> nutritionTypeVOList = new ArrayList();
|
||||
for(MenuNutritionType menuNutritionType : bigTypeList){
|
||||
NutritionTypeV2VO nutritionTypeVO = new NutritionTypeV2VO();
|
||||
List<NutritionTypeV2VO> littleTypeList = menuNutritionTypeMapper.selectLittleTypeList(menuNutritionType.getId()+"");
|
||||
nutritionTypeVO.setId(Integer.parseInt(menuNutritionType.getId()+""));
|
||||
nutritionTypeVO.setBigType(menuNutritionType.getName());
|
||||
nutritionTypeVO.setLittleTypeList(littleTypeList);
|
||||
nutritionTypeVOList.add(nutritionTypeVO);
|
||||
}
|
||||
|
||||
//
|
||||
// while(var3.hasNext()) {
|
||||
// String bigType = (String)var3.next();
|
||||
// NutritionTypeV2VO nutritionTypeVO = new NutritionTypeV2VO();
|
||||
// List<MenuNutritionType> littleTypeList = menuNutritionTypeMapper.selectLittleTypeList(bigType);
|
||||
// nutritionTypeVO.setBigType(bigType);
|
||||
// nutritionTypeVO.setLittleTypeList(littleTypeList);
|
||||
// nutritionTypeVOList.add(nutritionTypeVO);
|
||||
// }
|
||||
// TreeNodeUtil.assembleTree(list);
|
||||
return nutritionTypeVOList;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.bonus.canteen.core.menu.vo;
|
||||
|
||||
import com.bonus.canteen.core.menu.domain.BaseTreeNode;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author xliu
|
||||
* @date 2025/4/9 18:03
|
||||
*/
|
||||
@Data
|
||||
public class MenuNutritionTypeVO extends BaseTreeNode {
|
||||
private String typeName;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.bonus.canteen.core.menu.vo;
|
||||
|
||||
import com.bonus.canteen.core.menu.domain.MenuNutritionType;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xliu
|
||||
* @date 2025/4/7 16:47
|
||||
*/
|
||||
@Data
|
||||
public class NutritionTypeV2VO {
|
||||
|
||||
@ApiModelProperty("唯一标识")
|
||||
private Integer id;
|
||||
@ApiModelProperty("大类")
|
||||
private String bigType;
|
||||
@ApiModelProperty("小类")
|
||||
private List<NutritionTypeV2VO> littleTypeList;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -41,6 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="level != null">level,</if>
|
||||
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="name != null">#{name},</if>
|
||||
|
|
@ -50,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="level != null">#{level},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
|
@ -63,6 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="level != null">level = #{level},</if>
|
||||
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
|
@ -71,12 +76,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
delete from menu_nutrition_type where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteMenuNutritionTypeByIds" parameterType="String">
|
||||
delete from menu_nutrition_type where id in
|
||||
<update id="deleteMenuNutritionTypeByIds" parameterType="String">
|
||||
update menu_nutrition_type set del_flag = 1 where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</update>
|
||||
|
||||
<select id="selectTypeList" parameterType="String" resultType="String">
|
||||
select distinct big_type from menu_nutrition
|
||||
|
|
@ -86,12 +91,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
select distinct little_type from menu_nutrition where big_type = #{bigType}
|
||||
</select>
|
||||
|
||||
<select id="selectBigTypeList" resultType="java.lang.String">
|
||||
select distinct big_type from menu_nutrition
|
||||
<select id="selectBigTypeList" resultMap="MenuNutritionTypeResult">
|
||||
select * from menu_nutrition_type where level = 1 and del_flag = 0
|
||||
</select>
|
||||
|
||||
<select id="selectLittleTypeList" resultType="java.lang.String">
|
||||
select distinct little_type from menu_nutrition where big_type = #{bigType}
|
||||
<select id="selectLittleTypeList" resultType="com.bonus.canteen.core.menu.vo.NutritionTypeV2VO">
|
||||
select id,name as bigType from menu_nutrition_type where level = 2 and del_flag = 0 and parent_id = #{parentId}
|
||||
</select>
|
||||
|
||||
<select id="getOne" resultMap="MenuNutritionTypeResult" parameterType="com.bonus.canteen.core.menu.domain.MenuNutritionType">
|
||||
select * from menu_nutrition_type where name = #{name} and parent_id = #{parentId} and del_flag = 0 limit 1
|
||||
</select>
|
||||
|
||||
<select id="getParentOne" resultMap="MenuNutritionTypeResult" parameterType="com.bonus.canteen.core.menu.domain.MenuNutritionType">
|
||||
select * from menu_nutrition_type where id = #{parentId} and del_flag = 0 limit 1
|
||||
</select>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue