蛋蛋星球 后台端
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.
 
 
 

101 lines
3.4 KiB

  1. package friend_circle
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. md "applet/app/md/friend_circle"
  6. "applet/app/svc"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "code.fnuoos.com/EggPlanet/egg_models.git/src/model"
  9. "github.com/gin-gonic/gin"
  10. "time"
  11. )
  12. // GetFriendCircleBasicSettings
  13. // @Summary 社交管理-动态设置-基础设置(获取)
  14. // @Tags 动态设置
  15. // @Description 基础设置(获取)
  16. // @Accept json
  17. // @Produce json
  18. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  19. // @Success 200 {object} md.GetFriendCircleBasicSettingsResp "具体数据"
  20. // @Failure 400 {object} md.Response "具体错误"
  21. // @Router /api/friendCircleSettings/basic/index [GET]
  22. func GetFriendCircleBasicSettings(c *gin.Context) {
  23. basicDb := implement.NewEggFriendCircleBasicDb(db.Db)
  24. basic, err := basicDb.EggFriendCircleBasicGetOne()
  25. if err != nil {
  26. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  27. return
  28. }
  29. if basic == nil {
  30. now := time.Now()
  31. m := model.EggFriendCircleBasic{
  32. CommentIsRealName: 1,
  33. PublishIsRealName: 1,
  34. CommentNumsEveryDay: 0,
  35. PublishNumsEveryDay: 0,
  36. CreateAt: now.Format("2006-01-02 15:04:05"),
  37. UpdateAt: now.Format("2006-01-02 15:04:05"),
  38. }
  39. _, err := basicDb.EggFriendCircleBasicInsert(&m)
  40. if err != nil {
  41. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  42. return
  43. }
  44. basic, err = basicDb.EggFriendCircleBasicGetOne()
  45. if err != nil {
  46. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  47. return
  48. }
  49. }
  50. resp := md.GetFriendCircleBasicSettingsResp{
  51. Id: basic.Id,
  52. CommentIsRealName: basic.CommentIsRealName,
  53. PublishIsRealName: basic.PublishIsRealName,
  54. CommentNumsEveryDay: basic.CommentNumsEveryDay,
  55. PublishNumsEveryDay: basic.PublishNumsEveryDay,
  56. OfficialName: basic.OfficialName,
  57. OfficialLogo: basic.OfficialLogo,
  58. OfficialLogoUrl: svc.GetOssUrl(basic.OfficialLogo),
  59. }
  60. e.OutSuc(c, resp, nil)
  61. }
  62. // UpdateFriendCircleBasicSettings
  63. // @Summary 社交管理-动态设置-基础设置(更新)
  64. // @Tags 动态设置
  65. // @Description 基础设置(更新)
  66. // @Accept json
  67. // @Produce json
  68. // @param Authorization header string true "验证参数Bearer和token空格拼接"
  69. // @Param req body md.UpdateFriendCircleBasicSettingsReq true "id 必填"
  70. // @Success 200 {int} "修改数据条数"
  71. // @Failure 400 {object} md.Response "具体错误"
  72. // @Router /api/friendCircleSettings/basic/save [POST]
  73. func UpdateFriendCircleBasicSettings(c *gin.Context) {
  74. var req *md.UpdateFriendCircleBasicSettingsReq
  75. if err := c.ShouldBindJSON(&req); err != nil {
  76. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  77. return
  78. }
  79. m := model.EggFriendCircleBasic{
  80. Id: req.Id,
  81. CommentIsRealName: req.CommentIsRealName,
  82. PublishIsRealName: req.PublishIsRealName,
  83. CommentNumsEveryDay: req.CommentNumsEveryDay,
  84. PublishNumsEveryDay: req.PublishNumsEveryDay,
  85. OfficialName: req.OfficialName,
  86. OfficialLogo: req.OfficialLogo,
  87. }
  88. columns := []string{"official_name", "official_logo", "publish_nums_every_day", "comment_nums_every_day", "publish_is_real_name", "comment_is_real_name"}
  89. basicDb := implement.NewEggFriendCircleBasicDb(db.Db)
  90. affected, err := basicDb.UpdateEggFriendCircleBasic(&m, columns...)
  91. if err != nil {
  92. e.OutErr(c, e.ERR_DB_ORM, err.Error())
  93. return
  94. }
  95. e.OutSuc(c, affected, nil)
  96. }