Pārlūkot izejas kodu

update

add_mode
DengBiao pirms 1 gada
vecāks
revīzija
1e067a28a8
7 mainītis faili ar 192 papildinājumiem un 112 dzēšanām
  1. +33
    -2
      app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go
  2. +111
    -73
      app/admin/hdl/hdl_enterprise.go
  3. +18
    -14
      app/admin/md/md_enterprise.go
  4. +10
    -0
      app/admin/md/md_enterprise_manage.go
  5. +1
    -1
      app/customer/hdl/hdl_demo.go
  6. +9
    -13
      app/db/model/period.go
  7. +10
    -9
      app/router/admin_router.go

+ 33
- 2
app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go Parādīt failu

@@ -282,7 +282,7 @@ func CentralKitchenForSchoolTeacherDelete(c *gin.Context) {
return
}

func GetCentralKitchenForSchoolWithSpec(c *gin.Context) {
func GetCentralKitchenForSchoolWithSpecByTeacher(c *gin.Context) {
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0"))
centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
centralKitchenForSchoolWithSpec.Set(enterpriseId)
@@ -298,7 +298,7 @@ func GetCentralKitchenForSchoolWithSpec(c *gin.Context) {
return
}

func SetCentralKitchenForSchoolWithSpec(c *gin.Context) {
func SetCentralKitchenForSchoolWithSpecByTeacher(c *gin.Context) {
var req md.SetCentralKitchenForSchoolWithSpecReq
err := c.ShouldBindJSON(&req)
if err != nil {
@@ -372,6 +372,37 @@ func SetCentralKitchenForSchoolWithSpec(c *gin.Context) {
return
}

func SetCentralKitchenForSchoolWithSpecByPeriod(c *gin.Context) {
var req md.SetCentralKitchenForSchoolWithSpecByPeriodReq
err := c.ShouldBindJSON(&req)
if err != nil {
err = validate.HandleValidateErr(err)
err1 := err.(e.E)
e.OutErr(c, err1.Code, err1.Error())
return
}
for _, v := range req.List {
periodDb := db.PeriodDb{}
periodDb.Set(req.EnterpriseId)
period, err1 := periodDb.GetPeriod(v.PeriodId)
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
period.BreakfastUnitPrice = v.BreakfastUnitPrice
period.LunchUnitPrice = v.LunchUnitPrice
period.DinnerUnitPrice = v.DinnerUnitPrice
_, err2 := periodDb.PeriodUpdate(period, "breakfast_unit_price", "lunch_unit_price", "dinner_unit_price")
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
}

e.OutSuc(c, "success", nil)
return
}

func ListCentralKitchenForSchoolPackage(c *gin.Context) {
var req md.ListCentralKitchenForSchoolPackageReq
err := c.ShouldBindJSON(&req)


+ 111
- 73
app/admin/hdl/hdl_enterprise.go Parādīt failu

@@ -102,20 +102,20 @@ func SchoolBelowGrade(c *gin.Context) {
return
}

//func SchoolBelowPeriod(c *gin.Context) {
// periodId := c.DefaultQuery("period_id", "")
// gradeDb := db.GradeDb{}
// gradeDb.Set(utils.StrToInt(enterpriseId))
// gradeList, err := gradeDb.FindGrade()
// if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
// }
// e.OutSuc(c, map[string]interface{}{
// "list": gradeList,
// }, nil)
// return
//}
func SchoolBelowPeriod(c *gin.Context) {
enterpriseId := c.DefaultQuery("enterprise_id", "")
periodDb := db.PeriodDb{}
periodDb.Set(utils.StrToInt(enterpriseId))
periodList, err := periodDb.FindPeriod()
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
e.OutSuc(c, map[string]interface{}{
"list": periodList,
}, nil)
return
}

func SchoolGradeBelowClass(c *gin.Context) {
gradeId := c.DefaultQuery("grade_id", "")
@@ -300,112 +300,150 @@ func EnterpriseUpdate(c *gin.Context) {
return
}

//2、更新 grade && class 数据
//2、删除 grade && class 数据
//2、更新 period && grade && class 数据
periodDb := db.PeriodDb{}
periodDb.Set(req.Id)
gradeDb := db.GradeDb{}
gradeDb.Set(req.Id)
//_, err = gradeDb.ClassDeleteBySessionForEnterprise(db.Db.NewSession(), req.Id)
//if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
//}
classDb := db.ClassDb{}
classDb.Set(0)
//_, err = classDb.ClassDeleteBySessionForEnterprise(db.Db.NewSession(), req.Id)
//if err != nil {
// e.OutErr(c, e.ERR_DB_ORM, err.Error())
// return
//}

//新增 grade 数据 && class 数据
for _, v := range req.GradeList {
var classes []*model.Class

if v.Id == 0 {
var classes []*model.Class
for _, v := range req.PeriodList {
if v.Id != 0 {
//TODO::新增
insertId, err1 := gradeDb.GradeInsert(&model.Grade{
EnterpriseId: req.Id,
Name: v.Name,
Memo: "",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
insertId, err1 := periodDb.PeriodInsert(&model.Period{
EnterpriseId: req.Id,
Name: req.Name,
BreakfastUnitPrice: "0.00",
LunchUnitPrice: "0.00",
DinnerUnitPrice: "0.00",
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
for _, v1 := range v.ClassList {
classes = append(classes, &model.Class{

for _, v1 := range v.GradeList {
insertId1, err2 := gradeDb.GradeInsert(&model.Grade{
Name: v1.Name,
Memo: "",
GradeId: insertId,
PeriodId: insertId,
EnterpriseId: req.Id,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
}
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}

for _, v2 := range v1.ClassList {
classes = append(classes, &model.Class{
Name: v2.Name,
Memo: "",
GradeId: insertId1,
EnterpriseId: req.Id,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
}
}
} else {
//TODO::编辑
grade, err3 := gradeDb.GetGrade(v.Id)
if err3 != nil {
e.OutErr(c, e.ERR_DB_ORM, err3.Error())
period, err1 := periodDb.GetPeriod(v.Id)
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
if grade == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关年级信息")
if period == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关学段信息")
return
}

grade.Name = v.Name
_, err4 := gradeDb.GradeUpdate(grade, "name")
if err4 != nil {
e.OutErr(c, e.ERR_DB_ORM, err4.Error())
period.Name = v.Name
_, err2 := periodDb.PeriodUpdate(period, "name")
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
for _, v1 := range v.ClassList {
for _, v1 := range v.GradeList {
var gradeId int
if v1.Id == 0 {
//新增
classes = append(classes, &model.Class{
gradeId, err2 = gradeDb.GradeInsert(&model.Grade{
Name: v1.Name,
Memo: "",
GradeId: grade.Id,
PeriodId: period.Id,
EnterpriseId: req.Id,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
} else {
//编辑
class, err5 := classDb.GetClass(v1.Id)
if err5 != nil {
e.OutErr(c, e.ERR_DB_ORM, err5.Error())
grade, err3 := gradeDb.GetGrade(v1.Id)
if err3 != nil {
e.OutErr(c, e.ERR_DB_ORM, err3.Error())
return
}
if class == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关级信息")
if grade == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关级信息")
return
}
class.Name = v1.Name
_, err6 := classDb.ClassUpdate(class, "name")
if err6 != nil {
e.OutErr(c, e.ERR_DB_ORM, err6.Error())
grade.Name = v1.Name
_, err4 := gradeDb.GradeUpdate(grade, "name")
if err4 != nil {
e.OutErr(c, e.ERR_DB_ORM, err4.Error())
return
}
gradeId = grade.Id
}
}
}

if len(classes) > 0 {
_, err2 := classDb.BatchAddClass(classes)
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
for _, v2 := range v1.ClassList {
if v2.Id == 0 {
//新增
classes = append(classes, &model.Class{
Name: v2.Name,
Memo: "",
GradeId: gradeId,
EnterpriseId: req.Id,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
} else {
//编辑
class, err4 := classDb.GetClass(v2.Id)
if err4 != nil {
e.OutErr(c, e.ERR_DB_ORM, err4.Error())
return
}
if class == nil {
e.OutErr(c, e.ERR_NO_DATA, "未查询到相关班级信息")
return
}
class.Name = v2.Name
_, err6 := classDb.ClassUpdate(class, "name")
if err6 != nil {
e.OutErr(c, e.ERR_DB_ORM, err6.Error())
return
}
}
}
}
}
}

if len(classes) > 0 {
_, err2 := classDb.BatchAddClass(classes)
if err2 != nil {
e.OutErr(c, e.ERR_DB_ORM, err2.Error())
return
}
}
e.OutSuc(c, "success", nil)
return
}


+ 18
- 14
app/admin/md/md_enterprise.go Parādīt failu

@@ -11,21 +11,25 @@ type EnterpriseAddReq struct {
}

type EnterpriseUpdateReq struct {
Id int `json:"id" binding:"required" label:"企业id"`
Name string `json:"name" binding:"required" label:"名称"`
Pvd int32 `json:"pvd" label:"场景"`
Kind int32 `json:"kind" binding:"required" label:"种类(1:央厨-学校 2:央厨-工厂 3:自营-学校 4:自营-工厂 5:养老院)"`
CompanyId int `json:"company_id" binding:"required" label:"所属公司id"`
Memo string `json:"memo" label:"备注"`
State int32 `json:"state" label:"状态"`
GradeList []struct {
Id int `json:"id" label:"年级id"`
Id int `json:"id" binding:"required" label:"企业id"`
Name string `json:"name" binding:"required" label:"名称"`
Pvd int32 `json:"pvd" label:"场景"`
Kind int32 `json:"kind" binding:"required" label:"种类(1:央厨-学校 2:央厨-工厂 3:自营-学校 4:自营-工厂 5:养老院)"`
CompanyId int `json:"company_id" binding:"required" label:"所属公司id"`
Memo string `json:"memo" label:"备注"`
State int32 `json:"state" label:"状态"`
PeriodList []struct {
Id int `json:"id" label:"学段id"`
Name string `json:"name" label:"名称"`
ClassList []struct {
Id int `json:"id" label:"班级id"`
Name string `json:"name" label:"名称"`
} `json:"class_list" label:"班级"`
} `json:"grade_list" label:"年级"`
GradeList []struct {
Id int `json:"id" label:"年级id"`
Name string `json:"name" label:"名称"`
ClassList []struct {
Id int `json:"id" label:"班级id"`
Name string `json:"name" label:"名称"`
} `json:"class_list" label:"班级"`
} `json:"grade_list" label:"年级"`
} `json:"period_list" label:"学段"`
}

type EnterpriseDeleteReq struct {


+ 10
- 0
app/admin/md/md_enterprise_manage.go Parādīt failu

@@ -151,6 +151,16 @@ type SetCentralKitchenForSchoolWithSpecReq struct {
DinnerUnitPriceForTeacher string `json:"dinner_unit_price_for_teacher" binding:"required" label:"教师-晚餐-单价"`
}

type SetCentralKitchenForSchoolWithSpecByPeriodReq struct {
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`
List []struct {
PeriodId int `json:"period_id" binding:"required" label:"学段id"`
BreakfastUnitPrice string `json:"breakfast_unit_price" binding:"required" label:"早餐-单价"`
LunchUnitPrice string `json:"lunch_unit_price" binding:"required" label:"午餐-单价"`
DinnerUnitPrice string `json:"dinner_unit_price" binding:"required" label:"晚餐-单价"`
} `json:"list" binding:"required" label:"日期"`
}

type SaveCentralKitchenForSchoolPackageReq struct {
PackageId int `json:"package_id" label:"套餐ID"`
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"`


+ 1
- 1
app/customer/hdl/hdl_demo.go Parādīt failu

@@ -38,7 +38,7 @@ func Demo(c *gin.Context) {
return
}

func SanHu(c *gin.Context) {
func SanHu(c *gin.Context) { //实现网页截图
url := c.DefaultQuery("url", "")
if url == "" {
e.OutErr(c, e.ERR_NO_DATA, "网址不能为空")


+ 9
- 13
app/db/model/period.go Parādīt failu

@@ -1,17 +1,13 @@
package model

import (
"time"
)

type Period struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('单位id') INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
BreakfastUnitPrice string `json:"breakfast_unit_price" xorm:"not null default 0.00 comment('早餐-单价') DECIMAL(4,2)"`
LunchUnitPrice string `json:"lunch_unit_price" xorm:"not null default 0.00 comment('午餐-单价') DECIMAL(4,2)"`
DinnerUnitPrice string `json:"dinner_unit_price" xorm:"not null default 0.00 comment('晚餐-单价') DECIMAL(4,2)"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('单位id') INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
BreakfastUnitPrice string `json:"breakfast_unit_price" xorm:"not null default 0.00 comment('早餐-单价') DECIMAL(4,2)"`
LunchUnitPrice string `json:"lunch_unit_price" xorm:"not null default 0.00 comment('午餐-单价') DECIMAL(4,2)"`
DinnerUnitPrice string `json:"dinner_unit_price" xorm:"not null default 0.00 comment('晚餐-单价') DECIMAL(4,2)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 10
- 9
app/router/admin_router.go Parādīt failu

@@ -140,7 +140,7 @@ func rEnterprise(r *gin.RouterGroup) {
r.POST("/updateState", hdl2.EnterpriseUpdateState)
r.POST("/addGrade", hdl2.EnterpriseAddGrade)
r.GET("/detail", hdl2.Detail)
//r.GET("/schoolBelowPeriod", hdl2.SchoolBelowPeriod) //"学校"下年级
r.GET("/schoolBelowPeriod", hdl2.SchoolBelowPeriod) //"学校"下学段
r.GET("/schoolBelowGrade", hdl2.SchoolBelowGrade) //"学校"下年级
r.GET("/schoolGradeBelowClass", hdl2.SchoolGradeBelowClass) //"学校"年级下班级
r.POST("/setCentralKitchenForSchoolWithSpecForSystem", hdl2.SetCentralKitchenForSchoolWithSpecForSystem) //"央厨-学校-套餐-系统" 价格设置
@@ -180,14 +180,15 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.POST("/centralKitchenForSchoolOrderRefundList", hdl2.CentralKitchenForSchoolOrderRefundList) //"央厨-学校"订单退款列表
//r.POST("/centralKitchenForSchoolOrderRefundAudit", hdl2.CentralKitchenForSchoolOrderRefundAudit) //"央厨-学校"订单退款审核

r.POST("/setBasicCentralKitchenForSchool", hdl.SetBasicCentralKitchenForSchool) //"央厨-学校"设置基础设置
r.GET("/getBasicCentralKitchenForSchool", hdl.GetBasicCentralKitchenForSchool) //"央厨-学校"获取基础设置
r.POST("/setCentralKitchenForSchoolWithSpec", hdl.SetCentralKitchenForSchoolWithSpec) //设置"央厨-学校-规格"
r.GET("/getCentralKitchenForSchoolWithSpec", hdl.GetCentralKitchenForSchoolWithSpec) //获取"央厨-学校-规格"
r.POST("/listCentralKitchenForSchoolPackage", hdl.ListCentralKitchenForSchoolPackage) //"央厨-学校-套餐" 列表
r.GET("/detailCentralKitchenForSchoolPackage", hdl.DetailCentralKitchenForSchoolPackage) //"央厨-学校-套餐" 详情
r.POST("/saveCentralKitchenForSchoolPackage", hdl.SaveCentralKitchenForSchoolPackage) //新增/编辑 "央厨-学校-套餐"
r.DELETE("/deleteCentralKitchenForSchoolPackage/:id", hdl.DeleteCentralKitchenForSchoolPackage) //删除 "央厨-学校-套餐"
r.POST("/setBasicCentralKitchenForSchool", hdl.SetBasicCentralKitchenForSchool) //"央厨-学校"设置基础设置
r.GET("/getBasicCentralKitchenForSchool", hdl.GetBasicCentralKitchenForSchool) //"央厨-学校"获取基础设置
r.POST("/setCentralKitchenForSchoolWithSpecByTeacher", hdl.SetCentralKitchenForSchoolWithSpecByTeacher) //设置教师"央厨-学校-规格"
r.GET("/getCentralKitchenForSchoolWithSpecByTeacher", hdl.GetCentralKitchenForSchoolWithSpecByTeacher) //获取教师"央厨-学校-规格"
r.POST("/setCentralKitchenForSchoolWithSpecByPeriod", hdl.SetCentralKitchenForSchoolWithSpecByPeriod) //设置学段"央厨-学校-规格"
r.POST("/listCentralKitchenForSchoolPackage", hdl.ListCentralKitchenForSchoolPackage) //"央厨-学校-套餐" 列表
r.GET("/detailCentralKitchenForSchoolPackage", hdl.DetailCentralKitchenForSchoolPackage) //"央厨-学校-套餐" 详情
r.POST("/saveCentralKitchenForSchoolPackage", hdl.SaveCentralKitchenForSchoolPackage) //新增/编辑 "央厨-学校-套餐"
r.DELETE("/deleteCentralKitchenForSchoolPackage/:id", hdl.DeleteCentralKitchenForSchoolPackage) //删除 "央厨-学校-套餐"

r.POST("/selfSupportForSchool/userUpdate", hdl.SelfSupportForSchoolUserUpdate) //"自营-学校"用户编辑
r.POST("/selfSupportForSchool/userDelete", hdl.SelfSupportForSchoolUserDelete) //"自营-学校"用户删除


Notiek ielāde…
Atcelt
Saglabāt