智慧食堂
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_enterprise.go 16 KiB

пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
пре 1 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. package hdl
  2. import (
  3. enum2 "applet/app/admin/enum"
  4. "applet/app/admin/lib/validate"
  5. "applet/app/admin/md"
  6. "applet/app/admin/svc"
  7. "applet/app/db"
  8. "applet/app/db/model"
  9. "applet/app/e"
  10. "applet/app/enum"
  11. "applet/app/utils"
  12. "github.com/gin-gonic/gin"
  13. "time"
  14. )
  15. func EnterpriseList(c *gin.Context) {
  16. var req md.EnterpriseListReq
  17. err := c.ShouldBindJSON(&req)
  18. if err != nil {
  19. err = validate.HandleValidateErr(err)
  20. err1 := err.(e.E)
  21. e.OutErr(c, err1.Code, err1.Error())
  22. return
  23. }
  24. if req.Limit == 0 {
  25. req.Limit = 10
  26. }
  27. if req.Page == 0 {
  28. req.Page = 10
  29. }
  30. enterprises, total, err := svc.EnterpriseList(req)
  31. if err != nil {
  32. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  33. return
  34. }
  35. e.OutSuc(c, map[string]interface{}{
  36. "list": enterprises,
  37. "total": total,
  38. "state": []map[string]interface{}{
  39. {
  40. "name": enum.EnterpriseState(enum.EnterpriseStateForNormal).String(),
  41. "value": enum.EnterpriseStateForNormal,
  42. },
  43. {
  44. "name": enum.EnterpriseState(enum.EnterpriseStateForFreeze).String(),
  45. "value": enum.EnterpriseStateForFreeze,
  46. },
  47. },
  48. "kind": []map[string]interface{}{
  49. {
  50. "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForSchool).String(),
  51. "value": enum.EnterprisePvdByCentralKitchenForSchool,
  52. },
  53. {
  54. "name": enum.EnterprisePvd(enum.EnterprisePvdByCentralKitchenForFactory).String(),
  55. "value": enum.EnterprisePvdByCentralKitchenForFactory,
  56. },
  57. {
  58. "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForSchool).String(),
  59. "value": enum.EnterprisePvdBySelfSupportForSchool,
  60. },
  61. {
  62. "name": enum.EnterprisePvd(enum.EnterprisePvdBySelfSupportForFactory).String(),
  63. "value": enum.EnterprisePvdBySelfSupportForFactory,
  64. },
  65. {
  66. "name": enum.EnterprisePvd(enum.EnterprisePvdByNursingHome).String(),
  67. "value": enum.EnterprisePvdByNursingHome,
  68. },
  69. },
  70. }, nil)
  71. return
  72. }
  73. func Detail(c *gin.Context) {
  74. enterpriseId := c.DefaultQuery("id", "")
  75. detail, err := svc.EnterpriseDetail(utils.StrToInt(enterpriseId))
  76. if err != nil {
  77. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  78. return
  79. }
  80. e.OutSuc(c, detail, nil)
  81. return
  82. }
  83. func SchoolBelowGrade(c *gin.Context) {
  84. enterpriseId := c.DefaultQuery("enterprise_id", "")
  85. gradeDb := db.GradeDb{}
  86. gradeDb.Set(utils.StrToInt(enterpriseId))
  87. gradeList, err := gradeDb.FindGrade()
  88. if err != nil {
  89. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  90. return
  91. }
  92. e.OutSuc(c, map[string]interface{}{
  93. "list": gradeList,
  94. }, nil)
  95. return
  96. }
  97. func SchoolGradeBelowClass(c *gin.Context) {
  98. gradeId := c.DefaultQuery("grade_id", "")
  99. enterpriseId := c.DefaultQuery("enterprise_id", "")
  100. classDb := db.ClassDb{}
  101. if gradeId != "" {
  102. classDb.Set(utils.StrToInt(gradeId))
  103. classList, err := classDb.FindClass()
  104. if err != nil {
  105. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  106. return
  107. }
  108. e.OutSuc(c, map[string]interface{}{
  109. "list": classList,
  110. }, nil)
  111. } else {
  112. classDb.Set(0)
  113. classList, err := classDb.FindClassByEnterprise(enterpriseId)
  114. if err != nil {
  115. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  116. return
  117. }
  118. e.OutSuc(c, map[string]interface{}{
  119. "list": classList,
  120. }, nil)
  121. }
  122. return
  123. }
  124. func EnterpriseAdd(c *gin.Context) {
  125. var req md.EnterpriseAddReq
  126. err := c.ShouldBindJSON(&req)
  127. if err != nil {
  128. err = validate.HandleValidateErr(err)
  129. err1 := err.(e.E)
  130. e.OutErr(c, err1.Code, err1.Error())
  131. return
  132. }
  133. enterpriseDb := db.EnterpriseDb{}
  134. enterpriseDb.Set()
  135. now := time.Now()
  136. var pvd = 2
  137. if req.Kind == enum.EnterprisePvdByCentralKitchenForSchool || req.Kind == enum.EnterprisePvdByCentralKitchenForFactory {
  138. pvd = 1
  139. }
  140. enterprise := model.Enterprise{
  141. Name: req.Name,
  142. Pvd: int32(pvd),
  143. Kind: req.Kind,
  144. CompanyId: req.CompanyId,
  145. State: enum2.CompanyStateForNormal,
  146. Memo: req.Memo,
  147. CreateAt: now.Format("2006-01-02 15:04:05"),
  148. UpdateAt: now.Format("2006-01-02 15:04:05"),
  149. }
  150. enterpriseId, err := enterpriseDb.EnterpriseInsert(&enterprise)
  151. if err != nil {
  152. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  153. return
  154. }
  155. if req.Kind == enum.EnterprisePvdByCentralKitchenForSchool {
  156. //新增 `central_kitchen_for_school_set` && `central_kitchen_for_school_with_spec`
  157. centralKitchenForSchoolSetDb := db.CentralKitchenForSchoolSetDb{}
  158. centralKitchenForSchoolSetDb.Set(enterpriseId)
  159. centralKitchenForSchoolSetDb.CentralKitchenForSchoolSetInsert(&model.CentralKitchenForSchoolSet{
  160. EnterpriseId: enterpriseId,
  161. IsOpenTeacherReportMeal: 1,
  162. IsOpenReportMealForDay: 1,
  163. IsOpenReportMealForMonth: 1,
  164. IsOpenReportMealForSemester: 1,
  165. CreateAt: now.Format("2006-01-02 15:04:05"),
  166. UpdateAt: now.Format("2006-01-02 15:04:05"),
  167. })
  168. centralKitchenForSchoolWithSpec := db.CentralKitchenForSchoolWithSpec{}
  169. centralKitchenForSchoolWithSpec.Set(enterpriseId)
  170. centralKitchenForSchoolWithSpec.CentralKitchenForSchoolWithSpecInsert(&model.CentralKitchenForSchoolWithSpec{
  171. EnterpriseId: enterpriseId,
  172. IsOpenBreakfast: 1,
  173. IsOpenLunch: 1,
  174. IsOpenDinner: 1,
  175. BreakfastUnitPrice: "0.00",
  176. LunchUnitPrice: "0.00",
  177. DinnerUnitPrice: "0.00",
  178. BreakfastUnitPriceForTeacher: "0.00",
  179. LunchUnitPriceForTeacher: "0.00",
  180. DinnerUnitPriceForTeacher: "0.00",
  181. CreateAt: now.Format("2006-01-02 15:04:05"),
  182. UpdateAt: now.Format("2006-01-02 15:04:05"),
  183. })
  184. }
  185. if req.Kind == enum.EnterprisePvdByNursingHome {
  186. //新增 `nursing_home_set` && `nursing_home_with_spec`
  187. nursingHomeSetDb := db.NursingHomeSetDb{}
  188. nursingHomeSetDb.Set(enterpriseId)
  189. nursingHomeSetDb.NursingHomeSetInsert(&model.NursingHomeSet{
  190. EnterpriseId: enterpriseId,
  191. IsOpenReportMealForDay: 1,
  192. IsOpenReportMealForMonth: 1,
  193. IsOpenReportMealForYear: 1,
  194. CreateAt: now.Format("2006-01-02 15:04:05"),
  195. UpdateAt: now.Format("2006-01-02 15:04:05"),
  196. })
  197. nursingHomeWithSpec := db.NursingHomeWithSpec{}
  198. nursingHomeWithSpec.Set(enterpriseId)
  199. nursingHomeWithSpec.NursingHomeWithSpecInsert(&model.NursingHomeWithSpec{
  200. EnterpriseId: enterpriseId,
  201. IsOpenBreakfast: 1,
  202. IsOpenLunch: 1,
  203. IsOpenDinner: 1,
  204. BreakfastUnitPrice: "0.00",
  205. LunchUnitPrice: "0.00",
  206. DinnerUnitPrice: "0.00",
  207. CreateAt: now.Format("2006-01-02 15:04:05"),
  208. UpdateAt: now.Format("2006-01-02 15:04:05"),
  209. })
  210. }
  211. e.OutSuc(c, "success", nil)
  212. return
  213. }
  214. func EnterpriseDelete(c *gin.Context) {
  215. var req md.EnterpriseDeleteReq
  216. err := c.ShouldBindJSON(&req)
  217. if err != nil {
  218. err = validate.HandleValidateErr(err)
  219. err1 := err.(e.E)
  220. e.OutErr(c, err1.Code, err1.Error())
  221. return
  222. }
  223. err = svc.EnterpriseDelete(req.EnterpriseIds)
  224. if err != nil {
  225. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  226. return
  227. }
  228. e.OutSuc(c, "success", nil)
  229. return
  230. }
  231. func EnterpriseUpdate(c *gin.Context) {
  232. var req md.EnterpriseUpdateReq
  233. err := c.ShouldBindJSON(&req)
  234. if err != nil {
  235. err = validate.HandleValidateErr(err)
  236. err1 := err.(e.E)
  237. e.OutErr(c, err1.Code, err1.Error())
  238. return
  239. }
  240. //1、更新 enterprise
  241. enterpriseDb := db.EnterpriseDb{}
  242. enterpriseDb.Set()
  243. enterprise, err := enterpriseDb.GetEnterprise(req.Id)
  244. if err != nil {
  245. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  246. return
  247. }
  248. if enterprise == nil {
  249. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  250. return
  251. }
  252. var pvd = 2
  253. if req.Kind == enum.EnterprisePvdByCentralKitchenForSchool || req.Kind == enum.EnterprisePvdByCentralKitchenForFactory || req.Kind == enum.EnterprisePvdByNursingHome {
  254. pvd = 1
  255. }
  256. now := time.Now()
  257. enterprise.Name = req.Name
  258. enterprise.Memo = req.Memo
  259. enterprise.Pvd = int32(pvd)
  260. enterprise.Kind = req.Kind
  261. enterprise.CompanyId = req.CompanyId
  262. enterprise.UpdateAt = now.Format("2006-01-02 15:04:05")
  263. _, err = enterpriseDb.EnterpriseUpdate(enterprise, "name", "memo", "pvd", "kind", "company_id", "update_at")
  264. if err != nil {
  265. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  266. return
  267. }
  268. //2、更新 grade && class 数据
  269. //2、删除 grade && class 数据
  270. gradeDb := db.GradeDb{}
  271. gradeDb.Set(req.Id)
  272. //_, err = gradeDb.ClassDeleteBySessionForEnterprise(db.Db.NewSession(), req.Id)
  273. //if err != nil {
  274. // e.OutErr(c, e.ERR_DB_ORM, err.Error())
  275. // return
  276. //}
  277. classDb := db.ClassDb{}
  278. classDb.Set(0)
  279. //_, err = classDb.ClassDeleteBySessionForEnterprise(db.Db.NewSession(), req.Id)
  280. //if err != nil {
  281. // e.OutErr(c, e.ERR_DB_ORM, err.Error())
  282. // return
  283. //}
  284. //新增 grade 数据 && class 数据
  285. for _, v := range req.GradeList {
  286. var classes []*model.Class
  287. if v.Id == 0 {
  288. //TODO::新增
  289. insertId, err1 := gradeDb.GradeInsert(&model.Grade{
  290. EnterpriseId: req.Id,
  291. Name: v.Name,
  292. Memo: "",
  293. CreateAt: now.Format("2006-01-02 15:04:05"),
  294. UpdateAt: now.Format("2006-01-02 15:04:05"),
  295. })
  296. if err1 != nil {
  297. e.OutErr(c, e.ERR_DB_ORM, err1.Error())
  298. return
  299. }
  300. for _, v1 := range v.ClassList {
  301. classes = append(classes, &model.Class{
  302. Name: v1.Name,
  303. Memo: "",
  304. GradeId: insertId,
  305. EnterpriseId: req.Id,
  306. CreateAt: now.Format("2006-01-02 15:04:05"),
  307. UpdateAt: now.Format("2006-01-02 15:04:05"),
  308. })
  309. }
  310. } else {
  311. //TODO::编辑
  312. grade, err3 := gradeDb.GetGrade(v.Id)
  313. if err3 != nil {
  314. e.OutErr(c, e.ERR_DB_ORM, err3.Error())
  315. return
  316. }
  317. if grade == nil {
  318. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关年级信息")
  319. return
  320. }
  321. grade.Name = v.Name
  322. _, err4 := gradeDb.GradeUpdate(grade, "name")
  323. if err4 != nil {
  324. e.OutErr(c, e.ERR_DB_ORM, err4.Error())
  325. return
  326. }
  327. for _, v1 := range v.ClassList {
  328. if v1.Id == 0 {
  329. //新增
  330. classes = append(classes, &model.Class{
  331. Name: v1.Name,
  332. Memo: "",
  333. GradeId: grade.Id,
  334. EnterpriseId: req.Id,
  335. CreateAt: now.Format("2006-01-02 15:04:05"),
  336. UpdateAt: now.Format("2006-01-02 15:04:05"),
  337. })
  338. } else {
  339. //编辑
  340. class, err5 := classDb.GetClass(v1.Id)
  341. if err5 != nil {
  342. e.OutErr(c, e.ERR_DB_ORM, err5.Error())
  343. return
  344. }
  345. if class == nil {
  346. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关班级信息")
  347. return
  348. }
  349. class.Name = v1.Name
  350. _, err6 := classDb.ClassUpdate(class, "name")
  351. if err6 != nil {
  352. e.OutErr(c, e.ERR_DB_ORM, err6.Error())
  353. return
  354. }
  355. }
  356. }
  357. }
  358. if len(classes) > 0 {
  359. _, err2 := classDb.BatchAddClass(classes)
  360. if err2 != nil {
  361. e.OutErr(c, e.ERR_DB_ORM, err2.Error())
  362. return
  363. }
  364. }
  365. }
  366. e.OutSuc(c, "success", nil)
  367. return
  368. }
  369. func EnterpriseAddGrade(c *gin.Context) {
  370. var req md.EnterpriseUpdateStateReq
  371. err := c.ShouldBindJSON(&req)
  372. if err != nil {
  373. err = validate.HandleValidateErr(err)
  374. err1 := err.(e.E)
  375. e.OutErr(c, err1.Code, err1.Error())
  376. return
  377. }
  378. enterpriseDb := db.EnterpriseDb{}
  379. enterpriseDb.Set()
  380. enterprise, err := enterpriseDb.GetEnterprise(req.Id)
  381. if err != nil {
  382. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  383. return
  384. }
  385. if enterprise == nil {
  386. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  387. return
  388. }
  389. now := time.Now()
  390. enterprise.State = req.State
  391. enterprise.UpdateAt = now.Format("2006-01-02 15:04:05")
  392. _, err = enterpriseDb.EnterpriseUpdate(enterprise, "state", "update_at")
  393. if err != nil {
  394. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  395. return
  396. }
  397. e.OutSuc(c, "success", nil)
  398. return
  399. }
  400. func EnterpriseUpdateState(c *gin.Context) {
  401. var req md.EnterpriseUpdateStateReq
  402. err := c.ShouldBindJSON(&req)
  403. if err != nil {
  404. err = validate.HandleValidateErr(err)
  405. err1 := err.(e.E)
  406. e.OutErr(c, err1.Code, err1.Error())
  407. return
  408. }
  409. enterpriseDb := db.EnterpriseDb{}
  410. enterpriseDb.Set()
  411. enterprise, err := enterpriseDb.GetEnterprise(req.Id)
  412. if err != nil {
  413. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  414. return
  415. }
  416. if enterprise == nil {
  417. e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录")
  418. return
  419. }
  420. now := time.Now()
  421. enterprise.State = req.State
  422. enterprise.UpdateAt = now.Format("2006-01-02 15:04:05")
  423. _, err = enterpriseDb.EnterpriseUpdate(enterprise, "state", "update_at")
  424. if err != nil {
  425. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  426. return
  427. }
  428. e.OutSuc(c, "success", nil)
  429. return
  430. }
  431. func ListCentralKitchenForSchoolPackageForSystem(c *gin.Context) {
  432. var req md.ListCentralKitchenForSchoolPackageForSystemReq
  433. err := c.ShouldBindJSON(&req)
  434. if err != nil {
  435. err = validate.HandleValidateErr(err)
  436. err1 := err.(e.E)
  437. e.OutErr(c, err1.Code, err1.Error())
  438. return
  439. }
  440. centralKitchenForSchoolPackageForSystemDb := db.CentralKitchenForSchoolPackageForSystemDb{}
  441. centralKitchenForSchoolPackageForSystemDb.Set()
  442. list, total, err := centralKitchenForSchoolPackageForSystemDb.CentralKitchenForSchoolPackageForSystemList(req)
  443. if err != nil {
  444. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  445. return
  446. }
  447. e.OutSuc(c, map[string]interface{}{
  448. "list": list,
  449. "total": total,
  450. }, nil)
  451. return
  452. }
  453. func SetCentralKitchenForSchoolWithSpecForSystem(c *gin.Context) {
  454. var req md.SetCentralKitchenForSchoolWithSpecForSystemReq
  455. err := c.ShouldBindJSON(&req)
  456. if err != nil {
  457. err = validate.HandleValidateErr(err)
  458. err1 := err.(e.E)
  459. e.OutErr(c, err1.Code, err1.Error())
  460. return
  461. }
  462. centralKitchenForSchoolWithSpecForSystemDb := db.CentralKitchenForSchoolWithSpecForSystem{}
  463. centralKitchenForSchoolWithSpecForSystemDb.Set()
  464. system, err := centralKitchenForSchoolWithSpecForSystemDb.GetCentralKitchenForSchoolWithSpecForSystem()
  465. if err != nil {
  466. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  467. return
  468. }
  469. system.BreakfastUnitPrice = req.BreakfastUnitPrice
  470. system.LunchUnitPrice = req.LunchUnitPrice
  471. system.DinnerUnitPrice = req.DinnerUnitPrice
  472. system.BreakfastUnitPriceForTeacher = req.BreakfastUnitPriceForTeacher
  473. system.LunchUnitPriceForTeacher = req.LunchUnitPriceForTeacher
  474. system.DinnerUnitPriceForTeacher = req.DinnerUnitPriceForTeacher
  475. system.UpdateAt = time.Now().Format("2006-01-02 15:04:05")
  476. updateAffected, err := centralKitchenForSchoolWithSpecForSystemDb.CentralKitchenForSchoolWithSpecForSystemUpdate(system.Id, system)
  477. if err != nil {
  478. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  479. return
  480. }
  481. if updateAffected <= 0 {
  482. e.OutErr(c, e.ERR, "更新数据失败")
  483. return
  484. }
  485. e.OutSuc(c, "success", nil)
  486. return
  487. }
  488. func GetCentralKitchenForSchoolWithSpecForSystem(c *gin.Context) {
  489. centralKitchenForSchoolWithSpecForSystemDb := db.CentralKitchenForSchoolWithSpecForSystem{}
  490. centralKitchenForSchoolWithSpecForSystemDb.Set()
  491. system, err := centralKitchenForSchoolWithSpecForSystemDb.GetCentralKitchenForSchoolWithSpecForSystem()
  492. if err != nil {
  493. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  494. return
  495. }
  496. e.OutSuc(c, map[string]interface{}{
  497. "data": system,
  498. }, nil)
  499. return
  500. }
  501. func SaveCentralKitchenForSchoolPackageForSystem(c *gin.Context) {
  502. var req md.SaveCentralKitchenForSchoolPackageForSystemReq
  503. err := c.ShouldBindJSON(&req)
  504. if err != nil {
  505. err = validate.HandleValidateErr(err)
  506. err1 := err.(e.E)
  507. e.OutErr(c, err1.Code, err1.Error())
  508. return
  509. }
  510. //判断是新增 / 编辑
  511. if req.Id > 0 {
  512. err = svc.UpdateCentralKitchenForSchoolPackageForSystem(req)
  513. if err != nil {
  514. e.OutErr(c, e.ERR, err.Error())
  515. return
  516. }
  517. } else {
  518. err = svc.AddCentralKitchenForSchoolPackageForSystem(req)
  519. if err != nil {
  520. e.OutErr(c, e.ERR, err.Error())
  521. return
  522. }
  523. }
  524. e.OutSuc(c, "success", nil)
  525. return
  526. }
  527. func SyncCentralKitchenForSchoolPackageForSystem(c *gin.Context) {
  528. var req md.SyncCentralKitchenForSchoolPackageForSystemReq
  529. err := c.ShouldBindJSON(&req)
  530. if err != nil {
  531. err = validate.HandleValidateErr(err)
  532. err1 := err.(e.E)
  533. e.OutErr(c, err1.Code, err1.Error())
  534. return
  535. }
  536. err = svc.SyncCentralKitchenForSchoolPackageForSystem(req)
  537. if err != nil {
  538. e.OutErr(c, e.ERR, err.Error())
  539. return
  540. }
  541. e.OutSuc(c, "success", nil)
  542. return
  543. }
  544. func DeleteCentralKitchenForSchoolPackageForSystem(c *gin.Context) {
  545. id := c.Param("id")
  546. err := svc.DeleteCentralKitchenForSchoolPackageForSystem(utils.StrToInt(id))
  547. if err != nil {
  548. e.OutErr(c, e.ERR, err.Error())
  549. return
  550. }
  551. e.OutSuc(c, "success", nil)
  552. return
  553. }