Browse Source

add:增加权限研报校验

zqbao 9 months ago
parent
commit
be082769ea

+ 1 - 0
.gitignore

@@ -5,3 +5,4 @@
 *.exe~
 go.sum
 
+conf/app.conf

+ 62 - 0
controllers/chart.go

@@ -0,0 +1,62 @@
+package controllers
+
+import (
+	"eta/eta_mini_bridge/models"
+	"eta/eta_mini_bridge/models/response"
+	"eta/eta_mini_bridge/utils"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+type ChartController struct {
+	BaseAuthController
+}
+
+// @Title List
+// @Description create users
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.BaseResponse
+// @Failure 403 {object} models.BaseResponse
+// @router /list [get]
+func (this *ChartController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize2
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	total, err := models.GetChartCount()
+	if err != nil {
+		br.Msg = "获取图表列表失败"
+		br.ErrMsg = "获取图表列表失败,系统错误,Err:" + err.Error()
+		return
+	}
+	chartList, err := models.GetChartList(startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取图表列表失败"
+		br.ErrMsg = "获取图表列表失败,系统错误,Err:" + err.Error()
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(response.ChartListResp)
+	resp.List = chartList
+	resp.Paging = page
+
+	br.Ret = 200
+	br.Msg = "获取图表列表成功"
+	br.Success = true
+	br.Data = resp
+
+}

+ 81 - 5
controllers/report.go

@@ -5,6 +5,7 @@ import (
 	"eta/eta_mini_bridge/models/response"
 	"eta/eta_mini_bridge/utils"
 	"html"
+	"strconv"
 
 	"github.com/rdlucklib/rdluck_tools/paging"
 )
@@ -15,7 +16,11 @@ type ReportController struct {
 
 // @Title List
 // @Description create users
-// @Param	body		body 	models.User	true		"body for user content"
+// @Param   ChartPermissionId   query   int  true       "品种ID"
+// @Param   Level   query   int  true       "品种层级"
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   RangeType   query   string  true       "范围类型,1-一天内,2-一周内,3-半年内"
 // @Success 200 {int} models.User.Id
 // @Failure 403 body is empty
 // @router /list [get]
@@ -30,11 +35,21 @@ func (this *ReportController) List() {
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	chartPermissionId, _ := this.GetInt("ChartPermissionId")
 	level, _ := this.GetInt("Level")
+	rangeType, _ := this.GetInt("RangeType")
 
 	if chartPermissionId <= 0 {
 		br.Msg = "品种参数错误"
 		return
 	}
+	var condition string
+	switch rangeType {
+	case 1:
+		condition += ` AND DATE(a.modify_time)=DATE(NOW()) `
+	case 2:
+		condition += ` AND DATE(a.modify_time) BETWEEN DATE_SUB(NOW(),INTERVAL 1 WEEK) AND NOW() `
+	case 3:
+		condition += ` AND DATE(a.modify_time) BETWEEN DATE_SUB(NOW(),INTERVAL 6 MONTH) AND NOW() `
+	}
 
 	var startSize int
 	if pageSize <= 0 {
@@ -55,14 +70,14 @@ func (this *ReportController) List() {
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
-		tmptotal, err := models.GetReportCountByClassifyIds(classifyIds)
+		tmptotal, err := models.GetReportCountByClassifyIds(classifyIds, condition)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
 		total = tmptotal
-		tmpReportList, err := models.GetReportListByClassifyIds(classifyIds, startSize, pageSize)
+		tmpReportList, err := models.GetReportListByClassifyIds(classifyIds, condition, startSize, pageSize)
 		if err != nil {
 			br.Msg = "获取报告列表失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -82,14 +97,14 @@ func (this *ReportController) List() {
 			br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
 			return
 		}
-		tmptotal, err := models.GetReportCountByClassifyIds(classifyIds)
+		tmptotal, err := models.GetReportCountByClassifyIds(classifyIds, condition)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
 		total = tmptotal
-		tmpReportList, err := models.GetReportListByClassifyIds(classifyIds, startSize, pageSize)
+		tmpReportList, err := models.GetReportListByClassifyIds(classifyIds, condition, startSize, pageSize)
 		if err != nil {
 			br.Msg = "获取报告列表失败"
 			br.ErrMsg = "获取报告列表失败,Err:" + err.Error()
@@ -115,6 +130,7 @@ func (this *ReportController) List() {
 // @Title 日评详情
 // @Description 日评详情接口
 // @Param   ReportId   query   int  true       "报告id"
+// @Param   UserId   query   int  true       "用户id"
 // @Success 200 {object} models.ReportDetailResp
 // @router /detail [get]
 func (this *ReportController) Detail() {
@@ -124,6 +140,7 @@ func (this *ReportController) Detail() {
 		this.ServeJSON()
 	}()
 	reportId, err := this.GetInt("ReportId")
+	userId, err := this.GetInt("UserId")
 	if err != nil {
 		br.Msg = "参数获取失败"
 		br.ErrMsg = "参数获取失败,Err:" + err.Error()
@@ -134,6 +151,11 @@ func (this *ReportController) Detail() {
 		br.ErrMsg = "参数错误,报告id小于等于0"
 		return
 	}
+	if userId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误,用户id小于等于0"
+		return
+	}
 
 	report, err := models.GetReportById(reportId)
 	if err != nil {
@@ -146,6 +168,60 @@ func (this *ReportController) Detail() {
 		br.Msg = "报告不存在"
 		return
 	}
+	reportChartPermissionIds, err := models.GetChartPermissionIdsListByClassifyId(report.ClassifyIdSecond)
+	if err != nil {
+		br.Msg = "获取研报权限失败"
+		br.ErrMsg = "获取研报权限失败,Err:" + err.Error()
+		return
+	}
+	chartPermissionList, err := models.GetChartPermissionIdsByIds(reportChartPermissionIds)
+	if err != nil {
+		br.Msg = "获取研报权限失败"
+		br.ErrMsg = "获取研报权限失败,Err:" + err.Error()
+		return
+	}
+	var IsHas bool
+	var IsPublic bool
+	for _, v := range chartPermissionList {
+		if v.IsPublic == 1 {
+			IsPublic = true
+			break
+		}
+	}
+
+	if !IsPublic {
+		chartPermissionIds, err := models.GetChartPermissionIdByUserId(userId)
+		if err != nil {
+			br.Msg = "获取用户权限失败"
+			br.ErrMsg = "获取用户权限失败,Err:" + err.Error()
+			return
+		}
+		if len(chartPermissionIds) <= 0 {
+			br.Msg = "用户权限不足"
+			return
+		}
+		classifyIds, err := models.GetClassifyIdsListByIds(chartPermissionIds)
+		if err != nil {
+			br.Msg = "获取用户权限失败"
+			br.ErrMsg = "获取用户分类权限失败,Err:" + err.Error()
+			return
+		}
+		if len(classifyIds) <= 0 {
+			br.Msg = "用户权限不足"
+			return
+		}
+		reportClassifyIdStr := strconv.Itoa(report.ClassifyIdSecond)
+		for _, v := range classifyIds {
+			if v == reportClassifyIdStr {
+				IsHas = true
+			}
+		}
+		if !IsHas {
+			br.Msg = "用户权限不足"
+			return
+		}
+	}
+
 	report.ContentSub = html.UnescapeString(report.ContentSub)
 	report.Content = html.UnescapeString(report.Content)
 

+ 97 - 0
models/chart.go

@@ -0,0 +1,97 @@
+package models
+
+import (
+	"time"
+
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type ChartInfoView struct {
+	ChartInfoId       int    `orm:"column(chart_info_id);pk"`
+	ChartName         string `description:"来源名称"`
+	ChartNameEn       string `description:"英文图表名称"`
+	Unit              string `description:"中文单位名称"`
+	UnitEn            string `description:"英文单位名称"`
+	ChartClassifyId   int    `description:"图表分类id"`
+	ChartClassifyName string `description:"图表名称"`
+	SysUserId         int
+	SysUserRealName   string
+	UniqueCode        string `description:"图表唯一编码"`
+	CreateTime        time.Time
+	ModifyTime        time.Time
+	DateType          int    `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
+	StartDate         string `description:"自定义开始日期"`
+	EndDate           string `description:"自定义结束日期"`
+	IsSetName         int    `description:"设置名称"`
+	EdbInfoIds        string `description:"指标id"`
+	ChartType         int    `description:"生成样式:1:曲线图,2:季节性图"`
+	Calendar          string `description:"公历/农历"`
+	SeasonStartDate   string `description:"季节性图开始日期"`
+	SeasonEndDate     string `description:"季节性图开始日期"`
+	ChartImage        string `description:"图表图片"`
+	Sort              int    `description:"排序字段,数字越小越排前面"`
+	IsAdd             bool   `description:"true:已加入我的图库,false:未加入我的图库"`
+	MyChartId         int
+	MyChartClassifyId string `description:"我的图表分类,多个用逗号隔开"`
+	ChartClassify     []*ChartClassifyView
+	EdbEndDate        string `description:"指标最新更新日期"`
+	XMin              string `description:"图表X轴最小值"`
+	XMax              string `description:"图表X轴最大值"`
+	LeftMin           string `description:"图表左侧最小值"`
+	LeftMax           string `description:"图表左侧最大值"`
+	RightMin          string `description:"图表右侧最小值"`
+	RightMax          string `description:"图表右侧最大值"`
+	Right2Min         string `description:"图表右侧最小值"`
+	Right2Max         string `description:"图表右侧最大值"`
+	MinMaxSave        int    `description:"是否手动保存过上下限:0-否;1-是"`
+	IsEdit            bool   `description:"是否有编辑权限"`
+	IsEnChart         bool   `description:"是否展示英文标识"`
+	WarnMsg           string `description:"错误信息"`
+	Disabled          int    `description:"是否禁用,0:启用,1:禁用,默认:0"`
+	BarConfig         string `description:"柱方图的配置,json数据" json:"-"`
+	Source            int    `description:"1:ETA图库;2:商品价格曲线;3:相关性图表"`
+	//CorrelationLeadUnit string `description:"相关性图表-领先单位"`
+	ExtraConfig       string          `description:"图表额外配置,json数据"`
+	ChartSource       string          `description:"图表来源str"`
+	ChartSourceEn     string          `description:"图表来源(英文)"`
+	Button            ChartViewButton `description:"操作按钮"`
+	SeasonExtraConfig string          `description:"季节性图表中的配置,json数据"`
+	StartYear         int             `description:"当选择的日期类型为最近N年类型时,即date_type=20, 用start_year表示N"`
+	ChartThemeId      int             `description:"图表应用主题ID"`
+	ChartThemeStyle   string          `description:"图表应用主题样式"`
+	SourcesFrom       string          `description:"图表来源"`
+	Instructions      string          `description:"图表说明"`
+	MarkersLines      string          `description:"标识线"`
+	MarkersAreas      string          `description:"标识区"`
+	IsJoinPermission  int             `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
+	HaveOperaAuth     bool            `description:"是否有数据权限,默认:false"`
+	ForumChartInfoId  int             `description:"社区的图表ID"`
+}
+
+type ChartClassifyView struct {
+	ChartClassifyId   int    `orm:"column(chart_classify_id);pk"`
+	ChartClassifyName string `description:"分类名称"`
+	ParentId          int    `description:"父级id"`
+}
+
+type ChartViewButton struct {
+	IsEdit    bool `description:"是否有编辑权限"`
+	IsEnChart bool `description:"是否展示英文标识"`
+	IsAdd     bool `description:"true:已加入我的图库,false:未加入我的图库"`
+	IsCopy    bool `description:"是否有另存为按钮"`
+	IsSetName int  `description:"设置名称"`
+}
+
+func GetChartCount() (count int, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT COUNT(*) AS count FROM chart_info WHERE 1=1 `
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
+func GetChartList(startSize, pageSize int) (item []*ChartInfoView, err error) {
+	o := orm.NewOrmUsingDB("data")
+	sql := ` SELECT * FROM chart_info WHERE 1=1  ORDER BY modify_time DESC LIMIT ?,? `
+	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&item)
+	return
+}

+ 38 - 24
models/chart_permission.go

@@ -3,36 +3,37 @@ package models
 import (
 	"eta/eta_mini_bridge/utils"
 	"fmt"
+	"strings"
 	"time"
 
 	"github.com/beego/beego/v2/client/orm"
 )
 
 type ChartPermission struct {
-	ChartPermissionId     int       `orm:"column(chart_permission_id);pk" description:"问题ID" json:"chart_permission_id"`
-	ChartPermissionName   string    `description:"名称" json:"chart_permission_name"`
-	PermissionName        string    `description:"权限名" json:"permission_name"`
-	Sort                  int       `description:"排序" json:"sort"`
-	Enabled               int       `description:"是否可用" json:"enabled"`
-	CreatedTime           time.Time `description:"创建时间" json:"created_time"`
-	LastUpdatedTime       time.Time `description:"更新时间" json:"last_updated_time"`
-	TeleconferenceSort    int       `description:"电话会类型排序" json:"teleconference_sort"`
-	Remark                string    `description:"备注" json:"remark"`
-	ClassifyName          string    `description:"分类名称" json:"classify_name"`
-	ProductName           string    `description:"产品名称" json:"product_name"`
-	ProductId             int       `description:"产品ID" json:"product_id"`
-	ImageURL              string    `orm:"column(image_url);" description:"图片地址" json:"image_url"`
-	ShowType              int       `description:"1:查研观向小程序展示" json:"show_type"`
-	IsOther               int       `description:"是否是其他,用于查研观向小程序后台展示" json:"is_other"`
-	IsReport              int       `description:"是否是报告,用于查研观向小程序前台报告展示" json:"is_report"`
-	CygxAuth              int       `description:"是否是权限,用于查研观向小程序前台权限校验" json:"cygx_auth"`
-	PermissionType        int       `description:"1主观,2客观" json:"permission_type"`
-	YbImgUrl              string    `description:"研报小程序报告列表icon" json:"yb_img_url"`
-	ProductPermissionName string    `description:"种类权限名称" json:"product_permission_name"`
-	PriceDrivenState      int       `description:"品种价格驱动开启状态 0-关闭 1-开启" json:"price_driven_state"`
-	ImageUrlM             string    `description:"图片地址(查研观向移动端)" json:"image_url_m"`
-	ParentId              int       `description:"父级权限id" json:"parent_id"`
-	IsPublic              int       `description:"是否是公有权限1:公有权限,0私有权限" json:"is_public"`
+	ChartPermissionId     int       `orm:"column(chart_permission_id);pk" description:"问题ID"`
+	ChartPermissionName   string    `description:"名称"`
+	PermissionName        string    `description:"权限名"`
+	Sort                  int       `description:"排序"`
+	Enabled               int       `description:"是否可用"`
+	CreatedTime           time.Time `description:"创建时间"`
+	LastUpdatedTime       time.Time `description:"更新时间"`
+	TeleconferenceSort    int       `description:"电话会类型排序"`
+	Remark                string    `description:"备注"`
+	ClassifyName          string    `description:"分类名称"`
+	ProductName           string    `description:"产品名称" `
+	ProductId             int       `description:"产品ID"`
+	ImageURL              string    `orm:"column(image_url);" description:"图片地址"`
+	ShowType              int       `description:"1:查研观向小程序展示"`
+	IsOther               int       `description:"是否是其他,用于查研观向小程序后台展示"`
+	IsReport              int       `description:"是否是报告,用于查研观向小程序前台报告展示"`
+	CygxAuth              int       `description:"是否是权限,用于查研观向小程序前台权限校验"`
+	PermissionType        int       `description:"1主观,2客观"`
+	YbImgUrl              string    `description:"研报小程序报告列表icon"`
+	ProductPermissionName string    `description:"种类权限名称"`
+	PriceDrivenState      int       `description:"品种价格驱动开启状态 0-关闭 1-开启"`
+	ImageUrlM             string    `description:"图片地址(查研观向移动端)"`
+	ParentId              int       `description:"父级权限id"`
+	IsPublic              int       `description:"是否是公有权限1:公有权限,0私有权限"`
 }
 
 // GetChildChartPermissionListById 获取品种权限列表
@@ -51,6 +52,19 @@ func GetChildChartPermissionListById(chartPermissionId int) (items []*ChartPermi
 	return
 }
 
+// GetChartPermissionListById 获取品种权限列表
+func GetChartPermissionIdsByIds(chartPermissionIds []string) (items []*ChartPermission, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := `SELECT chart_permission_id FROM chart_permission WHERE enabled=1 `
+	if len(chartPermissionIds) > 0 {
+		sql += fmt.Sprintf(" AND chart_permission_id IN (%s) ", strings.Join(chartPermissionIds, ","))
+	}
+	sql += ` ORDER BY sort ASC `
+
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // GetChildChartPermissionListById 获取品种权限列表
 func GetChildChartPermissionIdsById(chartPermissionId int) (items []string, err error) {
 	o := orm.NewOrmUsingDB("rddp")

+ 9 - 0
models/chart_permission_search_key_word_mapping.go

@@ -15,6 +15,15 @@ func GetClassifyIdsListById(chartPermissionId int) (classifyIds []string, err er
 	return
 }
 
+func GetChartPermissionIdsListByClassifyId(classifyId int) (chartPermissionIds []string, err error) {
+	o := orm.NewOrmUsingDB("rddp")
+	sql := ` SELECT chart_permission_id
+		FROM chart_permission_search_key_word_mapping	
+		WHERE classify_id = ? `
+	_, err = o.Raw(sql, classifyId).QueryRows(&chartPermissionIds)
+	return
+}
+
 func GetClassifyIdsListByIds(chartPermissionIds []string) (classifyIds []string, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	sql := ` SELECT classify_id

+ 11 - 4
models/db.go

@@ -16,11 +16,18 @@ func init() {
 	report_db, _ := orm.GetDB("rddp")
 	report_db.SetConnMaxLifetime(10 * time.Minute)
 
-	_ = orm.RegisterDataBase("master", "mysql", utils.MYSQL_URL_MASTER)
-	orm.SetMaxIdleConns("master", 50)
-	orm.SetMaxOpenConns("master", 100)
+	_ = orm.RegisterDataBase("data", "mysql", utils.MYSQL_URL_DATA)
+	orm.SetMaxIdleConns("data", 50)
+	orm.SetMaxOpenConns("data", 100)
 
-	master_db, _ := orm.GetDB("master")
+	data_db, _ := orm.GetDB("data")
+	data_db.SetConnMaxLifetime(10 * time.Minute)
+
+	_ = orm.RegisterDataBase("default", "mysql", utils.MYSQL_URL_MASTER)
+	orm.SetMaxIdleConns("default", 50)
+	orm.SetMaxOpenConns("default", 100)
+
+	master_db, _ := orm.GetDB("default")
 	master_db.SetConnMaxLifetime(10 * time.Minute)
 
 	orm.Debug = true

+ 13 - 6
models/report.go

@@ -86,20 +86,23 @@ func GetReportListByIds(reportIds []string, startSize, pageSize int) (items []*R
 	return
 }
 
-func GetReportCountByClassifyIds(classifyIds []string) (count int, err error) {
+func GetReportCountByClassifyIds(classifyIds []string, condition string) (count int, err error) {
 	o := orm.NewOrmUsingDB("rddp")
-	sql := `SELECT  COUNT(*) AS count  FROM report
-			WHERE state=2 AND classify_id_second IN (%s) `
+	sql := `SELECT  COUNT(*) AS count  FROM report AS a
+			WHERE a.state=2 AND a.classify_id_second IN (%s) `
 	var reportIdsStr string
 	if len(classifyIds) > 0 {
 		reportIdsStr = strings.Join(classifyIds, ",")
 		sql = fmt.Sprintf(sql, reportIdsStr)
 	}
+	if condition != "" {
+		sql += condition
+	}
 	err = o.Raw(sql).QueryRow(&count)
 	return
 }
 
-func GetReportListByClassifyIds(classifyIds []string, startSize, pageSize int) (items []*ReportList, err error) {
+func GetReportListByClassifyIds(classifyIds []string, condition string, startSize, pageSize int) (items []*ReportList, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	sql := `SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,
 			a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript,
@@ -107,13 +110,17 @@ func GetReportListByClassifyIds(classifyIds []string, startSize, pageSize int) (
             CASE WHEN DATE(a.modify_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
             FROM report AS a
 			INNER JOIN  classify AS b ON a.classify_id_second=b.id
-			WHERE a.state=2 AND a.classify_id_second IN (%s) 
-			ORDER BY  a.publish_time DESC LIMIT ?,? `
+			WHERE a.state=2 AND a.classify_id_second IN (%s) `
+
 	var reportIdsStr string
 	if len(classifyIds) > 0 {
 		reportIdsStr = strings.Join(classifyIds, ",")
 		sql = fmt.Sprintf(sql, reportIdsStr)
 	}
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY  a.publish_time DESC LIMIT ?,? `
 	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
 	return
 }

+ 12 - 0
models/response/chart.go

@@ -0,0 +1,12 @@
+package response
+
+import (
+	"eta/eta_mini_bridge/models"
+
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+type ChartListResp struct {
+	List   []*models.ChartInfoView
+	Paging *paging.PagingItem
+}

+ 5 - 5
models/user.go

@@ -27,7 +27,7 @@ type User struct {
 }
 
 func (u *User) Insert() (insertId int64, err error) {
-	o := orm.NewOrmUsingDB("master")
+	o :=orm.NewOrm()
 	insertId, err = o.Insert(u)
 	return
 }
@@ -53,21 +53,21 @@ type UserItem struct {
 
 // 变更联系人是否已注册状态
 func ModifyUserRegisterStatus(userId int, status bool, registerTime, modifyTime time.Time) (err error) {
-	o := orm.NewOrmUsingDB("master")
+	o :=orm.NewOrm()
 	sql := `UPDATE user SET is_registered=?, register_time=?, modify_time=? WHERE user_id = ? `
 	_, err = o.Raw(sql, status, registerTime, modifyTime, userId).Exec()
 	return
 }
 
 func GetUserById(userId int) (item *User, err error) {
-	o := orm.NewOrmUsingDB("master")
+	o :=orm.NewOrm()
 	sql := `SELECT * FROM user WHERE user_id=? `
 	err = o.Raw(sql, userId).QueryRow(&item)
 	return
 }
 
 func GetUserList(condition string, pars []interface{}) (items []*User, err error) {
-	o := orm.NewOrmUsingDB("master")
+	o :=orm.NewOrm()
 	sql := `SELECT * FROM user WHERE 1=1 `
 	if condition != "" {
 		sql += condition
@@ -77,7 +77,7 @@ func GetUserList(condition string, pars []interface{}) (items []*User, err error
 }
 
 func GetUserItemByPhone(phone string) (item *UserItem, err error) {
-	o := orm.NewOrmUsingDB("master")
+	o :=orm.NewOrm()
 	sql := `SELECT * FROM user WHERE phone=? `
 	err = o.Raw(sql, phone).QueryRow(&item)
 	return

+ 2 - 2
models/user_chart_permission_mapping.go

@@ -8,8 +8,8 @@ type UserChartPermissionMapping struct {
 	ChartPermissionId            int `description:"品种id"`
 }
 
-func GetChartPermissionIdByUserId(UserId int) (items []int, err error) {
-	o := orm.NewOrmUsingDB("master")
+func GetChartPermissionIdByUserId(UserId int) (items []string, err error) {
+	o := orm.NewOrm()
 	sql := `SELECT chart_permission_id FROM user_chart_permission_mapping WHERE user_id=?`
 	_, err = o.Raw(sql, UserId).QueryRows(&items)
 	return

+ 1 - 1
models/user_template_record.go

@@ -15,7 +15,7 @@ type UserTemplateRecord struct {
 }
 
 func (u *UserTemplateRecord) Insert() (err error) {
-	o := orm.NewOrmUsingDB("master")
+	o := orm.NewOrm()
 	_, err = o.Insert(u)
 	return
 }

+ 2 - 2
models/wx_token.go

@@ -12,14 +12,14 @@ type WxToken struct {
 
 // Update 更新对应字段数据
 func (w *WxToken) Update(cols []string) (err error) {
-	o := orm.NewOrmUsingDB("master")
+	o := orm.NewOrm()
 	_, err = o.Update(w, cols...)
 	return
 }
 
 // GetById 根据id获取accessToken信息
 func GetWxTokenById() (info WxToken, err error) {
-	o := orm.NewOrmUsingDB("master")
+	o := orm.NewOrm()
 	sql := `SELECT * FROM wx_token WHERE id = ?`
 	err = o.Raw(sql, 0).QueryRow(&info)
 	return

+ 9 - 0
routers/commentsRouter.go

@@ -7,6 +7,15 @@ import (
 
 func init() {
 
+    beego.GlobalControllerRouter["eta/eta_mini_bridge/controllers:ChartController"] = append(beego.GlobalControllerRouter["eta/eta_mini_bridge/controllers:ChartController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_mini_bridge/controllers:ChartPermissionController"] = append(beego.GlobalControllerRouter["eta/eta_mini_bridge/controllers:ChartPermissionController"],
         beego.ControllerComments{
             Method: "AllList",

+ 5 - 0
routers/router.go

@@ -33,6 +33,11 @@ func init() {
 				&controllers.ChartPermissionController{},
 			),
 		),
+		web.NSNamespace("/chart",
+			web.NSInclude(
+				&controllers.ChartController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 2 - 0
utils/config.go

@@ -12,6 +12,7 @@ var (
 	RunMode          string // 运行模式
 	MYSQL_URL_MASTER string // 数据库地址
 	MYSQL_URL_RDDP   string // 数据库地址
+	MYSQL_URL_DATA   string
 
 	REDIS_CACHE string      //缓存地址
 	Rc          RedisClient //redis缓存
@@ -62,6 +63,7 @@ func init() {
 	// 数据库配置
 	MYSQL_URL_RDDP = config["mysql_url_rddp"]
 	MYSQL_URL_MASTER = config["mysql_url_master"]
+	MYSQL_URL_DATA = config["mysql_url_data"]
 
 	// 微信配置
 	WX_MINI_APPID = config["wx_mini_appid"]

+ 1 - 0
utils/constants.go

@@ -9,6 +9,7 @@ const (
 	FormatDateTimeUnSpace = "20060102150405"          //完整时间格式
 	PageSize15            = 15                        //列表页每页数据量
 	PageSize5             = 5
+	PageSize2             = 2
 	PageSize10            = 10
 	PageSize20            = 20
 	PageSize30            = 30