(c *gin.Context)
| 373 | } |
| 374 | |
| 375 | func GetAffCode(c *gin.Context) { |
| 376 | id := c.GetInt("id") |
| 377 | user, err := model.GetUserById(id, true) |
| 378 | if err != nil { |
| 379 | common.ApiError(c, err) |
| 380 | return |
| 381 | } |
| 382 | if user.AffCode == "" { |
| 383 | user.AffCode = common.GetRandomString(4) |
| 384 | if err := user.Update(false); err != nil { |
| 385 | c.JSON(http.StatusOK, gin.H{ |
| 386 | "success": false, |
| 387 | "message": err.Error(), |
| 388 | }) |
| 389 | return |
| 390 | } |
| 391 | } |
| 392 | c.JSON(http.StatusOK, gin.H{ |
| 393 | "success": true, |
| 394 | "message": "", |
| 395 | "data": user.AffCode, |
| 396 | }) |
| 397 | return |
| 398 | } |
| 399 | |
| 400 | func GetSelf(c *gin.Context) { |
| 401 | id := c.GetInt("id") |
nothing calls this directly
no test coverage detected