123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /*
- * @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 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) 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": "新增成功",
- })
- }
|