rdluck 4 years ago
parent
commit
01cd377711

+ 2 - 0
controllers/article.go

@@ -0,0 +1,2 @@
+package controllers
+

+ 32 - 0
controllers/chart_permission.go

@@ -0,0 +1,32 @@
+package controllers
+
+import "hongze/hongze_cygx/models"
+
+//品种
+type ChartPermissionController struct {
+	BaseCommonController
+}
+
+// @Title 获取所有品种
+// @Description 获取用户详情接口
+// @Success 200 {object} models.ChartPermissionResp
+// @router /all [get]
+func (this *ChartPermissionController) Detail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	list, err := models.GetChartPermissionAll()
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ChartPermissionResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 61 - 0
controllers/home.go

@@ -1,5 +1,66 @@
 package controllers
 
+import (
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"rdluck_tools/paging"
+)
+
 type HomeController struct {
 	BaseCommonController
 }
+
+// @Title 首页列表接口
+// @Description 首页列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ChartPermissionId   query   int  true       "品类id,最新传0"
+// @Success 200 {object} models.HomeList
+// @router /list [get]
+func (this *HomeController) ListHome() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+
+	if chartPermissionId > 0 {
+
+	}
+
+	total, err := models.GetHomeCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.Msg = "获取帖子总数失败,Err:" + err.Error()
+		return
+	}
+	list, err := models.GetHomeList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.Msg = "获取帖子数据失败,Err:" + err.Error()
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.HomeListResp)
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 175 - 1
controllers/user.go

@@ -1,7 +1,12 @@
 package controllers
 
 import (
+	"encoding/json"
 	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
 )
 
 //用户
@@ -9,6 +14,116 @@ type UserController struct {
 	BaseAuthController
 }
 
+// @Title 登录
+// @Description 登录接口
+// @Param	request	body models.LoginReq true "type json string"
+// @Success 200 {object} models.LoginResp
+// @router /login [post]
+func (this *UserController) Login() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var req models.LoginReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录"
+		br.Ret = 408
+		return
+	}
+
+	unionId := this.User.UnionId
+	userId := this.User.UserId
+	if unionId == "" {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,unionId 为空"
+		return
+	}
+	newUserId := 0
+	if req.LoginType == 1 {
+		//BindMobile(openId, mobile string, userId, loginType int) (err error) {
+		req.Mobile = strings.Trim(req.Mobile, " ")
+		newUserId, err = models.PcBindMobile(unionId, req.Mobile, userId, req.LoginType)
+	} else if req.LoginType == 2 {
+		if req.Email == "" {
+			br.ErrMsg = "邮箱不能为空,请输入邮箱"
+			br.Msg = "邮箱不能为空,请输入邮箱"
+			return
+		}
+		if !utils.ValidateEmailFormatat(req.Email) {
+			br.ErrMsg = "邮箱格式错误,请重新输入"
+			br.Msg = "邮箱格式错误,请重新输入"
+			return
+		}
+		newUserId, err = models.PcBindMobile(unionId, req.Email, userId, req.LoginType)
+	} else {
+		br.Msg = "无效的登录方式"
+		br.ErrMsg = "无效的登录方式,Err:" + err.Error()
+		return
+	}
+	var token string
+	tokenItem, err := models.GetTokenByUid(newUserId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "登录失败"
+		br.ErrMsg = "登录失败,获取token失败:" + err.Error()
+		return
+	}
+
+	if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
+		timeUnix := time.Now().Unix()
+		timeUnixStr := strconv.FormatInt(timeUnix, 10)
+		token := utils.MD5(strconv.Itoa(userId)) + utils.MD5(timeUnixStr)
+		//新增session
+		{
+			session := new(models.CygxSession)
+			session.OpenId = unionId
+			session.UnionId = unionId
+			session.UserId = userId
+			session.CreatedTime = time.Now()
+			session.LastUpdatedTime = time.Now()
+			session.ExpireTime = time.Now().AddDate(0, 1, 0)
+			session.AccessToken = token
+			err = models.AddSession(session)
+			if err != nil {
+				br.Msg = "登录失败"
+				br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
+				return
+			}
+		}
+	} else {
+		token = tokenItem.AccessToken
+	}
+
+	//新增登录日志
+	{
+		loginLog := new(models.WxUserLog)
+		loginLog.UserId = userId
+		loginLog.OpenId = unionId
+		loginLog.Mobile = req.Mobile
+		loginLog.Email = req.Email
+		loginLog.CreateTime = time.Now()
+		loginLog.Handle = "wechat_user_login"
+		loginLog.Remark = token
+		go models.AddWxUserLog(loginLog)
+	}
+
+	resp := new(models.LoginResp)
+	resp.UserId = newUserId
+	resp.Authorization = token
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+	br.Msg = "登录成功"
+}
+
 // @Title 获取用户详情
 // @Description 获取用户详情接口
 // @Success 200 {object} models.UserDetail
@@ -42,7 +157,13 @@ func (this *UserController) Detail() {
 	var hasPermission bool
 	if companyItem.Status == "试用" || companyItem.Status == "永续" || companyItem.Status == "正式" {
 		hasPermission = true
-
+		permissionStr, err := models.GetCompanyPermission(companyItem.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+			return
+		}
+		item.PermissionName = permissionStr
 	}
 	item.HasPermission = hasPermission
 	br.Ret = 200
@@ -50,3 +171,56 @@ func (this *UserController) Detail() {
 	br.Msg = "获取成功"
 	br.Data = item
 }
+
+//
+//// @Title 绑定手机号或邮箱
+//// @Description 绑定手机号或邮箱
+//// @Param	request	body models.WxGetPhoneNumberReq true "type json string"
+//// @Success 200 {object} models.WxGetPhoneNumberResp
+//// @router /bind [post]
+//func (this *WechatController) Bind() {
+//	br := new(models.BaseResponse).Init()
+//	defer func() {
+//		this.Data["json"] = br
+//		this.ServeJSON()
+//	}()
+//	var req models.WxGetPhoneNumberReq
+//	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+//	if err != nil {
+//		br.Msg = "参数解析异常!"
+//		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+//		return
+//	}
+//	if req.EncryptedData == "" || req.Iv == "" {
+//		br.Msg = "参数错误"
+//		return
+//	}
+//	user := this.User
+//	if user == nil {
+//		br.Msg = "请登陆"
+//		br.Ret = 408
+//		return
+//	}
+//	sessionKey := user.SessionKey
+//	wxMobile, err := weapp.DecryptMobile(sessionKey, req.EncryptedData, req.Iv)
+//	if err != nil {
+//		br.Msg = "解析用户手机号信息失败"
+//		br.ErrMsg = "解析用户手机号信息失败,Err:" + err.Error()
+//		return
+//	}
+//	err = models.ModifyUsersMobile(user.UserId, wxMobile.PurePhoneNumber)
+//	if err != nil {
+//		br.Msg = "获取失败"
+//		br.ErrMsg = "获取失败,Err:" + err.Error()
+//		return
+//	}
+//	resp := new(models.WxGetPhoneNumberResp)
+//	resp.Authorization = this.Token
+//	resp.PhoneNumber = wxMobile.PhoneNumber
+//	resp.PurePhoneNumber = wxMobile.PurePhoneNumber
+//	resp.CountryCode = wxMobile.CountryCode
+//	br.Msg = "获取成功!"
+//	br.Ret = 200
+//	br.Success = true
+//	br.Data = resp
+//}

+ 4 - 62
controllers/wechat.go

@@ -29,19 +29,13 @@ func (this *WechatCommonController) WechatLogin() {
 		this.Data["json"] = br
 		this.ServeJSON()
 	}()
-	var req models.WxLoginReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-	if req.Code == "" {
+	code:=this.GetString("Code")
+	if code == "" {
 		br.Msg = "参数错误"
 		br.ErrMsg = "Code 为空"
 		return
 	}
-	wxInfo, err := weapp.Login(utils.WxAppId, utils.WxAppSecret, req.Code)
+	wxInfo, err := weapp.Login(utils.WxAppId, utils.WxAppSecret, code)
 	if err != nil {
 		br.Msg = "获取用户信息失败"
 		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
@@ -138,7 +132,7 @@ func (this *WechatCommonController) WechatLogin() {
 
 	{
 		codeLog := new(models.WxUserCode)
-		codeLog.WxCode = req.Code
+		codeLog.WxCode = code
 		codeLog.UserId = userId
 		codeLog.Code = 0
 		codeLog.FirstLogin = firstLogin
@@ -436,55 +430,3 @@ func (this *WechatController) GetEmailCode() {
 	br.Ret = 200
 	br.Success = true
 }
-//
-//// @Title 绑定手机号或邮箱
-//// @Description 绑定手机号或邮箱
-//// @Param	request	body models.WxGetPhoneNumberReq true "type json string"
-//// @Success 200 {object} models.WxGetPhoneNumberResp
-//// @router /bind [post]
-//func (this *WechatController) Bind() {
-//	br := new(models.BaseResponse).Init()
-//	defer func() {
-//		this.Data["json"] = br
-//		this.ServeJSON()
-//	}()
-//	var req models.WxGetPhoneNumberReq
-//	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-//	if err != nil {
-//		br.Msg = "参数解析异常!"
-//		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-//		return
-//	}
-//	if req.EncryptedData == "" || req.Iv == "" {
-//		br.Msg = "参数错误"
-//		return
-//	}
-//	user := this.User
-//	if user == nil {
-//		br.Msg = "请登陆"
-//		br.Ret = 408
-//		return
-//	}
-//	sessionKey := user.SessionKey
-//	wxMobile, err := weapp.DecryptMobile(sessionKey, req.EncryptedData, req.Iv)
-//	if err != nil {
-//		br.Msg = "解析用户手机号信息失败"
-//		br.ErrMsg = "解析用户手机号信息失败,Err:" + err.Error()
-//		return
-//	}
-//	err = models.ModifyUsersMobile(user.UserId, wxMobile.PurePhoneNumber)
-//	if err != nil {
-//		br.Msg = "获取失败"
-//		br.ErrMsg = "获取失败,Err:" + err.Error()
-//		return
-//	}
-//	resp := new(models.WxGetPhoneNumberResp)
-//	resp.Authorization = this.Token
-//	resp.PhoneNumber = wxMobile.PhoneNumber
-//	resp.PurePhoneNumber = wxMobile.PurePhoneNumber
-//	resp.CountryCode = wxMobile.CountryCode
-//	br.Msg = "获取成功!"
-//	br.Ret = 200
-//	br.Success = true
-//	br.Data = resp
-//}

+ 28 - 0
models/article.go

@@ -0,0 +1,28 @@
+package models
+
+type CygxArticle struct {
+	Article_id      int    `description:"文章id"`
+	Title           string `description:"标题"`
+	TitleEn         string `description:"英文标题 "`
+	UpdateFrequency string `description:"更新周期"`
+	CreateDate      string `description:"创建时间"`
+	PublishDate     string `description:"发布时间"`
+	Body            string `description:"内容"`
+	Abstract        string `description:"摘要"`
+	CategoryName    string `description:"一级分类"`
+	SubCategoryName string `description:"二级分类"`
+}
+
+type HomeArticle struct {
+	Article_id      int    `description:"文章id"`
+	Title           string `description:"标题"`
+	TitleEn         string `description:"英文标题 "`
+	UpdateFrequency string `description:"更新周期"`
+	CreateDate      string `description:"创建时间"`
+	PublishDate     string `description:"发布时间"`
+	Body            string `description:"内容"`
+	Abstract        string `description:"摘要"`
+	CategoryName    string `description:"一级分类"`
+	SubCategoryName string `description:"二级分类"`
+}
+

+ 19 - 0
models/chart_permission.go

@@ -0,0 +1,19 @@
+package models
+
+import "rdluck_tools/orm"
+
+type ChartPermission struct {
+	ChartPermissionId   int       `description:"权限id"`
+	PermissionName      string    `description:"权限名称"`
+}
+
+type ChartPermissionResp struct {
+	List []*ChartPermission
+}
+
+func GetChartPermissionAll() (items []*ChartPermission, err error) {
+	o:=orm.NewOrm()
+	sql:=`SELECT * FROM chart_permission WHERE product_id=2 ORDER BY sort ASC `
+	_,err=o.Raw(sql).QueryRows(&items)
+	return
+}

+ 12 - 0
models/company.go

@@ -16,3 +16,15 @@ func GetCompanyDetailById(companyId int) (item *CompanyDetail, err error) {
 	err = o.Raw(sql, companyId).QueryRow(&item)
 	return
 }
+
+func GetCompanyPermission(companyId int) (permission string, err error) {
+	sql := ` SELECT GROUP_CONCAT(b.chart_permission_name SEPARATOR ',') AS chart_permission_name
+			FROM company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
+			WHERE 
+			a.company_id=?
+			AND a.product_id=2 `
+	o := orm.NewOrm()
+	err = o.Raw(sql, companyId).QueryRow(&permission)
+	return
+}

+ 36 - 0
models/home.go

@@ -0,0 +1,36 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"rdluck_tools/paging"
+)
+
+func GetHomeCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count
+                FROM cygx_article AS a
+                WHERE a.publish_status=1`
+	if condition != "" {
+		sql += condition
+	}
+	err = o.Raw(sql, pars).QueryRow(&count)
+	return
+}
+
+func GetHomeList(condition string, pars []interface{}, startSize, pageSize int) (items []*HomeArticle, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT *
+                 FROM cygx_article AS a
+                WHERE a.publish_status=1`
+	if condition != "" {
+		sql += condition
+	}
+	sql += `ORDER BY publish_date DESC LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type HomeListResp struct {
+	Paging *paging.PagingItem
+	List   []*HomeArticle
+}

+ 118 - 2
models/user.go

@@ -1,6 +1,10 @@
 package models
 
-import "rdluck_tools/orm"
+import (
+	"hongze/hongze_cygx/utils"
+	"rdluck_tools/orm"
+	"time"
+)
 
 type UserDetail struct {
 	Headimgurl     string `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
@@ -9,7 +13,7 @@ type UserDetail struct {
 	NickName       string `description:"用户昵称"`
 	RealName       string `description:"用户实际名称"`
 	CompanyName    string `description:"公司名称"`
-	PermissionName string `description:"拥有权限分类"`
+	PermissionName string `description:"拥有权限分类,多个用英文逗号分隔"`
 	HasPermission bool `description:"true:有权限,false:无权限"`
 }
 
@@ -24,3 +28,115 @@ type UserPermission struct {
 	CompanyName         string `description:"公司名称"`
 	ChartPermissionName string `description:"权限"`
 }
+
+
+type LoginReq struct {
+	LoginType int    `description:"登录方式:1:手机,2:邮箱"`
+	Mobile    string `description:"手机号"`
+	Email     string `description:"邮箱"`
+}
+
+
+func PcBindMobile(unionId, mobile string, userId, loginType int) (wxUserId int, err error) {
+	//loginType  登录方式:1:手机,2:邮箱
+
+	utils.FileLog.Info("绑定参数:%s %s %d %d", unionId, mobile, userId, loginType)
+
+	sql := ``
+	if loginType == 1 {
+		sql = `SELECT * FROM wx_user WHERE mobile = ? `
+	} else {
+		sql = "SELECT * FROM wx_user WHERE email = ? "
+	}
+	user := new(WxUser)
+	o := orm.NewOrm()
+	err = o.Raw(sql, mobile).QueryRow(&user)
+
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+
+	if user == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
+		utils.FileLog.Info("用户不存在,根据union_id绑定")
+		msql := ``
+		if loginType == 1 {
+			msql = "UPDATE wx_user SET mobile = ?,bind_account = ? WHERE union_id = ? "
+		} else {
+			msql = "UPDATE wx_user SET email = ?,bind_account = ? WHERE union_id = ?  "
+		}
+		_, err = o.Raw(msql, mobile, mobile, unionId).Exec()
+		wxUserId = userId
+	} else {
+		utils.FileLog.Info("用户存在,user.UnionId:%s", user.UnionId)
+		if user.UnionId == "" {
+			sql = `SELECT * FROM wx_user WHERE union_id = ? `
+			userInfo := new(WxUser)
+			o := orm.NewOrm()
+			err = o.Raw(sql, unionId).QueryRow(&userInfo)
+			if err != nil {
+				return
+			}
+
+			utils.FileLog.Info("user.RegisterTime %s", user.RegisterTime.Format(utils.FormatDateTime))
+			utils.FileLog.Info("userInfo.RegisterTime %s", userInfo.RegisterTime.Format(utils.FormatDateTime))
+
+			var maxRegisterTime time.Time
+			if user.RegisterTime.Before(userInfo.RegisterTime) {
+				maxRegisterTime = user.RegisterTime
+				utils.FileLog.Info("after")
+			} else {
+				maxRegisterTime = userInfo.RegisterTime
+				utils.FileLog.Info("not after")
+			}
+			utils.FileLog.Info("maxRegisterTime %s", maxRegisterTime.Format(utils.FormatDateTime))
+			wxUserId = user.UserId
+			dsql := ` DELETE FROM wx_user WHERE union_id = ? `
+			_, err = o.Raw(dsql, unionId).Exec()
+			if err != nil {
+				return wxUserId, err
+			}
+			msql := ` UPDATE wx_user SET union_id=?,register_time=?,province=?,city=?,country=?,headimgurl=?,unionid=?,sex=?  WHERE user_id = ?  `
+			_, err = o.Raw(msql, unionId, maxRegisterTime, userInfo.Province, userInfo.City, userInfo.Country, userInfo.Headimgurl, unionId, userInfo.Sex, user.UserId).Exec()
+			wxUserId = user.UserId
+		} else {
+			sql = `SELECT * FROM wx_user WHERE user_id = ? `
+			userInfo := new(WxUser)
+			o := orm.NewOrm()
+			err = o.Raw(sql, userId).QueryRow(&userInfo)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				return
+			}
+			dsql := ` DELETE FROM wx_user WHERE user_id = ? `
+			_, err = o.Raw(dsql, userId).Exec()
+			if err != nil {
+				return user.UserId, err
+			}
+			if user.Mobile == "" && loginType == 1 {
+				msql := ` UPDATE wx_user SET mobile = ?,bind_account = ?  WHERE user_id = ?`
+				_, err = o.Raw(msql, mobile, mobile, user.UserId).Exec()
+				wxUserId = user.UserId
+			}
+			if user.Email == "" && loginType == 2 {
+				msql := ` UPDATE wx_user SET email = ?,bind_account = ?  WHERE user_id = ?`
+				_, err = o.Raw(msql, mobile, mobile, user.UserId).Exec()
+				wxUserId = user.UserId
+			}
+			utils.FileLog.Info("用户存在,bind:%s,%d,%s", unionId, wxUserId)
+			wxUserId = userId
+		}
+	}
+	return
+}
+
+
+type LoginResp struct {
+	UserId         int    `description:"用户id"`
+	Authorization  string `description:"Token"`
+	Headimgurl     string `description:"用户头像"`
+	Mobile         string `description:"手机号"`
+	Email          string `description:"邮箱"`
+	CompanyName    string `description:"客户名称"`
+	Status         string `description:"状态"`
+	EndDate        string `description:"到期日期"`
+	ProductName    string `description:"客户类型名称"`
+}

+ 5 - 0
routers/router.go

@@ -38,6 +38,11 @@ func init() {
 				&controllers.UserController{},
 			),
 		),
+		beego.NSNamespace("/permission",
+			beego.NSInclude(
+				&controllers.ChartPermissionController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }

+ 247 - 1
swagger/swagger.json

@@ -15,6 +15,111 @@
     },
     "basePath": "/api",
     "paths": {
+        "/home/list": {
+            "get": {
+                "tags": [
+                    "home"
+                ],
+                "description": "首页列表接口",
+                "operationId": "HomeController.首页列表接口",
+                "parameters": [
+                    {
+                        "in": "query",
+                        "name": "PageSize",
+                        "description": "每页数据条数",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "query",
+                        "name": "CurrentIndex",
+                        "description": "当前页页码,从1开始",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    },
+                    {
+                        "in": "query",
+                        "name": "ChartPermissionId",
+                        "description": "品类id,最新传0",
+                        "required": true,
+                        "type": "integer",
+                        "format": "int64"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "",
+                        "schema": {
+                            "$ref": "#/definitions/models.HomeList"
+                        }
+                    }
+                }
+            }
+        },
+        "/permission/all": {
+            "get": {
+                "tags": [
+                    "permission"
+                ],
+                "description": "获取用户详情接口",
+                "operationId": "ChartPermissionController.获取所有品种",
+                "responses": {
+                    "200": {
+                        "description": "",
+                        "schema": {
+                            "$ref": "#/definitions/models.ChartPermissionResp"
+                        }
+                    }
+                }
+            }
+        },
+        "/user/detail": {
+            "get": {
+                "tags": [
+                    "user"
+                ],
+                "description": "获取用户详情接口",
+                "operationId": "UserController.获取用户详情",
+                "responses": {
+                    "200": {
+                        "description": "",
+                        "schema": {
+                            "$ref": "#/definitions/models.UserDetail"
+                        }
+                    }
+                }
+            }
+        },
+        "/user/login": {
+            "post": {
+                "tags": [
+                    "user"
+                ],
+                "description": "登录接口",
+                "operationId": "UserController.登录",
+                "parameters": [
+                    {
+                        "in": "body",
+                        "name": "request",
+                        "description": "type json string",
+                        "required": true,
+                        "schema": {
+                            "$ref": "#/definitions/models.LoginReq"
+                        }
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "",
+                        "schema": {
+                            "$ref": "#/definitions/models.LoginResp"
+                        }
+                    }
+                }
+            }
+        },
         "/wechat/getEmailCode": {
             "get": {
                 "tags": [
@@ -152,6 +257,137 @@
         }
     },
     "definitions": {
+        "models.ChartPermission": {
+            "title": "ChartPermission",
+            "type": "object",
+            "properties": {
+                "ChartPermissionId": {
+                    "description": "权限id",
+                    "type": "integer",
+                    "format": "int64"
+                },
+                "PermissionName": {
+                    "description": "权限名称",
+                    "type": "string"
+                }
+            }
+        },
+        "models.ChartPermissionResp": {
+            "title": "ChartPermissionResp",
+            "type": "object",
+            "properties": {
+                "List": {
+                    "type": "array",
+                    "items": {
+                        "$ref": "#/definitions/models.ChartPermission"
+                    }
+                }
+            }
+        },
+        "models.HomeList": {
+            "title": "HomeList",
+            "type": "object"
+        },
+        "models.LoginReq": {
+            "title": "LoginReq",
+            "type": "object",
+            "properties": {
+                "Email": {
+                    "description": "邮箱",
+                    "type": "string"
+                },
+                "LoginType": {
+                    "description": "登录方式:1:手机,2:邮箱",
+                    "type": "integer",
+                    "format": "int64"
+                },
+                "Mobile": {
+                    "description": "手机号",
+                    "type": "string"
+                }
+            }
+        },
+        "models.LoginResp": {
+            "title": "LoginResp",
+            "type": "object",
+            "properties": {
+                "Authorization": {
+                    "description": "Token",
+                    "type": "string"
+                },
+                "CompanyName": {
+                    "description": "客户名称",
+                    "type": "string"
+                },
+                "Email": {
+                    "description": "邮箱",
+                    "type": "string"
+                },
+                "EndDate": {
+                    "description": "到期日期",
+                    "type": "string"
+                },
+                "Headimgurl": {
+                    "description": "用户头像",
+                    "type": "string"
+                },
+                "Mobile": {
+                    "description": "手机号",
+                    "type": "string"
+                },
+                "ProductName": {
+                    "description": "客户类型名称",
+                    "type": "string"
+                },
+                "Status": {
+                    "description": "状态",
+                    "type": "string"
+                },
+                "UserId": {
+                    "description": "用户id",
+                    "type": "integer",
+                    "format": "int64"
+                }
+            }
+        },
+        "models.UserDetail": {
+            "title": "UserDetail",
+            "type": "object",
+            "properties": {
+                "CompanyName": {
+                    "description": "公司名称",
+                    "type": "string"
+                },
+                "Email": {
+                    "description": "邮箱",
+                    "type": "string"
+                },
+                "HasPermission": {
+                    "description": "true:有权限,false:无权限",
+                    "type": "boolean"
+                },
+                "Headimgurl": {
+                    "description": "用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空",
+                    "type": "string"
+                },
+                "Mobile": {
+                    "description": "手机号码",
+                    "type": "string"
+                },
+                "NickName": {
+                    "description": "用户昵称",
+                    "type": "string"
+                },
+                "PermissionName": {
+                    "description": "拥有权限分类,多个用英文逗号分隔",
+                    "type": "string"
+                },
+                "RealName": {
+                    "description": "用户实际名称",
+                    "type": "string"
+                }
+            }
+        },
         "models.WxGetPhoneNumberReq": {
             "title": "WxGetPhoneNumberReq",
             "type": "object",
@@ -265,5 +501,15 @@
                 }
             }
         }
-    }
+    },
+    "tags": [
+        {
+            "name": "user",
+            "description": "用户\n"
+        },
+        {
+            "name": "permission",
+            "description": "品种\n"
+        }
+    ]
 }

+ 173 - 0
swagger/swagger.yml

@@ -11,6 +11,76 @@ info:
     url: http://www.apache.org/licenses/LICENSE-2.0.html
 basePath: /api
 paths:
+  /home/list:
+    get:
+      tags:
+      - home
+      description: 首页列表接口
+      operationId: HomeController.首页列表接口
+      parameters:
+      - in: query
+        name: PageSize
+        description: 每页数据条数
+        required: true
+        type: integer
+        format: int64
+      - in: query
+        name: CurrentIndex
+        description: 当前页页码,从1开始
+        required: true
+        type: integer
+        format: int64
+      - in: query
+        name: ChartPermissionId
+        description: 品类id,最新传0
+        required: true
+        type: integer
+        format: int64
+      responses:
+        "200":
+          description: ""
+          schema:
+            $ref: '#/definitions/models.HomeList'
+  /permission/all:
+    get:
+      tags:
+      - permission
+      description: 获取用户详情接口
+      operationId: ChartPermissionController.获取所有品种
+      responses:
+        "200":
+          description: ""
+          schema:
+            $ref: '#/definitions/models.ChartPermissionResp'
+  /user/detail:
+    get:
+      tags:
+      - user
+      description: 获取用户详情接口
+      operationId: UserController.获取用户详情
+      responses:
+        "200":
+          description: ""
+          schema:
+            $ref: '#/definitions/models.UserDetail'
+  /user/login:
+    post:
+      tags:
+      - user
+      description: 登录接口
+      operationId: UserController.登录
+      parameters:
+      - in: body
+        name: request
+        description: type json string
+        required: true
+        schema:
+          $ref: '#/definitions/models.LoginReq'
+      responses:
+        "200":
+          description: ""
+          schema:
+            $ref: '#/definitions/models.LoginResp'
   /wechat/getEmailCode:
     get:
       tags:
@@ -100,6 +170,102 @@ paths:
           schema:
             $ref: '#/definitions/models.WxLoginResp'
 definitions:
+  models.ChartPermission:
+    title: ChartPermission
+    type: object
+    properties:
+      ChartPermissionId:
+        description: 权限id
+        type: integer
+        format: int64
+      PermissionName:
+        description: 权限名称
+        type: string
+  models.ChartPermissionResp:
+    title: ChartPermissionResp
+    type: object
+    properties:
+      List:
+        type: array
+        items:
+          $ref: '#/definitions/models.ChartPermission'
+  models.HomeList:
+    title: HomeList
+    type: object
+  models.LoginReq:
+    title: LoginReq
+    type: object
+    properties:
+      Email:
+        description: 邮箱
+        type: string
+      LoginType:
+        description: 登录方式:1:手机,2:邮箱
+        type: integer
+        format: int64
+      Mobile:
+        description: 手机号
+        type: string
+  models.LoginResp:
+    title: LoginResp
+    type: object
+    properties:
+      Authorization:
+        description: Token
+        type: string
+      CompanyName:
+        description: 客户名称
+        type: string
+      Email:
+        description: 邮箱
+        type: string
+      EndDate:
+        description: 到期日期
+        type: string
+      Headimgurl:
+        description: 用户头像
+        type: string
+      Mobile:
+        description: 手机号
+        type: string
+      ProductName:
+        description: 客户类型名称
+        type: string
+      Status:
+        description: 状态
+        type: string
+      UserId:
+        description: 用户id
+        type: integer
+        format: int64
+  models.UserDetail:
+    title: UserDetail
+    type: object
+    properties:
+      CompanyName:
+        description: 公司名称
+        type: string
+      Email:
+        description: 邮箱
+        type: string
+      HasPermission:
+        description: true:有权限,false:无权限
+        type: boolean
+      Headimgurl:
+        description: 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空
+        type: string
+      Mobile:
+        description: 手机号码
+        type: string
+      NickName:
+        description: 用户昵称
+        type: string
+      PermissionName:
+        description: 拥有权限分类,多个用英文逗号分隔
+        type: string
+      RealName:
+        description: 用户实际名称
+        type: string
   models.WxGetPhoneNumberReq:
     title: WxGetPhoneNumberReq
     type: object
@@ -182,3 +348,10 @@ definitions:
       UserId:
         type: integer
         format: int64
+tags:
+- name: user
+  description: |
+    用户
+- name: permission
+  description: |
+    品种

+ 1 - 1
utils/constants.go

@@ -19,7 +19,7 @@ const (
 )
 
 const (
-	APPNAME          = "弘则-查研观"
+	APPNAME          = "弘则-查研观"
 	EmailSendToUsers = "glji@hzinsights.com"
 )