智慧食堂
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.

286 lines
6.8 KiB

  1. package hdl
  2. import (
  3. "applet/app/admin/lib/validate"
  4. "applet/app/admin/md"
  5. "applet/app/admin/svc"
  6. "applet/app/db"
  7. "applet/app/e"
  8. "applet/app/utils"
  9. "github.com/gin-gonic/gin"
  10. "os"
  11. )
  12. func CentralKitchenForSchoolDataStatisticsList(c *gin.Context) {
  13. var req md.CentralKitchenForSchoolExportRecordsListReq
  14. err := c.ShouldBindJSON(&req)
  15. if err != nil {
  16. err = validate.HandleValidateErr(err)
  17. err1 := err.(e.E)
  18. e.OutErr(c, err1.Code, err1.Error())
  19. return
  20. }
  21. if req.Limit == 0 {
  22. req.Limit = 10
  23. }
  24. if req.Page == 0 {
  25. req.Page = 10
  26. }
  27. centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
  28. centralKitchenForSchoolExportRecordsDb.Set()
  29. list, total, err := centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsList(req)
  30. if err != nil {
  31. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  32. return
  33. }
  34. e.OutSuc(c, map[string]interface{}{
  35. "list": list,
  36. "total": total,
  37. "kind": []map[string]interface{}{
  38. {
  39. "name": "订单列表",
  40. "value": 1,
  41. },
  42. {
  43. "name": "退款申请表",
  44. "value": 2,
  45. },
  46. {
  47. "name": "学校预定统计表",
  48. "value": 3,
  49. },
  50. {
  51. "name": "班级明细表",
  52. "value": 4,
  53. },
  54. {
  55. "name": "退款明细表",
  56. "value": 5,
  57. },
  58. {
  59. "name": "收款统计表",
  60. "value": 6,
  61. },
  62. {
  63. "name": "班级收款明细表",
  64. "value": 7,
  65. },
  66. {
  67. "name": "学校预定数量统计表",
  68. "value": 8,
  69. },
  70. },
  71. }, nil)
  72. return
  73. }
  74. func CentralKitchenForSchoolDataStatisticsDelete(c *gin.Context) {
  75. id := c.Param("id")
  76. centralKitchenForSchoolExportRecordsDb := db.CentralKitchenForSchoolExportRecordsDb{}
  77. centralKitchenForSchoolExportRecordsDb.Set()
  78. centralKitchenForSchoolExportRecords, err := centralKitchenForSchoolExportRecordsDb.GetCentralKitchenForSchoolExportRecords(utils.StrToInt(id))
  79. if err != nil {
  80. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  81. return
  82. }
  83. if centralKitchenForSchoolExportRecords == nil {
  84. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  85. return
  86. }
  87. _, err = centralKitchenForSchoolExportRecordsDb.CentralKitchenForSchoolExportRecordsDelete(id)
  88. if err != nil {
  89. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  90. return
  91. }
  92. e.OutSuc(c, "success", nil)
  93. return
  94. }
  95. func CentralKitchenForSchoolDataStatisticsExport(c *gin.Context) {
  96. var req md.CentralKitchenForSchoolDataStatisticsExportReq
  97. err := c.ShouldBindJSON(&req)
  98. if err != nil {
  99. err = validate.HandleValidateErr(err)
  100. err1 := err.(e.E)
  101. e.OutErr(c, err1.Code, err1.Error())
  102. return
  103. }
  104. e.OutSuc(c, map[string]interface{}{
  105. "msg": "导出成功,请稍后刷新数据列表",
  106. }, nil)
  107. return
  108. }
  109. func NursingHomeDataStatisticsList(c *gin.Context) {
  110. var req md.NursingHomeExportRecordsListReq
  111. err := c.ShouldBindJSON(&req)
  112. if err != nil {
  113. err = validate.HandleValidateErr(err)
  114. err1 := err.(e.E)
  115. e.OutErr(c, err1.Code, err1.Error())
  116. return
  117. }
  118. if req.Limit == 0 {
  119. req.Limit = 10
  120. }
  121. if req.Page == 0 {
  122. req.Page = 10
  123. }
  124. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  125. nursingHomeExportRecordsDb.Set()
  126. list, total, err := nursingHomeExportRecordsDb.NursingHomeExportRecordsList(req)
  127. if err != nil {
  128. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  129. return
  130. }
  131. e.OutSuc(c, map[string]interface{}{
  132. "list": list,
  133. "total": total,
  134. "kind": []map[string]interface{}{
  135. {
  136. "name": "订单列表",
  137. "value": 1,
  138. },
  139. {
  140. "name": "退款申请表",
  141. "value": 2,
  142. },
  143. {
  144. "name": "预定统计表",
  145. "value": 3,
  146. },
  147. },
  148. }, nil)
  149. return
  150. }
  151. func NursingHomeDataStatisticsDelete(c *gin.Context) {
  152. id := c.Param("id")
  153. nursingHomeExportRecordsDb := db.NursingHomeExportRecordsDb{}
  154. nursingHomeExportRecordsDb.Set()
  155. centralKitchenForSchoolExportRecords, err := nursingHomeExportRecordsDb.GetNursingHomeExportRecords(utils.StrToInt(id))
  156. if err != nil {
  157. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  158. return
  159. }
  160. if centralKitchenForSchoolExportRecords == nil {
  161. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  162. return
  163. }
  164. os.RemoveAll("./static" + centralKitchenForSchoolExportRecords.DownloadPath) //移除文件
  165. _, err = nursingHomeExportRecordsDb.NursingHomeExportRecordsDelete(id)
  166. if err != nil {
  167. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  168. return
  169. }
  170. e.OutSuc(c, "success", nil)
  171. return
  172. }
  173. func NursingHomeDataStatisticsExport(c *gin.Context) {
  174. var req md.NursingHomeDataStatisticsExportReq
  175. err := c.ShouldBindJSON(&req)
  176. if err != nil {
  177. err = validate.HandleValidateErr(err)
  178. err1 := err.(e.E)
  179. e.OutErr(c, err1.Code, err1.Error())
  180. return
  181. }
  182. go svc.NursingHomeDataStatisticsExport(req)
  183. e.OutSuc(c, map[string]interface{}{
  184. "msg": "导出成功,请稍后刷新数据列表",
  185. }, nil)
  186. return
  187. }
  188. func SelfSupportForSchoolDataStatisticsList(c *gin.Context) {
  189. var req md.SelfSupportForSchoolExportRecordsListReq
  190. err := c.ShouldBindJSON(&req)
  191. if err != nil {
  192. err = validate.HandleValidateErr(err)
  193. err1 := err.(e.E)
  194. e.OutErr(c, err1.Code, err1.Error())
  195. return
  196. }
  197. if req.Limit == 0 {
  198. req.Limit = 10
  199. }
  200. if req.Page == 0 {
  201. req.Page = 10
  202. }
  203. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  204. selfSupportForSchoolExportRecordsDb.Set()
  205. list, total, err := selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsList(req)
  206. if err != nil {
  207. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  208. return
  209. }
  210. e.OutSuc(c, map[string]interface{}{
  211. "list": list,
  212. "total": total,
  213. "kind": []map[string]interface{}{
  214. {
  215. "name": "学生列表",
  216. "value": 1,
  217. },
  218. {
  219. "name": "老师列表",
  220. "value": 2,
  221. },
  222. {
  223. "name": "消费明细表",
  224. "value": 3,
  225. },
  226. },
  227. }, nil)
  228. return
  229. }
  230. func SelfSupportForSchoolDataStatisticsDelete(c *gin.Context) {
  231. id := c.Param("id")
  232. selfSupportForSchoolExportRecordsDb := db.SelfSupportForSchoolExportRecordsDb{}
  233. selfSupportForSchoolExportRecordsDb.Set()
  234. selfSupportForSchoolExportRecords, err := selfSupportForSchoolExportRecordsDb.GetSelfSupportForSchoolExportRecords(utils.StrToInt(id))
  235. if err != nil {
  236. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  237. return
  238. }
  239. if selfSupportForSchoolExportRecords == nil {
  240. e.OutErr(c, e.ERR_NO_DATA, "未查询到相关记录")
  241. return
  242. }
  243. os.RemoveAll("./static" + selfSupportForSchoolExportRecords.DownloadPath) //移除文件
  244. _, err = selfSupportForSchoolExportRecordsDb.SelfSupportForSchoolExportRecordsDelete(id)
  245. if err != nil {
  246. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  247. return
  248. }
  249. e.OutSuc(c, "success", nil)
  250. return
  251. }
  252. func SelfSupportForSchoolDataStatisticsExport(c *gin.Context) {
  253. var req md.SelfSupportForSchoolDataStatisticsExportReq
  254. err := c.ShouldBindJSON(&req)
  255. if err != nil {
  256. err = validate.HandleValidateErr(err)
  257. err1 := err.(e.E)
  258. e.OutErr(c, err1.Code, err1.Error())
  259. return
  260. }
  261. go svc.SelfSupportForSchoolDataStatisticsExport(req)
  262. e.OutSuc(c, map[string]interface{}{
  263. "msg": "导出成功,请稍后刷新数据列表",
  264. }, nil)
  265. return
  266. }