ice_raft.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. package service
  2. import (
  3. "cold-delivery/app/admin/model"
  4. "cold-delivery/app/admin/service/dto"
  5. "cold-delivery/common/actions"
  6. cDto "cold-delivery/common/dto"
  7. "cold-delivery/common/global"
  8. model2 "cold-delivery/common/model"
  9. "errors"
  10. "fmt"
  11. "gogs.baozhida.cn/zoie/OAuth-core/service"
  12. "gorm.io/gorm"
  13. "time"
  14. )
  15. type IceRaft struct {
  16. service.Service
  17. }
  18. // GetPage 获取IceRaft列表
  19. func (e *IceRaft) GetPage(c *dto.IceRaftGetPageReq, list *[]model.IceRaft, count *int64, p *actions.DataPermission) error {
  20. var err error
  21. var data model.IceRaft
  22. if c.PageSize == 9999 {
  23. err = e.Orm.Model(&data).
  24. Scopes(
  25. actions.Permission(data.TableName(), p),
  26. ).
  27. Find(list).Limit(-1).Offset(-1).
  28. Count(count).Error
  29. } else {
  30. err = e.Orm.Model(&data).
  31. Scopes(
  32. cDto.MakeCondition(c.GetNeedSearch()),
  33. cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
  34. actions.Permission(data.TableName(), p),
  35. ).
  36. Find(list).Limit(-1).Offset(-1).
  37. Count(count).Error
  38. }
  39. if err != nil {
  40. e.Log.Errorf("db error: %s", err)
  41. return global.GetFailedErr
  42. }
  43. return nil
  44. }
  45. func IceRaftNameRecordStatusScopes(status string) func(db *gorm.DB) *gorm.DB {
  46. return func(db *gorm.DB) *gorm.DB {
  47. if len(status) == 0 {
  48. return db
  49. }
  50. if status == "0" {
  51. return db.Where("ice_raft_record.status is null")
  52. }
  53. return db.Where("ice_raft_record.status = ?", status)
  54. }
  55. }
  56. func IceRaftNameRecordIceLockerIdScopes(iceLockerId int) func(db *gorm.DB) *gorm.DB {
  57. return func(db *gorm.DB) *gorm.DB {
  58. if iceLockerId == 0 {
  59. return db
  60. }
  61. return db.Where("ice_raft_record.ice_locker_id = ? and ice_raft_record.cooler_box_id = 0", iceLockerId)
  62. }
  63. }
  64. func IceRaftNameRecordCoolerBoxIdScopes(coolerBoxId int) func(db *gorm.DB) *gorm.DB {
  65. return func(db *gorm.DB) *gorm.DB {
  66. if coolerBoxId == 0 {
  67. return db
  68. }
  69. return db.Where("ice_raft_record.cooler_box_id = ?", coolerBoxId)
  70. }
  71. }
  72. func (e *IceRaft) GetRecordPage(c *dto.IceRaftGetNewestRecordPageReq, list *[]model.IceRaft, count *int64, p *actions.DataPermission) error {
  73. var err error
  74. var data model.IceRaft
  75. if c.PageSize == 9999 {
  76. err = e.Orm.Model(&data).
  77. Scopes(
  78. actions.Permission(data.TableName(), p),
  79. ).
  80. Where("ice_raft.status = '2'").
  81. Joins("left join ice_raft_record on ice_raft.ice_raft_record_id = ice_raft_record.id").
  82. Preload("IceRaftRecord.IceLocker").
  83. Preload("IceRaftRecord.CoolerBox").
  84. Order("FIELD(ice_raft_record.status,'2','','1','3','4')").
  85. Find(list).Limit(-1).Offset(-1).
  86. Count(count).Error
  87. } else {
  88. err = e.Orm.Model(&data).
  89. Scopes(
  90. cDto.MakeCondition(c.GetNeedSearch()),
  91. cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
  92. actions.Permission(data.TableName(), p),
  93. IceRaftNameRecordStatusScopes(c.Status),
  94. IceRaftNameRecordIceLockerIdScopes(c.IceLockerId),
  95. IceRaftNameRecordCoolerBoxIdScopes(c.CoolerBoxId),
  96. ).
  97. Where("ice_raft.status = '2'").
  98. Joins("left join ice_raft_record on ice_raft.ice_raft_record_id = ice_raft_record.id").
  99. Preload("IceRaftRecord.IceLocker").
  100. Preload("IceRaftRecord.CoolerBox").
  101. Order("FIELD(ice_raft_record.status,'2','','1','3','4')").
  102. Find(list).Limit(-1).Offset(-1).
  103. Count(count).Error
  104. }
  105. if err != nil {
  106. e.Log.Errorf("db error: %s", err)
  107. return global.GetFailedErr
  108. }
  109. return nil
  110. }
  111. // Get 获取IceRaft对象
  112. func (e *IceRaft) Get(d *dto.IceRaftGetReq, iceRaftModel *model.IceRaft, p *actions.DataPermission) error {
  113. err := e.Orm.
  114. Scopes(actions.Permission(iceRaftModel.TableName(), p)).
  115. First(iceRaftModel, d.GetId()).Error
  116. if err != nil {
  117. e.Log.Errorf("db error: %s", err)
  118. if errors.Is(err, gorm.ErrRecordNotFound) {
  119. return global.GetNotFoundOrNoPermissionErr
  120. }
  121. return global.GetFailedErr
  122. }
  123. return nil
  124. }
  125. func (e *IceRaft) GetByCode(d *dto.IceRaftGetByCodeReq, iceRaftModel *model.IceRaft, p *actions.DataPermission) error {
  126. err := e.Orm.
  127. Scopes(actions.Permission(iceRaftModel.TableName(), p)).
  128. Where("code = ?", d.Code).
  129. First(iceRaftModel).Error
  130. if err != nil {
  131. e.Log.Errorf("db error: %s", err)
  132. if errors.Is(err, gorm.ErrRecordNotFound) {
  133. return errors.New(fmt.Sprintf("冰排编号【%s】不存在!", d.Code))
  134. }
  135. return global.GetFailedErr
  136. }
  137. return nil
  138. }
  139. // Insert 创建IceRaft对象
  140. func (e *IceRaft) Insert(c *dto.IceRaftInsertReq) error {
  141. var err error
  142. var data model.IceRaft
  143. tx := e.Orm.Begin()
  144. defer func() {
  145. if err != nil {
  146. tx.Rollback()
  147. } else {
  148. tx.Commit()
  149. }
  150. }()
  151. for _, code := range c.CodeList {
  152. var k int64
  153. err = tx.Model(&data).Where("code = ? and dept_id = ?", code, c.DeptId).Count(&k).Error
  154. if err != nil {
  155. e.Log.Errorf("db error: %s", err)
  156. return global.CreateFailedErr
  157. }
  158. // 冰排编号已存在
  159. if k > 0 {
  160. continue
  161. }
  162. // 添加冰排
  163. data.Id = 0
  164. c.Generate(&data, code)
  165. err = tx.Create(&data).Error
  166. if err != nil {
  167. e.Log.Errorf("db error: %s", err)
  168. return global.CreateFailedErr
  169. }
  170. }
  171. return nil
  172. }
  173. // Update 修改IceRaft对象
  174. func (e *IceRaft) Update(c *dto.IceRaftUpdateReq, p *actions.DataPermission) error {
  175. var err error
  176. tx := e.Orm.Begin()
  177. defer func() {
  178. if err != nil {
  179. tx.Rollback()
  180. } else {
  181. tx.Commit()
  182. }
  183. }()
  184. var iceRaftModel = model.IceRaft{}
  185. // 查询冰排是否存在
  186. err = e.Orm.Scopes(actions.Permission(iceRaftModel.TableName(), p)).
  187. First(&iceRaftModel, c.GetId()).Error
  188. if err != nil {
  189. e.Log.Errorf("db error: %s", err)
  190. if errors.Is(err, gorm.ErrRecordNotFound) {
  191. return global.UpdateNotFoundOrNoPermissionErr
  192. }
  193. return global.UpdateFailedErr
  194. }
  195. if iceRaftModel.Code != c.Code {
  196. var k int64
  197. var data = model.IceRaft{}
  198. err = tx.Model(&data).Where("code = ? and dept_id = ?", c.Code, iceRaftModel.DeptId).Count(&k).Error
  199. if err != nil {
  200. e.Log.Errorf("db error: %s", err)
  201. return global.CreateFailedErr
  202. }
  203. if k > 0 {
  204. err = errors.New("冰排编号已存在!")
  205. e.Log.Errorf("db error: %s", err)
  206. return err
  207. }
  208. }
  209. c.Generate(&iceRaftModel)
  210. err = tx.Save(&iceRaftModel).Error
  211. if err != nil {
  212. e.Log.Errorf("db error: %s", err)
  213. return global.UpdateFailedErr
  214. }
  215. c.Id = iceRaftModel.Id
  216. return nil
  217. }
  218. // Remove 删除IceRaft
  219. func (e *IceRaft) Remove(c *dto.IceRaftDeleteReq, p *actions.DataPermission) error {
  220. var err error
  221. tx := e.Orm.Begin()
  222. defer func() {
  223. if err != nil {
  224. tx.Rollback()
  225. } else {
  226. tx.Commit()
  227. }
  228. }()
  229. var iceRaftModel model.IceRaft
  230. // 查询冰排是否存在
  231. err = e.Orm.Scopes(actions.Permission(iceRaftModel.TableName(), p)).
  232. First(&iceRaftModel, c.GetId()).Error
  233. if err != nil {
  234. e.Log.Errorf("db error: %s", err)
  235. if errors.Is(err, gorm.ErrRecordNotFound) {
  236. return global.DeleteNotFoundOrNoPermissionErr
  237. }
  238. return global.DeleteFailedErr
  239. }
  240. db := tx.Delete(&iceRaftModel)
  241. if err = db.Error; err != nil {
  242. e.Log.Errorf("db error: %s", err)
  243. return global.DeleteFailedErr
  244. }
  245. if db.RowsAffected == 0 {
  246. return global.DeleteNotFoundOrNoPermissionErr
  247. }
  248. return nil
  249. }
  250. func (e *IceRaft) InStorage(c *dto.IceRaftInStorageReq, p *actions.DataPermission) error {
  251. var err error
  252. tx := e.Orm.Begin()
  253. defer func() {
  254. if err != nil {
  255. tx.Rollback()
  256. } else {
  257. tx.Commit()
  258. }
  259. }()
  260. // 查询冷冻柜信息
  261. var iceLockerModel model.IceLocker
  262. err = e.Orm.Scopes(actions.Permission(iceLockerModel.TableName(), p)).
  263. First(&iceLockerModel, c.IceLockerId).Error
  264. if err != nil {
  265. e.Log.Errorf("db error: %s", err)
  266. return errors.New("获取冷冻柜信息失败")
  267. }
  268. if iceLockerModel.Status != model.IceLockerStatusNormal {
  269. err = errors.New("冷冻柜状态异常")
  270. return err
  271. }
  272. for _, code := range c.Code {
  273. // 查询冰排是否存在
  274. var iceRaftModel model.IceRaft
  275. err = e.Orm.Scopes(actions.Permission(iceRaftModel.TableName(), p)).
  276. Where("code = ?", code).
  277. Preload("IceRaftRecord").
  278. First(&iceRaftModel).Error
  279. if err != nil {
  280. // 冰排编号不存在,添加
  281. //if errors.Is(err, gorm.ErrRecordNotFound) {
  282. // iceRaftModel.Code = code
  283. // iceRaftModel.Status = model.IceRaftStatusNormal
  284. // iceRaftModel.DeptId = p.DeptId
  285. // iceRaftModel.CreateBy = p.UserId
  286. // err = tx.Create(&iceRaftModel).Error
  287. // if err != nil {
  288. // e.Log.Errorf("db error: %s", err)
  289. // return errors.New(fmt.Sprintf("添加冰排【%s】信息失败", code))
  290. // }
  291. //} else {
  292. // e.Log.Errorf("db error: %s", err)
  293. // return errors.New(fmt.Sprintf("获取冰排【%s】信息失败",code))
  294. //}
  295. e.Log.Errorf("db error: %s", err)
  296. return errors.New(fmt.Sprintf("获取冰排【%s】信息失败", code))
  297. }
  298. if iceRaftModel.Status != model.IceRaftStatusNormal {
  299. err = errors.New(fmt.Sprintf("冰排【%s】状态异常", code))
  300. return err
  301. }
  302. if iceRaftModel.IceRaftRecord.Status == model.IceRaftRecordStatusFreezing || iceRaftModel.IceRaftRecord.Status == model.IceRaftRecordStatusWaitUse {
  303. err = errors.New(fmt.Sprintf("冰排【%s】状态为%s,入库失败!", code, model.GetIceRaftRecordStatus(iceRaftModel.IceRaftRecord.Status)))
  304. return err
  305. }
  306. // 更新冰排记录状态 使用中 -> 已完成
  307. err = tx.Model(&model.IceRaftRecord{}).
  308. Where("ice_raft_id = ? and status = ?", iceRaftModel.Id, model.IceRaftRecordStatusUsing).
  309. Updates(map[string]interface{}{
  310. "status": model.IceRaftRecordStatusFinish,
  311. }).Error
  312. // 添加冰排记录
  313. var iceRaftRecordModel = model.IceRaftRecord{
  314. IceLockerId: iceLockerModel.Id,
  315. IceRaftId: iceRaftModel.Id,
  316. Status: model.IceRaftRecordStatusFreezing,
  317. InStorageTime: model2.Time(time.Now()),
  318. FreezeClaim: iceRaftModel.FreezeClaim,
  319. DeptBy: model2.DeptBy{
  320. DeptId: p.DeptId,
  321. },
  322. }
  323. err = tx.Create(&iceRaftRecordModel).Error
  324. if err != nil {
  325. e.Log.Errorf("db error: %s", err)
  326. return errors.New("添加冰排记录失败")
  327. }
  328. // 更新冰排使用记录
  329. err = tx.Model(&iceRaftModel).
  330. Where("id = ?", iceRaftModel.Id).
  331. Updates(map[string]interface{}{
  332. "ice_raft_record_id": iceRaftRecordModel.Id,
  333. }).Error
  334. if err != nil {
  335. e.Log.Errorf("db error: %s", err)
  336. return errors.New("关联冰排记录失败")
  337. }
  338. }
  339. return nil
  340. }
  341. func (e *IceRaft) OutStorage(c *dto.IceRaftOutStorageReq, p *actions.DataPermission) error {
  342. var err error
  343. tx := e.Orm.Begin()
  344. defer func() {
  345. if err != nil {
  346. tx.Rollback()
  347. } else {
  348. tx.Commit()
  349. }
  350. }()
  351. // 查询保温箱信息
  352. var coolerBoxModel model.CoolerBox
  353. err = e.Orm.Scopes(actions.Permission(coolerBoxModel.TableName(), p)).
  354. First(&coolerBoxModel, c.CoolerBoxId).Error
  355. if err != nil {
  356. e.Log.Errorf("db error: %s", err)
  357. return errors.New("获取保温箱信息失败")
  358. }
  359. if coolerBoxModel.Status != model.CoolerBoxStatusNormal {
  360. err = errors.New("保温箱状态异常")
  361. return err
  362. }
  363. for _, code := range c.Code {
  364. // 查询冰排是否存在
  365. var iceRaftModel model.IceRaft
  366. err = e.Orm.Scopes(actions.Permission(iceRaftModel.TableName(), p)).
  367. Where("code = ?", code).
  368. Preload("IceRaftRecord").
  369. First(&iceRaftModel).Error
  370. if err != nil {
  371. e.Log.Errorf("db error: %s", err)
  372. return errors.New("获取冰排信息失败")
  373. }
  374. if iceRaftModel.Status != model.IceRaftStatusNormal {
  375. err = errors.New(fmt.Sprintf("冰排【%s】状态异常", code))
  376. return err
  377. }
  378. // 获取冰排记录
  379. var iceRaftRecordModel model.IceRaftRecord
  380. err = e.Orm.Scopes(actions.Permission(iceRaftRecordModel.TableName(), p)).
  381. Where("ice_raft_id = ?", iceRaftModel.Id).
  382. First(&iceRaftRecordModel, iceRaftModel.IceRaftRecordId).Error
  383. if err != nil {
  384. e.Log.Errorf("db error: %s", err)
  385. return errors.New("获取冰排记录失败,请确认冰排是否入库!")
  386. }
  387. if len(iceRaftRecordModel.OutStorageTime.String()) > 0 {
  388. err = errors.New(fmt.Sprintf("冰排【%s】已出库,禁止出库!", code))
  389. return err
  390. }
  391. inTime := iceRaftRecordModel.InStorageTime.Local()
  392. if inTime.Add(time.Hour * time.Duration(iceRaftRecordModel.FreezeClaim)).After(time.Now()) {
  393. err = errors.New(fmt.Sprintf("冰排【%s】未达到冷冻时长,禁止出库", code))
  394. return err
  395. }
  396. iceRaftRecordModel.Status = model.IceRaftRecordStatusUsing
  397. iceRaftRecordModel.CoolerBoxId = coolerBoxModel.Id
  398. iceRaftRecordModel.OutStorageTime = model2.Time(time.Now())
  399. err = tx.Save(&iceRaftRecordModel).Error
  400. if err != nil {
  401. e.Log.Errorf("db error: %s", err)
  402. return errors.New("保存冰排记录失败")
  403. }
  404. }
  405. return nil
  406. }
  407. // 查询保温箱关联的冰排
  408. func (e *IceRaft) GetPageByCoolerBoxId(coolerBoxId int, list *[]string, p *actions.DataPermission) error {
  409. var data model.IceRaft
  410. err := e.Orm.Model(&data).
  411. Select("code").
  412. Scopes(
  413. actions.Permission(data.TableName(), p),
  414. IceRaftNameRecordStatusScopes(model.IceRaftRecordStatusUsing),
  415. IceRaftNameRecordCoolerBoxIdScopes(coolerBoxId),
  416. ).
  417. Joins("left join ice_raft_record on ice_raft.ice_raft_record_id = ice_raft_record.id").
  418. Find(list).Error
  419. if err != nil {
  420. e.Log.Errorf("db error: %s", err)
  421. return global.GetFailedErr
  422. }
  423. return nil
  424. }
  425. type IceRaftRecord struct {
  426. service.Service
  427. }
  428. // GetPage 获取IceRaft列表
  429. func (e *IceRaftRecord) GetPage(c *dto.IceRaftRecordGetPageReq, list *[]model.IceRaftRecord, count *int64, p *actions.DataPermission) error {
  430. var err error
  431. var data model.IceRaftRecord
  432. if c.PageSize == 9999 {
  433. err = e.Orm.Model(&data).
  434. Scopes(
  435. actions.Permission(data.TableName(), p),
  436. ).
  437. Preload("IceLocker").
  438. Preload("CoolerBox").
  439. Find(list).Limit(-1).Offset(-1).
  440. Count(count).Error
  441. } else {
  442. err = e.Orm.Model(&data).
  443. Scopes(
  444. cDto.MakeCondition(c.GetNeedSearch()),
  445. cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
  446. actions.Permission(data.TableName(), p),
  447. ).
  448. Preload("IceLocker").
  449. Preload("CoolerBox").
  450. Find(list).Limit(-1).Offset(-1).
  451. Count(count).Error
  452. }
  453. if err != nil {
  454. e.Log.Errorf("db error: %s", err)
  455. return global.GetFailedErr
  456. }
  457. return nil
  458. }
  459. // Update 修改IceRaft对象
  460. func (e *IceRaftRecord) Update(c *dto.IceRaftRecordUpdateReq, p *actions.DataPermission) error {
  461. var err error
  462. tx := e.Orm.Begin()
  463. defer func() {
  464. if err != nil {
  465. tx.Rollback()
  466. } else {
  467. tx.Commit()
  468. }
  469. }()
  470. var iceRaftRecordModel = model.IceRaftRecord{}
  471. // 查询冰排是否存在
  472. err = e.Orm.Scopes(actions.Permission(iceRaftRecordModel.TableName(), p)).
  473. First(&iceRaftRecordModel, c.GetId()).Error
  474. if err != nil {
  475. e.Log.Errorf("db error: %s", err)
  476. if errors.Is(err, gorm.ErrRecordNotFound) {
  477. return global.UpdateNotFoundOrNoPermissionErr
  478. }
  479. return global.UpdateFailedErr
  480. }
  481. iceRaftRecordModel.IceLockerId = c.IceLockerId
  482. iceRaftRecordModel.FreezeClaim = c.FreezeClaim
  483. if len(iceRaftRecordModel.OutStorageTime.String()) > 0 {
  484. iceRaftRecordModel.CoolerBoxId = c.CoolerBoxId
  485. }
  486. err = tx.Save(&iceRaftRecordModel).Error
  487. if err != nil {
  488. e.Log.Errorf("db error: %s", err)
  489. return global.UpdateFailedErr
  490. }
  491. c.Id = iceRaftRecordModel.Id
  492. return nil
  493. }
  494. // Remove 删除IceRaft
  495. func (e *IceRaftRecord) Remove(c *dto.IceRaftRecordDeleteReq, p *actions.DataPermission) error {
  496. var err error
  497. tx := e.Orm.Begin()
  498. defer func() {
  499. if err != nil {
  500. tx.Rollback()
  501. } else {
  502. tx.Commit()
  503. }
  504. }()
  505. var iceRaftRecordModel model.IceRaftRecord
  506. // 查询冰排是否存在
  507. err = e.Orm.Scopes(actions.Permission(iceRaftRecordModel.TableName(), p)).
  508. First(&iceRaftRecordModel, c.GetId()).Error
  509. if err != nil {
  510. e.Log.Errorf("db error: %s", err)
  511. if errors.Is(err, gorm.ErrRecordNotFound) {
  512. return global.DeleteNotFoundOrNoPermissionErr
  513. }
  514. return global.DeleteFailedErr
  515. }
  516. db := tx.Delete(&iceRaftRecordModel)
  517. if err = db.Error; err != nil {
  518. e.Log.Errorf("db error: %s", err)
  519. return global.DeleteFailedErr
  520. }
  521. if db.RowsAffected == 0 {
  522. return global.DeleteNotFoundOrNoPermissionErr
  523. }
  524. // 更改冰排关联状态
  525. var iceRaftModel model.IceRaft
  526. var secondIceRaftRecordModel model.IceRaftRecord
  527. err = e.Orm.Scopes(actions.Permission(iceRaftModel.TableName(), p)).
  528. First(&iceRaftModel, iceRaftRecordModel.IceRaftId).Error
  529. if err != nil {
  530. e.Log.Errorf("db error: %s", err)
  531. return global.DeleteFailedErr
  532. }
  533. err = e.Orm.Scopes(actions.Permission(secondIceRaftRecordModel.TableName(), p)).
  534. Where("ice_raft_id = ? and id != ?", iceRaftRecordModel.IceRaftId, iceRaftRecordModel.Id).
  535. First(&secondIceRaftRecordModel).Error
  536. if err != nil {
  537. if errors.Is(err, gorm.ErrRecordNotFound) {
  538. iceRaftModel.IceRaftRecordId = 0
  539. }
  540. }
  541. iceRaftModel.IceRaftRecordId = secondIceRaftRecordModel.Id
  542. err = tx.Save(&iceRaftModel).Error
  543. if err != nil {
  544. e.Log.Errorf("db error: %s", err)
  545. return global.UpdateFailedErr
  546. }
  547. return nil
  548. }