蛋蛋星球 后台端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

95 lignes
3.2 KiB

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