package friend_circle import ( "applet/app/db" "applet/app/e" md "applet/app/md/friend_circle" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "code.fnuoos.com/EggPlanet/egg_models.git/src/model" "github.com/gin-gonic/gin" "time" ) // GetFriendCircleBasicSettings // @Summary 社交管理-动态设置-基础设置(获取) // @Tags 动态设置 // @Description 基础设置(获取) // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Success 200 {object} md.GetFriendCircleBasicSettingsResp "具体数据" // @Failure 400 {object} md.Response "具体错误" // @Router /api/friendCircleSettings/basic/index [GET] func GetFriendCircleBasicSettings(c *gin.Context) { basicDb := implement.NewEggFriendCircleBasicDb(db.Db) basic, err := basicDb.EggFriendCircleBasicGetOne() if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } if basic == nil { now := time.Now() m := model.EggFriendCircleBasic{ CommentIsRealName: 1, PublishIsRealName: 1, CommentNumsEveryDay: 0, PublishNumsEveryDay: 0, CreateAt: now.Format("2006-01-02 15:04:05"), UpdateAt: now.Format("2006-01-02 15:04:05"), } _, err := basicDb.EggFriendCircleBasicInsert(&m) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } basic, err = basicDb.EggFriendCircleBasicGetOne() if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } } resp := md.GetFriendCircleBasicSettingsResp{ Id: basic.Id, CommentIsRealName: basic.CommentIsRealName, PublishIsRealName: basic.PublishIsRealName, CommentNumsEveryDay: basic.CommentNumsEveryDay, PublishNumsEveryDay: basic.PublishNumsEveryDay, } e.OutSuc(c, resp, nil) } // UpdateFriendCircleBasicSettings // @Summary 社交管理-动态设置-基础设置(更新) // @Tags 动态设置 // @Description 基础设置(更新) // @Accept json // @Produce json // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Param req body md.UpdateFriendCircleBasicSettingsReq true "id 必填" // @Success 200 {int} "修改数据条数" // @Failure 400 {object} md.Response "具体错误" // @Router /api/friendCircleSettings/basic/save [POST] func UpdateFriendCircleBasicSettings(c *gin.Context) { var req *md.UpdateFriendCircleBasicSettingsReq if err := c.ShouldBindJSON(&req); err != nil { e.OutErr(c, e.ERR_INVALID_ARGS, err) return } m := model.EggFriendCircleBasic{ Id: req.Id, CommentIsRealName: req.CommentIsRealName, PublishIsRealName: req.PublishIsRealName, CommentNumsEveryDay: req.CommentNumsEveryDay, PublishNumsEveryDay: req.PublishNumsEveryDay, } columns := []string{"publish_nums_every_day", "comment_nums_every_day", "publish_is_real_name", "comment_is_real_name"} basicDb := implement.NewEggFriendCircleBasicDb(db.Db) affected, err := basicDb.UpdateEggFriendCircleBasic(&m, columns...) if err != nil { e.OutErr(c, e.ERR_DB_ORM, err.Error()) return } e.OutSuc(c, affected, nil) }