/* * @description: 项目账号相关 * @Author: CP * @Date: 2020-09-25 14:42:31 * @FilePath: \construction_management\web\api\project_account_api.go */ package api import ( "fmt" "strconv" "github.com/dgrijalva/jwt-go" "github.com/kataras/iris/v12" "go.mod/comm" "go.mod/conf" "go.mod/services" ) 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 // } userInfo := c.Ctx.Values().Get("jwt").(*jwt.Token).Claims.(jwt.MapClaims) accountId := userInfo["identity"].(string) aid, err := comm.AesDecrypt(accountId, conf.CookieSecret) id, err := strconv.Atoi(aid) // 获得项目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(id) c.Ctx.JSON(iris.Map{ "code": 0, "msg": "", "data": AccountData, }) }