apply.go 808 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package controller
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/go-playground/validator/v10"
  5. "project_management/app/e"
  6. "project_management/app/model"
  7. "project_management/app/services"
  8. "project_management/unity"
  9. )
  10. var Apply services.Apply = &model.Apply{}
  11. func GetApplyList(c *gin.Context) {
  12. }
  13. // AddApply 添加应用
  14. func AddApply(c *gin.Context) {
  15. var apply model.Apply
  16. if err := c.ShouldBindJSON(&apply); err != nil {
  17. e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
  18. return
  19. }
  20. validate := validator.New()
  21. if err := validate.Struct(apply); err != nil {
  22. e.ResponseWithMsg(c, e.ERROR, err.Error())
  23. return
  24. }
  25. // 生成应用ID
  26. id := unity.RandomAppID()
  27. for model.AppIdISRepeat(id) {
  28. id = unity.RandomAppID()
  29. }
  30. apply.AppID = id
  31. Apply.AddApply(apply)
  32. }