附近小店
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.
 
 
 

79 lines
1.8 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/e"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "github.com/gin-gonic/gin"
  9. "strings"
  10. "time"
  11. )
  12. func Notice(c *gin.Context) {
  13. var args map[string]string
  14. if err := c.ShouldBindJSON(&args); err != nil {
  15. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  16. return
  17. }
  18. user := svc.GetUser(c)
  19. args["uid"] = utils.IntToStr(user.Info.Uid)
  20. data, total := db.GetBankNoticeAll(svc.MasterDb(c), args)
  21. list := make([]map[string]string, 0)
  22. if data != nil {
  23. for _, v := range *data {
  24. tmp := map[string]string{
  25. "id": utils.IntToStr(v.Id),
  26. "title": v.Title,
  27. "content": v.Content,
  28. "create_time": v.CreateTime.Format("2006-01-02 15:04"),
  29. }
  30. list = append(list, tmp)
  31. }
  32. }
  33. res := map[string]interface{}{
  34. "list": list, "total": total,
  35. }
  36. e.OutSuc(c, res, nil)
  37. return
  38. }
  39. func NoticeSave(c *gin.Context) {
  40. var args map[string]string
  41. if err := c.ShouldBindJSON(&args); err != nil {
  42. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  43. return
  44. }
  45. user := svc.GetUser(c)
  46. eg := svc.MasterDb(c)
  47. if args["id"] != "" {
  48. notice := db.GetNotice(eg, args["id"])
  49. notice.UpdateTime = time.Now()
  50. notice.Title = args["title"]
  51. notice.Content = args["content"]
  52. } else {
  53. notice := &model.CommunityTeamStoreNotice{
  54. Uid: user.Info.Uid,
  55. CreateTime: time.Now(),
  56. UpdateTime: time.Now(),
  57. Title: args["title"],
  58. Content: args["content"],
  59. }
  60. eg.Insert(notice)
  61. }
  62. e.OutSuc(c, "success", nil)
  63. return
  64. }
  65. func NoticeDel(c *gin.Context) {
  66. var arg map[string]string
  67. if err := c.ShouldBindJSON(&arg); err != nil {
  68. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  69. return
  70. }
  71. svc.MasterDb(c).In("id", strings.Split(arg["ids"], ",")).Delete(&model.CommunityTeamStoreNotice{})
  72. e.OutSuc(c, "success", nil)
  73. return
  74. }