Browse Source

feat:参数调整

wangshan 1 year ago
parent
commit
1989b6314a

+ 3 - 1
api/hello/v1/contract.go → api/hello/v1/personnel.go

@@ -2,7 +2,7 @@ package v1
 
 import "github.com/gogf/gf/v2/frame/g"
 
-type ContractInsertReq struct {
+type PersonnelInsertReq struct {
 	g.Meta      `path:"/statistics" tags:"contract" method:"post" summary:"insert records"`
 	ActionId    string `json:"action_id" dc:"事件ID"`
 	ActionType  string `json:"action_type" dc:"事件类型"`
@@ -14,8 +14,10 @@ type ContractInsertReq struct {
 	PayWay      string `json:"pay_way" dc:"支付方式"`
 	Price       int64  `json:"price" dc:"金额(元)"`
 	Product     string `json:"product" dc:"产品类型"`
+	ProductName string `json:"product_name" dc:"产品类型名称"`
 	PageId      string `json:"page_id" dc:"页面ID"`
 	PageName    string `json:"page_name" dc:"页面名称"`
+	BiddingId   string `json:"bidding_id" dc:"详情页id"`
 	Desc        string `json:"desc" dc:"页面功能简述"`
 	Source      string `json:"source" dc:"来源名称"`
 	ChainName   string `json:"chain_name" v:"required"  dc:"公链名称"`

BIN
gfpb.exe


+ 3 - 6
internal/cmd/cmd.go

@@ -2,13 +2,11 @@ package cmd
 
 import (
 	"context"
-	"personnelBehavior/internal/controller"
-	"personnelBehavior/internal/controller/personnel"
-	"personnelBehavior/internal/utils"
-
 	"github.com/gogf/gf/v2/frame/g"
 	"github.com/gogf/gf/v2/net/ghttp"
 	"github.com/gogf/gf/v2/os/gcmd"
+	"personnelBehavior/internal/controller/personnel"
+	"personnelBehavior/internal/utils"
 )
 
 var (
@@ -19,12 +17,11 @@ var (
 		Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
 			s := g.Server()
 			s.Group("/personnel", func(group *ghttp.RouterGroup) {
-				//group.Middleware(ghttp.MiddlewareHandlerResponse)
 				group.POST("/behavior/statistics", personnel.Statistics)
 				group.Middleware(utils.MiddlewareAuth)
 				group.Middleware(utils.MiddlewareSession)
 				group.Bind(
-					controller.Contract,
+					personnel.Personnel,
 				)
 			})
 			s.Run()

+ 28 - 5
internal/common/common.go

@@ -4,18 +4,41 @@ var (
 	RedisPersonnelTable = "personnel_%s_%s"
 	IsExistsTableSql    = `SELECT count(*) as c FROM system.tables WHERE database = '%s' AND name = '%s'`
 	PersonnelTable      = `CREATE TABLE %s.%s
-							(
-								userid String COMMENT '用户id',
-								create_time DateTime COMMENT '创建时间',
+							(   id Nullable(String) DEFAULT NULL COMMENT '自增id',
+								user_id Nullable(String) DEFAULT NULL COMMENT '用户ID',
+								position_id Nullable(Int64) DEFAULT NULL COMMENT '职位id'
 								phone Nullable(String) DEFAULT NULL COMMENT '手机号',
 								ip Nullable(String) DEFAULT NULL COMMENT '访问IP',
 								platform Nullable(String) DEFAULT NULL COMMENT '平台来源',
 								os Nullable(String) DEFAULT NULL COMMENT '系统',
+								os_version Nullable(String) DEFAULT NULL COMMENT '系统版本',
 								browser Nullable(String) DEFAULT NULL COMMENT '浏览器',
-								position_id Nullable(Int64) DEFAULT NULL COMMENT '职位id'
+								browser_version Nullable(String) DEFAULT NULL COMMENT '浏览器版本',
+								date DateTime COMMENT '访问时间',
+								action_id Nullable(String) DEFAULT NULL COMMENT '事件ID',
+								action_type Nullable(String) DEFAULT NULL COMMENT '事件类型描述',
+								breaker_id Nullable(String) DEFAULT NULL COMMENT '断点ID',
+								breaker_name Nullable(String) DEFAULT NULL COMMENT '断点名称',
+								click_time Nullable(DateTime) DEFAULT NULL COMMENT '点击时间',
+								date Nullable(DateTime) DEFAULT NULL COMMENT '提交时间',
+								order_id Nullable(String) DEFAULT NULL COMMENT '订单编号',
+								order_time Nullable(DateTime) DEFAULT NULL COMMENT '下单时间',
+								pay_time Nullable(DateTime) DEFAULT NULL COMMENT '支付时间',
+								pay_way Nullable(String) DEFAULT NULL COMMENT '支付方式',
+								price Nullable(Int32) DEFAULT NULL COMMENT '金额(元)',
+								product Nullable(String) DEFAULT NULL COMMENT '产品类型',
+								product_name Nullable(String) DEFAULT NULL COMMENT '产品名称',
+								page_id Nullable(String) DEFAULT NULL COMMENT '页面ID',
+								page_name Nullable(String) DEFAULT NULL COMMENT '页面名称',
+    							bidding_id Nullable(String) DEFAULT NULL COMMENT '详情页信息id',
+								desc Nullable(String) DEFAULT NULL COMMENT '页面功能简述',
+								url Nullable(String) DEFAULT NULL COMMENT '页面URL',
+								source Nullable(String) DEFAULT NULL COMMENT '来源名称',
+								user_agent Nullable(String) DEFAULT NULL COMMENT 'header信息'
 							)
 							ENGINE = MergeTree
-							ORDER BY userid
+							ORDER BY date
+							TTL date + toIntervalMonth(3)
 							SETTINGS index_granularity = 8192;`
 	DropTable = "DROP TABLE IF EXISTS %s.%s"
 )

+ 0 - 80
internal/controller/contract.go

@@ -1,80 +0,0 @@
-package controller
-
-import (
-	"app.yhyue.com/moapp/jybase/common"
-	"context"
-	"github.com/gogf/gf/v2/frame/g"
-	v1 "personnelBehavior/api/hello/v1"
-	"personnelBehavior/internal/model"
-	"personnelBehavior/internal/service"
-	"personnelBehavior/internal/utils"
-	"time"
-)
-
-var (
-	Contract = contract{}
-)
-
-type contract struct{}
-
-func (c *contract) Insert(ctx context.Context, req *v1.ContractInsertReq) (res *utils.ResponseRes, err error) {
-	//参数判断
-	if utils.ExistsSpecialLetters(req.PageName) {
-		g.RequestFromCtx(ctx).Response.WriteJson(utils.Err.WithMsg("Cannot contain special characters"))
-		return nil, err
-	}
-	if g.IsEmpty(req.ChainName) {
-		g.RequestFromCtx(ctx).Response.WriteJson(utils.Err.WithMsg("Public chain name is empty"))
-		return nil, err
-	}
-	//判断表是否存在
-	err = service.Contract().IsExists(ctx, req.ChainName)
-	if err != nil {
-		//新建表
-		err = service.Contract().CreateTable(ctx, req.ChainName)
-		if err != nil {
-			//新建表 失败
-			g.RequestFromCtx(ctx).Response.WriteJson(utils.Err.WithMsg("Create table failed"))
-			return nil, err
-		}
-	}
-	var in model.ContractInsertInput
-	in.ActionId = req.ActionId
-	in.ActionType = req.ActionType
-	in.BreakerId = req.BreakerId
-	in.BreakerName = req.BreakerName
-	in.OrderId = req.OrderId
-	in.OrderTime = req.OrderTime
-	in.PayTime = req.PayTime
-	in.PayWay = req.PayWay
-	in.Price = req.Price
-	in.Product = req.Product
-	in.PageId = req.PageId
-	in.PageName = req.PageName
-	in.Desc = req.Desc
-	in.Source = req.Source
-	session := model.UserSessionCtx.Get(ctx).JySession
-	if session.MgoUserId != "" {
-		in.UserId = session.UserId
-		in.PositionId = session.PositionId
-		in.Phone = session.Phone
-	}
-	in.Date = time.Now().Unix()
-	//浏览器信息
-	r := g.RequestFromCtx(ctx).Request
-	in.Ip = common.GetIp(r)
-	in.Url = r.Referer()
-	userAgent := utils.GetUserAgentInfo(r)
-	in.Browser = userAgent.BrowserName
-	in.BrowserVersion = userAgent.BrowserVersion
-	in.Os = userAgent.OsName
-	in.OsVersion = userAgent.OsVersion
-	in.Platform = userAgent.Platform
-	in.UserAgent = r.UserAgent()
-	err = service.Contract().InsertRecords(ctx, in, req.ChainName)
-	if err != nil {
-		utils.OK.WithMsg(err.Error())
-	}
-	g.RequestFromCtx(ctx).Response.WriteJson(utils.OK)
-	return
-}

+ 74 - 16
internal/controller/personnel/personnel.go

@@ -1,26 +1,84 @@
 package personnel
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"context"
 	"github.com/gogf/gf/v2/frame/g"
-	"github.com/gogf/gf/v2/net/ghttp"
-	. "personnelBehavior/internal/model/entity"
+	v1 "personnelBehavior/api/hello/v1"
+	"personnelBehavior/internal/model"
+	"personnelBehavior/internal/service"
+	"personnelBehavior/internal/utils"
+	"time"
 )
 
-func Statistics(r *ghttp.Request) {
-	g.Log().Info(r.Context(), "--数据--", r.Header)
-	findSql := `SELECT  id,ip  FROM data_analysis.dwd_f_user_log_info order by date desc limit 10 `
-	res, err := g.DB().Query(r.Context(), findSql)
-	if err == nil {
-		for _, l := range res.List() {
-			g.Log().Info(r.Context(), "----:", l)
+var (
+	Personnel = personnel{}
+)
+
+type personnel struct{}
+
+// Statistics 统计信息保存
+func (p *personnel) Statistics(ctx context.Context, req *v1.PersonnelInsertReq) (res *utils.ResponseRes, err error) {
+	//参数判断
+	if utils.ExistsSpecialLetters(req.PageName) {
+		g.RequestFromCtx(ctx).Response.WriteJson(utils.Err.WithMsg("Cannot contain special characters"))
+		return nil, err
+	}
+	if g.IsEmpty(req.ChainName) {
+		g.RequestFromCtx(ctx).Response.WriteJson(utils.Err.WithMsg("Public chain name is empty"))
+		return nil, err
+	}
+	//判断表是否存在
+	err = service.Personnel().IsExists(ctx, req.ChainName)
+	if err != nil {
+		//新建表
+		err = service.Personnel().CreateTable(ctx, req.ChainName)
+		if err != nil {
+			//新建表 失败
+			g.RequestFromCtx(ctx).Response.WriteJson(utils.Err.WithMsg("Create table failed"))
+			return nil, err
 		}
 	}
-	result := &Res{
-		ErrorCode: 1,
-		ErrorName: "success",
-		Data: map[string]interface{}{
-			"name": "成功",
-		},
+	var in model.PersonnelInsertInput
+	in.ActionId = req.ActionId
+	in.ActionType = req.ActionType
+	in.BreakerId = req.BreakerId
+	in.BreakerName = req.BreakerName
+	in.OrderId = req.OrderId
+	in.OrderTime = req.OrderTime
+	in.PayTime = req.PayTime
+	in.PayWay = req.PayWay
+	in.Price = req.Price
+	in.Product = req.Product
+	in.ProductName = req.Product
+	in.PageId = req.PageId
+	in.PageName = req.PageName
+	in.Desc = req.Desc
+	in.Source = req.Source
+	in.BiddingId = common.If(req.BiddingId != "", encrypt.DecodeArticleId(req.BiddingId), "").(string)
+	session := model.UserSessionCtx.Get(ctx).JySession
+	if session.MgoUserId != "" {
+		in.UserId = session.UserId
+		in.PositionId = session.PositionId
+		in.Phone = session.Phone
+	}
+	in.Date = time.Now().Unix()
+	//浏览器信息
+	r := g.RequestFromCtx(ctx).Request
+	in.Ip = common.GetIp(r)
+	in.Url = r.Referer()
+	userAgent := utils.GetUserAgentInfo(r)
+	in.Browser = userAgent.BrowserName
+	in.BrowserVersion = userAgent.BrowserVersion
+	in.Os = userAgent.OsName
+	in.OsVersion = userAgent.OsVersion
+	in.Platform = userAgent.Platform
+	in.UserAgent = r.UserAgent()
+	err = service.Personnel().InsertRecords(ctx, in, req.ChainName)
+	if err != nil {
+		utils.OK.WithMsg(err.Error())
 	}
-	g.RequestFromCtx(r.Context()).Response.WriteJson(result)
+	g.RequestFromCtx(ctx).Response.WriteJson(utils.OK)
+	return
 }

+ 26 - 0
internal/controller/personnel/statistics.go

@@ -0,0 +1,26 @@
+package personnel
+
+import (
+	"github.com/gogf/gf/v2/frame/g"
+	"github.com/gogf/gf/v2/net/ghttp"
+	. "personnelBehavior/internal/model/entity"
+)
+
+func Statistics(r *ghttp.Request) {
+	g.Log().Info(r.Context(), "--数据--", r.Header)
+	findSql := `SELECT  id,ip  FROM data_analysis.dwd_f_user_log_info order by date desc limit 10 `
+	res, err := g.DB().Query(r.Context(), findSql)
+	if err == nil {
+		for _, l := range res.List() {
+			g.Log().Info(r.Context(), "----:", l)
+		}
+	}
+	result := &Res{
+		ErrorCode: 1,
+		ErrorName: "success",
+		Data: map[string]interface{}{
+			"name": "成功",
+		},
+	}
+	g.RequestFromCtx(r.Context()).Response.WriteJson(result)
+}

+ 5 - 5
internal/dao/contract.go

@@ -2,14 +2,14 @@ package dao
 
 import "personnelBehavior/internal/dao/internal"
 
-type internalContractDao = *internal.ContractDao
+type internalPersonnelDao = *internal.PersonnelDao
 
-type contractDao struct {
-	internalContractDao
+type personnelDao struct {
+	internalPersonnelDao
 }
 
 var (
-	Contract = contractDao{
-		internal.NewContractDao(),
+	Personnel = personnelDao{
+		internal.NewPersonnelDao(),
 	}
 )

+ 64 - 17
internal/dao/internal/contract.go → internal/dao/internal/personnel.go

@@ -19,48 +19,48 @@ import (
 	"time"
 )
 
-type ContractDao struct {
+type PersonnelDao struct {
 	table string
 	group string
 }
 
-// NewContractDao creates and returns a new DAO object for table data access.
-func NewContractDao() *ContractDao {
-	return &ContractDao{
+// NewPersonnelDao  creates and returns a new DAO object for table data access.
+func NewPersonnelDao() *PersonnelDao {
+	return &PersonnelDao{
 		table: g.Cfg().MustGet(gctx.New(), "table").String(),
 		group: g.Cfg().MustGet(gctx.New(), "group").String(),
 	}
 }
 
 // DB  database management object of current DAO.
-func (dao *ContractDao) DB() gdb.DB {
+func (dao *PersonnelDao) DB() gdb.DB {
 	log.Println(dao.group, "-------------")
 	return g.DB(dao.group)
 }
 
 // Table  .
-func (dao *ContractDao) Table(suffix string) string {
+func (dao *PersonnelDao) Table(suffix string) string {
 	return fmt.Sprintf("%s_%s", dao.table, suffix)
 }
 
 // Group .
-func (dao *ContractDao) Group(chainName string) string {
+func (dao *PersonnelDao) Group(chainName string) string {
 	if chainName != "" {
 		return chainName
 	}
 	return dao.group
 }
 
-func (dao *ContractDao) Ctx(ctx context.Context) *gdb.Model {
+func (dao *PersonnelDao) Ctx(ctx context.Context) *gdb.Model {
 	return dao.DB().Model(dao.table).Safe().Ctx(ctx)
 }
 
-func (dao *ContractDao) CtxWithDatabase(ctx context.Context, database string) *gdb.Model {
+func (dao *PersonnelDao) CtxWithDatabase(ctx context.Context, database string) *gdb.Model {
 	return dao.DB().Model(database + "." + dao.table).Safe().Ctx(ctx)
 }
 
 // ExecInsert 保存行为记录
-func (dao *ContractDao) ExecInsert(ctx context.Context, in model.ContractInsertInput, chainName string) (err error) {
+func (dao *PersonnelDao) ExecInsert(ctx context.Context, in model.PersonnelInsertInput, chainName string) (err error) {
 	var (
 		dimSqlDML bytes.Buffer
 		now       = time.Now()
@@ -68,10 +68,13 @@ func (dao *ContractDao) ExecInsert(ctx context.Context, in model.ContractInsertI
 	)
 	dimSqlDML.WriteString("insert into ")
 	dimSqlDML.WriteString(dao.Group(chainName) + "." + dao.Table(ym))
-	dimSqlDML.WriteString(" (userid,create_time,phone,ip,platform,os,browser,position_id) values ( ")
+	dimSqlDML.WriteString(" (user_id,position_id,phone,ip,platform,os,os_version,browser," +
+		"browser_version,date,action_id,action_type,breaker_id,breaker_name,click_time,date,order_id," +
+		"order_time,pay_time,pay_way,price,product,product_name,page_id,page_name,bidding_id,desc," +
+		"url,source,user_agent) values ( ")
 	dimSqlDML.WriteString("'" + in.UserId + "'")
 	dimSqlDML.WriteString(",")
-	dimSqlDML.WriteString("'" + date.FormatDate(&now, date.Date_Full_Layout) + "'")
+	dimSqlDML.WriteString(strconv.FormatInt(in.PositionId, 10))
 	dimSqlDML.WriteString(",")
 	dimSqlDML.WriteString("'" + in.Phone + "'")
 	dimSqlDML.WriteString(",")
@@ -81,9 +84,53 @@ func (dao *ContractDao) ExecInsert(ctx context.Context, in model.ContractInsertI
 	dimSqlDML.WriteString(",")
 	dimSqlDML.WriteString("'" + in.Os + "'")
 	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.OsVersion + "'")
+	dimSqlDML.WriteString(",")
 	dimSqlDML.WriteString("'" + in.Browser + "'")
 	dimSqlDML.WriteString(",")
-	dimSqlDML.WriteString(strconv.FormatInt(in.PositionId, 10))
+	dimSqlDML.WriteString("'" + in.BrowserVersion + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + date.FormatDate(&now, date.Date_Full_Layout) + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.ActionId + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.ActionType + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.BreakerId + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.BreakerName + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + date.FormatDate(&now, date.Date_Full_Layout) + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + date.FormatDate(&now, date.Date_Full_Layout) + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.OrderId + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + date.FormatDate(&now, date.Date_Full_Layout) + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + date.FormatDate(&now, date.Date_Full_Layout) + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.PayWay + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString(strconv.FormatInt(in.Price, 10))
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.Product + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.ProductName + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.PageId + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.PageName + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.BiddingId + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.Desc + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.Url + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.Source + "'")
+	dimSqlDML.WriteString(",")
+	dimSqlDML.WriteString("'" + in.UserAgent + "'")
 	dimSqlDML.WriteString(")")
 	log.Println("insert sql :", dimSqlDML.String())
 	_, err = g.DB().Exec(ctx, dimSqlDML.String())
@@ -95,7 +142,7 @@ func (dao *ContractDao) ExecInsert(ctx context.Context, in model.ContractInsertI
 }
 
 // IsExists 当前表是否存在
-func (dao *ContractDao) IsExists(ctx context.Context, chainName string) (err error) {
+func (dao *PersonnelDao) IsExists(ctx context.Context, chainName string) (err error) {
 	var (
 		ym               = utils.GetYearMonth(0)
 		isExistsTableSql = fmt.Sprintf(IsExistsTableSql, dao.Group(chainName), dao.Table(ym))
@@ -118,7 +165,7 @@ func (dao *ContractDao) IsExists(ctx context.Context, chainName string) (err err
 }
 
 // UpdateRedis 更新redis表信息--无效
-func (dao *ContractDao) UpdateRedis(ctx context.Context, chainName string) (err error) {
+func (dao *PersonnelDao) UpdateRedis(ctx context.Context, chainName string) (err error) {
 	var (
 		month    = strconv.Itoa(int(time.Now().Month()))
 		redisKey = fmt.Sprintf(RedisPersonnelTable, dao.Group(chainName), dao.Table(month))
@@ -131,7 +178,7 @@ func (dao *ContractDao) UpdateRedis(ctx context.Context, chainName string) (err
 }
 
 // CreateTable 创建表
-func (dao *ContractDao) CreateTable(ctx context.Context, chainName string) (err error) {
+func (dao *PersonnelDao) CreateTable(ctx context.Context, chainName string) (err error) {
 	var (
 		ym        = utils.GetYearMonth(0)
 		createSql = fmt.Sprintf(PersonnelTable, dao.Group(chainName), dao.Table(ym))
@@ -152,7 +199,7 @@ func (dao *ContractDao) CreateTable(ctx context.Context, chainName string) (err
 }
 
 // DropTable 创建表
-func (dao *ContractDao) DropTable(ctx context.Context) (err error) {
+func (dao *PersonnelDao) DropTable(ctx context.Context) (err error) {
 	var (
 		ym      = utils.GetYearMonth(do.TaskConfig.DropTask.DataMonth)
 		dropSql = fmt.Sprintf(DropTable, dao.Group(""), dao.Table(ym))

+ 0 - 49
internal/logic/contract/contract.go

@@ -1,49 +0,0 @@
-package contract
-
-import (
-	"context"
-	"log"
-	"personnelBehavior/internal/dao"
-	"personnelBehavior/internal/model"
-	"personnelBehavior/internal/service"
-)
-
-//业务接口的实现
-
-type (
-	sContract struct{}
-)
-
-func init() {
-	log.Println("--初始 接口 实现--")
-	service.RegisterContract(New())
-}
-
-func New() *sContract {
-	return &sContract{}
-}
-
-// InsertRecords 用户行为记录
-func (s *sContract) InsertRecords(ctx context.Context, in model.ContractInsertInput, chainName string) (err error) {
-	return dao.Contract.ExecInsert(ctx, in, chainName)
-}
-
-// IsExists 表是否存在
-func (s *sContract) IsExists(ctx context.Context, chainName string) (err error) {
-	return dao.Contract.IsExists(ctx, chainName)
-}
-
-// UpdateRedis 更新redis 表信息
-func (s *sContract) UpdateRedis(ctx context.Context, chainName string) (err error) {
-	return dao.Contract.UpdateRedis(ctx, chainName)
-}
-
-// CreateTable 创建表
-func (s *sContract) CreateTable(ctx context.Context, chainName string) (err error) {
-	return dao.Contract.CreateTable(ctx, chainName)
-}
-
-// DropTable 删除表
-func (s *sContract) DropTable(ctx context.Context) (err error) {
-	return dao.Contract.DropTable(ctx)
-}

+ 1 - 1
internal/logic/logic.go

@@ -1,5 +1,5 @@
 package logic
 
 import (
-	_ "personnelBehavior/internal/logic/contract"
+	_ "personnelBehavior/internal/logic/personnel"
 )

+ 44 - 0
internal/logic/personnel/personnel.go

@@ -0,0 +1,44 @@
+package personnel
+
+import (
+	"context"
+	"personnelBehavior/internal/dao"
+	"personnelBehavior/internal/model"
+	"personnelBehavior/internal/service"
+)
+
+// 业务接口实现
+type sPersonnel struct{}
+
+func New() *sPersonnel {
+	return &sPersonnel{}
+}
+
+func init() {
+	service.RegisterPersonnel(New())
+}
+
+// InsertRecords 用户行为记录
+func (s *sPersonnel) InsertRecords(ctx context.Context, in model.PersonnelInsertInput, chainName string) (err error) {
+	return dao.Personnel.ExecInsert(ctx, in, chainName)
+}
+
+// IsExists 表是否存在
+func (s *sPersonnel) IsExists(ctx context.Context, chainName string) (err error) {
+	return dao.Personnel.IsExists(ctx, chainName)
+}
+
+// UpdateRedis 更新redis 表信息
+func (s *sPersonnel) UpdateRedis(ctx context.Context, chainName string) (err error) {
+	return dao.Personnel.UpdateRedis(ctx, chainName)
+}
+
+// CreateTable 创建表
+func (s *sPersonnel) CreateTable(ctx context.Context, chainName string) (err error) {
+	return dao.Personnel.CreateTable(ctx, chainName)
+}
+
+// DropTable 删除表
+func (s *sPersonnel) DropTable(ctx context.Context) (err error) {
+	return dao.Personnel.DropTable(ctx)
+}

+ 0 - 44
internal/model/do/init.go

@@ -1,45 +1 @@
 package do
-
-//
-//import (
-//	"fmt"
-//	"github.com/gogf/gf/v2/frame/g"
-//	"log"
-//)
-//
-//func init() {
-//	g.Log().Info(Ctx, "----初始化----")
-//	return
-//	res, err1 := g.DB().Query(Ctx, `SELECT count(*) as c FROM system.tables WHERE database = 'data_analysis' AND name = 'dwd_f_user_log_info1'`)
-//	log.Println(res, err1)
-//	if err1 == nil {
-//
-//		for _, l := range res.List() {
-//			g.Log().Info(Ctx, "----:", l["c"])
-//		}
-//		log.Println(res.Len(), len(res.List()), "-----:", res.MapKeyValue("c"))
-//	}
-//	return
-//	redisKey := fmt.Sprintf("ws_%s", "0001")
-//	err := g.Redis().SetEX(Ctx, redisKey, "ws", 120)
-//	if err != nil {
-//		log.Println("err:", err.Error())
-//	} else {
-//		r, err := g.Redis().Get(Ctx, redisKey)
-//		if err != nil {
-//			log.Println(err.Error())
-//			return
-//		}
-//		log.Println(r.String())
-//	}
-//	//
-//	return
-//	res, err2 := g.DB().Query(Ctx, `SELECT  id,ip  FROM data_analysis.dwd_f_user_log_info order by date desc limit 10 `)
-//	if err2 == nil {
-//		for _, l := range res.List() {
-//			g.Log().Info(Ctx, "----:", l)
-//		}
-//	} else {
-//		log.Println(err2.Error())
-//	}
-//}

+ 3 - 1
internal/model/contract.go → internal/model/personnel.go

@@ -1,6 +1,6 @@
 package model
 
-type ContractInsertInput struct {
+type PersonnelInsertInput struct {
 	ActionId       string
 	ActionType     string
 	BreakerId      string
@@ -11,8 +11,10 @@ type ContractInsertInput struct {
 	PayWay         string
 	Price          int64
 	Product        string
+	ProductName    string
 	PageId         string
 	PageName       string
+	BiddingId      string
 	Desc           string
 	Source         string
 	UserId         string

+ 0 - 28
internal/service/contract.go

@@ -1,28 +0,0 @@
-package service
-
-import (
-	"context"
-	"personnelBehavior/internal/model"
-)
-
-// IContract 接口
-type IContract interface {
-	InsertRecords(ctx context.Context, in model.ContractInsertInput, chainName string) (err error)
-	IsExists(ctx context.Context, chainName string) (err error)
-	UpdateRedis(ctx context.Context, chainName string) (err error)
-	CreateTable(ctx context.Context, chainName string) (err error)
-	DropTable(ctx context.Context) (err error)
-}
-
-var localContract IContract
-
-func Contract() IContract {
-	if localContract == nil {
-		panic("未找到 IContract 接口的实现")
-	}
-	return localContract
-}
-
-func RegisterContract(i IContract) {
-	localContract = i
-}

+ 28 - 0
internal/service/personnel.go

@@ -0,0 +1,28 @@
+package service
+
+import (
+	"context"
+	"personnelBehavior/internal/model"
+)
+
+// IPersonnel  接口
+type IPersonnel interface {
+	InsertRecords(ctx context.Context, in model.PersonnelInsertInput, chainName string) (err error)
+	IsExists(ctx context.Context, chainName string) (err error)
+	UpdateRedis(ctx context.Context, chainName string) (err error)
+	CreateTable(ctx context.Context, chainName string) (err error)
+	DropTable(ctx context.Context) (err error)
+}
+
+var localPersonnel IPersonnel
+
+func Personnel() IPersonnel {
+	if localPersonnel == nil {
+		panic("未找到 IPersonnel 接口的实现")
+	}
+	return localPersonnel
+}
+
+func RegisterPersonnel(i IPersonnel) {
+	localPersonnel = i
+}

+ 1 - 1
internal/task/manage.go

@@ -6,5 +6,5 @@ import (
 )
 
 func DropTableTask(ctx context.Context) (err error) {
-	return service.Contract().DropTable(ctx)
+	return service.Personnel().DropTable(ctx)
 }

+ 1 - 1
manifest/config/task.yaml

@@ -1,5 +1,5 @@
 name: "定时清理处理行为记录表"
-mainSwitch: true
+mainSwitch: false
 dropTask:
   firstRun: true
   taskRun: true