MCPcopy Index your code
hub / github.com/aiprodcoder/MIXAPI / GetAffCode

Function GetAffCode

controller/user.go:375–398  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

373}
374
375func 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
400func GetSelf(c *gin.Context) {
401 id := c.GetInt("id")

Callers

nothing calls this directly

Calls 5

GetUserByIdFunction · 0.92
ApiErrorFunction · 0.92
GetRandomStringFunction · 0.92
ErrorMethod · 0.80
UpdateMethod · 0.45

Tested by

no test coverage detected