12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- /*
- * @description: 项目账号相关
- * @Author: CP
- * @Date: 2020-09-25 14:42:31
- * @FilePath: \construction_management\web\api\project_account_api.go
- */
- package api
- import (
- "fmt"
- "github.com/kataras/iris/v12"
- "go.mod/services"
- "go.mod/web/utils"
- )
- type ProjectAccountApi struct {
- //框架-web应用上下文环境
- Ctx iris.Context
- // 需要用的service
- ServiceProjectAccount services.ProjectAccountService
- }
- // @Summary 获得登陆账号信息相关
- // @Tags 项目账号相关
- // @Description 获得登陆账号相关信息
- // @Security ApiKeyAuth
- // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
- // @Router /api/projectAccount [get]
- func (c *ProjectAccountApi) Get() {
- // 获得项目账号ID
- projectAccountIdInt, err := utils.GetProjectAccountId(c.Ctx)
- 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
- }
- // 获得登陆用户
- AccountData := c.ServiceProjectAccount.Get(projectAccountIdInt, projectIdInt)
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "",
- "data": AccountData,
- })
- }
- // @Summary 获得项目账号列表
- // @Tags 项目账号相关
- // @Description 获得项目账号列表
- // @Security ApiKeyAuth
- // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
- // @Router /api/projectAccount/list [get]
- func (c *ProjectAccountApi) GetList() {
- // 获得项目ID
- projectIdInt, err := utils.GetProjectId(c.Ctx)
- if err != nil {
- c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
- return
- }
- AccountData := c.ServiceProjectAccount.GetAll(projectIdInt)
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "",
- "data": AccountData,
- })
- }
- // @Summary 获得项目账号角色列表
- // @Tags 项目账号相关
- // @Description 获得项目账号角色列表
- // @Security ApiKeyAuth
- // @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
- // @Router /api/projectAccount/role [get]
- func (c *ProjectAccountApi) GetRole() {
- roleDate := map[int]string{
- 1: "建设单位",
- 2: "监理单位",
- 3: "施工单位",
- 4: "设计单位",
- }
- c.Ctx.JSON(iris.Map{
- "code": 0,
- "msg": "",
- "data": roleDate,
- })
- }
|