瀏覽代碼

update

master
dengbiao 3 月之前
父節點
當前提交
cd3923b703
共有 6 個檔案被更改,包括 102 行新增152 行删除
  1. +68
    -133
      app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go
  2. +19
    -6
      app/admin/md/md_enterprise_manage.go
  3. +3
    -2
      app/db/db_meal_label.go
  4. +1
    -1
      app/db/model/meal_label.go
  5. +9
    -8
      app/enum/enum_sys_cfg.go
  6. +2
    -2
      app/router/admin_router.go

+ 68
- 133
app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go 查看文件

@@ -504,98 +504,34 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) {
now := time.Now()
mealLabelDb := db.MealLabelDb{}
mealLabelDb.Set(req.EnterpriseId)
for _, v := range req.List {
for _, vv := range v.MealLabelListForBreakfast {
if vv.Id != 0 {
mealLabel, err := mealLabelDb.GetMealLabel(vv.Id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
mealLabel.Name = vv.Name
mealLabel.Price = vv.Price
_, err = mealLabelDb.MealLabelUpdate(mealLabel, "name", "price")
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
} else {
mealLabel := &model.MealLabel{
Name: vv.Name,
EnterpriseId: req.EnterpriseId,
PeriodId: v.PeriodId,
Kind: 1,
Price: vv.Price,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}
_, err = mealLabelDb.MealLabelInsert(mealLabel)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
for _, v := range req.MealLabelList {
if v.Id != 0 {
mealLabel, err := mealLabelDb.GetMealLabel(v.Id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
}
for _, vv := range v.MealLabelListForLunch {
if vv.Id != 0 {
mealLabel, err := mealLabelDb.GetMealLabel(vv.Id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
mealLabel.Name = vv.Name
mealLabel.Price = vv.Price
_, err = mealLabelDb.MealLabelUpdate(mealLabel, "name", "price")
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
} else {
mealLabel := &model.MealLabel{
Name: vv.Name,
EnterpriseId: req.EnterpriseId,
PeriodId: v.PeriodId,
Kind: 2,
Price: vv.Price,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}
_, err = mealLabelDb.MealLabelInsert(mealLabel)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
mealLabel.Name = v.Name
mealLabel.Price = v.Price
_, err = mealLabelDb.MealLabelUpdate(mealLabel, "name", "price")
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
}
for _, vv := range v.MealLabelListForDinner {
if vv.Id != 0 {
mealLabel, err := mealLabelDb.GetMealLabel(vv.Id)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
mealLabel.Name = vv.Name
mealLabel.Price = vv.Price
_, err = mealLabelDb.MealLabelUpdate(mealLabel, "name", "price")
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
} else {
mealLabel := &model.MealLabel{
Name: vv.Name,
EnterpriseId: req.EnterpriseId,
PeriodId: v.PeriodId,
Kind: 3,
Price: vv.Price,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}
_, err = mealLabelDb.MealLabelInsert(mealLabel)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
} else {
mealLabel := &model.MealLabel{
Name: v.Name,
EnterpriseId: req.EnterpriseId,
GradeId: req.GradeId,
Kind: req.Kind,
Price: v.Price,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
}
_, err = mealLabelDb.MealLabelInsert(mealLabel)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
}
}
@@ -605,66 +541,65 @@ func SetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) {
}

func GetCentralKitchenForSchoolWithSpecByMealLabel(c *gin.Context) {
enterpriseId := c.DefaultQuery("enterprise_id", "")
periodDb := db.PeriodDb{}
periodDb.Set(utils.StrToInt(enterpriseId))
periodList, err := periodDb.FindPeriod()
var req md.GetCentralKitchenForSchoolWithSpecByMealLabelReq
if req.Kind == 0 {
req.Kind = 1 //TODO::默认查询早餐
}
err := c.ShouldBindJSON(&req)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}

var resp = md.GetCentralKitchenForSchoolWithSpecByMealLabelResp{}
resp.EnterpriseId = req.EnterpriseId
resp.Kind = req.Kind

gradeList, total, err := svc2.SelfSupportForSchoolGradeList(md.SelfSupportForSchoolGradeListReq{
EnterpriseId: req.EnterpriseId,
Limit: req.Limit,
Page: req.Page,
Name: "",
})
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

var resp = md.SetCentralKitchenForSchoolWithSpecByMealLabel{}
resp.EnterpriseId = utils.StrToInt(enterpriseId)
mealLabelDb := db.MealLabelDb{}
mealLabelDb.Set(resp.EnterpriseId)
for _, v := range *periodList {
mealLabels, err := mealLabelDb.FindMealLabel(v.Id)
for _, v := range gradeList {
mealLabels, err := mealLabelDb.FindMealLabel(v.Id, req.Kind)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}

var mealLabelListForBreakfast, mealLabelListForLunch, mealLabelListForDinner []md.MealLabelList
var mealLabelList []md.MealLabelList
for _, vv := range *mealLabels {
if vv.Kind == 1 {
mealLabelListForBreakfast = append(mealLabelListForBreakfast, md.MealLabelList{
Id: vv.Id,
Name: vv.Name,
Price: vv.Price,
})
}
if vv.Kind == 2 {
mealLabelListForLunch = append(mealLabelListForLunch, md.MealLabelList{
Id: vv.Id,
Name: vv.Name,
Price: vv.Price,
})
}
if vv.Kind == 3 {
mealLabelListForDinner = append(mealLabelListForDinner, md.MealLabelList{
Id: vv.Id,
Name: vv.Name,
Price: vv.Price,
})
}
mealLabelList = append(mealLabelList, md.MealLabelList{
Id: vv.Id,
Name: vv.Name,
Price: vv.Price,
})
}

resp.List = append(resp.List, struct {
PeriodId int `json:"period_id" binding:"required" label:"学段id"`
Name string `json:"name" label:"学段名称"`
MealLabelListForBreakfast []md.MealLabelList `json:"meal_label_list_for_breakfast" label:"早餐集合"`
MealLabelListForLunch []md.MealLabelList `json:"meal_label_list_for_lunch" label:"午餐集合"`
MealLabelListForDinner []md.MealLabelList `json:"meal_label_list_for_dinner" label:"晚餐集合"`
GradeId int `json:"grade_id" binding:"required" label:"年级id"`
Name string `json:"name" label:"年级名称"`
MealLabelList []md.MealLabelList `json:"meal_label_list" label:"餐标集合"`
}{
PeriodId: v.Id,
Name: v.Name,
MealLabelListForBreakfast: mealLabelListForBreakfast,
MealLabelListForLunch: mealLabelListForLunch,
MealLabelListForDinner: mealLabelListForDinner,
GradeId: v.Id,
Name: v.Name,
MealLabelList: mealLabelList,
})
}

e.OutSuc(c, resp, nil)
e.OutSuc(c, map[string]interface{}{
"list": resp,
"total": total,
}, nil)
return
}



+ 19
- 6
app/admin/md/md_enterprise_manage.go 查看文件

@@ -168,13 +168,26 @@ type SetCentralKitchenForSchoolWithSpecByPeriodReq struct {
}

type SetCentralKitchenForSchoolWithSpecByMealLabel struct {
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`
Kind int32 `json:"kind" binding:"required" label:"餐标类型(1:早餐 2:午餐 3:晚餐) "`
GradeId int `json:"grade_id" binding:"required" label:"年级id"`
MealLabelList []MealLabelList `json:"meal_label_list" label:"餐标集合"`
}

type GetCentralKitchenForSchoolWithSpecByMealLabelReq struct {
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`
Kind int32 `json:"kind" label:"餐标类型(1:早餐 2:午餐 3:晚餐) "`
Page int `json:"page" label:"页码"`
Limit int `json:"limit" label:"每页数量"`
}

type GetCentralKitchenForSchoolWithSpecByMealLabelResp struct {
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`
Kind int32 `json:"kind" binding:"required" label:"餐标类型(1:早餐 2:午餐 3:晚餐) "`
List []struct {
PeriodId int `json:"period_id" binding:"required" label:"学段id"`
Name string `json:"name" label:"学段名称"`
MealLabelListForBreakfast []MealLabelList `json:"meal_label_list_for_breakfast" label:"早餐集合"`
MealLabelListForLunch []MealLabelList `json:"meal_label_list_for_lunch" label:"午餐集合"`
MealLabelListForDinner []MealLabelList `json:"meal_label_list_for_dinner" label:"晚餐集合"`
GradeId int `json:"grade_id" binding:"required" label:"年级id"`
Name string `json:"name" label:"年级名称"`
MealLabelList []MealLabelList `json:"meal_label_list" label:"餐标集合"`
} `json:"list" binding:"required" label:"数据集合"`
}



+ 3
- 2
app/db/db_meal_label.go 查看文件

@@ -17,9 +17,10 @@ func (MealLabelDb *MealLabelDb) Set(enterpriseId int) { // set方法
MealLabelDb.EnterpriseId = enterpriseId
}

func (MealLabelDb *MealLabelDb) FindMealLabel(periodId int) (*[]model.MealLabel, error) {
func (MealLabelDb *MealLabelDb) FindMealLabel(gradeId int, kind int32) (*[]model.MealLabel, error) {
var m []model.MealLabel
if err := MealLabelDb.Db.Desc("id").Where("enterprise_id =?", MealLabelDb.EnterpriseId).And("period_id =?", periodId).Find(&m); err != nil {
if err := MealLabelDb.Db.Desc("id").Where("enterprise_id =?", MealLabelDb.EnterpriseId).And("grade_id =?", gradeId).
And("kind =?", kind).Find(&m); err != nil {
return nil, logx.Error(err)
}
return &m, nil


+ 1
- 1
app/db/model/meal_label.go 查看文件

@@ -4,7 +4,7 @@ type MealLabel struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('单位id') INT(11)"`
PeriodId int `json:"period_id" xorm:"not null default 0 comment('学段id') INT(11)"`
GradeId int `json:"grade_id" xorm:"not null default 0 comment('年级id') INT(11)"`
Kind int32 `json:"kind" xorm:"not null default 0 comment('餐标类型(1:早餐 2:午餐 3:晚餐)') INT(11)"`
Price string `json:"price" xorm:"not null default 0.00 comment('单价') DECIMAL(4,2)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`


+ 9
- 8
app/enum/enum_sys_cfg.go 查看文件

@@ -16,14 +16,15 @@ const (
OpenAppletAppPublicKey = "open_applet_app_public_key"
OpenAppletPublicKey = "open_applet_public_key"

FileBucketHost = "file_bucket_host"
FileBucketRegion = "file_bucket_region"
FileBucketScheme = "file_bucket_scheme"
FileExt = "file_ext"
FileSecretKey = "file_secret_key"
FileUserUploadMaxSize = "file_user_upload_max_size"
FileAccessKey = "file_access_key"
FileBucket = "file_bucket"
FileBucketHost = "file_bucket_host"
FileBucketRegion = "file_bucket_region"
FileBucketScheme = "file_bucket_scheme"
FileExt = "file_ext"
FileSecretKey = "file_secret_key"
FileUserUploadMaxSize = "file_user_upload_max_size"
FileAccessKey = "file_access_key"
FileBucket = "file_bucket"

AdministratorContactInfo = "administrator_contact_info"
CentralKitchenForSchoolReserveMealTime = "central_kitchen_for_school_reserve_meal_time"
CentralKitchenForSchoolCancelMealTime = "central_kitchen_for_school_cancel_meal_time"


+ 2
- 2
app/router/admin_router.go 查看文件

@@ -212,8 +212,8 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.POST("/setCentralKitchenForSchoolWithSpecByTeacher", hdl.SetCentralKitchenForSchoolWithSpecByTeacher) //设置教师"央厨-学校-规格"
r.GET("/getCentralKitchenForSchoolWithSpecByTeacher", hdl.GetCentralKitchenForSchoolWithSpecByTeacher) //获取教师"央厨-学校-规格"
r.POST("/setCentralKitchenForSchoolWithSpecByPeriod", hdl.SetCentralKitchenForSchoolWithSpecByPeriod) //设置学段"央厨-学校-规格"
r.GET("/getCentralKitchenForSchoolWithSpecByMealLabel", hdl.GetCentralKitchenForSchoolWithSpecByMealLabel) //获取学段"央厨-学校-餐标规格"
r.POST("/setCentralKitchenForSchoolWithSpecByMealLabel", hdl.SetCentralKitchenForSchoolWithSpecByMealLabel) //设置学段"央厨-学校-餐标规格"
r.POST("/getCentralKitchenForSchoolWithSpecByMealLabel", hdl.GetCentralKitchenForSchoolWithSpecByMealLabel) //获取学段"央厨-学校-年级-餐标规格"
r.POST("/setCentralKitchenForSchoolWithSpecByMealLabel", hdl.SetCentralKitchenForSchoolWithSpecByMealLabel) //设置学段"央厨-学校-年级-餐标规格"
r.POST("/listCentralKitchenForSchoolPackage", hdl.ListCentralKitchenForSchoolPackage) //"央厨-学校-套餐" 列表
r.GET("/detailCentralKitchenForSchoolPackage", hdl.DetailCentralKitchenForSchoolPackage) //"央厨-学校-套餐" 详情
r.POST("/saveCentralKitchenForSchoolPackage", hdl.SaveCentralKitchenForSchoolPackage) //新增/编辑 "央厨-学校-套餐"


Loading…
取消
儲存