123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /*
- * @description:项目设置-权限管理
- * @Author: CP
- * @Date: 2020-10-20 15:47:07
- * @FilePath: \construction_management\web\api\project_setting_auth_api.go
- */
- package api
- import (
- "fmt"
- "github.com/kataras/iris/v12"
- "go.mod/web/utils"
- "go.mod/web/viewmodels"
- )
- // @Summary 获得标段账号
- // @Tags 项目设置-标段成员权限-管理员
- // @Description 获得标段账号
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param bidsectionId path string false "标段ID"
- // @Success 200 {object} viewmodels.ProjectAccount "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
- // @Router /api/projectSetting/bid/account [get]
- func (c *ProjectSettingApi) GetBidAccount() {
- // 获得标段ID
- TreeData := viewmodels.Tree{}
- err := c.Ctx.ReadForm(&TreeData)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
- return
- }
- if TreeData.BidsectionId == "" {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": "标段ID不能为空"})
- return
- }
- // 解密标段ID
- bidsectionId, err := utils.GetDecryptId(TreeData.BidsectionId)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
- return
- }
- // 获得项目ID
- projectIdInt, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 获得项目账号ID
- projectAccountIdInt, err := utils.GetProjectAccountId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
- return
- }
- dataList := c.ServiceProjectAccount.GetBidAccount(bidsectionId, projectIdInt, projectAccountIdInt)
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "",
- "data": dataList,
- })
- }
- // @Summary 标段中添加成员-账号
- // @Tags 项目设置-标段成员权限-管理员
- // @Description 标段中添加成员-账号
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param bidsectionId body string false "标段ID"
- // @Param accountId body string false "账号ID"
- // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
- // @Router /api/projectSetting/bid/account/create [post]
- func (c *ProjectSettingApi) PostBidAccountCreate() {
- // 账号ID,标段ID,目录ID
- BidAccountData, err := c.ServiceBidAccount.ValidRule(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": utils.FormValidError(err)})
- return
- }
- // 获得项目ID
- projectIdInt, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 创建标段和账号的关系
- err = c.ServiceBidAccount.Create(BidAccountData, projectIdInt)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": ""})
- return
- }
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "新增成功",
- })
- }
- // 设置权限
- func (c *ProjectSettingApi) PostBidAccountAuth() {
- }
- // @Summary 移除标段成员-账号
- // @Tags 项目设置-标段成员权限-管理员
- // @Description 移除标段成员-账号
- // @Accept json
- // @Produce json
- // @Security ApiKeyAuth
- // @Param bidsectionId body string false "标段ID"
- // @Param accountId body string false "账号ID"
- // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
- // @Router /api/projectSetting/bid/account [delete]
- func (c *ProjectSettingApi) DeleteBidAccount() {
- // 账号ID,标段ID
- BidAccountData, err := c.ServiceBidAccount.ValidRule(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": utils.FormValidError(err)})
- return
- }
- // 获得项目ID
- projectIdInt, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
- return
- }
- // 创建标段和账号的关系
- err = c.ServiceBidAccount.Delete(BidAccountData, projectIdInt)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": ""})
- return
- }
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "移除成功",
- })
- }
|