浏览代码

feat(新增数据表注册)

Roc 4 年之前
父节点
当前提交
62ad064bf2

+ 2 - 2
controllers/approval.go

@@ -317,7 +317,7 @@ func (this *ApprovalCommon) GetApprovalPermissionList() {
 // @Description 审批接口
 // @Param	request	body approval.CompanyApplyApproveReq true "type json string"
 // @Success Ret=200 审批成功
-// @router /approval/approve [post]
+// @router /approve [post]
 func (this *ApprovalCommon) ApplyApprove() {
 	sysUser := this.AdminWx
 	var req approval2.CompanyApplyApproveReq
@@ -488,7 +488,7 @@ func (this *ApprovalCommon) ApplyApprove() {
 			go services.AddCompanyApprovalMessage(sysUser.AdminId, approvalItem.ApplyUserId, req.CompanyId, approvalItem.CompanyApprovalId, 2, companyProduct.CompanyName, content, content, approvalSysUser.Mobile)
 		}
 	}
-	this.OkWithMessage("审批成功")
+	this.OkWithMessage("审批操作成功")
 }
 
 //// @Title 审批列表删除

+ 3 - 2
controllers/base_auth.go

@@ -27,12 +27,13 @@ func (this *BaseAuth) Prepare() {
 	} else {
 		requestBody, _ = url.QueryUnescape(string(this.Ctx.Input.RequestBody))
 	}
+	authorization := this.Ctx.Input.Header("Authorization")
+
 	fmt.Println("requestBody:", requestBody)
 	ip := this.Ctx.Input.IP()
 	fmt.Println("ip:", ip)
-	apiLog.Println("请求地址:", this.Ctx.Input.URI(), "RequestBody:", requestBody, "IP:", ip)
 
-	authorization := this.Ctx.Input.Header("Authorization")
+	//apiLog.Println("请求地址:", this.Ctx.Input.URI(), "RequestBody:", requestBody, "IP:", ip, ";authorization:", authorization)
 	//if authorization == "" {
 	//	cookie := this.Ctx.GetCookie("rddp_access_token")
 	//	utils.FileLog.Info("authorization:%s,cookie:%s", authorization, cookie)

+ 14 - 0
controllers/base_common.go

@@ -1,8 +1,11 @@
 package controllers
 
 import (
+	"encoding/json"
+	"fmt"
 	"github.com/astaxie/beego"
 	"hongze/hongze_mobile_admin/utils"
+	"net/url"
 	"rdluck_tools/log"
 )
 
@@ -40,6 +43,17 @@ const (
 
 //返回数据
 func (this BaseCommon) Result() {
+	var content []byte
+	var err error
+	content, err = json.Marshal(this.Response)
+	ip := this.Ctx.Input.IP()
+	requestBody, err := url.QueryUnescape(string(this.Ctx.Input.RequestBody))
+	if err != nil {
+		fmt.Println("base auth url.QueryUnescape Err:", err.Error())
+		requestBody = string(this.Ctx.Input.RequestBody)
+	}
+	apiLog.Println("请求地址:", this.Ctx.Input.URI(), "Authorization:", this.Ctx.Input.Header("Authorization"), "RequestBody:", requestBody, "ResponseBody", string(content), "IP:", ip)
+
 	this.Controller.Data["json"] = this.Response
 	this.Controller.ServeJSON()
 	this.StopRun()

+ 1 - 1
controllers/base_not_auth.go

@@ -23,7 +23,7 @@ func (this *BaseNotAuth) Prepare() {
 	fmt.Println("requestBody:", requestBody)
 	ip := this.Ctx.Input.IP()
 	fmt.Println("ip:", ip)
-	apiLog.Println("请求地址:", this.Ctx.Input.URI(), "RequestBody:", requestBody, "IP:", ip)
+	//apiLog.Println("请求地址:", this.Ctx.Input.URI(), "RequestBody:", requestBody, "IP:", ip)
 
 	authorization := this.Ctx.Input.Header("Authorization")
 	if authorization == "" {

+ 0 - 11
controllers/wechat.go

@@ -7,7 +7,6 @@ import (
 	"hongze/hongze_mobile_admin/services"
 	"hongze/hongze_mobile_admin/utils"
 	"strconv"
-	"time"
 )
 
 type WeChatCommon struct {
@@ -77,13 +76,3 @@ func (this *WeChatCommon) WeChatLogin() {
 
 	this.OkDetailed(resp, "登录成功")
 }
-
-// @Title test
-// @Description test
-// @Success 200 {string} string "{"code":0,"data":{"Id":9},"msg":"操作成功"}"
-// @Failure 403 body is empty
-// @router /test [get]
-func (this *BaseNotAuth) Test() {
-	time.Sleep(time.Second * 5)
-	this.OkWithData(1)
-}

+ 22 - 1
models/db_init.go

@@ -5,12 +5,18 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/admin"
 	"hongze/hongze_mobile_admin/models/tables/admin_record"
 	"hongze/hongze_mobile_admin/models/tables/company_approval"
+	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
 	"hongze/hongze_mobile_admin/models/tables/company_contract"
 	"hongze/hongze_mobile_admin/models/tables/company_delay_permission"
+	"hongze/hongze_mobile_admin/models/tables/company_operation_record"
 	"hongze/hongze_mobile_admin/models/tables/company_permission_log"
+	"hongze/hongze_mobile_admin/models/tables/company_product"
+	"hongze/hongze_mobile_admin/models/tables/company_product_log"
 	"hongze/hongze_mobile_admin/models/tables/company_report_permission"
 	"hongze/hongze_mobile_admin/models/tables/h5_admin_session"
+	"hongze/hongze_mobile_admin/models/tables/report"
 	"hongze/hongze_mobile_admin/models/tables/wx_token"
+	"hongze/hongze_mobile_admin/models/tables/wx_user"
 	"hongze/hongze_mobile_admin/utils"
 	"rdluck_tools/orm"
 	"time"
@@ -24,16 +30,31 @@ func InitDb() {
 	db, _ := orm.GetDB("default")
 	db.SetConnMaxLifetime(10 * time.Minute)
 
+	//rddp数据库
+	_ = orm.RegisterDataBase("rddp", "mysql", utils.MYSQL_URL_RDDP)
+	orm.SetMaxIdleConns("rddp", 50)
+	orm.SetMaxOpenConns("rddp", 100)
+
+	report_db, _ := orm.GetDB("rddp")
+	report_db.SetConnMaxLifetime(10 * time.Minute)
+
 	//注册对象
 	orm.RegisterModel(
 		new(admin.Admin),
 		new(admin_record.AdminRecord),
 		new(company_approval.CompanyApproval),
+		new(company_approval_message.CompanyApprovalMessage),
+		new(company_contract.CompanyContract),
 		new(company_delay_permission.CompanyDelayPermission),
+		new(company_operation_record.CompanyOperationRecord),
 		new(company_permission_log.CompanyPermissionLog),
+		new(company_product.CompanyProduct),
+		new(company_product_log.CompanyProductLog),
 		new(company_report_permission.CompanyReportPermission),
 		new(h5_admin_session.H5AdminSession),
 		new(wx_token.WxToken),
-		new(company_contract.CompanyContract),
+		new(wx_user.WxUser),
+		new(report.Report),
 	)
+
 }

+ 0 - 5
models/tables/h5_admin_session/h5_admin_session.go

@@ -18,7 +18,6 @@ type H5AdminSession struct {
 func GetSessionByToken(token string) (item *H5AdminSession, err error) {
 	sql := `SELECT * FROM h5_admin_session WHERE access_token=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()
-	o.Using("rddp")
 	err = o.Raw(sql, token).QueryRow(&item)
 	return
 }
@@ -26,7 +25,6 @@ func GetSessionByToken(token string) (item *H5AdminSession, err error) {
 func GetSessionCountByToken(token string) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM h5_admin_session WHERE access_token=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()
-	o.Using("rddp")
 	err = o.Raw(sql, token).QueryRow(&count)
 	return
 }
@@ -34,7 +32,6 @@ func GetSessionCountByToken(token string) (count int, err error) {
 //添加用户session信息
 func AddSession(item *H5AdminSession) (err error) {
 	o := orm.NewOrm()
-	o.Using("rddp")
 	_, err = o.Insert(item)
 	return
 }
@@ -42,7 +39,6 @@ func AddSession(item *H5AdminSession) (err error) {
 func GetTokenByUid(adminId int) (item *H5AdminSession, err error) {
 	sql := `SELECT * FROM h5_admin_session WHERE admin_id=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()
-	o.Using("rddp")
 	err = o.Raw(sql, adminId).QueryRow(&item)
 	return
 }
@@ -51,7 +47,6 @@ func GetTokenByUid(adminId int) (item *H5AdminSession, err error) {
 func GetTokenByOpenId(openId string) (item *H5AdminSession, err error) {
 	sql := `SELECT * FROM h5_admin_session WHERE open_id=? AND expire_time> NOW() ORDER BY session_id DESC LIMIT 1 `
 	o := orm.NewOrm()
-	o.Using("rddp")
 	err = o.Raw(sql, openId).QueryRow(&item)
 	return
 }

+ 18 - 0
models/tables/wx_user/wx_user.go

@@ -2,8 +2,26 @@ package wx_user
 
 import (
 	"rdluck_tools/orm"
+	"time"
 )
 
+type WxUser struct {
+	UserId           int64 `orm:"column(user_id);pk"`
+	Mobile           string
+	Email            string
+	CompanyId        int
+	RealName         string `description:"姓名"`
+	CreatedTime      time.Time
+	MobileTwo        string `description:"备用手机号"`
+	BusinessCardUrl  string `description:"名片"`
+	IsMaker          int    `description:"是否决策人,1:是,0:否"`
+	Position         string `description:"职位"`
+	Sex              int    `description:"普通用户性别,1为男性,2为女性"`
+	DepartmentName   string `description:"联系人部门"`
+	RegisterTime     time.Time
+	RegisterPlatform int
+}
+
 type OpenIdList struct {
 	OpenId string
 }

+ 4 - 2
utils/config.go

@@ -7,8 +7,9 @@ import (
 )
 
 var (
-	RunMode   string //运行模式
-	MYSQL_URL string //数据库连接
+	RunMode        string //运行模式
+	MYSQL_URL      string //数据库连接
+	MYSQL_URL_RDDP string //数据库连接
 )
 
 //微信配置信息
@@ -31,6 +32,7 @@ func init() {
 	}
 	logs.Info(RunMode + " 模式")
 	MYSQL_URL = config["mysql_url"]
+	MYSQL_URL_RDDP = config["mysql_url_rddp"]
 
 	if RunMode == "release" {
 		WxAppId = "wx4a844c734d8c8e56"