营养、原料相关接口编写

This commit is contained in:
liux 2025-04-09 15:30:33 +08:00
parent 7e2e18dc5d
commit 8879270fac
19 changed files with 768 additions and 267 deletions

View File

@ -2,9 +2,11 @@ package com.bonus.canteen.core.menu.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import com.bonus.canteen.core.menu.domain.MenuMaterialCategory;
import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO;
import com.bonus.canteen.core.menu.dto.MenuMaterialCategoryAddDTO;
import com.bonus.canteen.core.menu.service.IMenuMaterialCategoryService;
import com.bonus.common.log.enums.OperaType;
import io.swagger.annotations.Api;
@ -78,10 +80,10 @@ public class MenuMaterialCategoryController extends BaseController {
//@PreventRepeatSubmit
//@RequiresPermissions("menu:category:add")
@SysLog(title = "原料类别", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增原料类别")
@PostMapping
public AjaxResult add(@RequestBody MenuMaterialCategory menuMaterialCategory) {
@PostMapping("/add")
public AjaxResult add(@RequestBody @Valid MenuMaterialCategoryAddDTO dto) {
try {
return toAjax(menuMaterialCategoryService.insertMenuMaterialCategory(menuMaterialCategory));
return toAjax(menuMaterialCategoryService.insertMenuMaterialCategory(dto));
} catch (Exception e) {
return error("系统错误, " + e.getMessage());
}

View File

@ -40,8 +40,8 @@ public class MenuNutritionController extends BaseController {
*/
@ApiOperation(value = "查询食材营养基础信息列表")
//@RequiresPermissions("menu:nutrition:list")
@GetMapping("/list")
public TableDataInfo list(MenuNutrition menuNutrition) {
@PostMapping ("/list")
public TableDataInfo list(@RequestBody MenuNutrition menuNutrition) {
startPage();
List<MenuNutrition> list = menuNutritionService.selectMenuNutritionList(menuNutrition);
return getDataTable(list);
@ -78,7 +78,7 @@ public class MenuNutritionController extends BaseController {
//@PreventRepeatSubmit
//@RequiresPermissions("menu:nutrition:add")
@SysLog(title = "食材营养基础信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增食材营养基础信息")
@PostMapping
@PostMapping("/add")
public AjaxResult add(@RequestBody MenuNutritionDTO menuNutrition) {
try {
return toAjax(menuNutritionService.insertMenuNutrition(menuNutrition));

View File

@ -1,14 +1,20 @@
package com.bonus.canteen.core.menu.domain;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import java.time.LocalDateTime;
/**
* 原料类别对象 menu_material_category
*
*
* @author xsheng
* @date 2025-04-03
*/
@ -16,56 +22,43 @@ import com.bonus.common.core.web.domain.BaseEntity;
@Data
@ToString
public class MenuMaterialCategory extends BaseEntity {
public class MenuMaterialCategory extends Model<MenuMaterialCategory> {
private static final long serialVersionUID = 1L;
/** 主键id */
@TableId
@ApiModelProperty("主键id")
private Long id;
/** 区域id */
@Excel(name = "区域id")
@ApiModelProperty(value = "区域id")
private Long areaId;
/** 类别id */
@Excel(name = "类别id")
@ApiModelProperty(value = "类别id")
@ApiModelProperty("类别id")
private Long categoryId;
/** 类别编码 */
@Excel(name = "类别编码")
@ApiModelProperty(value = "类别编码")
@ApiModelProperty("类别编码")
private String categoryNum;
/** 类别名称 */
@Excel(name = "类别名称")
@ApiModelProperty(value = "类别名称")
@ApiModelProperty("类别名称")
private String categoryName;
/** 父类id */
@Excel(name = "父类id")
@ApiModelProperty(value = "父类id")
@ApiModelProperty("父类id")
private Long parentId;
/** 类型(1原料2商品) */
@Excel(name = "类型(1原料2商品)")
@ApiModelProperty(value = "类型(1原料2商品)")
private Long categoryType;
/** 乐观锁 */
@Excel(name = "乐观锁")
@ApiModelProperty(value = "乐观锁")
private Long revision;
/** 等级(0,1,2,3) */
@Excel(name = "等级(0,1,2,3)")
@ApiModelProperty(value = "等级(0,1,2,3)")
private Long level;
/** 大类id */
@Excel(name = "大类id")
@ApiModelProperty(value = "大类id")
@ApiModelProperty("类型(1原料2商品)")
private Integer categoryType;
@ApiModelProperty("删除标识(1-删除,2-正常)")
private Integer delFlag;
@ApiModelProperty("乐观锁")
private Integer revision;
@TableField(value = "create_by",fill = FieldFill.INSERT)
@ApiModelProperty("创建人")
private String createBy;
@TableField( value = "create_time", fill = FieldFill.INSERT)
@ApiModelProperty("创建时间")
private LocalDateTime createTime;
@TableField(value = "update_by",fill = FieldFill.UPDATE )
@ApiModelProperty("更新人")
private String updateBy;
@TableField(value = "update_time",fill = FieldFill.UPDATE)
@ApiModelProperty("更新时间")
private LocalDateTime updateTime;
@ApiModelProperty("区域ID")
private Long areaId;
@ApiModelProperty("等级(0,1,2,3)")
private Integer level;
@ApiModelProperty("大类id")
private Long bigCategoryId;
}

View File

@ -46,7 +46,7 @@ public class MenuNutrition extends BaseEntity {
/** 标准份重量(g) */
@Excel(name = "标准份重量(g)")
@ApiModelProperty(value = "标准份重量(g)")
private BigDecimal weight;
private Double weight;
/** 食材基础单价(分) */
@Excel(name = "食材基础单价(分)")
@ -86,7 +86,7 @@ public class MenuNutrition extends BaseEntity {
/** 加工时间(min) */
@Excel(name = "加工时间(min)")
@ApiModelProperty(value = "加工时间(min)")
private BigDecimal processingTime;
private Double processingTime;
/** 推荐组合(以英文逗号分割,食材编码区分不超过20个) */
@Excel(name = "推荐组合(以英文逗号分割,食材编码区分不超过20个)")
@ -101,87 +101,87 @@ public class MenuNutrition extends BaseEntity {
/** 可食部分(g/100g) */
@Excel(name = "可食部分(g/100g)")
@ApiModelProperty(value = "可食部分(g/100g)")
private BigDecimal edible;
private Double edible;
/** 水分(g/100g) */
@Excel(name = "水分(g/100g)")
@ApiModelProperty(value = "水分(g/100g)")
private BigDecimal water;
private Double water;
/** 热量(千卡/100g) */
@Excel(name = "热量(千卡/100g)")
@ApiModelProperty(value = "热量(千卡/100g)")
private BigDecimal calories;
private Double calories;
/** 蛋白质(g/100g) */
@Excel(name = "蛋白质(g/100g)")
@ApiModelProperty(value = "蛋白质(g/100g)")
private BigDecimal protein;
private Double protein;
/** 脂肪(g/100g) */
@Excel(name = "脂肪(g/100g)")
@ApiModelProperty(value = "脂肪(g/100g)")
private BigDecimal fat;
private Double fat;
/** 碳水化合物(g/100g) */
@Excel(name = "碳水化合物(g/100g)")
@ApiModelProperty(value = "碳水化合物(g/100g)")
private BigDecimal carbohydrate;
private Double carbohydrate;
/** 不溶性膳食纤维(g/100g) */
@Excel(name = "不溶性膳食纤维(g/100g)")
@ApiModelProperty(value = "不溶性膳食纤维(g/100g)")
private BigDecimal dietaryFiber;
private Double dietaryFiber;
/** 胆固醇(mg/100g) */
@Excel(name = "胆固醇(mg/100g)")
@ApiModelProperty(value = "胆固醇(mg/100g)")
private BigDecimal cholesterol;
private Double cholesterol;
/** 灰分(g/100g) */
@Excel(name = "灰分(g/100g)")
@ApiModelProperty(value = "灰分(g/100g)")
private BigDecimal ash;
private Double ash;
/** 维生素a(μg/100g) */
@Excel(name = "维生素a(μg/100g)")
@ApiModelProperty(value = "维生素a(μg/100g)")
private BigDecimal vitaminA;
private Double vitaminA;
/** 胡萝卜素(μg/100g) */
@Excel(name = "胡萝卜素(μg/100g)")
@ApiModelProperty(value = "胡萝卜素(μg/100g)")
private BigDecimal carotene;
private Double carotene;
/** 硫胺素(mg/100g) */
@Excel(name = "硫胺素(mg/100g)")
@ApiModelProperty(value = "硫胺素(mg/100g)")
private BigDecimal thiamine;
private Double thiamine;
/** 核黄素(mg/100g) */
@Excel(name = "核黄素(mg/100g)")
@ApiModelProperty(value = "核黄素(mg/100g)")
private BigDecimal riboflavin;
private Double riboflavin;
/** 烟酸/尼克酸(mg/100g) */
@Excel(name = "烟酸/尼克酸(mg/100g)")
@ApiModelProperty(value = "烟酸/尼克酸(mg/100g)")
private BigDecimal niacin;
private Double niacin;
/** 维生素c(mg/100g) */
@Excel(name = "维生素c(mg/100g)")
@ApiModelProperty(value = "维生素c(mg/100g)")
private BigDecimal vitaminC;
private Double vitaminC;
/** 维生素d(μg/100g) */
@Excel(name = "维生素d(μg/100g)")
@ApiModelProperty(value = "维生素d(μg/100g)")
private BigDecimal vitaminD;
private Double vitaminD;
/** 维生素e(mg/100g) */
@Excel(name = "维生素e(mg/100g)")
@ApiModelProperty(value = "维生素e(mg/100g)")
private BigDecimal vitaminE;
private Double vitaminE;
/** 删除标识(1删除,2正常) */
private Integer delFlag;
@ -189,147 +189,147 @@ public class MenuNutrition extends BaseEntity {
/** 胆碱(mg/100g) */
@Excel(name = "胆碱(mg/100g)")
@ApiModelProperty(value = "胆碱(mg/100g)")
private BigDecimal choline;
private Double choline;
/** 生物素/维生素7(ug/100g) */
@Excel(name = "生物素/维生素7(ug/100g)")
@ApiModelProperty(value = "生物素/维生素7(ug/100g)")
private BigDecimal biotin;
private Double biotin;
/** 泛酸(mg/100g) */
@Excel(name = "泛酸(mg/100g)")
@ApiModelProperty(value = "泛酸(mg/100g)")
private BigDecimal pantothenicAcid;
private Double pantothenicAcid;
/** 鸟嘌呤(mg/100g) */
@Excel(name = "鸟嘌呤(mg/100g)")
@ApiModelProperty(value = "鸟嘌呤(mg/100g)")
private BigDecimal guanine;
private Double guanine;
/** 腺嘌呤(mg/100g) */
@Excel(name = "腺嘌呤(mg/100g)")
@ApiModelProperty(value = "腺嘌呤(mg/100g)")
private BigDecimal adenine;
private Double adenine;
/** 次黄嘌呤(mg/100g) */
@Excel(name = "次黄嘌呤(mg/100g)")
@ApiModelProperty(value = "次黄嘌呤(mg/100g)")
private BigDecimal hypoxanthine;
private Double hypoxanthine;
/** 黄嘌呤(mg/100g) */
@Excel(name = "黄嘌呤(mg/100g)")
@ApiModelProperty(value = "黄嘌呤(mg/100g)")
private BigDecimal xanthine;
private Double xanthine;
/** 总嘌呤含量(mg/100g) */
@Excel(name = "总嘌呤含量(mg/100g)")
@ApiModelProperty(value = "总嘌呤含量(mg/100g)")
private BigDecimal purine;
private Double purine;
/** 血糖生成指数(GI) */
@Excel(name = "血糖生成指数(GI)")
@ApiModelProperty(value = "血糖生成指数(GI)")
private BigDecimal glycemicIndex;
private Double glycemicIndex;
/** 植物甾醇总含量(mg/100g) */
@Excel(name = "植物甾醇总含量(mg/100g)")
@ApiModelProperty(value = "植物甾醇总含量(mg/100g)")
private BigDecimal totalPhytosterolContent;
private Double totalPhytosterolContent;
/** β-谷甾醇(mg/100g) */
@Excel(name = "β-谷甾醇(mg/100g)")
@ApiModelProperty(value = "β-谷甾醇(mg/100g)")
private BigDecimal cerealSterol;
private Double cerealSterol;
/** 菜油甾醇(mg/100g) */
@Excel(name = "菜油甾醇(mg/100g)")
@ApiModelProperty(value = "菜油甾醇(mg/100g)")
private BigDecimal cameliaSterol;
private Double cameliaSterol;
/** 豆甾醇(mg/100g) */
@Excel(name = "豆甾醇(mg/100g)")
@ApiModelProperty(value = "豆甾醇(mg/100g)")
private BigDecimal sterol;
private Double sterol;
/** β-谷甾烷醇(mg/100g) */
@Excel(name = "β-谷甾烷醇(mg/100g)")
@ApiModelProperty(value = "β-谷甾烷醇(mg/100g)")
private BigDecimal cerealSteranol;
private Double cerealSteranol;
/** 菜油甾烷醇(mg/100g) */
@Excel(name = "菜油甾烷醇(mg/100g)")
@ApiModelProperty(value = "菜油甾烷醇(mg/100g)")
private BigDecimal rapesanol;
private Double rapesanol;
/** 菜子甾醇(mg/100g) */
@Excel(name = "菜子甾醇(mg/100g)")
@ApiModelProperty(value = "菜子甾醇(mg/100g)")
private BigDecimal rapeseedSteranol;
private Double rapeseedSteranol;
/** 叶黄素+玉米素(μg/100g) */
@Excel(name = "叶黄素+玉米素(μg/100g)")
@ApiModelProperty(value = "叶黄素+玉米素(μg/100g)")
private BigDecimal luteinZeaxanthin;
private Double luteinZeaxanthin;
/** 槲皮素(mg/100g) */
@Excel(name = "槲皮素(mg/100g)")
@ApiModelProperty(value = "槲皮素(mg/100g)")
private BigDecimal quercetin;
private Double quercetin;
/** 杨梅黄酮(mg/100g) */
@Excel(name = "杨梅黄酮(mg/100g)")
@ApiModelProperty(value = "杨梅黄酮(mg/100g)")
private BigDecimal myricetin;
private Double myricetin;
/** 玉米黄酮(mg/100g) */
@Excel(name = "玉米黄酮(mg/100g)")
@ApiModelProperty(value = "玉米黄酮(mg/100g)")
private BigDecimal luteolin;
private Double luteolin;
/** 坎二菲醇(mg/100g) */
@Excel(name = "坎二菲醇(mg/100g)")
@ApiModelProperty(value = "坎二菲醇(mg/100g)")
private BigDecimal kaemPferol;
private Double kaemPferol;
/** 芹菜配基(mg/100g) */
@Excel(name = "芹菜配基(mg/100g)")
@ApiModelProperty(value = "芹菜配基(mg/100g)")
private BigDecimal apigenin;
private Double apigenin;
/** 大豆异黄酮总含量(mg/100g) */
@Excel(name = "大豆异黄酮总含量(mg/100g)")
@ApiModelProperty(value = "大豆异黄酮总含量(mg/100g)")
private BigDecimal isoflavone;
private Double isoflavone;
/** 黄豆苷元(mg/100g) */
@Excel(name = "黄豆苷元(mg/100g)")
@ApiModelProperty(value = "黄豆苷元(mg/100g)")
private BigDecimal daidzein;
private Double daidzein;
/** 染料木黄酮(mg/100g) */
@Excel(name = "染料木黄酮(mg/100g)")
@ApiModelProperty(value = "染料木黄酮(mg/100g)")
private BigDecimal genistein;
private Double genistein;
/** 黄豆黄素(mg/100g) */
@Excel(name = "黄豆黄素(mg/100g)")
@ApiModelProperty(value = "黄豆黄素(mg/100g)")
private BigDecimal glycitein;
private Double glycitein;
/** 花青素(mg/100g鲜重,包含飞燕草素、矢车菊素、芍药素) */
@Excel(name = "花青素(mg/100g鲜重,包含飞燕草素、矢车菊素、芍药素)")
@ApiModelProperty(value = "花青素(mg/100g鲜重,包含飞燕草素、矢车菊素、芍药素)")
private BigDecimal anthocyan;
private Double anthocyan;
/** 白藜芦醇(μg/100g) */
@Excel(name = "白藜芦醇(μg/100g)")
@ApiModelProperty(value = "白藜芦醇(μg/100g)")
private BigDecimal resveratrol;
private Double resveratrol;
/** 白藜芦醇苷(μg/100g) */
@Excel(name = "白藜芦醇苷(μg/100g)")
@ApiModelProperty(value = "白藜芦醇苷(μg/100g)")
private BigDecimal polydatin;
private Double polydatin;
/** 备注/原产地 */
@Excel(name = "备注/原产地")
@ -339,167 +339,167 @@ public class MenuNutrition extends BaseEntity {
/** 钙(mg/100g) */
@Excel(name = "钙(mg/100g)")
@ApiModelProperty(value = "钙(mg/100g)")
private BigDecimal calcium;
private Double calcium;
/** 磷(mg/100g) */
@Excel(name = "磷(mg/100g)")
@ApiModelProperty(value = "磷(mg/100g)")
private BigDecimal phosphorus;
private Double phosphorus;
/** 钾(mg/100g) */
@Excel(name = "钾(mg/100g)")
@ApiModelProperty(value = "钾(mg/100g)")
private BigDecimal kalium;
private Double kalium;
/** 钠(mg/100g) */
@Excel(name = "钠(mg/100g)")
@ApiModelProperty(value = "钠(mg/100g)")
private BigDecimal sodium;
private Double sodium;
/** 镁(mg/100g) */
@Excel(name = "镁(mg/100g)")
@ApiModelProperty(value = "镁(mg/100g)")
private BigDecimal magnesium;
private Double magnesium;
/** 铁(mg/100g) */
@Excel(name = "铁(mg/100g)")
@ApiModelProperty(value = "铁(mg/100g)")
private BigDecimal iron;
private Double iron;
/** 锌(mg/100g) */
@Excel(name = "锌(mg/100g)")
@ApiModelProperty(value = "锌(mg/100g)")
private BigDecimal zinc;
private Double zinc;
/** 硒(μg/100g) */
@Excel(name = "硒(μg/100g)")
@ApiModelProperty(value = "硒(μg/100g)")
private BigDecimal selenium;
private Double selenium;
/** 铜(mg/100g) */
@Excel(name = "铜(mg/100g)")
@ApiModelProperty(value = "铜(mg/100g)")
private BigDecimal cuprum;
private Double cuprum;
/** 锰(mg/100g) */
@Excel(name = "锰(mg/100g)")
@ApiModelProperty(value = "锰(mg/100g)")
private BigDecimal manganese;
private Double manganese;
/** 异亮氨酸(mg/100g) */
@Excel(name = "异亮氨酸(mg/100g)")
@ApiModelProperty(value = "异亮氨酸(mg/100g)")
private BigDecimal isoleucine;
private Double isoleucine;
/** 亮氨酸(mg/100g) */
@Excel(name = "亮氨酸(mg/100g)")
@ApiModelProperty(value = "亮氨酸(mg/100g)")
private BigDecimal leucine;
private Double leucine;
/** 赖氨酸(mg/100g) */
@Excel(name = "赖氨酸(mg/100g)")
@ApiModelProperty(value = "赖氨酸(mg/100g)")
private BigDecimal lysine;
private Double lysine;
/** 含硫氨基酸(mg/100g) */
@Excel(name = "含硫氨基酸(mg/100g)")
@ApiModelProperty(value = "含硫氨基酸(mg/100g)")
private BigDecimal saaTotal;
private Double saaTotal;
/** 芳香族氨基酸(mg/100g) */
@Excel(name = "芳香族氨基酸(mg/100g)")
@ApiModelProperty(value = "芳香族氨基酸(mg/100g)")
private BigDecimal aaaTotal;
private Double aaaTotal;
/** 苏氨酸(mg/100g) */
@Excel(name = "苏氨酸(mg/100g)")
@ApiModelProperty(value = "苏氨酸(mg/100g)")
private BigDecimal threonine;
private Double threonine;
/** 色氨酸(mg/100g) */
@Excel(name = "色氨酸(mg/100g)")
@ApiModelProperty(value = "色氨酸(mg/100g)")
private BigDecimal tryptophan;
private Double tryptophan;
/** 缬氨酸(mg/100g) */
@Excel(name = "缬氨酸(mg/100g)")
@ApiModelProperty(value = "缬氨酸(mg/100g)")
private BigDecimal valine;
private Double valine;
/** 精氨酸(mg/100g) */
@Excel(name = "精氨酸(mg/100g)")
@ApiModelProperty(value = "精氨酸(mg/100g)")
private BigDecimal arginine;
private Double arginine;
/** 组氨酸(mg/100g) */
@Excel(name = "组氨酸(mg/100g)")
@ApiModelProperty(value = "组氨酸(mg/100g)")
private BigDecimal histidine;
private Double histidine;
/** 丙氨酸(mg/100g) */
@Excel(name = "丙氨酸(mg/100g)")
@ApiModelProperty(value = "丙氨酸(mg/100g)")
private BigDecimal alanine;
private Double alanine;
/** 天冬氨酸(mg/100g) */
@Excel(name = "天冬氨酸(mg/100g)")
@ApiModelProperty(value = "天冬氨酸(mg/100g)")
private BigDecimal asparticAcid;
private Double asparticAcid;
/** 谷氨酸(mg/100g) */
@Excel(name = "谷氨酸(mg/100g)")
@ApiModelProperty(value = "谷氨酸(mg/100g)")
private BigDecimal glutamate;
private Double glutamate;
/** 甘氨酸(mg/100g) */
@Excel(name = "甘氨酸(mg/100g)")
@ApiModelProperty(value = "甘氨酸(mg/100g)")
private BigDecimal glycine;
private Double glycine;
/** 脯氨酸(mg/100g) */
@Excel(name = "脯氨酸(mg/100g)")
@ApiModelProperty(value = "脯氨酸(mg/100g)")
private BigDecimal proline;
private Double proline;
/** 丝氨酸(mg/100g) */
@Excel(name = "丝氨酸(mg/100g)")
@ApiModelProperty(value = "丝氨酸(mg/100g)")
private BigDecimal serine;
private Double serine;
/** 脂肪酸(g/100g可食部) */
@Excel(name = "脂肪酸(g/100g可食部)")
@ApiModelProperty(value = "脂肪酸(g/100g可食部)")
private BigDecimal fattyAcid;
private Double fattyAcid;
/** 饱和脂肪酸(g/100g可食部) */
@Excel(name = "饱和脂肪酸(g/100g可食部)")
@ApiModelProperty(value = "饱和脂肪酸(g/100g可食部)")
private BigDecimal saturatedFattyAcid;
private Double saturatedFattyAcid;
/** 单不饱和脂肪酸(g/100g可食部) */
@Excel(name = "单不饱和脂肪酸(g/100g可食部)")
@ApiModelProperty(value = "单不饱和脂肪酸(g/100g可食部)")
private BigDecimal monounsaturatedFattyAcid;
private Double monounsaturatedFattyAcid;
/** 多不饱和脂肪酸(g/100g可食部) */
@Excel(name = "多不饱和脂肪酸(g/100g可食部)")
@ApiModelProperty(value = "多不饱和脂肪酸(g/100g可食部)")
private BigDecimal polyunsaturatedFattyAcid;
private Double polyunsaturatedFattyAcid;
/** 碘(μg/100g) */
@Excel(name = "碘(μg/100g)")
@ApiModelProperty(value = "碘(μg/100g)")
private BigDecimal iodine;
private Double iodine;
/** 叶酸(mg/100g) */
@Excel(name = "叶酸(mg/100g)")
@ApiModelProperty(value = "叶酸(mg/100g)")
private BigDecimal folic;
private Double folic;
/** 视黄醇(μg/100g) */
@Excel(name = "视黄醇(μg/100g)")
@ApiModelProperty(value = "视黄醇(μg/100g)")
private BigDecimal retinol;
private Double retinol;
/** 是否默认(1-默认,2-非默认) */
@Excel(name = "是否默认(1-默认,2-非默认)")

View File

@ -0,0 +1,25 @@
package com.bonus.canteen.core.menu.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author xliu
* @date 2025/4/9 13:31
*/
@Data
public class MenuMaterialCategoryAddDTO {
@ApiModelProperty("类别名称")
private @NotBlank(
message = "{menu_category_name_null}"
) String categoryName;
@ApiModelProperty("父类id")
private Long parentId;
@ApiModelProperty("类型(1原料2商品)")
private Integer categoryType;
@ApiModelProperty("区域ID")
private Long areaId;
}

View File

@ -13,6 +13,8 @@ import java.util.List;
@Data
public class MenuNutritionDTO {
private Long id;
@ApiModelProperty("食材营养id")
private Long nutritionId;
@ApiModelProperty("食材编码")
@ -32,9 +34,7 @@ public class MenuNutritionDTO {
@ApiModelProperty("食材颜色")
private String color;
@ApiModelProperty("食材大类")
private @NotNull(
message = "{menu_big_type_null}"
) String bigType;
private @NotNull( message = "{menu_big_type_null}" ) String bigType;
@ApiModelProperty("食材小类")
private @NotNull(
message = "{menu_little_type_null}"
@ -219,4 +219,6 @@ public class MenuNutritionDTO {
private Integer current;
private Integer size;
private Long updateBy;
private String remark;
}

View File

@ -0,0 +1,32 @@
package com.bonus.canteen.core.menu.enums;
public enum LeLevelEnum {
FIRST(1, "一级"),
SECOND(2, "二级"),
THIRD(3, "三级"),
FOURTH(4, "四级"),
FIFTH(5, "五级"),
SIXTH(6, "六级"),
SEVENTH(7, "七级");
private final Integer key;
private final String desc;
private LeLevelEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
// $FF: synthetic method
private static LeLevelEnum[] $values() {
return new LeLevelEnum[]{FIRST, SECOND, THIRD, FOURTH, FIFTH, SIXTH, SEVENTH};
}
}

View File

@ -0,0 +1,44 @@
package com.bonus.canteen.core.menu.enums;
import java.util.Objects;
public enum MgrRoleTypeEnum {
ROLE_ADMIN(1, "全数据类"),
ROLE_ORG(2, "组织类"),
ROLE_MERCHANT(3, "商户/仓库类");
private final Integer key;
private final String value;
public static MgrRoleTypeEnum getEnumByKey(Integer key) {
MgrRoleTypeEnum[] var1 = values();
int var2 = var1.length;
for(int var3 = 0; var3 < var2; ++var3) {
MgrRoleTypeEnum roleType = var1[var3];
if (Objects.equals(roleType.key, key)) {
return roleType;
}
}
return null;
}
public Integer getKey() {
return this.key;
}
public String getValue() {
return this.value;
}
private MgrRoleTypeEnum(final Integer key, final String value) {
this.key = key;
this.value = value;
}
// $FF: synthetic method
private static MgrRoleTypeEnum[] $values() {
return new MgrRoleTypeEnum[]{ROLE_ADMIN, ROLE_ORG, ROLE_MERCHANT};
}
}

View File

@ -0,0 +1,85 @@
package com.bonus.canteen.core.menu.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author xliu
* @date 2025/4/9 14:39
*/
public enum RoleCodeEnum {
ROLE_SUPER_ADMIN("ROLE_ADMIN", "管理员"),
ROLE_ADMIN("ROLE_ADMIN", "全数据类"),
ROLE_ORG("ROLE_ORG", "组织类"),
ROLE_MERCHANT("ROLE_MERCHANT", "商户/仓库类");
private final String key;
private final String value;
private RoleCodeEnum(String key, String value) {
this.key = key;
this.value = value;
}
public static String getKey(String value) {
RoleCodeEnum[] roleCodeEnums = values();
RoleCodeEnum[] var2 = roleCodeEnums;
int var3 = roleCodeEnums.length;
for(int var4 = 0; var4 < var3; ++var4) {
RoleCodeEnum roleCodeEnum = var2[var4];
if (roleCodeEnum.value().equals(value)) {
return roleCodeEnum.key();
}
}
return null;
}
public static String getValue(String key) {
RoleCodeEnum[] roleCodeEnums = values();
RoleCodeEnum[] var2 = roleCodeEnums;
int var3 = roleCodeEnums.length;
for(int var4 = 0; var4 < var3; ++var4) {
RoleCodeEnum roleCodeEnum = var2[var4];
if (roleCodeEnum.key().equals(key)) {
return roleCodeEnum.value();
}
}
return null;
}
public static List<Map<String, String>> getAllEnumsList() {
RoleCodeEnum[] roleCodeEnums = values();
List<Map<String, String>> roleCodeList = new ArrayList();
RoleCodeEnum[] var2 = roleCodeEnums;
int var3 = roleCodeEnums.length;
for(int var4 = 0; var4 < var3; ++var4) {
RoleCodeEnum roleCodeEnum = var2[var4];
Map<String, String> roleCodeMap = new HashMap();
roleCodeMap.put("key", roleCodeEnum.key);
roleCodeMap.put("value", roleCodeEnum.value);
roleCodeList.add(roleCodeMap);
}
return roleCodeList;
}
public String key() {
return this.key;
}
public String value() {
return this.value;
}
// $FF: synthetic method
private static RoleCodeEnum[] $values() {
return new RoleCodeEnum[]{ROLE_SUPER_ADMIN, ROLE_ADMIN, ROLE_ORG, ROLE_MERCHANT};
}
}

View File

@ -2,9 +2,13 @@ package com.bonus.canteen.core.menu.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.menu.domain.MenuMaterialCategory;
import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO;
import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo;
import com.bonus.canteen.core.menu.po.MgrUserAuthPO;
import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* 原料类别Mapper接口
@ -12,7 +16,7 @@ import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo;
* @author xsheng
* @date 2025-04-03
*/
public interface MenuMaterialCategoryMapper {
public interface MenuMaterialCategoryMapper extends BaseMapper<MenuMaterialCategory> {
/**
* 查询原料类别
*
@ -61,5 +65,12 @@ public interface MenuMaterialCategoryMapper {
*/
public int deleteMenuMaterialCategoryByIds(Long[] ids);
List<MenuCategoryTreeVo> selectCategoryTree(CategoryTreeListDTO content);
List<MenuCategoryTreeVO> selectCategoryTrees(CategoryTreeListDTO content);
@Select({"select category_id id, parent_id, category_name,category_type,area_id from menu_material_category ${ew.customSqlSegment}"})
List<MenuCategoryTreeVO> selectCategoryTree(CategoryTreeListDTO content);
@Select({"select MAX(category_num) from menu_material_category where parent_id = #{parentId} and category_type = #{categoryType} and del_flag = #{delFlag}"})
String getCategoryChildMaxNum(@Param("parentId") Long parentId, @Param("categoryType") Integer categoryType, @Param("delFlag") Integer delFlag);
List<Long> getTenantAreaIdList(@Param("excludeMiddle") Integer excludeMiddle, @Param("authPO") MgrUserAuthPO mgrUserAuthPO);
}

View File

@ -0,0 +1,50 @@
package com.bonus.canteen.core.menu.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class MgrUserAuthPO {
@ApiModelProperty("角色类型")
private Integer roleType;
@ApiModelProperty("角色编码")
private String roleCode;
@ApiModelProperty("用户id")
private Long userId;
@ApiModelProperty("用户名称")
private String userName;
public Integer getRoleType() {
return this.roleType;
}
public String getRoleCode() {
return this.roleCode;
}
public Long getUserId() {
return this.userId;
}
public String getUserName() {
return this.userName;
}
public void setRoleType(final Integer roleType) {
this.roleType = roleType;
}
public void setRoleCode(final String roleCode) {
this.roleCode = roleCode;
}
public void setUserId(final Long userId) {
this.userId = userId;
}
public void setUserName(final String userName) {
this.userName = userName;
}
}

View File

@ -2,9 +2,11 @@ package com.bonus.canteen.core.menu.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bonus.canteen.core.menu.domain.MenuMaterialCategory;
import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO;
import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo;
import com.bonus.canteen.core.menu.dto.MenuMaterialCategoryAddDTO;
import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVO;
/**
* 原料类别Service接口
@ -12,7 +14,7 @@ import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo;
* @author xsheng
* @date 2025-04-03
*/
public interface IMenuMaterialCategoryService {
public interface IMenuMaterialCategoryService extends IService<MenuMaterialCategory> {
/**
* 查询原料类别
*
@ -35,7 +37,7 @@ public interface IMenuMaterialCategoryService {
* @param menuMaterialCategory 原料类别
* @return 结果
*/
public int insertMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory);
public int insertMenuMaterialCategory(MenuMaterialCategoryAddDTO menuMaterialCategory);
/**
* 修改原料类别
@ -61,5 +63,9 @@ public interface IMenuMaterialCategoryService {
*/
public int deleteMenuMaterialCategoryById(Long id);
List<MenuCategoryTreeVo> getTree(CategoryTreeListDTO content);
List<MenuCategoryTreeVO> getTree(CategoryTreeListDTO content);
void syncAllCategoryBigCategoryAndLevel();
void generateCategoryNum(Long categoryId, Long parentId, Integer categoryType);
}

View File

@ -1,23 +1,38 @@
package com.bonus.canteen.core.menu.service.impl;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bonus.canteen.core.menu.domain.BaseTreeNode;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.menu.dto.CategoryTreeListDTO;
import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo;
import com.bonus.canteen.core.menu.dto.MenuMaterialCategoryAddDTO;
import com.bonus.canteen.core.menu.enums.MgrRoleTypeEnum;
import com.bonus.canteen.core.menu.enums.RoleCodeEnum;
import com.bonus.canteen.core.menu.po.MgrUserAuthPO;
import com.bonus.canteen.core.menu.vo.MenuCategoryTreeVO;
import com.bonus.canteen.core.menu.enums.LeLevelEnum;
import com.bonus.canteen.core.utils.BnsConstants;
import com.bonus.canteen.core.utils.GlobalConstants;
import com.bonus.canteen.core.utils.TreeNodeUtil;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.constant.DelFlagEnum;
import com.bonus.common.houqin.constant.LeConstants;
import com.bonus.common.houqin.i18n.I18n;
import com.bonus.common.houqin.utils.id.Id;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.menu.mapper.MenuMaterialCategoryMapper;
import com.bonus.canteen.core.menu.domain.MenuMaterialCategory;
import com.bonus.canteen.core.menu.service.IMenuMaterialCategoryService;
import org.springframework.util.CollectionUtils;
/**
* 原料类别Service业务层处理
@ -26,7 +41,7 @@ import com.bonus.canteen.core.menu.service.IMenuMaterialCategoryService;
* @date 2025-04-03
*/
@Service
public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategoryService {
public class MenuMaterialCategoryServiceImpl extends ServiceImpl<MenuMaterialCategoryMapper, MenuMaterialCategory> implements IMenuMaterialCategoryService {
@Autowired
private MenuMaterialCategoryMapper menuMaterialCategoryMapper;
@ -55,19 +70,162 @@ public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategorySer
/**
* 新增原料类别
*
* @param menuMaterialCategory 原料类别
* @param content 原料类别
* @return 结果
*/
@Override
public int insertMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory) {
menuMaterialCategory.setCreateTime(DateUtils.getNowDate());
public int insertMenuMaterialCategory(MenuMaterialCategoryAddDTO content) {
try {
return menuMaterialCategoryMapper.insertMenuMaterialCategory(menuMaterialCategory);
int num = 0;
Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryName, content.getCategoryName())
.eq(content.getAreaId() != null, MenuMaterialCategory::getAreaId,
content.getAreaId())
.isNull(content.getAreaId() == null, MenuMaterialCategory::getAreaId)
.eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
if (ObjectUtil.isNotNull(count) && count > 0L) {
throw new ServiceException(I18n.getMessage("menu_material_name_repeat", new Object[0]));
} else {
Long parentId = content.getParentId();
if (ObjectUtil.isNotNull(parentId) && parentId != -1L) {
Long countParent = this.baseMapper.selectCount(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, parentId));
if (ObjectUtil.isNull(countParent) || countParent <= 0L) {
throw new ServiceException(I18n.getMessage("menu_parent_type_not_exist", new Object[0]));
}
}
String username = SecurityUtils.getUsername();
MenuMaterialCategory materialCategory = new MenuMaterialCategory();
BeanUtil.copyProperties(content, materialCategory, new String[0]);
materialCategory.setCategoryId(Id.next());
materialCategory.setCreateBy(username);
this.syncAllCategoryBigCategoryAndLevel();
MenuMaterialCategory parentCategory = this.baseMapper.selectOne(
Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, content.getParentId())
.select(MenuMaterialCategory::getCategoryId, MenuMaterialCategory::getLevel,
MenuMaterialCategory::getBigCategoryId));
materialCategory.setLevel(parentCategory.getLevel() + 1);
materialCategory.setBigCategoryId(parentCategory.getBigCategoryId());
num = this.baseMapper.insert(materialCategory);
// MqUtil.pushToTenantAllDevice(materialCategory, LeMqConstant.Topic.DRP_SYNC_MATERIAL_BIG_CATEGORY);
this.generateCategoryNum(materialCategory.getCategoryId(), materialCategory.getParentId(), materialCategory.getCategoryType());
}
//return menuMaterialCategoryMapper.insertMenuMaterialCategory(menuMaterialCategory);
return num;
} catch (Exception e) {
throw new ServiceException("错误信息描述");
}
}
@Override
public void generateCategoryNum(Long categoryId, Long parentId, Integer categoryType) {
MenuMaterialCategory parentCategory = this.baseMapper.selectOne(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, parentId)
.eq(MenuMaterialCategory::getCategoryType, categoryType)
.eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key())
.select(MenuMaterialCategory::getCategoryId, MenuMaterialCategory::getParentId,
MenuMaterialCategory::getCategoryNum));
if (ObjectUtil.isNotEmpty(parentCategory)) {
if (CharSequenceUtil.isNotEmpty(parentCategory.getCategoryNum())) {
String maxCategoryNum = this.baseMapper.getCategoryChildMaxNum(parentCategory.getCategoryId(), categoryType,
DelFlagEnum.DEL_FALSE.key());
String categoryNum = "";
if (CharSequenceUtil.isNotEmpty(maxCategoryNum)) {
String lastStr = maxCategoryNum.substring(maxCategoryNum.lastIndexOf("-") + 1);
String lastNum = String.format("%02d", Integer.parseInt(lastStr) + 1);
String var10000 = parentCategory.getCategoryNum();
categoryNum = var10000 + "-" + lastNum;
} else {
categoryNum = parentCategory.getCategoryNum() + "-01";
}
this.baseMapper.update(null, Wrappers.lambdaUpdate(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, categoryId)
.set(MenuMaterialCategory::getCategoryNum, categoryNum));
} else {
this.generateCategoryNum(parentCategory.getCategoryId(), parentCategory.getParentId(), categoryType);
}
} else {
this.baseMapper.update(null,Wrappers.lambdaUpdate(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getParentId, -1).eq(MenuMaterialCategory::getCategoryType, categoryType)
.set(MenuMaterialCategory::getCategoryNum, categoryType));
}
MenuMaterialCategory menuMaterialCategory = this.baseMapper.selectOne(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, categoryId).eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key())
.select(MenuMaterialCategory::getCategoryNum));
if (!ObjectUtil.isNotEmpty(menuMaterialCategory) || !CharSequenceUtil.isNotEmpty(menuMaterialCategory.getCategoryNum())) {
this.generateCategoryNum(categoryId, parentId, categoryType);
}
}
@Override
public void syncAllCategoryBigCategoryAndLevel() {
Long checkIfExistLevel = this.baseMapper.selectCount(new LambdaQueryWrapper<>(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key())
.isNull(MenuMaterialCategory::getBigCategoryId).or()
.isNull(MenuMaterialCategory::getLevel));
System.err.println("[货品类别_所有货品类别的所属大类和等级]_未赋值大类id和等级的类别数量{}"+checkIfExistLevel);
if (checkIfExistLevel <= 0L) {
System.err.println("[货品类别_所有货品类别的所属大类和等级]_不需要同步,跳过!");
} else {
List<MenuMaterialCategory> topCategoryList = this.baseMapper.selectList(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getParentId, -1).eq(MenuMaterialCategory::getDelFlag,
DelFlagEnum.DEL_FALSE.key()));
Iterator var3 = topCategoryList.iterator();
while(true) {
List menuMaterialCategoryList;
do {
if (!var3.hasNext()) {
return;
}
MenuMaterialCategory topCategory = (MenuMaterialCategory)var3.next();
this.baseMapper.update(null,Wrappers.lambdaUpdate(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, topCategory.getCategoryId())
.set(MenuMaterialCategory::getLevel, 0)
.set(MenuMaterialCategory::getBigCategoryId, topCategory.getCategoryId()));
menuMaterialCategoryList = this.baseMapper.selectList(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getParentId, topCategory.getCategoryId()));
} while(CollUtil.isEmpty(menuMaterialCategoryList));
Iterator var6 = menuMaterialCategoryList.iterator();
while(var6.hasNext()) {
MenuMaterialCategory menuMaterialCategory = (MenuMaterialCategory)var6.next();
this.baseMapper.update(null, Wrappers.lambdaUpdate(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, menuMaterialCategory.getCategoryId())
.set(MenuMaterialCategory::getLevel, LeLevelEnum.FIRST.getKey())
.set(MenuMaterialCategory::getBigCategoryId, menuMaterialCategory.getCategoryId()));
menuMaterialCategory.setLevel(LeLevelEnum.FIRST.getKey());
menuMaterialCategory.setBigCategoryId(menuMaterialCategory.getCategoryId());
this.setChildBigCategoryAndLevel(menuMaterialCategory, LeLevelEnum.FIRST.getKey() + 1, menuMaterialCategory.getCategoryId());
}
}
}
}
public void setChildBigCategoryAndLevel(MenuMaterialCategory parentCategory, Integer level, Long bigCategoryId) {
List<MenuMaterialCategory> childCategoryList = this.baseMapper.selectList(Wrappers.lambdaQuery(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getParentId, parentCategory.getCategoryId()));
if (!CollUtil.isEmpty(childCategoryList)) {
Iterator var5 = childCategoryList.iterator();
while(var5.hasNext()) {
MenuMaterialCategory childCategory = (MenuMaterialCategory)var5.next();
this.baseMapper.update(null, Wrappers.lambdaUpdate(MenuMaterialCategory.class)
.eq(MenuMaterialCategory::getCategoryId, childCategory.getCategoryId())
.set(MenuMaterialCategory::getLevel, level)
.set(MenuMaterialCategory::getBigCategoryId, bigCategoryId));
this.setChildBigCategoryAndLevel(childCategory, level + 1, bigCategoryId);
}
}
}
/**
* 修改原料类别
*
@ -76,7 +234,6 @@ public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategorySer
*/
@Override
public int updateMenuMaterialCategory(MenuMaterialCategory menuMaterialCategory) {
menuMaterialCategory.setUpdateTime(DateUtils.getNowDate());
try {
return menuMaterialCategoryMapper.updateMenuMaterialCategory(menuMaterialCategory);
} catch (Exception e) {
@ -107,12 +264,85 @@ public class MenuMaterialCategoryServiceImpl implements IMenuMaterialCategorySer
}
@Override
public List<MenuCategoryTreeVo> getTree(CategoryTreeListDTO content) {
public List<MenuCategoryTreeVO> getTree(CategoryTreeListDTO content) {
// LambdaQueryWrapper<MenuMaterialCategory> lambdaQueryWrapper = new LambdaQueryWrapper();
// lambdaQueryWrapper.eq(MenuMaterialCategory::getDelFlag, DelFlagEnum.DEL_FALSE.key());
// content.setAreaAuth(getTenantAreaIdList(BnsConstants.COMMON_YES));
// if (ObjectUtil.isNotEmpty(content.getCategoryType())) {
// lambdaQueryWrapper.eq(MenuMaterialCategory::getCategoryType, content.getCategoryType());
// }
//
// if (ObjectUtil.isNotEmpty(content.getAreaId())) {
// lambdaQueryWrapper.and((i) -> {
// i.eq(MenuMaterialCategory::getAreaId, content.getAreaId()).or()
// .isNull(MenuMaterialCategory::getAreaId);
// });
// }
//
// if (ObjectUtil.isNotEmpty(content.getAreaAuth())) {
// lambdaQueryWrapper.and((i) -> {
// i.in(MenuMaterialCategory::getAreaId, content.getAreaAuth()).or()
// .isNull(MenuMaterialCategory::getAreaId);
// });
// }
//
// if (ObjectUtil.isNotEmpty(content.getIfAdd()) && ObjectUtil.isEmpty(content.getAreaId())) {
// lambdaQueryWrapper.isNull(MenuMaterialCategory::getAreaId);
// }
//
// List<MenuCategoryTreeVO> sqlList = this.baseMapper.selectCategoryTree(lambdaQueryWrapper);
// Map<Long, String> areaNameMap = this.allocCanteenApi.getAreaNameMap(sqlList.stream().map(MenuCategoryTreeVO::getAreaId).filter(Objects::nonNull).collect(Collectors.toList()));
List<MenuCategoryTreeVO> list = menuMaterialCategoryMapper.selectCategoryTrees(content);
List<MenuCategoryTreeVo> list = menuMaterialCategoryMapper.selectCategoryTree(content);
return TreeNodeUtil.assembleTree(list);
}
public List<Long> getTenantAreaIdList(Integer excludeMiddle) {
MgrUserAuthPO mgrUserAuthPO = this.getUserAuthPO();
return ObjectUtil.equal(mgrUserAuthPO.getRoleType(), LeConstants.DATA_DEFAULT_INTEGER) ? CollUtil.newArrayList(new Long[0]) : menuMaterialCategoryMapper.getTenantAreaIdList(excludeMiddle, mgrUserAuthPO);
}
public MgrUserAuthPO getUserAuthPO() {
MgrUserAuthPO userAuthPO = new MgrUserAuthPO();
LoginUser user = SecurityUtils.getLoginUser();
user.setUserid(SecurityUtils.getUserId());
user.setUsername(SecurityUtils.getUsername());
Set<String> roleSet = user.getRoles();
if (CollectionUtils.isEmpty(roleSet)) {
throw new ServiceException(I18n.getMessage("auth_user_no_role_code", new Object[0]));
}
Integer roleType = null;
String roleCodeResult = null;
for (String roleCode : roleSet) {
roleCodeResult = roleCode;
if (roleCode.startsWith(RoleCodeEnum.ROLE_ADMIN.key()) || GlobalConstants.SUPER_ADMIN_ROLE_KEY.equals(roleCode)) {
roleType = MgrRoleTypeEnum.ROLE_ADMIN.getKey();
// if (CharSequenceUtil.split(roleCode, "&&").size() > 1) {
// roleType = MgrRoleTypeV2Enum.ROLE_ADMIN.getKey();
// } else {
// roleType = LeConstants.DATA_DEFAULT_INTEGER;
// }
break;
} else if (roleCode.startsWith(RoleCodeEnum.ROLE_ORG.key())) {
roleType = MgrRoleTypeEnum.ROLE_ORG.getKey();
break;
} else {
if (!roleCode.startsWith(RoleCodeEnum.ROLE_MERCHANT.key())) {
throw new ServiceException(I18n.getMessage("auth_role_type_error", new Object[0]));
}
roleType = MgrRoleTypeEnum.ROLE_MERCHANT.getKey();
break;
}
}
userAuthPO.setUserId(user.getUserid());
userAuthPO.setRoleType(roleType);
userAuthPO.setRoleCode(roleCodeResult);
userAuthPO.setUserName(user.getUsername());
return userAuthPO;
}
}

View File

@ -93,10 +93,14 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService {
return menuNutritionMapper.updateMenuNutrition(menuNutritionDTO);
}else{
if(menuNutrition == null){
menuNutrition = new MenuNutrition();
}
Long nutritionId = Id.next();
menuNutrition.setNutritionId(Id.next());
menuNutrition.setCrby(username);
menuNutrition.setId(nutritionId);
BnsUtils.copyProperties(menuNutritionDTO, menuNutrition);
return menuNutritionMapper.insertMenuNutrition(menuNutrition);
}
} catch (Exception e) {
@ -151,7 +155,7 @@ public class MenuNutritionServiceImpl implements IMenuNutritionService {
}
return menuNutritionMapper.updateMenuNutrition(menuNutritionDTO);
} catch (Exception e) {
throw new ServiceException("错误信息描述");
throw new ServiceException(e.toString());
}
}

View File

@ -11,7 +11,7 @@ import java.io.Serializable;
* @date 2025/4/7 16:49
*/
@Data
public class MenuCategoryTreeVo extends BaseTreeNode implements Serializable {
public class MenuCategoryTreeVO extends BaseTreeNode implements Serializable {
@ApiModelProperty("区域ID")
private Long areaId;
@ApiModelProperty("区域名称")

View File

@ -0,0 +1,32 @@
package com.bonus.canteen.core.utils;
/**
* @author xliu
* @date 2025/4/9 14:34
*/
public interface BnsConstants {
String ID_TEMPORARY_PRE = "xnznkjxnznkj";
String NUM_PRE = "0";
Long DATA_DEFAULT_LONG = -1L;
Integer DATA_DEFAULT_INTEGER = -1;
Integer COMMON_YES = 1;
Integer COMMON_NO = 2;
Integer MAX_CARD_NUM = 100000;
Integer MAX_CUST_LIMIT_ID = 65535;
Integer MIN_DATA_NUM = 1;
Integer MAX_CUST_PSN_TYPE = 100;
String DEFAULT_GRADE_NAME = "普通会员";
String DEFAULT_PSN_TYPE_NAME = "类别";
String MAPPING_OBJECT = "object";
String MAPPING_PAGE = "page";
String MERCHANT_ID = "MERCHANT-ID";
String MERCHANT_ID_LOW = "merchant-id";
String OPENID = "openid";
String SOURCE_TYPE = "source-type";
String FACE_VER = "face-ver";
String MACHINE_SN = "machine-sn";
String MACHINE_NUM = "machine-num";
String MERCHANT_DEFAULT = "(默认)";
String DEFAULT_ORG_NUM = "0";
}

View File

@ -0,0 +1,81 @@
package com.bonus.canteen.core.utils;
/**
* 全局常量
* @author bns_han
*/
public class GlobalConstants {
/**
* super admin role key
*/
public static final String SUPER_ADMIN_ROLE_KEY = "admin";
/**
* 字符串 MSIE
*/
public static final String STRING_MSIE = "MSIE";
/**
* 字符串 Firefox
*/
public static final String STRING_FIREFOX = "Firefox";
/**
* 字符串 Chrome
*/
public static final String STRING_CHROME = "Chrome";
/**
* 字符串 #//
*/
public static final String STRING_HASH_HASH = "#//";
/**
* 字符串 unknown
*/
public static final String STRING_UNKNOWN = "unknown";
/**
* 字符串 ,
*/
public static final String STRING_COMMA = ",";
/**
* 字符串 *
*/
public static final String STRING_ASTERISK = "*";
/**
* 字符串 ascending
*/
public static final String STRING_ASCENDING = "ascending";
/**
* 字符串 descending
*/
public static final String STRING_DESCENDING = "descending";
/**
* 字符串 application/json
*/
public static final String STRING_APPLICATION_JSON = "application/json";
/**
* 字符串 XMLHttpRequest
*/
public static final String STRING_XML_HTTP_REQUEST = "XMLHttpRequest";
/**
* 字符串 .json
*/
public static final String STRING_JSON = ".json";
/**
* 字符串 .xml
*/
public static final String STRING_XML = ".xml";
/**
* 字符串 _
*/
public static final String STRING_UNDERLINE = "_";
/**
* 字符串 win
*/
public static final String STRING_WIN = "win";
/**
* 字符串 ok
*/
public static final String STRING_OK = "ok";
/**
* 字符串 true
*/
public static final String STRING_TRUE = "true";
}

View File

@ -113,7 +113,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<select id="selectCategoryTree" resultType="com.bonus.canteen.core.menu.vo.MenuCategoryTreeVo">
<select id="selectCategoryTrees" resultType="com.bonus.canteen.core.menu.vo.MenuCategoryTreeVO">
select category_id as id, parent_id as parentId, category_name as categoryName,category_type as categoryType,area_id as areaId from menu_material_category
</select>
<select id="getTenantAreaIdList" resultType="java.lang.Long">
SELECT r.area_id
FROM sys_role_area r
LEFT JOIN sys_role o ON o.role_id = r.role_id
LEFT JOIN sys_user_role u ON r.role_id = u.role_id
WHERE u.user_id = #{authPO.userId}
AND o.role_key = #{authPO.roleCode}
AND o.del_flag = 0
</select>
</mapper>

View File

@ -130,103 +130,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectMenuNutritionList" parameterType="com.bonus.canteen.core.menu.domain.MenuNutrition" resultMap="MenuNutritionResult">
<include refid="selectMenuNutritionVo"/>
<where>
<if test="nutritionId != null "> and nutrition_id = #{nutritionId}</if>
<if test="nutritionCode != null and nutritionCode != ''"> and nutrition_code = #{nutritionCode}</if>
<if test="nutritionCode != null and nutritionCode != ''"> and nutrition_code like concat('%', #{nutritionCode}, '%')</if>
<if test="nutritionName != null and nutritionName != ''"> and nutrition_name like concat('%', #{nutritionName}, '%')</if>
<if test="nutritionImageUrl != null and nutritionImageUrl != ''"> and nutrition_image_url = #{nutritionImageUrl}</if>
<if test="weight != null "> and weight = #{weight}</if>
<if test="price != null "> and price = #{price}</if>
<if test="color != null and color != ''"> and color = #{color}</if>
<if test="categoryId != null "> and category_id = #{categoryId}</if>
<if test="bigType != null and bigType != ''"> and big_type = #{bigType}</if>
<if test="littleType != null and littleType != ''"> and little_type = #{littleType}</if>
<if test="label != null and label != ''"> and label = #{label}</if>
<if test="processingMethod != null and processingMethod != ''"> and processing_method = #{processingMethod}</if>
<if test="processingTime != null "> and processing_time = #{processingTime}</if>
<if test="recommendedCombination != null and recommendedCombination != ''"> and recommended_combination = #{recommendedCombination}</if>
<if test="combinationNotRecommended != null and combinationNotRecommended != ''"> and combination_not_recommended = #{combinationNotRecommended}</if>
<if test="edible != null "> and edible = #{edible}</if>
<if test="water != null "> and water = #{water}</if>
<if test="calories != null "> and calories = #{calories}</if>
<if test="protein != null "> and protein = #{protein}</if>
<if test="fat != null "> and fat = #{fat}</if>
<if test="carbohydrate != null "> and carbohydrate = #{carbohydrate}</if>
<if test="dietaryFiber != null "> and dietary_fiber = #{dietaryFiber}</if>
<if test="cholesterol != null "> and cholesterol = #{cholesterol}</if>
<if test="ash != null "> and ash = #{ash}</if>
<if test="vitaminA != null "> and vitamin_a = #{vitaminA}</if>
<if test="carotene != null "> and carotene = #{carotene}</if>
<if test="thiamine != null "> and thiamine = #{thiamine}</if>
<if test="riboflavin != null "> and riboflavin = #{riboflavin}</if>
<if test="niacin != null "> and niacin = #{niacin}</if>
<if test="vitaminC != null "> and vitamin_c = #{vitaminC}</if>
<if test="vitaminD != null "> and vitamin_d = #{vitaminD}</if>
<if test="vitaminE != null "> and vitamin_e = #{vitaminE}</if>
<if test="choline != null "> and choline = #{choline}</if>
<if test="biotin != null "> and biotin = #{biotin}</if>
<if test="pantothenicAcid != null "> and pantothenic_acid = #{pantothenicAcid}</if>
<if test="guanine != null "> and guanine = #{guanine}</if>
<if test="adenine != null "> and adenine = #{adenine}</if>
<if test="hypoxanthine != null "> and hypoxanthine = #{hypoxanthine}</if>
<if test="xanthine != null "> and xanthine = #{xanthine}</if>
<if test="purine != null "> and purine = #{purine}</if>
<if test="glycemicIndex != null "> and glycemic_index = #{glycemicIndex}</if>
<if test="totalPhytosterolContent != null "> and total_phytosterol_content = #{totalPhytosterolContent}</if>
<if test="cerealSterol != null "> and cereal_sterol = #{cerealSterol}</if>
<if test="cameliaSterol != null "> and camelia_sterol = #{cameliaSterol}</if>
<if test="sterol != null "> and sterol = #{sterol}</if>
<if test="cerealSteranol != null "> and cereal_steranol = #{cerealSteranol}</if>
<if test="rapesanol != null "> and rapesanol = #{rapesanol}</if>
<if test="rapeseedSteranol != null "> and rapeseed_steranol = #{rapeseedSteranol}</if>
<if test="luteinZeaxanthin != null "> and lutein_zeaxanthin = #{luteinZeaxanthin}</if>
<if test="quercetin != null "> and quercetin = #{quercetin}</if>
<if test="myricetin != null "> and myricetin = #{myricetin}</if>
<if test="luteolin != null "> and luteolin = #{luteolin}</if>
<if test="kaemPferol != null "> and kaem_pferol = #{kaemPferol}</if>
<if test="apigenin != null "> and apigenin = #{apigenin}</if>
<if test="isoflavone != null "> and isoflavone = #{isoflavone}</if>
<if test="daidzein != null "> and daidzein = #{daidzein}</if>
<if test="genistein != null "> and genistein = #{genistein}</if>
<if test="glycitein != null "> and glycitein = #{glycitein}</if>
<if test="anthocyan != null "> and anthocyan = #{anthocyan}</if>
<if test="resveratrol != null "> and resveratrol = #{resveratrol}</if>
<if test="polydatin != null "> and polydatin = #{polydatin}</if>
<if test="originPlace != null and originPlace != ''"> and origin_place = #{originPlace}</if>
<if test="calcium != null "> and calcium = #{calcium}</if>
<if test="phosphorus != null "> and phosphorus = #{phosphorus}</if>
<if test="kalium != null "> and kalium = #{kalium}</if>
<if test="sodium != null "> and sodium = #{sodium}</if>
<if test="magnesium != null "> and magnesium = #{magnesium}</if>
<if test="iron != null "> and iron = #{iron}</if>
<if test="zinc != null "> and zinc = #{zinc}</if>
<if test="selenium != null "> and selenium = #{selenium}</if>
<if test="cuprum != null "> and cuprum = #{cuprum}</if>
<if test="manganese != null "> and manganese = #{manganese}</if>
<if test="isoleucine != null "> and isoleucine = #{isoleucine}</if>
<if test="leucine != null "> and leucine = #{leucine}</if>
<if test="lysine != null "> and lysine = #{lysine}</if>
<if test="saaTotal != null "> and saa_total = #{saaTotal}</if>
<if test="aaaTotal != null "> and aaa_total = #{aaaTotal}</if>
<if test="threonine != null "> and threonine = #{threonine}</if>
<if test="tryptophan != null "> and tryptophan = #{tryptophan}</if>
<if test="valine != null "> and valine = #{valine}</if>
<if test="arginine != null "> and arginine = #{arginine}</if>
<if test="histidine != null "> and histidine = #{histidine}</if>
<if test="alanine != null "> and alanine = #{alanine}</if>
<if test="asparticAcid != null "> and aspartic_acid = #{asparticAcid}</if>
<if test="glutamate != null "> and glutamate = #{glutamate}</if>
<if test="glycine != null "> and glycine = #{glycine}</if>
<if test="proline != null "> and proline = #{proline}</if>
<if test="serine != null "> and serine = #{serine}</if>
<if test="fattyAcid != null "> and fatty_acid = #{fattyAcid}</if>
<if test="saturatedFattyAcid != null "> and saturated_fatty_acid = #{saturatedFattyAcid}</if>
<if test="monounsaturatedFattyAcid != null "> and monounsaturated_fatty_acid = #{monounsaturatedFattyAcid}</if>
<if test="polyunsaturatedFattyAcid != null "> and polyunsaturated_fatty_acid = #{polyunsaturatedFattyAcid}</if>
<if test="iodine != null "> and iodine = #{iodine}</if>
<if test="folic != null "> and folic = #{folic}</if>
<if test="retinol != null "> and retinol = #{retinol}</if>
<if test="defaultFlag != null "> and default_flag = #{defaultFlag}</if>
<if test="revision != null "> and revision = #{revision}</if>
</where>
</select>
@ -452,21 +359,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateMenuNutrition" parameterType="com.bonus.canteen.core.menu.dto.MenuNutritionDTO">
update menu_nutrition
<trim prefix="SET" suffixOverrides=",">
<if test="nutritionId != null">nutrition_id = #{nutritionId},</if>
<if test="nutritionCode != null and nutritionCode != ''">nutrition_code = #{nutritionCode},</if>
<if test="nutritionName != null and nutritionName != ''">nutrition_name = #{nutritionName},</if>
<if test="nutritionImageUrl != null and nutritionImageUrl != ''">nutrition_image_url = #{nutritionImageUrl},</if>
<if test="weight != null">weight = #{weight},</if>
<if test="price != null">price = #{price},</if>
<if test="color != null and color != ''">color = #{color},</if>
<if test="categoryId != null">category_id = #{categoryId},</if>
<if test="bigType != null and bigType != ''">big_type = #{bigType},</if>
<if test="littleType != null and littleType != ''">little_type = #{littleType},</if>
<if test="label != null and label != ''">label = #{label},</if>
<if test="processingMethod != null and processingMethod != ''">processing_method = #{processingMethod},</if>
<if test="processingTime != null">processing_time = #{processingTime},</if>
<if test="recommendedCombination != null and recommendedCombination != ''">recommended_combination = #{recommendedCombination},</if>
<if test="combinationNotRecommended != null and combinationNotRecommended != ''">combination_not_recommended = #{combinationNotRecommended},</if>
<if test="edible != null">edible = #{edible},</if>
<if test="water != null">water = #{water},</if>
<if test="calories != null">calories = #{calories},</if>
@ -474,6 +372,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="fat != null">fat = #{fat},</if>
<if test="carbohydrate != null">carbohydrate = #{carbohydrate},</if>
<if test="dietaryFiber != null">dietary_fiber = #{dietaryFiber},</if>
<if test="cholesterol != null">cholesterol = #{cholesterol},</if>
<if test="ash != null">ash = #{ash},</if>
<if test="vitaminA != null">vitamin_a = #{vitaminA},</if>
@ -548,12 +447,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="iodine != null">iodine = #{iodine},</if>
<if test="folic != null">folic = #{folic},</if>
<if test="retinol != null">retinol = #{retinol},</if>
<if test="defaultFlag != null">default_flag = #{defaultFlag},</if>
<if test="revision != null">revision = #{revision},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<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="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
@ -573,7 +467,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getOne" resultMap="MenuNutritionResult" parameterType="com.bonus.canteen.core.menu.dto.MenuNutritionDTO">
select *
from menu_nutrition
where nutritionCode = #{nutritionCode} or nutritionName = #{nutritionName}
where nutrition_code = #{nutritionCode} or nutrition_name = #{nutritionName}
limit 1
</select>