project_setting_auth_api.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * @description:项目设置-权限管理
  3. * @Author: CP
  4. * @Date: 2020-10-20 15:47:07
  5. * @FilePath: \construction_management\web\api\project_setting_auth_api.go
  6. */
  7. package api
  8. import (
  9. "fmt"
  10. "github.com/kataras/iris/v12"
  11. "go.mod/web/utils"
  12. "go.mod/web/viewmodels"
  13. )
  14. // @Summary 获得标段账号
  15. // @Tags 项目设置-标段成员权限-管理员
  16. // @Description 获得标段账号
  17. // @Accept json
  18. // @Produce json
  19. // @Security ApiKeyAuth
  20. // @Param bidsectionId path string false "标段ID"
  21. // @Success 200 {object} viewmodels.ProjectAccount "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
  22. // @Router /api/projectSetting/bid/account [get]
  23. func (c *ProjectSettingApi) GetBidAccount() {
  24. // 获得标段ID
  25. TreeData := viewmodels.Tree{}
  26. err := c.Ctx.ReadForm(&TreeData)
  27. if err != nil {
  28. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  29. return
  30. }
  31. if TreeData.BidsectionId == "" {
  32. c.Ctx.JSON(iris.Map{"code": -1, "msg": "标段ID不能为空"})
  33. return
  34. }
  35. // 解密标段ID
  36. bidsectionId, err := utils.GetDecryptId(TreeData.BidsectionId)
  37. if err != nil {
  38. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  39. return
  40. }
  41. // 获得项目ID
  42. projectIdInt, err := utils.GetProjectId(c.Ctx)
  43. if err != nil {
  44. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  45. return
  46. }
  47. // 获得项目账号ID
  48. projectAccountIdInt, err := utils.GetProjectAccountId(c.Ctx)
  49. if err != nil {
  50. c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
  51. return
  52. }
  53. dataList := c.ServiceProjectAccount.GetBidAccount(bidsectionId, projectIdInt, projectAccountIdInt)
  54. c.Ctx.JSON(iris.Map{
  55. "code": 0,
  56. "msg": "",
  57. "data": dataList,
  58. })
  59. }
  60. // 标段中添加成员-账号
  61. // @Summary 获得标段账号
  62. // @Tags 项目设置-标段成员权限-管理员
  63. // @Description 获得标段账号
  64. // @Accept json
  65. // @Produce json
  66. // @Security ApiKeyAuth
  67. // @Param bidsectionId path string false "标段ID"
  68. // @Success 200 {object} viewmodels.ProjectAccount "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
  69. // @Router /api/projectSetting/bid/account [get]
  70. func (c *ProjectSettingApi) PostBidAccountCreate() {
  71. // 账号ID,标段ID,目录ID
  72. BidAccountData, err := c.ServiceBidAccount.ValidRule(c.Ctx)
  73. if err != nil {
  74. c.Ctx.JSON(iris.Map{"code": -1, "msg": utils.FormValidError(err)})
  75. return
  76. }
  77. // 获得项目ID
  78. projectIdInt, err := utils.GetProjectId(c.Ctx)
  79. if err != nil {
  80. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  81. return
  82. }
  83. // 创建标段和账号的关系
  84. err = c.ServiceBidAccount.Create(BidAccountData, projectIdInt)
  85. if err != nil {
  86. c.Ctx.JSON(iris.Map{"code": -1, "msg": ""})
  87. return
  88. }
  89. c.Ctx.JSON(iris.Map{
  90. "code": 0,
  91. "msg": "新增成功",
  92. })
  93. }