Browse Source

update

master
dengbiao 3 months ago
parent
commit
affb64209d
8 changed files with 99 additions and 19 deletions
  1. +30
    -0
      app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go
  2. +30
    -0
      app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go
  3. +1
    -1
      app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go
  4. +1
    -1
      app/admin/svc/enterprise_manage/svc_self_support_for_school.go
  5. +9
    -1
      app/db/db_class.go
  6. +1
    -0
      app/db/model/class.go
  7. +2
    -0
      app/router/admin_router.go
  8. +25
    -16
      main.go

+ 30
- 0
app/admin/hdl/enterprise_manage/hdl_central_kitchen_for_school.go View File

@@ -1761,6 +1761,36 @@ func CentralKitchenForSchoolClassList(c *gin.Context) {
return
}

type CentralKitchenForSchoolClassSortArgs struct {
Ids []string `json:"ids" binding:"required"`
Page int `json:"page" binding:"required"`
Limit int `json:"limit" binding:"required"`
}

func CentralKitchenForSchoolClassSort(c *gin.Context) {
var ClassSortArgs CentralKitchenForSchoolClassSortArgs
if err := c.ShouldBindJSON(&ClassSortArgs); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
classDb := db.ClassDb{}
classDb.Set(0)
class, err := classDb.FindClassById(ClassSortArgs.Ids)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
for k, v := range *class {
v.Sort = (ClassSortArgs.Page-1)*ClassSortArgs.Limit + k
_, err1 := classDb.ClassUpdate(&v, "sort")
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
}
e.OutSuc(c, "success", nil)
}

func CentralKitchenForSchoolGradeDelete(c *gin.Context) {
gradeId := c.Param("id")
//1、查找当前年级


+ 30
- 0
app/admin/hdl/enterprise_manage/hdl_self_support_for_school.go View File

@@ -623,6 +623,36 @@ func SelfSupportForSchoolClassList(c *gin.Context) {
return
}

type SelfSupportForSchoolClassSortArgs struct {
Ids []string `json:"ids" binding:"required"`
Page int `json:"page" binding:"required"`
Limit int `json:"limit" binding:"required"`
}

func SelfSupportForSchoolClassSort(c *gin.Context) {
var ClassSortArgs SelfSupportForSchoolClassSortArgs
if err := c.ShouldBindJSON(&ClassSortArgs); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
classDb := db.ClassDb{}
classDb.Set(0)
class, err := classDb.FindClassById(ClassSortArgs.Ids)
if err != nil {
e.OutErr(c, e.ERR_DB_ORM, err.Error())
return
}
for k, v := range *class {
v.Sort = (ClassSortArgs.Page-1)*ClassSortArgs.Limit + k
_, err1 := classDb.ClassUpdate(&v, "sort")
if err1 != nil {
e.OutErr(c, e.ERR_DB_ORM, err1.Error())
return
}
}
e.OutSuc(c, "success", nil)
}

func SelfSupportForSchoolGradeDelete(c *gin.Context) {
gradeId := c.Param("id")
//1、查找当前年级


+ 1
- 1
app/admin/svc/enterprise_manage/svc_central_kitchen_for_school.go View File

@@ -2571,7 +2571,7 @@ func CentralKitchenForSchoolClassList(req md.CentralKitchenForSchoolClassListReq
if req.GradeId != 0 {
sess.And("grade_id = ?", req.GradeId)
}
count, err = sess.Asc("id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
count, err = sess.Asc("sort").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
if err != nil {
return nil, 0, err
}


+ 1
- 1
app/admin/svc/enterprise_manage/svc_self_support_for_school.go View File

@@ -587,7 +587,7 @@ func SelfSupportForSchoolClassList(req md.SelfSupportForSchoolClassListReq) (m [
if req.GradeId != 0 {
sess.And("grade_id = ?", req.GradeId)
}
count, err = sess.Asc("id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
count, err = sess.Asc("sort").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m)
if err != nil {
return nil, 0, err
}


+ 9
- 1
app/db/db_class.go View File

@@ -41,7 +41,7 @@ func (classDb *ClassDb) FindClassByEnterprise(enterpriseId interface{}) (*[]mode

func (classDb *ClassDb) FindClassAscByEnterprise(enterpriseId interface{}) (*[]model.Class, error) {
var m []model.Class
if err := classDb.Db.Asc("id").Where("enterprise_id =?", enterpriseId).Find(&m); err != nil {
if err := classDb.Db.Asc("sort").Where("enterprise_id =?", enterpriseId).Find(&m); err != nil {
return nil, logx.Error(err)
}
return &m, nil
@@ -70,6 +70,14 @@ func (classDb *ClassDb) ClassDeleteBySessionForEnterprise(session *xorm.Session,
}
}

func (classDb *ClassDb) FindClassById(ids interface{}) (*[]model.Class, error) {
var m []model.Class
if err := classDb.Db.In("id", ids).Find(&m); err != nil {
return nil, logx.Error(err)
}
return &m, nil
}

func (classDb *ClassDb) BatchAddClass(mm []*model.Class) (int64, error) {
affected, err := classDb.Db.Insert(mm)
if err != nil {


+ 1
- 0
app/db/model/class.go View File

@@ -6,6 +6,7 @@ type Class struct {
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
GradeId int `json:"grade_id" xorm:"not null default 0 comment('年级id') INT(11)"`
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('单位id') INT(11)"`
Sort int `json:"sort" xorm:"not null default 0 comment('排序') TINYINT(3)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
}

+ 2
- 0
app/router/admin_router.go View File

@@ -195,6 +195,7 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.POST("/centralKitchenForSchool/periodList", hdl.CentralKitchenForSchoolPeriodList) //"央厨-学校"学段列表
r.DELETE("/centralKitchenForSchool/periodDelete/:id", hdl.CentralKitchenForSchoolPeriodDelete) //"央厨-学校"学段删除
r.POST("/centralKitchenForSchool/classList", hdl.CentralKitchenForSchoolClassList) //"央厨-学校"班级列表
r.POST("/sort", hdl.CentralKitchenForSchoolClassSort) //"央厨-学校"班级排序
r.DELETE("/centralKitchenForSchool/classDelete/:id", hdl.CentralKitchenForSchoolClassDelete) //"央厨-学校"班级删除
r.GET("/centralKitchenForSchool/classDeleteCheck/:id", hdl.CentralKitchenForSchoolClassDeleteCheck) //"央厨-学校"检测班级删除
r.POST("/centralKitchenForSchool/ordList", hdl.CentralKitchenForSchoolOrdList) //"央厨-学校"订单列表
@@ -236,6 +237,7 @@ func rEnterpriseManage(r *gin.RouterGroup) {
r.POST("/selfSupportForSchool/gradeList", hdl.SelfSupportForSchoolGradeList) //"自营-学校"年级列表
r.DELETE("/selfSupportForSchool/gradeDelete/:id", hdl.SelfSupportForSchoolGradeDelete) //"自营-学校"年级删除
r.POST("/selfSupportForSchool/classList", hdl.SelfSupportForSchoolClassList) //"自营-学校"班级列表
r.POST("/selfSupportForSchool/classList", hdl.SelfSupportForSchoolClassSort) //"自营-学校"班级列表
r.DELETE("/selfSupportForSchool/classDelete/:id", hdl.SelfSupportForSchoolClassDelete) //"自营-学校"班级删除
r.POST("/selfSupportForSchool/periodList", hdl.SelfSupportForSchoolPeriodList) //"央厨-学校"学段列表
r.DELETE("/selfSupportForSchool/periodDelete/:id", hdl.SelfSupportForSchoolPeriodDelete) //"央厨-学校"学段删除


+ 25
- 16
main.go View File

@@ -83,22 +83,31 @@ func main() {
// // }
// // fmt.Println(">>>>>>>>>>>>>>>>>affected1<<<<<<<<<<<<<<<<<<<", affected1)
// // continue
// // var mm []model.CentralKitchenForSchoolUserRefundDay
// // if err := db.Db.Where("uid = ?", v.Uid).And("state = 1").Desc("records_id").Find(&mm); err != nil {
// // fmt.Println(err)
// // }
// //
// // if len(mm) > 0 {
// // mmm := new(model.CentralKitchenForSchoolUserWithDay)
// // _, err := db.Db.Where("id =?", mm[0].RecordsId).Get(mmm)
// // if err != nil {
// // fmt.Println(err)
// // }
// // //if mmm.Date == "2024-01-31" {
// // //1、更改当前记录
// // v.Uid = -v.Uid
// // affected1, err := db.Db.Where("id=?", v.Id).Cols("uid").Update(&v)
// // if err != nil {
//var mm []model.CentralKitchenForSchoolUserRefundDay
//if err := db.Db.Where("memo = ?", "退款处理失败:(未查询到对应预定记录)").Find(&mm); err != nil {
// fmt.Println(err)
//}
//// //
//if len(mm) > 0 {
// for _, v := range mm {
// mmm := new(model.CentralKitchenForSchoolUserWithDay)
// has, err := db.Db.Where("id =?", v.RecordsId).Get(mmm)
// if err != nil {
// fmt.Println(err)
// }
// if !has {
// utils.FilePutContents("test_test", utils.IntToStr(v.Id))
// fmt.Println(v)
// }
// }
//
//}
//return
// //if mmm.Date == "2024-01-31" {
// //1、更改当前记录
// v.Uid = -v.Uid
// affected1, err := db.Db.Where("id=?", v.Id).Cols("uid").Update(&v)
// if err != nil {
// // fmt.Println(err)
// // }
// // fmt.Println(">>>>>>>>>>>>>>>>>affected1<<<<<<<<<<<<<<<<<<<", affected1)


Loading…
Cancel
Save