project_setting_auth_api.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. // @Summary 标段中添加成员-账号
  61. // @Tags 项目设置-标段成员权限-管理员
  62. // @Description 标段中添加成员-账号
  63. // @Accept json
  64. // @Produce json
  65. // @Security ApiKeyAuth
  66. // @Param bidsectionId body string false "标段ID"
  67. // @Param accountId body string false "账号ID"
  68. // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
  69. // @Router /api/projectSetting/bid/account/create [post]
  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. }
  94. // 设置权限
  95. func (c *ProjectSettingApi) PostBidAccountAuth() {
  96. }
  97. // @Summary 移除标段成员-账号
  98. // @Tags 项目设置-标段成员权限-管理员
  99. // @Description 移除标段成员-账号
  100. // @Accept json
  101. // @Produce json
  102. // @Security ApiKeyAuth
  103. // @Param bidsectionId body string false "标段ID"
  104. // @Param accountId body string false "账号ID"
  105. // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
  106. // @Router /api/projectSetting/bid/account [delete]
  107. func (c *ProjectSettingApi) DeleteBidAccount() {
  108. // 账号ID,标段ID
  109. BidAccountData, err := c.ServiceBidAccount.ValidRule(c.Ctx)
  110. if err != nil {
  111. c.Ctx.JSON(iris.Map{"code": -1, "msg": utils.FormValidError(err)})
  112. return
  113. }
  114. // 获得项目ID
  115. projectIdInt, err := utils.GetProjectId(c.Ctx)
  116. if err != nil {
  117. c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
  118. return
  119. }
  120. // 创建标段和账号的关系
  121. err = c.ServiceBidAccount.Delete(BidAccountData, projectIdInt)
  122. if err != nil {
  123. c.Ctx.JSON(iris.Map{"code": -1, "msg": ""})
  124. return
  125. }
  126. c.Ctx.JSON(iris.Map{
  127. "code": 0,
  128. "msg": "移除成功",
  129. })
  130. }