Roc преди 5 месеца
родител
ревизия
cbb86ca942
променени са 77 файла, в които са добавени 3 реда и са изтрити 1655 реда
  1. 0 7
      config/config.go
  2. 0 25
      controller/auth.go
  3. 0 8
      controller/gn/auth.go
  4. 0 6
      controller/gn/oa.go
  5. 0 54
      controller/gn/user.go
  6. 0 9
      controller/index_data/gn_index.go
  7. 0 21
      controller/resp/base.go
  8. 0 26
      core/log.go
  9. 0 7
      core/run_server.go
  10. 0 5
      docs/docs.go
  11. 0 13
      global/global.go
  12. 0 9
      global/validator.go
  13. 0 24
      init_serve/dm.go
  14. 0 10
      init_serve/mysql.go
  15. 0 37
      init_serve/redis.go
  16. 0 1
      init_serve/router.go
  17. 0 9
      init_serve/task.go
  18. 0 19
      logic/gn/auth.go
  19. 0 28
      logic/gn/mdm.go
  20. 0 284
      logic/gn/user.go
  21. 0 1
      main.go
  22. 0 14
      middleware/auth.go
  23. 0 37
      middleware/common.go
  24. 0 4
      middleware/cors.go
  25. 0 2
      middleware/recover.go
  26. 0 17
      models/base/base.go
  27. 1 1
      models/base/time_base.go
  28. 0 2
      models/crm/admin.go
  29. 0 1
      models/crm/open_api_user.go
  30. 0 8
      models/eta/admin.go
  31. 0 3
      models/eta/crm_config.go
  32. 0 7
      models/eta/sys_department.go
  33. 0 7
      models/eta/sys_group.go
  34. 0 5
      models/eta/sys_role.go
  35. 0 3
      models/eta/sys_session.go
  36. 0 5
      models/eta/sys_third_session.go
  37. 0 1
      models/eta/sys_user_login_record.go
  38. 0 1
      models/gn/index.go
  39. 0 5
      models/gn/mdm.go
  40. 0 31
      models/gn/user.go
  41. 0 10
      models/index/base.go
  42. 0 6
      models/index/business_sys_interaction_log.go
  43. 0 11
      models/index/edb_update_log.go
  44. 0 3
      models/rddp/sys_session.go
  45. 0 1
      models/rddp/sys_user_login_record.go
  46. 0 3
      models/request/gn/auth.go
  47. 0 2
      models/request/gn/mdm.go
  48. 0 2
      models/request/gn/oa.go
  49. 0 6
      models/request/gn/user.go
  50. 0 2
      models/request/index_data/gn_index.go
  51. 0 1
      models/response/gn_index.go
  52. 0 1
      routers/auth.go
  53. 0 4
      routers/gn.go
  54. 0 1
      routers/index_data.go
  55. 0 6
      services/alarm_msg/alarm_msg.go
  56. 0 89
      services/binlog/binlog.go
  57. 0 60
      services/binlog/handler.go
  58. 0 1
      services/company.go
  59. 1 56
      services/gn/auth.go
  60. 0 24
      services/gn/oa.go
  61. 0 5
      services/index_data/edb_update_log.go
  62. 0 99
      services/index_data/gn_base_data_platform.go
  63. 0 1
      services/index_data/gn_base_data_platform_v2.go
  64. 1 40
      services/index_data/gn_platform.go
  65. 0 31
      services/session.go
  66. 0 3
      task/task.go
  67. 0 117
      utils/common.go
  68. 0 18
      utils/constants.go
  69. 0 11
      utils/des3.go
  70. 0 12
      utils/directory.go
  71. 0 27
      utils/drawtext.go
  72. 0 14
      utils/gin.go
  73. 0 2
      utils/redis.go
  74. 0 109
      utils/redis/cluster_redis.go
  75. 0 103
      utils/redis/standalone_redis.go
  76. 0 13
      utils/validator.go
  77. 0 4
      utils/whereBuild.go

+ 0 - 7
config/config.go

@@ -8,7 +8,6 @@ type Config struct {
 	Gn    Gn    `mapstructure:"gn" json:"gn" yaml:"gn"`
 }
 
-// Serve gin服务配置
 type Serve struct {
 	Port      int    `mapstructure:"port" json:"port" yaml:"port" description:"gin开启监听http服务的端口"`
 	RunMode   string `mapstructure:"run-mode" json:"run-mode" yaml:"run-mode" description:"gin运行模式的默认,枚举值:debug,release"`
@@ -22,7 +21,6 @@ type Serve struct {
 	IsStopTask bool   `mapstructure:"is-stop-task" json:"is-stop-task" yaml:"is-stop-task" description:"是否停止任务,此功能用于多服务器部署时,定时任务只需一台服务器执行,其他服务器不执行的情况下设置为true"`
 }
 
-// Log 日志配置
 type Log struct {
 	Prefix          string `mapstructure:"prefix" json:"prefix" yaml:"prefix" description:"日志输出前缀"`
 	LogFile         bool   `mapstructure:"log-file" json:"logFile" yaml:"log-file" description:""`
@@ -38,9 +36,7 @@ type Log struct {
 	FilelogSoftLink string `mapstructure:"filelog-soft-link" json:"filelog-soft-link" yaml:"filelog-soft-link" description:"用户自主记录的日志软链接"`
 }
 
-// Mysql 数据库配置
 type Mysql struct {
-	//LogMode             bool        `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode" description:"是否开启日志"`
 	Stdout              bool        `mapstructure:"stdout" json:"stdout" yaml:"stdout" description:"日志是否输出在控制台"`
 	DefaultDsnAliasName string      `mapstructure:"default-dsn-alias-name" json:"default-dsn-alias-name" yaml:"default-dsn-alias-name" description:"默认的数据库连接别名"`
 	List                []MysqlConn `mapstructure:"list" json:"list" yaml:"list" description:"数据库链接配置列表"`
@@ -57,7 +53,6 @@ type Binlog struct {
 	Db         string `mapstructure:"db" json:"db" yaml:"db" description:"mysql binlog数据库"`
 }
 
-// MysqlConn mysql数据链接配置
 type MysqlConn struct {
 	Dsn          string `mapstructure:"dsn" json:"dsc" yaml:"dsn" description:"数据库连接配置"`
 	AliasName    string `mapstructure:"alias-name" json:"alias-name" yaml:"alias-name" description:"数据库别名"`
@@ -65,7 +60,6 @@ type MysqlConn struct {
 	MaxOpenConns int    `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns" description:"最大连接数"`
 }
 
-// Redis redis配置
 type Redis struct {
 	Address   string `mapstructure:"address" json:"address" yaml:"address" description:"redis服务链接地址"`
 	Password  string `mapstructure:"password" json:"password" yaml:"password" description:"redis服务密码"`
@@ -73,7 +67,6 @@ type Redis struct {
 	ServeType string `mapstructure:"serve-type" json:"serve-type" yaml:"serve-type" description:"redis服务类型,单机或者cluster;默认单机"`
 }
 
-// Gn 国能的的配置
 type Gn struct {
 	IndexSyncMinute     int    `mapstructure:"index-sync-minute" json:"index-sync-minute" yaml:"index-sync-minute" description:"国能同步N分钟前至现在的指标(负数)"`
 	DataHost            string `mapstructure:"data-host" json:"data-host" yaml:"data-host" description:"数据节点地址"`

+ 0 - 25
controller/auth.go

@@ -19,10 +19,6 @@ import (
 
 type AuthController struct{}
 
-// CreateAuthCode
-// @Description 生成编码
-// @Success 200 {string} string "获取成功"
-// @Router /auth/auth_code [post]
 func (a *AuthController) CreateAuthCode(c *gin.Context) {
 	var req request.CreateAuthCodeReq
 	err := c.Bind(&req)
@@ -43,7 +39,6 @@ func (a *AuthController) CreateAuthCode(c *gin.Context) {
 	str := base64.URLEncoding.EncodeToString([]byte(req.AdminName))
 	key := fmt.Sprint(prefix[req.Source], str)
 
-	// 是否已生成但未消费
 	exist, _ := global.Rc.RedisString(key)
 	if exist != "" {
 		resp.OkData("获取成功", str, c)
@@ -56,10 +51,6 @@ func (a *AuthController) CreateAuthCode(c *gin.Context) {
 	return
 }
 
-// GetEtaToken
-// @Description 换取ETA系统Token
-// @Success 200 {string} string "操作成功"
-// @Router /auth/eta_token [post]
 func (a *AuthController) GetEtaToken(c *gin.Context) {
 	var req request.TokenLoginReq
 	err := c.Bind(&req)
@@ -92,12 +83,10 @@ func (a *AuthController) GetEtaToken(c *gin.Context) {
 		resp.Fail("获取失败, 无效编码", c)
 		return
 	}
-	// 清除AuthCode
 	defer func() {
 		_ = global.Rc.Delete(key)
 	}()
 
-	// 获取用户信息
 	sysUser, e := eta.GetSysUserByAdminName(adminName)
 	if e != nil {
 		if e == utils.ErrNoRow {
@@ -110,7 +99,6 @@ func (a *AuthController) GetEtaToken(c *gin.Context) {
 
 	var token string
 	account := utils.MD5(adminName)
-	// 获取用户未过期的session, 避免过于频繁生成token
 	expired := time.Now().AddDate(0, 0, 1).Format(utils.FormatDateTime)
 	session, _ := eta.GetUserUnexpiredSysSession(adminName, expired)
 	if session != nil && session.AccessToken != "" {
@@ -142,7 +130,6 @@ func (a *AuthController) GetEtaToken(c *gin.Context) {
 	login.RoleTypeCode = sysUser.RoleTypeCode
 	login.Authority = sysUser.Authority
 
-	// 判断实际的角色类型
 	if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
 		login.RoleTypeCode = utils.ROLE_TYPE_CODE_FICC_SELLER
 	}
@@ -162,7 +149,6 @@ func (a *AuthController) GetEtaToken(c *gin.Context) {
 		login.RoleTypeCode = utils.ROLE_TYPE_CODE_FICC_SELLER
 	}
 
-	// 角色产品ID
 	productId := services.GetProductId(sysUser.RoleTypeCode)
 	productIdName := map[int]string{
 		0:                             "admin",
@@ -171,7 +157,6 @@ func (a *AuthController) GetEtaToken(c *gin.Context) {
 	}
 	login.ProductName = productIdName[productId]
 
-	// 新增登录记录
 	{
 		record := new(eta.SysUserLoginRecord)
 		record.Uid = sysUser.AdminId
@@ -185,10 +170,6 @@ func (a *AuthController) GetEtaToken(c *gin.Context) {
 	resp.OkData("获取成功", login, c)
 }
 
-// GetCrmToken
-// @Description 换取CRM系统Token
-// @Success 200 {string} string "操作成功"
-// @Router /auth/crm_token [post]
 func (a *AuthController) GetCrmToken(c *gin.Context) {
 	var req request.TokenLoginReq
 	err := c.Bind(&req)
@@ -216,12 +197,10 @@ func (a *AuthController) GetCrmToken(c *gin.Context) {
 		resp.Fail("获取失败, 无效编码", c)
 		return
 	}
-	// 清除AuthCode
 	defer func() {
 		_ = global.Rc.Delete(key)
 	}()
 
-	// 获取用户信息
 	sysUser, e := crm.GetSysUserByAdminName(adminName)
 	if e != nil {
 		if e == utils.ErrNoRow {
@@ -234,7 +213,6 @@ func (a *AuthController) GetCrmToken(c *gin.Context) {
 
 	var token string
 	account := utils.MD5(adminName)
-	// 获取用户未过期的session, 避免过于频繁生成token
 	expired := time.Now().AddDate(0, 0, 1).Format(utils.FormatDateTime)
 	session, _ := rddp.GetUserUnexpiredSysSession(adminName, expired)
 	if session != nil && session.AccessToken != "" {
@@ -266,7 +244,6 @@ func (a *AuthController) GetCrmToken(c *gin.Context) {
 	login.RoleTypeCode = sysUser.RoleTypeCode
 	login.Authority = sysUser.Authority
 
-	// 判断实际的角色类型
 	if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
 		login.RoleTypeCode = utils.ROLE_TYPE_CODE_FICC_SELLER
 	}
@@ -286,7 +263,6 @@ func (a *AuthController) GetCrmToken(c *gin.Context) {
 		login.RoleTypeCode = utils.ROLE_TYPE_CODE_FICC_SELLER
 	}
 
-	// 角色产品ID
 	productId := services.GetProductId(sysUser.RoleTypeCode)
 	productIdName := map[int]string{
 		0:                             "admin",
@@ -295,7 +271,6 @@ func (a *AuthController) GetCrmToken(c *gin.Context) {
 	}
 	login.ProductName = productIdName[productId]
 
-	// 新增登录记录
 	{
 		record := new(rddp.SysUserLoginRecord)
 		record.Uid = sysUser.AdminId

+ 0 - 8
controller/gn/auth.go

@@ -10,7 +10,6 @@ import (
 	"github.com/go-playground/validator/v10"
 )
 
-// GuoNengController 国能
 type GuoNengController struct{}
 
 func (gc *GuoNengController) GetToken(c *gin.Context) {
@@ -38,12 +37,6 @@ func (gc *GuoNengController) GetToken(c *gin.Context) {
 	resp.OkData("获取成功", result, c)
 }
 
-// GetUserInfo
-// @Description: 根据sci的token获取用户信息
-// @author: Roc
-// @receiver gc
-// @datetime 2024-10-30 10:11:51
-// @param c *gin.Context
 func (gc *GuoNengController) GetUserInfo(c *gin.Context) {
 	var req gnRequest.GetUserInfoReq
 	if e := c.Bind(&req); e != nil {
@@ -60,7 +53,6 @@ func (gc *GuoNengController) GetUserInfo(c *gin.Context) {
 		return
 	}
 
-	// 根据token在卓创这边获取用户信息
 	result, err, errMsg := gn.GetUserInfoByToken(req.Token)
 	if err != nil {
 		fmt.Printf("获取失败, Err: %v, ErrMsg: %s", err, errMsg)

+ 0 - 6
controller/gn/oa.go

@@ -9,12 +9,6 @@ import (
 	"github.com/go-playground/validator/v10"
 )
 
-// OA
-// @Description: 发布OA待办
-// @author: Roc
-// @receiver gc
-// @datetime 2024-10-29 13:23:42
-// @param c *gin.Context
 func (gc *GuoNengController) OA(c *gin.Context) {
 	var req gnRequest.PostOAReq
 	if e := c.Bind(&req); e != nil {

+ 0 - 54
controller/gn/user.go

@@ -12,24 +12,8 @@ import (
 	"time"
 )
 
-// 同步用户锁,防止重复同步,不管是全量还是增量,都是同一时间只能一个同步
-//var lockSyncUser sync.Mutex
 
-// SyncUser 临时-全量同步用户
-//func (gc *GuoNengController) SyncUser(c *gin.Context) {
-//	lockSyncUser.Lock()
-//	defer func() {
-//		lockSyncUser.Unlock()
-//	}()
-//	err := gnLogic.SyncUser()
-//	if err != nil {
-//		resp.FailData("同步失败", err.Error(), c)
-//		return
-//	}
-//	resp.Ok("同步成功", c)
-//}
 
-// AddAccount 创建新账号
 func (gc *GuoNengController) AddAccount(c *gin.Context) {
 	var req gnRequest.AddAccountReq
 	if e := c.Bind(&req); e != nil {
@@ -68,7 +52,6 @@ func (gc *GuoNengController) AddAccount(c *gin.Context) {
 		return
 	}
 
-	// 新增账号
 	errMsg, e := gnLogic.AddAccount(req.UserEntity)
 	if e != nil {
 		resp.Gn4AResultData(resp.FAIL_CODE, errMsg, fmt.Sprintf("AddAccount: %v", e), c)
@@ -77,7 +60,6 @@ func (gc *GuoNengController) AddAccount(c *gin.Context) {
 	resp.Gn4AResultData(resp.GN_OK_CODE, "成功", "", c)
 }
 
-// ModifyAccount 修改账号信息
 func (gc *GuoNengController) ModifyAccount(c *gin.Context) {
 	var req gnRequest.ModifyAccountReq
 	if e := c.Bind(&req); e != nil {
@@ -88,22 +70,6 @@ func (gc *GuoNengController) ModifyAccount(c *gin.Context) {
 		resp.Gn4AResultData(resp.FAIL_CODE, "登录账号标识不可为空", "登录账号标识不可为空", c)
 		return
 	}
-	//if req.FirstName == nil || (req.FirstName != nil && *req.FirstName == "") {
-	//	resp.Gn4AResultData(resp.FAIL_CODE, "姓名不可为空", "姓名不可为空", c)
-	//	return
-	//}
-	//if req.LastName == nil || (req.LastName != nil && *req.LastName == "") {
-	//	resp.Gn4AResultData(resp.FAIL_CODE, "姓名不可为空", "姓名不可为空", c)
-	//	return
-	//}
-	//if req.UserStatus == nil || (req.UserStatus != nil && *req.UserStatus == "") {
-	//	resp.Gn4AResultData(resp.FAIL_CODE, "账号状态不可为空", "账号状态不可为空", c)
-	//	return
-	//}
-	//if req.Password == nil || (req.Password != nil && *req.Password == "") {
-	//	resp.Gn4AResultData(resp.FAIL_CODE, "密码不可为空", "密码不可为空", c)
-	//	return
-	//}
 	if req.UserStatus != nil {
 		statsMap := map[string]int{gn.UserStatusActive: 1, gn.UserStatusDisable: 0}
 		if _, ok := statsMap[*req.UserStatus]; !ok {
@@ -111,12 +77,7 @@ func (gc *GuoNengController) ModifyAccount(c *gin.Context) {
 			return
 		}
 	}
-	//if req.EmpNumber == nil || (req.EmpNumber != nil && *req.EmpNumber == "") {
-	//	resp.Gn4AResultData(resp.FAIL_CODE, "员工编号不可为空", "员工编号不可为空", c)
-	//	return
-	//}
 
-	// 更新账号
 	errMsg, e := gnLogic.ModifyAccount(req.UserEntity)
 	if e != nil {
 		resp.Gn4AResultData(resp.FAIL_CODE, errMsg, fmt.Sprintf("ModifyAccount: %v", e), c)
@@ -125,7 +86,6 @@ func (gc *GuoNengController) ModifyAccount(c *gin.Context) {
 	resp.Gn4AResultData(resp.GN_OK_CODE, "成功", "", c)
 }
 
-// DeleteAccount 删除账号
 func (gc *GuoNengController) DeleteAccount(c *gin.Context) {
 	var req gnRequest.DeleteAccountReq
 	if e := c.Bind(&req); e != nil {
@@ -137,7 +97,6 @@ func (gc *GuoNengController) DeleteAccount(c *gin.Context) {
 		return
 	}
 
-	//errMsg, e := gnLogic.DeleteAccount(req.UserId)
 	errMsg, e := gnLogic.SuspendAccount(req.UserId)
 	if e != nil {
 		resp.Gn4AResultData(resp.FAIL_CODE, errMsg, fmt.Sprintf("DeleteAccount: %v", e), c)
@@ -146,7 +105,6 @@ func (gc *GuoNengController) DeleteAccount(c *gin.Context) {
 	resp.Gn4AResultData(resp.GN_OK_CODE, "成功", "", c)
 }
 
-// SuspendAccount 禁用账号
 func (gc *GuoNengController) SuspendAccount(c *gin.Context) {
 	var req gnRequest.SuspendAccountReq
 	if e := c.Bind(&req); e != nil {
@@ -166,7 +124,6 @@ func (gc *GuoNengController) SuspendAccount(c *gin.Context) {
 	resp.Gn4AResultData(resp.GN_OK_CODE, "成功", "", c)
 }
 
-// RestoreAccount 禁用账号
 func (gc *GuoNengController) RestoreAccount(c *gin.Context) {
 	var req gnRequest.RestoreAccountReq
 	if e := c.Bind(&req); e != nil {
@@ -186,7 +143,6 @@ func (gc *GuoNengController) RestoreAccount(c *gin.Context) {
 	resp.Gn4AResultData(resp.GN_OK_CODE, "成功", "", c)
 }
 
-// ChangePassword 修改密码
 func (gc *GuoNengController) ChangePassword(c *gin.Context) {
 	var req gnRequest.ChangePasswordReq
 	if e := c.Bind(&req); e != nil {
@@ -211,7 +167,6 @@ func (gc *GuoNengController) ChangePassword(c *gin.Context) {
 	resp.Gn4AResultData(resp.GN_OK_CODE, "成功", "", c)
 }
 
-// SyncMdmOrganization 同步mdm组织部门
 func (gc *GuoNengController) SyncMdmOrganization(c *gin.Context) {
 	var req gnRequest.SyncMdmOrganizationReq
 	if e := c.Bind(&req); e != nil {
@@ -224,7 +179,6 @@ func (gc *GuoNengController) SyncMdmOrganization(c *gin.Context) {
 		return
 	}
 
-	// 根据主编码判断是否已同步过, 同步过则更新
 	ob := new(gn.MDM_COMSTRU)
 	cond := ` AND Main_Field_Comstru_Code = ?`
 	pars := make([]interface{}, 0)
@@ -235,7 +189,6 @@ func (gc *GuoNengController) SyncMdmOrganization(c *gin.Context) {
 		return
 	}
 
-	// 更新
 	if item != nil && item.Id > 0 {
 		updateCols := []string{"Main_Field_Comstru_Code_HR", "Main_Field_Comstru_Type_HR", "ZDWLX", "Main_Field_Comstru_Name_HR", "Main_Field_Comstru_Short_Name_HR", "Main_Field_ParentAdmin_Comstru_Code_HR", "Main_Field_ParentAdmin_Comstru_Code", "Main_Field_ParentAdmin_Comstru_Name", "Main_Field_Company_Level", "Main_Field_Secondcomstrucodehr", "Main_Field_Sh_Business_Type", "Main_Field_YZGDWZCNDGX", "Main_Field_Order_HR", "Main_Field_Company_Code", "Main_Field_Company_Chain", "Main_Field_PARENTCOMPANYVIRTUAL", "ZQYZT", "ModifyTime"}
 		item.MainFieldComstruCodeHR = req.MainFieldComstruCodeHR
@@ -264,7 +217,6 @@ func (gc *GuoNengController) SyncMdmOrganization(c *gin.Context) {
 		return
 	}
 
-	// 新增
 	newOrganizer := gn.MDM_COMSTRU{
 		MainFieldComstruCode:              req.MainFieldComstruCode,
 		MainFieldComstruCodeHR:            req.MainFieldComstruCodeHR,
@@ -292,7 +244,6 @@ func (gc *GuoNengController) SyncMdmOrganization(c *gin.Context) {
 		return
 	}
 
-	// 同步ETA部门
 	go func() {
 		_ = gnLogic.SyncSysDepartment(&newOrganizer)
 	}()
@@ -300,7 +251,6 @@ func (gc *GuoNengController) SyncMdmOrganization(c *gin.Context) {
 	resp.Gn4AResultData(resp.GN_OK_CODE, "成功", "", c)
 }
 
-// SyncMdmEmployee 同步mdm员工
 func (gc *GuoNengController) SyncMdmEmployee(c *gin.Context) {
 	var req gnRequest.SyncMdmEmployeeReq
 	if e := c.Bind(&req); e != nil {
@@ -313,7 +263,6 @@ func (gc *GuoNengController) SyncMdmEmployee(c *gin.Context) {
 		return
 	}
 
-	// 根据主编码判断是否已同步过, 同步过则更新
 	ob := new(gn.MDM_EMPLOYEE)
 	cond := ` AND Main_Field_Employee_Code = ?`
 	pars := make([]interface{}, 0)
@@ -324,7 +273,6 @@ func (gc *GuoNengController) SyncMdmEmployee(c *gin.Context) {
 		return
 	}
 
-	// 员工组织关系
 	relations := make([]*gn.MDM_RELA_COMSTRU_EMPLOYEE, 0)
 	if len(req.MDM_MATERIAL_PROPS) > 0 {
 		for _, v := range req.MDM_MATERIAL_PROPS {
@@ -340,7 +288,6 @@ func (gc *GuoNengController) SyncMdmEmployee(c *gin.Context) {
 		}
 	}
 
-	// 更新
 	var isUpdate bool
 	employeeOb := new(gn.MDM_EMPLOYEE)
 	if item != nil && item.Id > 0 {
@@ -365,7 +312,6 @@ func (gc *GuoNengController) SyncMdmEmployee(c *gin.Context) {
 		}
 	}
 
-	// 新增
 	if !isUpdate {
 		newEmployee := &gn.MDM_EMPLOYEE{
 			MainFieldEmployeeCode:        req.MainFieldEmployeeCode,

+ 0 - 9
controller/index_data/gn_index.go

@@ -10,13 +10,8 @@ import (
 	"github.com/go-playground/validator/v10"
 )
 
-// GnIndexController 国能指标
 type GnIndexController struct{}
 
-// GetPageIndex
-// @Description 获取国能指标列表-分页
-// @Success 200 {string} string "获取成功"
-// @Router /gn/page_index [post]
 func (j *GnIndexController) GetPageIndex(c *gin.Context) {
 	var req indexDataReq.GnPageIndexReq
 	if e := c.Bind(&req); e != nil {
@@ -43,10 +38,6 @@ func (j *GnIndexController) GetPageIndex(c *gin.Context) {
 	return
 }
 
-// GetIndexData
-// @Description 获取国能指标数据
-// @Success 200 {string} string "获取成功"
-// @Router /gn/index_data [post]
 func (j *GnIndexController) GetIndexData(c *gin.Context) {
 	var req indexDataReq.GnDataReq
 	if e := c.Bind(&req); e != nil {

+ 0 - 21
controller/resp/base.go

@@ -28,15 +28,11 @@ type ResultData struct {
 func result(code int, resultData ResultData, c *gin.Context) {
 	jsonByte, _ := json.Marshal(resultData)
 	logSlice := utils.GetBridgeLogListByClaims(c)
-	//logSlice = append(logSlice, fmt.Sprint("resultData:", string(jsonByte)))
 
-	//记录错误日志
 	if resultData.ErrMsg != "" {
 		logSlice = append(logSlice, fmt.Sprint("ErrMsg:", resultData.ErrMsg))
-		//global.LOG.Info(strings.Join(logSlice, ";"))
 	}
 
-	// 测试环境不加密
 	if global.CONFIG.Serve.RunMode == "debug" {
 		global.LOG.Info(strings.Join(logSlice, "\n"))
 		c.JSON(code, resultData)
@@ -48,7 +44,6 @@ func result(code int, resultData ResultData, c *gin.Context) {
 	c.Abort()
 }
 
-// OK 操作成功
 func Ok(msg string, c *gin.Context) {
 	resultData := ResultData{
 		Code: OK_CODE,
@@ -57,7 +52,6 @@ func Ok(msg string, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// OkData 成功返回数据
 func OkData(msg string, data interface{}, c *gin.Context) {
 	resultData := ResultData{
 		Code: OK_CODE,
@@ -67,7 +61,6 @@ func OkData(msg string, data interface{}, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// Fail 操作失败
 func Fail(msg string, c *gin.Context) {
 	resultData := ResultData{
 		Code: FAIL_CODE,
@@ -76,7 +69,6 @@ func Fail(msg string, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// FailData 成功返回数据
 func FailData(msg string, data interface{}, c *gin.Context) {
 	resultData := ResultData{
 		Code: FAIL_CODE,
@@ -86,7 +78,6 @@ func FailData(msg string, data interface{}, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// Custom 自定义状态码+操作成功
 func Custom(code int, msg string, c *gin.Context) {
 	resultData := ResultData{
 		Code: code,
@@ -95,7 +86,6 @@ func Custom(code int, msg string, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// CustomData 自定义状态码+返回数据
 func CustomData(code int, msg string, data interface{}, c *gin.Context) {
 	resultData := ResultData{
 		Code: code,
@@ -105,7 +95,6 @@ func CustomData(code int, msg string, data interface{}, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// TokenError token异常
 func TokenError(data interface{}, message, errMsg string, c *gin.Context) {
 	resultData := ResultData{
 		Code:   TOKEN_ERROR_CODE,
@@ -116,7 +105,6 @@ func TokenError(data interface{}, message, errMsg string, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// AuthError 没有权限
 func AuthError(data interface{}, message string, c *gin.Context) {
 	resultData := ResultData{
 		Code: NO_AUTH,
@@ -126,7 +114,6 @@ func AuthError(data interface{}, message string, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// SpecificFail 业务指定错误
 func SpecificFail(data interface{}, message string, c *gin.Context) {
 	resultData := ResultData{
 		Code: SPECIFIC_FAIL_CODE,
@@ -136,7 +123,6 @@ func SpecificFail(data interface{}, message string, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// FailMsg 操作失败
 func FailMsg(msg, errMsg string, c *gin.Context) {
 	resultData := ResultData{
 		Code:   FAIL_CODE,
@@ -146,18 +132,12 @@ func FailMsg(msg, errMsg string, c *gin.Context) {
 	result(200, resultData, c)
 }
 
-// Gn4AOperationResult 国能4A响应结果
 type Gn4AOperationResult struct {
-	//RequestId  string `json:"requestID" description:"请求唯一标识"`
-	//ReturnFlag bool   `json:"returnFlag" description:"处理结果标识: true-成功; false-失败"`
-	//ReturnCode string `json:"returnCode" description:"返回结果编号, returnFlag为true时, returnCode为0, 否则为错误编码"`
-	//ReturnMsg  string `json:"returnMsg" description:"返回结果信息, 可自定义"`
 	Code   int    `json:"code" description:"状态码"`
 	Msg    string `json:"msg" description:"提示信息"`
 	ErrMsg string `json:"-" description:"错误信息,仅做日志记录"`
 }
 
-// Gn4AResultData 4A返回结果
 func Gn4AResultData(code int, msg, errMsg string, c *gin.Context) {
 	resultData := Gn4AOperationResult{
 		Code:   code,
@@ -169,7 +149,6 @@ func Gn4AResultData(code int, msg, errMsg string, c *gin.Context) {
 
 func gnResult(code int, resultData Gn4AOperationResult, c *gin.Context) {
 	logSlice := utils.GetBridgeLogListByClaims(c)
-	// 记录错误日志
 	if resultData.ErrMsg != "" {
 		logSlice = append(logSlice, fmt.Sprintf("ErrCode: %d, Msg: %s, ErrMsg: %s", resultData.Code, resultData.Msg, resultData.ErrMsg))
 	}

+ 0 - 26
core/log.go

@@ -22,15 +22,12 @@ var (
 	defaultFormatter = ` %{time:2006/01/02 - 15:04:05.000} %{longfile} %{color:bold}▶ [%{level:.6s}] %{message}%{color:reset}`
 )
 
-// 初始化日志
 func init() {
 	logConfig := global.CONFIG.Log
 	logger := oplogging.MustGetLogger(Module)
 	var backends []oplogging.Backend
-	//注册输出
 	registerStdout(logConfig, &backends)
 
-	//注册框架输出(日志文件)
 	fileWriter := registerFile(logConfig, &backends, logConfig.LogDirPath, logConfig.LogSoftLink)
 	if fileWriter != nil {
 		if global.CONFIG.Serve.RunMode == "debug" {
@@ -42,30 +39,23 @@ func init() {
 	oplogging.SetBackend(backends...)
 	global.LOG = logger
 
-	//初始化mysql数据库日志
 	initMysqlLog()
 
-	// 初始化自定义输出的日志
 	initFileLog()
 }
 
-// initMysqlLog 初始化mysql数据库日志
 func initMysqlLog() {
 	logConfig := global.CONFIG.Log
 	var backends []oplogging.Backend
-	//注册输出
 	registerStdout(logConfig, &backends)
 
-	//注册框架输出(日志文件)
 	fileWriter := registerFile(logConfig, &backends, logConfig.BinlogDirPath, logConfig.BinlogSoftLink)
 	global.MYSQL_LOG = fileWriter
 }
 
-// initFileLog 初始化自定义日志
 func initFileLog() {
 	logConfig := global.CONFIG.Log
 
-	// 没有单独配置的话,那就走默认的日志输出
 	if logConfig.FilelogDirPath == "" || logConfig.FilelogSoftLink == `` {
 		global.FILE_LOG = global.LOG
 		return
@@ -73,10 +63,7 @@ func initFileLog() {
 
 	logger := oplogging.MustGetLogger(Module)
 	var backends []oplogging.Backend
-	//注册控制台输出
-	//registerStdout(logConfig, &backends)
 
-	// 注册文件输出(日志文件)
 	_ = registerFile(logConfig, &backends, logConfig.FilelogDirPath, logConfig.FilelogSoftLink)
 	defaultBackend := oplogging.AddModuleLevel(backends[0])
 	logger.SetBackend(defaultBackend)
@@ -93,29 +80,20 @@ func registerStdout(c config.Log, backends *[]oplogging.Backend) {
 	}
 }
 
-// registerFile 注册文件日志
 func registerFile(c config.Log, backends *[]oplogging.Backend, logDir, logSoftLink string) io.Writer {
 	if c.FileStdout != "" {
 		if ok, _ := utils.PathExists(logDir); !ok {
-			// directory not exist
 			fmt.Println("create log directory")
 			_ = os.Mkdir(logDir, os.ModePerm)
 		}
 
-		//日志保留时间
 		saveMaxTime := time.Duration(global.CONFIG.Log.SaveMaxDay) * 24 * time.Hour
-		//日志切割时间(每隔多久切割一次)
 		cuttingTime := time.Duration(global.CONFIG.Log.CuttingDay) * 24 * time.Hour
 
-		//使用rotatelogs
 		fileWriter, err := rotatelogs.New(
 			logDir+string(os.PathSeparator)+"%Y-%m-%d-%H-%M.log",
-			// 生成软链,指向最新日志文件
 			rotatelogs.WithLinkName(logSoftLink),
-			// 以下两个配置不能同时设置,一个是保留天数,一个是保留分拣份数
 			rotatelogs.WithMaxAge(saveMaxTime), //日志保留多久,最小分钟为单位
-			//rotatelogs.WithRotationCount(5),        //number 默认7份 大于7份 或到了清理时间 开始清理
-			// time period of log file switching
 			rotatelogs.WithRotationTime(cuttingTime), //rotate 最小为1分钟轮询。默认60s  低于1分钟就按1分钟来
 		)
 		if err != nil {
@@ -132,7 +110,6 @@ func registerFile(c config.Log, backends *[]oplogging.Backend, logDir, logSoftLi
 	return nil
 }
 
-// createBackend 创建一个新的日志记录器
 func createBackend(w io.Writer, c config.Log, level oplogging.Level) oplogging.Backend {
 	backend := oplogging.NewLogBackend(w, c.Prefix, 0)
 	stdoutWriter := false
@@ -148,13 +125,10 @@ func createBackend(w io.Writer, c config.Log, level oplogging.Level) oplogging.B
 func getLogFormatter(c config.Log, stdoutWriter bool) oplogging.Formatter {
 	pattern := defaultFormatter
 	if !stdoutWriter {
-		// Color is only required for console output
-		// Other writers don't need %{color} tag
 		pattern = strings.Replace(pattern, "%{color:bold}", "", -1)
 		pattern = strings.Replace(pattern, "%{color:reset}", "", -1)
 	}
 	if !c.LogFile {
-		// Remove %{logfile} tag
 		pattern = strings.Replace(pattern, "%{longfile}", "", -1)
 	}
 	return oplogging.MustStringFormatter(pattern)

+ 0 - 7
core/run_server.go

@@ -7,21 +7,14 @@ import (
 )
 
 func RunServe() {
-	// 初始化路由
 	r := init_serve.InitRouter()
 
-	// 如果配置了redis,那么链接redis
 	if global.CONFIG.Serve.UseRedis {
-		//初始化redis
 		init_serve.Redis()
 	}
 
-	// 初始化mysql数据库
-	//init_serve.Mysql()
-	// 初始化 达梦数据库
 	init_serve.InitDm()
 
-	// 启动任务
 	init_serve.InitTask()
 
 	fmt.Println("port:", global.CONFIG.Serve.Port)

+ 0 - 5
docs/docs.go

@@ -1,5 +1,3 @@
-// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-// This file was generated by swaggo/swag
 package docs
 
 import (
@@ -43,7 +41,6 @@ type swaggerInfo struct {
 	Description string
 }
 
-// SwaggerInfo holds exported Swagger Info so clients can modify it
 var SwaggerInfo = swaggerInfo{
 	Version:     "1.0",
 	Host:        "127.0.0.1:8607",
@@ -65,9 +62,7 @@ func (s *s) ReadDoc() string {
 			return string(a)
 		},
 		"escape": func(v interface{}) string {
-			// escape tabs
 			str := strings.Replace(v.(string), "\t", "\\t", -1)
-			// replace " with \", and if that results in \\", replace that with \\\"
 			str = strings.Replace(str, "\"", "\\\"", -1)
 			return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
 		},

+ 0 - 13
global/global.go

@@ -19,10 +19,8 @@ var (
 	MYSQL         map[string]*gorm.DB //数据库连接配置
 	MYSQL_LOG     io.Writer
 	DEFAULT_MYSQL *gorm.DB //默认数据库连接配置
-	//Redis         *redis.Client //redis链接
 	OracleJy *sql.DB //嘉悦物产数据库连接
 
-	//Rc *cache.Cache //redis缓存
 	Rc utils.RedisClient //redis缓存
 	Re error             //redis错误
 )
@@ -35,14 +33,12 @@ func init() {
 
 	configFilePath := ConfigFile
 
-	//如果不存在该配置文件,那么应该是线上环境,那么去寻找线上配置文件的路径
 	if !utils.FileIsExist(configFilePath) {
 		configFilePath = ProConfigFile
 	}
 
 	fmt.Println("configFilePath->", configFilePath)
 
-	//设置配置文件
 	v.SetConfigFile(configFilePath)
 
 	err := v.ReadInConfig()
@@ -50,7 +46,6 @@ func init() {
 		panic(fmt.Errorf("读取配置失败,Err: %s \n", err))
 	}
 
-	//持续监听文件
 	v.WatchConfig()
 
 	v.OnConfigChange(func(e fsnotify.Event) {
@@ -62,12 +57,6 @@ func init() {
 	return
 }
 
-// handleConfig
-// @Description: 配置文件处理
-// @author: Roc
-// @datetime 2024-03-13 10:27:40
-// @param v *viper.Viper
-// @param handleType string
 func handleConfig(v *viper.Viper, handleType string) {
 	if err := v.Unmarshal(&CONFIG); err != nil {
 		fmt.Println(handleType+"赋值失败,Err:", err)
@@ -75,6 +64,4 @@ func handleConfig(v *viper.Viper, handleType string) {
 	if CONFIG.Mysql.Binlog.LogSaveDay == 0 {
 		CONFIG.Mysql.Binlog.LogSaveDay = 31
 	}
-	//fmt.Println(CONFIG)
-	//fmt.Println(CONFIG.Mysql.UpdateLogSaveDay)
 }

+ 0 - 9
global/validator.go

@@ -11,28 +11,19 @@ import (
 	zhTranslations "github.com/go-playground/validator/v10/translations/zh"
 )
 
-// 定义一个全局翻译器T
 var Trans ut.Translator
 
-// InitTrans 初始化翻译器
 
 func InitTrans(locale string) (err error) {
-	// 修改gin框架中的Validator引擎属性,实现自定制
 	if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
 		zhT := zh.New() // 中文翻译器
 		enT := en.New() // 英文翻译器
-		// 第一个参数是备用(fallback)的语言环境
-		// 后面的参数是应该支持的语言环境(支持多个)
-		// uni := ut.New(zhT, zhT) 也是可以的
 		uni := ut.New(enT, zhT, enT)
-		// locale 通常取决于 http 请求头的 'Accept-Language'
 		var ok bool
-		// 也可以使用 uni.FindTranslator(...) 传入多个locale进行查找
 		Trans, ok = uni.GetTranslator(locale)
 		if !ok {
 			return fmt.Errorf("uni.GetTranslator(%s) failed", locale)
 		}
-		// 注册翻译器
 		switch locale {
 		case "en":
 			err = enTranslations.RegisterDefaultTranslations(v, Trans)

+ 0 - 24
init_serve/dm.go

@@ -19,12 +19,9 @@ import (
 
 type LocalTime time.Time
 
-// InitDm
-// @Description: 达梦数据库初始化
 func InitDm() {
 	dmSqlMap := make(map[string]*gorm.DB)
 
-	//开启日志
 	logWriter := io.MultiWriter(global.MYSQL_LOG) //binlog日志,记录到文件中去
 	if global.CONFIG.Mysql.Stdout {
 		logWriter = io.MultiWriter(global.MYSQL_LOG, os.Stdout)
@@ -44,35 +41,22 @@ func InitDm() {
 
 	for _, conf := range mysqlConf.List {
 		isDefault := false
-		//默认数据库连接
 		if mysqlConf.DefaultDsnAliasName == conf.AliasName {
 			isDefault = true
 		}
 
-		// 库连接
 		connectDm(conf.Dsn, conf.AliasName, newLogger, dmSqlMap, isDefault)
 
 	}
 
-	//全局赋值数据库链接
 	global.MYSQL = dmSqlMap
 
 }
 
-// connectDm
-// @Description: 达梦数据库连接
-// @param dsn
-// @param aliasName
-// @param newLogger
-// @param dmSqlMap
-// @param isDefault
 func connectDm(dsn, aliasName string, newLogger logger.Interface, dmSqlMap map[string]*gorm.DB, isDefault bool) {
-	//fmt.Println("dsn:", dsn, "  ==  ;aliasName:", aliasName)
 	if dsn == `` {
 		return
 	}
-	//dsn := "dm://SYSDBA:SYSDBA001@8.136.199.33:30236?schema=\"eta_master\""
-	//dsn := "dm://ETA:Han6258199118%60@localhost:5236?schema=ECOLOGY_TARGET"
 	db, err := gorm.Open(dm.Open(dsn), &gorm.Config{
 		Logger: newLogger,
 		NamingStrategy: schema.NamingStrategy{
@@ -80,30 +64,23 @@ func connectDm(dsn, aliasName string, newLogger logger.Interface, dmSqlMap map[s
 		},
 	})
 	if err != nil {
-		//global.LOG.Errorf("mysql 启动异常,数据库:default;Err:", err)
 		panic(fmt.Errorf("mysql 启动异常,数据库:%s;Err:%s", aliasName, err))
 	}
-	//创建连接池
 	sqlDB, err := db.DB()
 	if err != nil {
-		//global.LOG.Errorf("mysql 创建连接池失败,数据库:default;Err:", err)
 		panic(fmt.Errorf("mysql 创建连接池失败,数据库:%s;Err:%s", aliasName, err))
 	}
 
 	dmSqlMap[aliasName] = db
 
-	//默认数据库连接
 	if isDefault {
 		global.DEFAULT_MYSQL = db
 	}
 
-	// SetMaxIdleConns 设置空闲连接池中连接的最大数量
 	sqlDB.SetMaxIdleConns(50)
 
-	// SetMaxOpenConns 设置打开数据库连接的最大数量。
 	sqlDB.SetMaxOpenConns(100)
 
-	// SetConnMaxLifetime 设置了连接可复用的最大时间。
 	sqlDB.SetConnMaxLifetime(10 * time.Minute)
 
 }
@@ -119,7 +96,6 @@ func (t *LocalTime) MarshalJSON() ([]byte, error) {
 func (t LocalTime) Value() (driver.Value, error) {
 	var zeroTime time.Time
 	tlt := time.Time(t)
-	//判断给定时间是否和默认零时间的时间戳相同
 	if tlt.UnixNano() == zeroTime.UnixNano() {
 		return nil, nil
 	}

+ 0 - 10
init_serve/mysql.go

@@ -13,7 +13,6 @@ import (
 	"time"
 )
 
-// Mysql 数据库初始化
 func Mysql() {
 	mysqlConf := global.CONFIG.Mysql
 	if len(mysqlConf.List) <= 0 {
@@ -21,7 +20,6 @@ func Mysql() {
 		panic(fmt.Errorf("mysql链接未配置"))
 	}
 
-	//开启日志
 	logWriter := io.MultiWriter(global.MYSQL_LOG) //binlog日志,记录到文件中去
 	if global.CONFIG.Mysql.Stdout {
 		logWriter = io.MultiWriter(global.MYSQL_LOG, os.Stdout)
@@ -45,7 +43,6 @@ func Mysql() {
 			panic(fmt.Errorf("mysql 启动异常,数据库:", conf.AliasName, "Err:%s", err))
 		}
 
-		//创建连接池
 		sqlDB, err := db.DB()
 		if err != nil {
 			global.LOG.Errorf("mysql 创建连接池失败,数据库:", conf.AliasName, ";Err:", err)
@@ -54,25 +51,18 @@ func Mysql() {
 
 		mysqlMap[conf.AliasName] = db
 
-		//默认数据库连接
 		if mysqlConf.DefaultDsnAliasName == conf.AliasName {
 			global.DEFAULT_MYSQL = db
 		}
 
-		// SetMaxIdleConns 设置空闲连接池中连接的最大数量
 		sqlDB.SetMaxIdleConns(conf.MaxIdleConns)
 
-		// SetMaxOpenConns 设置打开数据库连接的最大数量。
 		sqlDB.SetMaxOpenConns(conf.MaxOpenConns)
 
-		// SetConnMaxLifetime 设置了连接可复用的最大时间。
-		//sqlDB.SetConnMaxLifetime(time.Hour)
 	}
 
-	//全局赋值数据库链接
 	global.MYSQL = mysqlMap
 
-	// 开启mysql binlog监听
 	if mysqlConf.Binlog.IsListen {
 		go binlog.ListenMysql()
 	}

+ 0 - 37
init_serve/redis.go

@@ -6,46 +6,9 @@ import (
 	"fmt"
 )
 
-//func Redis() {
-//	redisConf := global.CONFIG.Redis
-//	client := redis.NewClient(&redis.Options{
-//		Addr:     redisConf.Address,
-//		Password: redisConf.Password,
-//		DB:       redisConf.Db,
-//		//PoolSize: 10, //连接池最大socket连接数,默认为10倍CPU数, 10 * runtime.NumCPU(暂不配置)
-//	})
-//	_, err := client.Ping(context.TODO()).Result()
-//	if err != nil {
-//		global.LOG.Error("redis 链接失败:", err)
-//		panic("redis 链接失败:" + err.Error())
-//	}
-//
-//	//全局赋值redis链接
-//	global.Redis = client
-//}
-//
-//func RedisTool() {
-//	fmt.Println("init RedisTool start")
-//	redisConf := global.CONFIG.Redis
-//	fmt.Println(redisConf)
-//	REDIS_CACHE := fmt.Sprintf(`{"key":"redis","conn":"%s","password":"%s"}`, redisConf.Address, redisConf.Password)
-//	fmt.Println("REDIS_CACHE:" + REDIS_CACHE)
-//	global.Rc, global.Re = cache.NewCache(REDIS_CACHE) //初始化缓存
-//	if global.Re != nil {
-//		fmt.Println(global.Re)
-//		panic(global.Re)
-//	}
-//	fmt.Println("init RedisTool end")
-//}
 
 func Redis() {
 	var conf string
-	//switch global.CONFIG.Redis.ServeType {
-	//case "cluster": // 集群
-	//	conf = fmt.Sprintf(`{"key":"redis","conn":"%s","password":"%s"}`,global.CONFIG.Redis.Address, global.CONFIG.Redis.Password)
-	//default: // 默认走单机
-	//	redisClient, err = redis.InitStandaloneRedis(conf)
-	//}
 	conf = fmt.Sprintf(`{"key":"redis","conn":"%s","password":"%s"}`, global.CONFIG.Redis.Address, global.CONFIG.Redis.Password)
 	redisClient, err := utils.InitRedis(global.CONFIG.Redis.ServeType, conf)
 

+ 0 - 1
init_serve/router.go

@@ -8,7 +8,6 @@ import (
 	"github.com/gin-gonic/gin"
 )
 
-// InitRouter 初始化路由
 func InitRouter() (r *gin.Engine) {
 	gin.SetMode(global.CONFIG.Serve.RunMode)
 

+ 0 - 9
init_serve/task.go

@@ -7,22 +7,13 @@ import (
 )
 
 func InitTask() {
-	// 如果配置文件中设置了停止任务,则不执行定时任务
-	// 此功能用于多服务器部署时,定时任务只需一台服务器执行,其他服务器不执行;所以只需要一台服务器设置为false,其他服务器设置为true
 	if global.CONFIG.Serve.IsStopTask {
 		return
 	}
 
-	// 修复数据
-	//if global.CONFIG.Gn.DataHost != `` {
-	//	fmt.Println("开始修复数据了")
-	//	index_data.FixData()
-	//}
 
-	// 开始定时任务
 	c := cron.New(cron.WithSeconds())
 
-	// 定时清除指标更新日志
 	if global.CONFIG.Mysql.Binlog.IsListen {
 		_, err := c.AddFunc("0 0 0 * * *", index_data.DeleteBeforeTenDayLog)
 		if err != nil {

+ 0 - 19
logic/gn/auth.go

@@ -9,15 +9,6 @@ import (
 	"time"
 )
 
-// LoginEta
-// @Description: 获取eta的session
-// @author: Roc
-// @datetime 2024-01-23 17:44:15
-// @param code string
-// @return resp response.LoginResp
-// @return err error
-// @return errMsg string
-// func LoginEta(code string) (resp response.GnUserResp, err error, errMsg string) {
 func LoginEta(code string) (resp response.LoginResp, err error, errMsg string) {
 	tokenResp, e := gn.GetToken(code)
 	if e != nil {
@@ -26,26 +17,18 @@ func LoginEta(code string) (resp response.LoginResp, err error, errMsg string) {
 	}
 	accessToken := tokenResp.AccessToken
 
-	// 获取用户信息
 	res, e := gn.GetUserInfo(code, accessToken)
 	if e != nil {
 		err = fmt.Errorf("获取用户基础信息失败, Err: %v, Code: %s, Token: %s", e, code, accessToken)
 		return
 	}
-	//resp.Sub = res.Sub
-	//resp.PreferredUsername = res.PreferredUsername
-	//resp.Name = res.Name
-	//resp.FamilyName = res.FamilyName
-	//resp.GivenName = res.GivenName
 
-	// 获取eta用户信息
 	adminInfo, e := eta.GetSysUserByAdminName(res.PreferredUsername)
 	if e != nil {
 		err = fmt.Errorf("用户不存在, UserName: %s", res.PreferredUsername)
 		return
 	}
 
-	// 生成登录session
 	sessionResp, session, e, _ := services.CreateEtaSession(adminInfo)
 	if e != nil {
 		err = fmt.Errorf("登录失败, %v", e)
@@ -53,7 +36,6 @@ func LoginEta(code string) (resp response.LoginResp, err error, errMsg string) {
 	}
 	resp = sessionResp
 
-	// 记录两方session的绑定信息
 	thirdSession := &eta.SysThirdSession{
 		SysUserID:        uint64(session.SysUserId),
 		UserName:         session.UserName,
@@ -68,7 +50,6 @@ func LoginEta(code string) (resp response.LoginResp, err error, errMsg string) {
 }
 
 func GetUserInfoByToken(token string) (res *gn.UserBaseInfoResp, err error, errMsg string) {
-	// 获取用户信息
 	res, e := gn.GetUserInfoBySci(token)
 	if e != nil {
 		err = fmt.Errorf("获取用户基础信息失败, Err: %v,  Token: %s", e, token)

+ 0 - 28
logic/gn/mdm.go

@@ -10,7 +10,6 @@ import (
 	"time"
 )
 
-// SyncSysDepartment 同步部门
 func SyncSysDepartment(mdmDepart *gn.MDM_COMSTRU) (err error) {
 	defer func() {
 		if err != nil {
@@ -22,16 +21,13 @@ func SyncSysDepartment(mdmDepart *gn.MDM_COMSTRU) (err error) {
 		return
 	}
 
-	// 上级编码为空, ETA中为部门
 	if mdmDepart.MainFieldParentAdminComstruCode == "" {
-		// 查询ETA中是否已同步
 		existDepart, e := eta.GetSysDepartmentByOutId(mdmDepart.MainFieldComstruCode)
 		if e != nil && !utils.IsErrNoRow(e) {
 			err = fmt.Errorf("获取ETA部门失败, %v", e)
 			return
 		}
 
-		// 已同步, 名称不一致时更新
 		if existDepart != nil && existDepart.DepartmentId > 0 {
 			if existDepart.DepartmentName != mdmDepart.MainFieldComstruNameHR {
 				existDepart.DepartmentName = mdmDepart.MainFieldComstruNameHR
@@ -43,7 +39,6 @@ func SyncSysDepartment(mdmDepart *gn.MDM_COMSTRU) (err error) {
 			return
 		}
 
-		// 新增部门
 		newDepart := new(eta.SysDepartment)
 		newDepart.DepartmentName = mdmDepart.MainFieldComstruNameHR
 		newDepart.OutID = mdmDepart.MainFieldComstruCode
@@ -56,11 +51,9 @@ func SyncSysDepartment(mdmDepart *gn.MDM_COMSTRU) (err error) {
 		return
 	}
 
-	// 上级编码不为空, ETA中为分组
 	if mdmDepart.MainFieldParentAdminComstruCode != "" {
 		var departmentId, parentId int
 		var isFind bool
-		// 查询父级, 先从分组中找
 		parentGroup, e := eta.GetSysGroupByOutId(mdmDepart.MainFieldParentAdminComstruCode)
 		if e != nil && !utils.IsErrNoRow(e) {
 			err = fmt.Errorf("获取ETA父级分组失败, %v", e)
@@ -88,14 +81,12 @@ func SyncSysDepartment(mdmDepart *gn.MDM_COMSTRU) (err error) {
 			return
 		}
 
-		// 查询ETA中是否已同步
 		existGroup, e := eta.GetSysGroupByOutId(mdmDepart.MainFieldComstruCode)
 		if e != nil && !utils.IsErrNoRow(e) {
 			err = fmt.Errorf("获取ETA分组失败, %v", e)
 			return
 		}
 
-		// 已同步则更新
 		if existGroup != nil && existGroup.GroupId > 0 {
 			updateCols := []string{"GroupName", "DepartmentId", "ParentId"}
 			existGroup.GroupName = mdmDepart.MainFieldComstruNameHR
@@ -107,7 +98,6 @@ func SyncSysDepartment(mdmDepart *gn.MDM_COMSTRU) (err error) {
 			return
 		}
 
-		// 否则新增分组
 		newGroup := new(eta.SysGroup)
 		newGroup.DepartmentId = departmentId
 		newGroup.GroupName = mdmDepart.MainFieldComstruNameHR
@@ -122,11 +112,9 @@ func SyncSysDepartment(mdmDepart *gn.MDM_COMSTRU) (err error) {
 		}
 	}
 
-	// TODO:父级从分组到部门交叉改变的情况?
 	return
 }
 
-// GetDepartmentGroupIdByMdmCode 根据MDM的部门编码获取ETA的部门和分组ID
 func GetDepartmentGroupIdByMdmCode(mdmCode string) (departmentId, groupId int, departmentName, groupName string, err error) {
 	defer func() {
 		if departmentId == 0 && groupId == 0 {
@@ -134,21 +122,7 @@ func GetDepartmentGroupIdByMdmCode(mdmCode string) (departmentId, groupId int, d
 		}
 	}()
 
-	// 校验一下MDM部门是否存在?
-	//mdmDepartOb := new(gn.MDM_COMSTRU)
-	//cond := ` AND Main_Field_Comstru_Code = ?`
-	//pars := make([]interface{}, 0)
-	//_, e := mdmDepartOb.GetItemByCondition(cond, pars)
-	//if e != nil {
-	//	if utils.IsErrNoRow(e) {
-	//		err = fmt.Errorf("MDM部门不存在, code: %s", mdmCode)
-	//		return
-	//	}
-	//	err = fmt.Errorf("获取MDM部门失败, %v", e)
-	//	return
-	//}
 
-	// 先查分组, 查得到的话直接返回
 	groupOb := new(eta.SysGroup)
 	cond := ` AND out_id = ?`
 	pars := make([]interface{}, 0)
@@ -161,7 +135,6 @@ func GetDepartmentGroupIdByMdmCode(mdmCode string) (departmentId, groupId int, d
 	if groupItem != nil && groupItem.GroupId > 0 {
 		groupId = groupItem.GroupId
 		groupName = groupItem.GroupName
-		// 查询部门
 		depart, e := eta.GetDepartmentById(groupItem.DepartmentId)
 		if e != nil && !utils.IsErrNoRow(e) {
 			err = fmt.Errorf("获取部门失败, %v", e)
@@ -172,7 +145,6 @@ func GetDepartmentGroupIdByMdmCode(mdmCode string) (departmentId, groupId int, d
 		return
 	}
 
-	// 查部门
 	departOb := new(eta.SysDepartment)
 	departItem, e := departOb.GetItemByCondition(cond, pars)
 	if e != nil && !utils.IsErrNoRow(e) {

+ 0 - 284
logic/gn/user.go

@@ -9,270 +9,12 @@ import (
 	"time"
 )
 
-// SyncUser
-// @Description: 全量同步用户
-// @author: Roc
-// @datetime 2024-01-22 10:28:39
-// @return err error
-//func SyncUser() (err error) {
-//	roleId := global.CONFIG.Gn.DefaultRoleId
-//	if roleId <= 0 {
-//		err = fmt.Errorf("默认角色ID不能为空")
-//		return
-//	}
-//	if global.CONFIG.Gn.DefaultUserPass == "" {
-//		err = fmt.Errorf("默认用户密码不能为空")
-//		return
-//	}
-//
-//	// 指定的角色
-//	roleInfo, e := eta.GetSysRoleById(roleId)
-//	if e != nil {
-//		err = fmt.Errorf("获取默认角色信息失败, %v", e)
-//		return
-//	}
-//
-//	// 获取所有部门和分组
-//	departmentMap, _, groupMap, _, userMap, e := getAllDepartmentAndGroup()
-//	if e != nil {
-//		err = fmt.Errorf("获取部门/分组/用户失败, %v", e)
-//		return
-//	}
-//
-//	// 从公共库里面读取部门和用户
-//	oaUser, e := gn.GetGnOaUser()
-//	if e != nil {
-//		err = fmt.Errorf("获取OA全量用户失败, %v", e)
-//		return
-//	}
-//
-//	for _, v := range oaUser {
-//		fmt.Printf("正在同步用户: %s\n", v.AddrName)
-//		e = handleUser(v, departmentMap, groupMap, userMap, roleInfo)
-//		if e != nil {
-//			err = fmt.Errorf("同步OA用户失败, %v", e)
-//			return
-//		}
-//	}
-//	return
-//}
 
-// getAllDepartmentAndGroup
-// @Description: 获取所有的部门和分组
-// @author: Roc
-// @datetime 2024-01-18 17:39:14
-// @return departmentMap map[string]*eta.SysDepartment
-// @return groupMap map[string]*eta.SysGroup
-// @return err error
-//func getAllDepartmentAndGroup() (departmentMap, departmentNameMap map[string]*eta.SysDepartment, groupMap, groupNameMap map[string]*eta.SysGroup, userMap map[string]*eta.Admin, err error) {
-//	// 获取所有的部门
-//	departmentList, e := eta.GetAllDepartment()
-//	if e != nil {
-//		err = fmt.Errorf("获取所有部门失败, %v", e)
-//		return
-//	}
-//	departmentMap = make(map[string]*eta.SysDepartment)
-//	departmentNameMap = make(map[string]*eta.SysDepartment)
-//	for _, department := range departmentList {
-//		if department.OutID == `` {
-//			//departmentNameMap[department.DepartmentName] = department
-//		} else {
-//			departmentMap[department.OutID] = department
-//		}
-//	}
-//
-//	// 获取所有的分组
-//	groupList, e := eta.GetAllSysGroup()
-//	if e != nil {
-//		err = fmt.Errorf("获取所有分组失败, %v", e)
-//		return
-//	}
-//	groupMap = make(map[string]*eta.SysGroup)
-//	groupNameMap = make(map[string]*eta.SysGroup)
-//	for _, group := range groupList {
-//		if group.OutID == `` {
-//			//groupNameMap[fmt.Sprint(group.DepartmentId, "_", group.GroupName)] = group
-//		} else {
-//			groupMap[group.OutID] = group
-//		}
-//	}
-//
-//	// 获取所有的用户
-//	adminList, e := eta.GetAllSysUser()
-//	if e != nil {
-//		err = fmt.Errorf("获取所有用户失败, %v", e)
-//		return
-//	}
-//	userMap = make(map[string]*eta.Admin)
-//	for _, admin := range adminList {
-//		userMap[admin.AdminName] = admin
-//	}
-//	return
-//}
 
-//func handleUser(oaUser *gn.OaUser, departmentMap map[string]*eta.SysDepartment, groupMap map[string]*eta.SysGroup, userMap map[string]*eta.Admin, roleInfo *eta.SysRole) (err error) {
-//	if oaUser == nil {
-//		err = fmt.Errorf("OA用户信息不存在")
-//		return
-//	}
-//	// 从部门字段中拆分出部门和分组, 数据格式: 销售业务部/福建办事处/华南销售分公司, 层级不定, 目前最大3级
-//	oaUser.AddrDepartmentFullName = strings.TrimSpace(oaUser.AddrDepartmentFullName)
-//	departmentArr := strings.Split(oaUser.AddrDepartmentFullName, "/")
-//	//var departmentId, groupId int
-//	departmentLen := len(departmentArr)
-//	departmentInfo := new(eta.SysDepartment)
-//	groupInfo := new(eta.SysGroup)
-//	if departmentLen > 0 {
-//		// 部门是最后那个
-//		departmentName := departmentArr[departmentLen-1]
-//		depart, ok := departmentMap[departmentName]
-//		if !ok {
-//			// 如果没有的话,那么就创建该部门
-//			depart = &eta.SysDepartment{
-//				DepartmentName: departmentName,
-//				OutID:          departmentName, // 因为部门是从用户信息中取的, 没有ID这种字段, 所以部门全程作为out_id
-//				CreateTime:     time.Now(),
-//			}
-//			if err = depart.Create(); err != nil {
-//				return
-//			}
-//
-//			departmentMap[departmentName] = depart
-//		} else {
-//			// TODO:是否更新outId
-//		}
-//		departmentInfo = depart
-//
-//		// 分组信息
-//		reversed := departmentArr
-//		for i, j := 0, departmentLen-1; i < j; i, j = i+1, j-1 {
-//			reversed[i], reversed[j] = reversed[j], reversed[i]
-//		}
-//		lastOutId := departmentName // 分组的out_id格式: 部门out_id_一级分组out_id_二级分组out_id...
-//		for k, v := range reversed {
-//			if k == 0 {
-//				continue
-//			}
-//
-//			lastOutId = fmt.Sprintf("%s_%s", lastOutId, v)
-//			group, ok := groupMap[lastOutId]
-//			if !ok {
-//				group = &eta.SysGroup{
-//					DepartmentId: departmentInfo.DepartmentId,
-//					GroupName:    v,
-//					CreateTime:   time.Now(),
-//					ParentId:     groupInfo.GroupId,
-//					OutID:        lastOutId,
-//				}
-//				if err = group.Create(); err != nil {
-//					return
-//				}
-//
-//				groupMap[lastOutId] = group
-//			} else {
-//				// TODO:是否更新outId
-//			}
-//			groupInfo = group
-//		}
-//	}
-//
-//	// 同步用户
-//	userInfo, ok := userMap[oaUser.AddrUserId]
-//	if !ok {
-//		userInfo = &eta.Admin{
-//			AdminName:                 oaUser.AddrUserId,
-//			RealName:                  oaUser.AddrName,
-//			Password:                  utils.MD5(global.CONFIG.Gn.DefaultUserPass),
-//			Enabled:                   1,
-//			Email:                     "",
-//			CreatedTime:               time.Now(),
-//			LastUpdatedTime:           time.Now(),
-//			Mobile:                    oaUser.AddrMobilePhone,
-//			RoleType:                  0,
-//			RoleId:                    roleInfo.RoleId,
-//			RoleName:                  roleInfo.RoleName,
-//			RoleTypeCode:              roleInfo.RoleTypeCode,
-//			DepartmentId:              departmentInfo.DepartmentId,
-//			DepartmentName:            departmentInfo.DepartmentName,
-//			GroupId:                   groupInfo.GroupId,
-//			GroupName:                 groupInfo.GroupName,
-//			Authority:                 0,
-//			Position:                  oaUser.AddrJobTitle,
-//			ChartPermission:           0,
-//			EdbPermission:             0,
-//			MysteelChemicalPermission: 0,
-//			OpenId:                    "",
-//			UnionId:                   "",
-//			PredictEdbPermission:      0,
-//			Province:                  "",
-//			ProvinceCode:              "",
-//			City:                      "",
-//			CityCode:                  "",
-//			EmployeeId:                "",
-//			TelAreaCode:               "",
-//			OutID:                     oaUser.AddrUserId,
-//		}
-//		if err = userInfo.Create(); err != nil {
-//			return
-//		}
-//		userMap[oaUser.AddrUserId] = userInfo
-//	} else {
-//		updateColList := make([]string, 0)
-//
-//		// 部门
-//		if userInfo.DepartmentId != departmentInfo.DepartmentId {
-//			updateColList = append(updateColList, "DepartmentId", "DepartmentName")
-//			userInfo.DepartmentId = departmentInfo.DepartmentId
-//			userInfo.DepartmentName = departmentInfo.DepartmentName
-//		}
-//
-//		// 分组
-//		if userInfo.GroupId != groupInfo.GroupId {
-//			updateColList = append(updateColList, "GroupId", "GroupName")
-//			userInfo.GroupId = groupInfo.GroupId
-//			userInfo.GroupName = groupInfo.GroupName
-//		}
-//
-//		// 职位
-//		if userInfo.Position != oaUser.AddrJobTitle {
-//			updateColList = append(updateColList, "Position")
-//			userInfo.Position = oaUser.AddrJobTitle
-//		}
-//
-//		// 姓名
-//		if userInfo.RealName != oaUser.AddrName {
-//			updateColList = append(updateColList, "RealName")
-//			userInfo.RealName = oaUser.AddrName
-//		}
-//
-//		// 手机号
-//		if userInfo.Mobile != oaUser.AddrMobilePhone {
-//			updateColList = append(updateColList, "Mobile")
-//			userInfo.Mobile = oaUser.AddrMobilePhone
-//		}
-//
-//		// 外部id
-//		if userInfo.OutID == `` {
-//			updateColList = append(updateColList, "OutID")
-//			userInfo.OutID = oaUser.AddrUserId
-//		}
-//
-//		if len(updateColList) > 0 {
-//			updateColList = append(updateColList, "LastUpdatedTime")
-//			userInfo.LastUpdatedTime = time.Now()
-//			if err = userInfo.Update(updateColList); err != nil {
-//				return
-//			}
-//		}
-//	}
-//	return
-//}
 
-// AddAccount 创建新账号
 func AddAccount(userReq gn.UserEntity) (errMsg string, err error) {
 	adminName := *userReq.UserId
 
-	// 校验是否存在, 若存在则更新信息, 否则新增
 	userInfo, e := eta.GetSysUserByAdminName(adminName)
 	if e != nil && !utils.IsErrNoRow(e) {
 		errMsg = "用户不存在"
@@ -280,7 +22,6 @@ func AddAccount(userReq gn.UserEntity) (errMsg string, err error) {
 		return
 	}
 
-	// 更新数据
 	if userInfo != nil && userInfo.AdminId > 0 {
 		if e = UpdateUser(userInfo, userReq); e != nil {
 			errMsg = "操作失败"
@@ -290,7 +31,6 @@ func AddAccount(userReq gn.UserEntity) (errMsg string, err error) {
 		return
 	}
 
-	// 新增数据
 	newUser := new(eta.Admin)
 	newUser.AdminName = adminName
 	newUser.RealName = fmt.Sprint(*userReq.LastName, *userReq.FirstName)
@@ -300,7 +40,6 @@ func AddAccount(userReq gn.UserEntity) (errMsg string, err error) {
 	newUser.Email = *userReq.Mail
 	newUser.Mobile = *userReq.Mobile
 	newUser.Position = *userReq.TitleName
-	// 部门分组
 	departmentId, groupId, departmentName, groupName, e := GetDepartmentGroupIdByMdmCode(*userReq.DepartmentNum)
 	if e != nil {
 		errMsg = "操作失败"
@@ -315,15 +54,12 @@ func AddAccount(userReq gn.UserEntity) (errMsg string, err error) {
 	newUser.LastUpdatedTime = time.Now()
 	newUser.OutID = *userReq.EmpNumber // 这里用工号
 
-	// 默认角色
 	if global.CONFIG.Gn.DefaultRoleId > 0 {
 		roleInfo, tmpErr := eta.GetSysRoleById(global.CONFIG.Gn.DefaultRoleId)
 		if tmpErr == nil {
-			// 默认角色
 			newUser.RoleId = roleInfo.RoleId
 			newUser.RoleName = roleInfo.RoleName
 			newUser.RoleTypeCode = roleInfo.RoleTypeCode
-			//newUser.RoleType = roleInfo.RoleType
 		}
 	}
 	if e = newUser.Create(); e != nil {
@@ -334,19 +70,16 @@ func AddAccount(userReq gn.UserEntity) (errMsg string, err error) {
 	return
 }
 
-// UpdateUser 更新用户非null字段
 func UpdateUser(originUser *eta.Admin, userReq gn.UserEntity) (err error) {
 	if originUser == nil {
 		err = fmt.Errorf("用户信息有误")
 		return
 	}
 	updateCols := make([]string, 0)
-	// 密码
 	if userReq.Password != nil {
 		originUser.Password = utils.MD5(*userReq.Password)
 		updateCols = append(updateCols, "Password")
 	}
-	// 部门分组
 	if userReq.DepartmentNum != nil {
 		departmentId, groupId, departmentName, groupName, e := GetDepartmentGroupIdByMdmCode(*userReq.DepartmentNum)
 		if e != nil {
@@ -359,18 +92,15 @@ func UpdateUser(originUser *eta.Admin, userReq gn.UserEntity) (err error) {
 		originUser.GroupName = groupName
 		updateCols = append(updateCols, "DepartmentId", "DepartmentName", "GroupId", "GroupName")
 	}
-	// 姓名
 	if userReq.FirstName != nil && userReq.LastName != nil {
 		originUser.RealName = fmt.Sprint(*userReq.LastName, *userReq.FirstName)
 		updateCols = append(updateCols, "RealName")
 	}
-	// 状态
 	if userReq.UserStatus != nil {
 		statsMap := map[string]int{gn.UserStatusActive: 1, gn.UserStatusDisable: 0}
 		originUser.Enabled = statsMap[*userReq.UserStatus]
 		updateCols = append(updateCols, "Enabled")
 	}
-	// 联系方式
 	if userReq.Mail != nil {
 		originUser.Email = *userReq.Mail
 		updateCols = append(updateCols, "Email")
@@ -379,12 +109,10 @@ func UpdateUser(originUser *eta.Admin, userReq gn.UserEntity) (err error) {
 		originUser.Mobile = *userReq.Mobile
 		updateCols = append(updateCols, "Mobile")
 	}
-	// 职位
 	if userReq.TitleName != nil {
 		originUser.Position = *userReq.TitleName
 		updateCols = append(updateCols, "Position")
 	}
-	// 更新数据
 	originUser.LastUpdatedTime = time.Now()
 	updateCols = append(updateCols, "LastUpdatedTime")
 	if e := originUser.Update(updateCols); e != nil {
@@ -394,11 +122,9 @@ func UpdateUser(originUser *eta.Admin, userReq gn.UserEntity) (err error) {
 	return
 }
 
-// ModifyAccount 修改账号
 func ModifyAccount(userReq gn.UserEntity) (errMsg string, err error) {
 	adminName := *userReq.UserId
 
-	// 校验是否存在, 不存在返回异常
 	userInfo, e := eta.GetSysUserByAdminName(adminName)
 	if e != nil {
 		if utils.IsErrNoRow(e) {
@@ -411,7 +137,6 @@ func ModifyAccount(userReq gn.UserEntity) (errMsg string, err error) {
 		return
 	}
 
-	// 更新数据
 	if e = UpdateUser(userInfo, userReq); e != nil {
 		errMsg = "操作失败"
 		err = fmt.Errorf("更新用户数据失败, %v", e)
@@ -420,9 +145,7 @@ func ModifyAccount(userReq gn.UserEntity) (errMsg string, err error) {
 	return
 }
 
-// DeleteAccount 删除账号
 func DeleteAccount(userId string) (errMsg string, err error) {
-	// 校验是否存在, 不存在返回成功
 	_, e := eta.GetSysUserByAdminName(userId)
 	if e != nil {
 		if utils.IsErrNoRow(e) {
@@ -433,7 +156,6 @@ func DeleteAccount(userId string) (errMsg string, err error) {
 		return
 	}
 
-	// 删除用户
 	if e = eta.DeleteSysUserByName(userId); e != nil {
 		errMsg = "操作失败"
 		err = fmt.Errorf("删除用户失败, %v", e)
@@ -442,9 +164,7 @@ func DeleteAccount(userId string) (errMsg string, err error) {
 	return
 }
 
-// SuspendAccount 停用账号
 func SuspendAccount(userId string) (errMsg string, err error) {
-	// 校验是否存在, 不存在返回异常
 	userInfo, e := eta.GetSysUserByAdminName(userId)
 	if e != nil {
 		if utils.IsErrNoRow(e) {
@@ -468,9 +188,7 @@ func SuspendAccount(userId string) (errMsg string, err error) {
 	return
 }
 
-// RestoreAccount 启用账号
 func RestoreAccount(userId string) (errMsg string, err error) {
-	// 校验是否存在, 不存在返回异常
 	userInfo, e := eta.GetSysUserByAdminName(userId)
 	if e != nil {
 		if utils.IsErrNoRow(e) {
@@ -494,9 +212,7 @@ func RestoreAccount(userId string) (errMsg string, err error) {
 	return
 }
 
-// ChangePassword 修改密码
 func ChangePassword(userId, newPassword string) (errMsg string, err error) {
-	// 校验是否存在, 不存在返回异常
 	userInfo, e := eta.GetSysUserByAdminName(userId)
 	if e != nil {
 		if utils.IsErrNoRow(e) {

+ 0 - 1
main.go

@@ -4,7 +4,6 @@ import (
 	"eta_gn/eta_bridge/core"
 )
 
-// @BasePath /
 func main() {
 	core.RunServe()
 }

+ 0 - 14
middleware/auth.go

@@ -46,7 +46,6 @@ func signCheck(c *gin.Context) (ok bool, err error) {
 	}
 	signData := convertParam(params)
 
-	// 签名校验
 	ip := c.ClientIP()
 	err = checkSignData(signData, ip)
 	if err != nil {
@@ -56,7 +55,6 @@ func signCheck(c *gin.Context) (ok bool, err error) {
 	return
 }
 
-// convertParam 将请求传入的数据格式转换成签名需要的格式
 func convertParam(params map[string][]string) (signData map[string]string) {
 	signData = make(map[string]string)
 	for key := range params {
@@ -65,10 +63,8 @@ func convertParam(params map[string][]string) (signData map[string]string) {
 	return signData
 }
 
-// checkSignData 请求参数签名校验
 func checkSignData(postData map[string]string, ip string) (err error) {
 	isSandbox := postData["is_sandbox"]
-	// 如果是测试环境, 且是沙箱环境的话, 那么绕过测试
 	if global.CONFIG.Serve.RunMode == "debug" && isSandbox != "" {
 		return
 	}
@@ -94,7 +90,6 @@ func checkSignData(postData map[string]string, ip string) (err error) {
 		return
 	}
 
-	// 如果有ip限制, 则校验IP
 	if apiUser.Ip != "" {
 		if !strings.Contains(apiUser.Ip, ip) {
 			err = errors.New(fmt.Sprintf("无权限访问该接口,ip:%v,请联系管理员", ip))
@@ -102,7 +97,6 @@ func checkSignData(postData map[string]string, ip string) (err error) {
 		}
 	}
 
-	// 接口提交的签名字符串
 	ownSign := postData["sign"]
 	if ownSign == "" {
 		err = errors.New("参数异常,缺少签名字符串")
@@ -117,7 +111,6 @@ func checkSignData(postData map[string]string, ip string) (err error) {
 		return
 	} else {
 		timeUnix := time.Now().Unix() // 当前格林威治时间,int64类型
-		// 将接口传入的时间做转换
 		timestamp, timeErr := strconv.ParseInt(postData["timestamp"], 10, 64)
 		if timeErr != nil {
 			err = errors.New("参数异常,时间戳格式异常")
@@ -129,7 +122,6 @@ func checkSignData(postData map[string]string, ip string) (err error) {
 		}
 	}
 
-	// 先取出除sign外的所有的提交的参数key
 	var keys []string
 	for k := range postData {
 		if k != "sign" {
@@ -137,19 +129,13 @@ func checkSignData(postData map[string]string, ip string) (err error) {
 		}
 	}
 
-	//1,根据参数名称的ASCII码表的顺序排序
 	sort.Strings(keys)
 
-	//2 根据排序后的参数名称,取出对应的值,并拼接字符串
 	var signStr string
 	for _, v := range keys {
 		signStr += v + "=" + postData[v] + "&"
 	}
-	//3,全转小写(md5(拼装的字符串后+分配给你的app_secret))
-	//sign := strings.ToLower(fmt.Sprintf("%x", md5.Sum([]byte(strings.Trim(signStr, "&")+key))))
 
-	//md5.Sum([]byte(signStr+"key="+key))  这是md5加密出来后的每个字符的AscII码,需要再转换成对应的字符
-	//3,全转大写(md5(拼装的字符串后+分配给你的app_secret))
 	sign := strings.ToUpper(fmt.Sprintf("%x", md5.Sum([]byte(signStr+"secret="+apiUser.Secret))))
 	if sign != ownSign {
 		global.LOG.Info(fmt.Sprintf("签名校验异常,签名字符串:%v;服务端签名值:%v", signStr, sign))

+ 0 - 37
middleware/common.go

@@ -10,35 +10,9 @@ import (
 	"strconv"
 )
 
-// Common 公共中间件
-//func Common() gin.HandlerFunc {
-//	return func(c *gin.Context) {
-//		var currPage, pageSize int
-//		reqPage := c.DefaultQuery("curr_page", "0")
-//		currPage, _ = strconv.Atoi(reqPage)
-//		if currPage <= 0 {
-//			currPage = 1
-//		}
-//
-//		reqPageSize := c.DefaultQuery("page_size", "0")
-//		pageSize, _ = strconv.Atoi(reqPageSize)
-//		if pageSize <= 0 {
-//			pageSize = 20
-//		}
-//		c.Set("curr_page", currPage)
-//		c.Set("page_size", pageSize)
-//		c.Next()
-//	}
-//}
 
 type Common struct{}
 
-// Page
-// @Description: 分页参数
-// @author: Roc
-// @receiver common
-// @datetime 2024-10-31 10:19:36
-// @param c *gin.Context
 func (common *Common) Page(c *gin.Context) {
 	var currPage, pageSize int
 	reqPage := c.DefaultQuery("curr_page", "0")
@@ -57,27 +31,16 @@ func (common *Common) Page(c *gin.Context) {
 	c.Next()
 }
 
-// RequestLog
-// @Description: 请求参数日志
-// @author: Roc
-// @receiver common
-// @datetime 2024-10-31 10:19:36
-// @param c *gin.Context
 func (common *Common) RequestLog(c *gin.Context) {
-	// 读取请求体
 	body, err := io.ReadAll(c.Request.Body)
 	if err != nil {
-		//log.Printf("Error reading request body: %v", err)
 		c.AbortWithStatus(http.StatusInternalServerError)
 		return
 	}
 
-	// 将请求地址添加到上下文的日志中
 	utils.SetBridgeLogListByClaims(c, fmt.Sprint("Url:", c.Request.RequestURI))
-	// 将请求参数添加到上下文的日志中
 	utils.SetBridgeLogListByClaims(c, fmt.Sprint("RequestBody:", string(body)))
 
-	// 将请求体恢复到原始状态
 	c.Request.Body = io.NopCloser(bytes.NewBuffer(body))
 
 	c.Next()

+ 0 - 4
middleware/cors.go

@@ -5,23 +5,19 @@ import (
 	"net/http"
 )
 
-// Cors 处理跨域请求,支持options访问
 func Cors() gin.HandlerFunc {
 	return func(c *gin.Context) {
 		method := c.Request.Method
 
 		c.Header("Access-Control-Allow-Origin", "*")
-		//c.Header("Access-Control-Allow-Origin", c.Request.Referer())
 		c.Header("Access-Control-Allow-Headers", "Content-Type,AccessToken,X-CSRF-Token, Authorization, Token,X-Token,X-User-Id")
 		c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS,DELETE,PUT")
 		c.Header("Access-Control-Expose-Headers", "Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type")
 		c.Header("Access-Control-Allow-Credentials", "true")
 
-		// 放行所有OPTIONS方法
 		if method == "OPTIONS" {
 			c.AbortWithStatus(http.StatusNoContent)
 		}
-		// 处理请求
 		c.Next()
 	}
 }

+ 0 - 2
middleware/recover.go

@@ -12,11 +12,9 @@ import (
 	"time"
 )
 
-// Recover 异常处理
 func Recover() gin.HandlerFunc {
 	return func(c *gin.Context) {
 		contentType := c.ContentType()
-		// 为 multipart forms 设置较低的内存限制(50M) (默认是 32 MiB)
 		if contentType == "multipart/form-data" {
 			err := c.Request.ParseMultipartForm(10 << 20)
 			if err != nil {

+ 0 - 17
models/base/base.go

@@ -10,7 +10,6 @@ import (
 
 var globalIsRelated bool = true // 全局预加载
 
-// prepare for other
 type BaseMgr struct {
 	*gorm.DB
 	Ctx       context.Context
@@ -19,55 +18,45 @@ type BaseMgr struct {
 	isRelated bool
 }
 
-// SetTimeOut set timeout
 func (obj *BaseMgr) SetTimeOut(timeout time.Duration) {
 	obj.Ctx, obj.cancel = context.WithTimeout(context.Background(), timeout)
 	obj.timeout = timeout
 }
 
-// SetCtx set context
 func (obj *BaseMgr) SetCtx(c context.Context) {
 	if c != nil {
 		obj.Ctx = c
 	}
 }
 
-// GetCtx get context
 func (obj *BaseMgr) GetCtx() context.Context {
 	return obj.Ctx
 }
 
-// Cancel cancel context
 func (obj *BaseMgr) Cancel(c context.Context) {
 	obj.cancel()
 }
 
-// GetDB get gorm.DB info
 func (obj *BaseMgr) GetDB() *gorm.DB {
 	return obj.DB
 }
 
-// UpdateDB update gorm.DB info
 func (obj *BaseMgr) UpdateDB(db *gorm.DB) {
 	obj.DB = db
 }
 
-// GetIsRelated Query foreign key Association.获取是否查询外键关联(gorm.Related)
 func (obj *BaseMgr) GetIsRelated() bool {
 	return obj.isRelated
 }
 
-// SetIsRelated Query foreign key Association.设置是否查询外键关联(gorm.Related)
 func (obj *BaseMgr) SetIsRelated(b bool) {
 	obj.isRelated = b
 }
 
-// New new gorm.新gorm,重置条件
 func (obj *BaseMgr) New() {
 	obj.DB = obj.NewDB()
 }
 
-// NewDB new gorm.新gorm
 func (obj *BaseMgr) NewDB() *gorm.DB {
 	return obj.DB.Session(&gorm.Session{NewDB: true, Context: obj.Ctx})
 }
@@ -76,7 +65,6 @@ type Options struct {
 	Query map[string]interface{}
 }
 
-// Option overrides behavior of Connect.
 type Option interface {
 	Apply(*Options)
 }
@@ -87,17 +75,14 @@ func (f OptionFunc) apply(o *Options) {
 	f(o)
 }
 
-// OpenRelated 打开全局预加载
 func OpenRelated() {
 	globalIsRelated = true
 }
 
-// CloseRelated 关闭全局预加载
 func CloseRelated() {
 	globalIsRelated = true
 }
 
-// 自定义sql查询
 type Condition struct {
 	list []*conditionInfo
 }
@@ -114,7 +99,6 @@ func (c *Condition) AndWithCondition(condition bool, column string, cases string
 	return c
 }
 
-// And a Condition by and .and 一个条件
 func (c *Condition) And(column string, cases string, value interface{}) *Condition {
 	return c.AndWithCondition(true, column, cases, value)
 }
@@ -131,7 +115,6 @@ func (c *Condition) OrWithCondition(condition bool, column string, cases string,
 	return c
 }
 
-// Or a Condition by or .or 一个条件
 func (c *Condition) Or(column string, cases string, value interface{}) *Condition {
 	return c.OrWithCondition(true, column, cases, value)
 }

+ 1 - 1
models/base/time_base.go

@@ -10,4 +10,4 @@ type TimeBase struct {
 func (item *TimeBase) Set() {
 	item.CreateTime = time.Now()
 	item.ModifyTime = time.Now()
-}
+}

+ 0 - 2
models/crm/admin.go

@@ -5,7 +5,6 @@ import (
 	"time"
 )
 
-// Admin 管理员表
 type Admin struct {
 	AdminId                   int       `gorm:"primaryKey;column:admin_id;type:bigint(20);not null" json:"admin_id"`
 	AdminName                 string    `gorm:"uniqueIndex:un;index:name;index:admin_pass;column:admin_name;type:varchar(60);not null" json:"admin_name"`
@@ -49,7 +48,6 @@ func (m *Admin) TableName() string {
 	return "admin"
 }
 
-// GetSysUserByAdminName 用户名获取系统用户
 func GetSysUserByAdminName(adminName string) (item *Admin, err error) {
 	err = global.MYSQL["hz_crm"].Where("admin_name = ?", adminName).First(&item).Error
 	return

+ 0 - 1
models/crm/open_api_user.go

@@ -18,7 +18,6 @@ func (m *OpenApiUser) TableName() string {
 	return "open_api_user"
 }
 
-// GetItemByAppid AppID获取信息
 func (m *OpenApiUser) GetItemByAppid(appid string) (item *OpenApiUser, err error) {
 	err = global.MYSQL["hz_crm"].Model(m).Where("appid = ?", appid).First(&item).Error
 	return

+ 0 - 8
models/eta/admin.go

@@ -6,7 +6,6 @@ import (
 	"time"
 )
 
-// Admin 管理员表
 type Admin struct {
 	AdminId                   int       `gorm:"primaryKey;column:admin_id;type:bigint(20);not null" json:"admin_id"`
 	AdminName                 string    `gorm:"uniqueIndex:un;index:name;index:admin_pass;column:admin_name;type:varchar(60);not null" json:"admin_name"`
@@ -51,45 +50,38 @@ func (m *Admin) TableName() string {
 	return "admin"
 }
 
-// Create 新增用户
 func (m *Admin) Create() (err error) {
 	err = global.MYSQL["hz_eta"].Create(m).Error
 	return
 }
 
-// Update 更新用户
 func (m *Admin) Update(cols []string) (err error) {
 	err = global.MYSQL["hz_eta"].Model(m).Select(cols).Updates(m).Error
 	return
 }
 
-// GetSysUserById 主键获取系统用户
 func GetSysUserById(sysUserId int) (item *Admin, err error) {
 	err = global.MYSQL["hz_eta"].Where("admin_id = ?", sysUserId).First(&item).Error
 	return
 }
 
-// GetSysUserByAdminName 用户名获取系统用户
 func GetSysUserByAdminName(adminName string) (item *Admin, err error) {
 	err = global.MYSQL["hz_eta"].Where("admin_name = ?", adminName).First(&item).Error
 	return
 }
 
-// DeleteSysUserByName 根据用户名删除用户
 func DeleteSysUserByName(adminName string) (err error) {
 	sql := `DELETE FROM admin WHERE admin_name = ? LIMIT 1`
 	err = global.MYSQL["hz_eta"].Exec(sql, adminName).Error
 	return
 }
 
-// GetAllSysUser 获取所有用户
 func GetAllSysUser() (items []*Admin, err error) {
 	sql := `SELECT * FROM "admin" `
 	err = global.MYSQL["hz_eta"].Raw(sql).Find(&items).Error
 	return
 }
 
-// GetSysUserByOutId 通过外部id获取系统用户
 func GetSysUserByOutId(outId string) (item *Admin, err error) {
 	if outId == `` {
 		err = errors.New("outId不能为空")

+ 0 - 3
models/eta/crm_config.go

@@ -9,7 +9,6 @@ const (
 	ConfEnAuthRoleKey = "en_auth_role" // 英文权限角色配置Key
 )
 
-// CrmConfig CRM配置表
 type CrmConfig struct {
 	ConfigId    int       `gorm:"primaryKey;column:config_id;type:int(11);not null" json:"config_id"`
 	ConfigCode  string    `gorm:"column:config_code;type:varchar(50);default:''" json:"config_code"` // 配置编码
@@ -22,13 +21,11 @@ func (m *CrmConfig) TableName() string {
 	return "crm_config"
 }
 
-// GetCrmConfByCode code获取配置
 func GetCrmConfByCode(code string) (item *CrmConfig, err error) {
 	err = global.MYSQL["hz_eta"].Where("config_code = ?", code).First(&item).Error
 	return
 }
 
-// ConfEnAuthRole 配置-英文权限角色
 type ConfEnAuthRole struct {
 	RoleCode string `description:"角色编码"`
 	RoleName string `description:"角色名称"`

+ 0 - 7
models/eta/sys_department.go

@@ -19,33 +19,27 @@ func (m *SysDepartment) TableName() string {
 	return "sys_department"
 }
 
-// Create 新增部门
 func (m *SysDepartment) Create() (err error) {
 	err = global.MYSQL["hz_eta"].Create(m).Error
 	return
 }
 
-// Update 更新部门
 func (m *SysDepartment) Update(cols []string) (err error) {
 	err = global.MYSQL["hz_eta"].Model(m).Select(cols).Updates(m).Error
 	return
 }
 
-// GetDepartmentById 主键获取部门
 func GetDepartmentById(departmentId int) (item *SysDepartment, err error) {
 	err = global.MYSQL["hz_eta"].Where("department_id = ?", departmentId).First(&item).Error
 	return
 }
 
-// GetAllDepartment 获取所有部门
 func GetAllDepartment() (items []*SysDepartment, err error) {
-	//sql := `SELECT * FROM sys_department WHERE out_id <> ""`
 	sql := `SELECT * FROM sys_department `
 	err = global.MYSQL["hz_eta"].Raw(sql).Find(&items).Error
 	return
 }
 
-// DeleteDepartmentById 主键删除部门
 func DeleteDepartmentById(departmentId int) (err error) {
 	sql := `DELETE FROM sys_department WHERE department_id = ? LIMIT 1`
 	err = global.MYSQL["hz_eta"].Exec(sql, departmentId).Error
@@ -72,7 +66,6 @@ func (m *SysDepartment) GetItemsByCondition(condition string, pars []interface{}
 	return
 }
 
-// GetSysDepartmentByOutId 获取部门-根据OutId
 func GetSysDepartmentByOutId(outId string) (item *SysDepartment, err error) {
 	err = global.MYSQL["hz_eta"].Where("out_id = ?", outId).First(&item).Error
 	return

+ 0 - 7
models/eta/sys_group.go

@@ -21,39 +21,33 @@ func (m *SysGroup) TableName() string {
 	return "sys_group"
 }
 
-// Create 新增分组
 func (m *SysGroup) Create() (err error) {
 	err = global.MYSQL["hz_eta"].Create(m).Error
 	return
 }
 
-// Update 更新分组
 func (m *SysGroup) Update(cols []string) (err error) {
 	err = global.MYSQL["hz_eta"].Model(m).Select(cols).Updates(m).Error
 	return
 }
 
-// GetSysGroupByGroupId 获取分组-根据主键
 func GetSysGroupByGroupId(groupId int) (item *SysGroup, err error) {
 	err = global.MYSQL["hz_eta"].Where("group_id = ?", groupId).First(&item).Error
 	return
 }
 
-// GetAllSysGroup 获取所有的分组
 func GetAllSysGroup() (items []*SysGroup, err error) {
 	sql := `SELECT * FROM sys_group `
 	err = global.MYSQL["hz_eta"].Raw(sql).Find(&items).Error
 	return
 }
 
-// DeleteGroupByGroupId 删除分组-根据主键
 func DeleteGroupByGroupId(groupId int) (err error) {
 	sql := `DELETE FROM sys_group WHERE group_id = ? LIMIT 1`
 	err = global.MYSQL["hz_eta"].Exec(sql, groupId).Error
 	if err != nil {
 		return
 	}
-	// 清除关联
 	sql = `UPDATE admin SET group_id = 0, group_name = '' WHERE group_id = ? `
 	err = global.MYSQL["hz_eta"].Exec(sql, groupId).Error
 	return
@@ -79,7 +73,6 @@ func (m *SysGroup) GetItemsByCondition(condition string, pars []interface{}, fie
 	return
 }
 
-// GetSysGroupByOutId 获取分组-根据OutId
 func GetSysGroupByOutId(outId string) (item *SysGroup, err error) {
 	err = global.MYSQL["hz_eta"].Where("out_id = ?", outId).First(&item).Error
 	return

+ 0 - 5
models/eta/sys_role.go

@@ -5,7 +5,6 @@ import (
 	"time"
 )
 
-// SysRole 角色表
 type SysRole struct {
 	RoleId       int       `gorm:"primaryKey;column:role_id;type:int(11);not null" json:"role_id""`
 	RoleName     string    `gorm:"column:role_name;type:varchar(100)" json:"role_name"`
@@ -20,25 +19,21 @@ func (m *SysRole) TableName() string {
 	return "sys_role"
 }
 
-// Create 新增角色
 func (m *SysRole) Create() (err error) {
 	err = global.MYSQL["hz_eta"].Create(m).Error
 	return
 }
 
-// Update 更新角色
 func (m *SysRole) Update(cols []string) (err error) {
 	err = global.MYSQL["hz_eta"].Model(m).Select(cols).Updates(m).Error
 	return
 }
 
-// GetSysRoleById 主键获取角色
 func GetSysRoleById(roleId int) (item *SysRole, err error) {
 	err = global.MYSQL["hz_eta"].Where("role_id = ?", roleId).First(&item).Error
 	return
 }
 
-// DeleteRoleById 主键删除角色
 func DeleteRoleById(roleId int) (err error) {
 	sql := `DELETE FROM sys_role WHERE role_id = ? LIMIT 1`
 	err = global.MYSQL["hz_eta"].Exec(sql, roleId).Error

+ 0 - 3
models/eta/sys_session.go

@@ -20,19 +20,16 @@ func (m *SysSession) TableName() string {
 	return "sys_session"
 }
 
-// AddSysSession 新增session
 func AddSysSession(item *SysSession) (err error) {
 	err = global.MYSQL["hz_eta"].Create(item).Error
 	return
 }
 
-// GetSysSessionByToken 根据Token获取session
 func GetSysSessionByToken(token string) (item *SysSession, err error) {
 	err = global.MYSQL["hz_eta"].Where("access_token = ? AND expired_time > NOW()", token).Order("expired_time DESC").First(&item).Error
 	return
 }
 
-// GetUserUnexpiredSysSession 获取用户未过期的Token
 func GetUserUnexpiredSysSession(userName, expiredTime string) (item *SysSession, err error) {
 	err = global.MYSQL["hz_eta"].Where("user_name = ? AND expired_time > ?", userName, expiredTime).Order("expired_time DESC").First(&item).Error
 	return

+ 0 - 5
models/eta/sys_third_session.go

@@ -5,15 +5,12 @@ import (
 	"time"
 )
 
-// SysThirdSession
-// @Description: 第三方登录会话session
 type SysThirdSession struct {
 	ID               uint64 `gorm:"primaryKey;column:id;autoIncrement:true"`
 	SysUserID        uint64 `gorm:"column:sys_user_id"`
 	UserName         string `gorm:"column:user_name"`
 	AccessToken      string `gorm:"index:access_token;column:access_token"`
 	ThirdAccessToken string `gorm:"index:third_access_token;column:third_access_token"`
-	//ThirdRefreshToken string    `gorm:"column:third_refresh_token"`
 	ThirdExpiredTime time.Time `gorm:"column:third_expired_time"`
 	CreatedTime      time.Time `gorm:"index:created_time;column:created_time"`
 	LastUpdatedTime  time.Time `gorm:"index:last_updated_time;column:last_updated_time"`
@@ -23,13 +20,11 @@ func (m *SysThirdSession) TableName() string {
 	return "sys_third_session"
 }
 
-// AddSysThirdSession 新增第三方的session
 func AddSysThirdSession(item *SysThirdSession) (err error) {
 	err = global.MYSQL["hz_eta"].Create(item).Error
 	return
 }
 
-// GetSysThirdSessionByToken 根据Token获取第三方session
 func GetSysThirdSessionByToken(token string) (item *SysThirdSession, err error) {
 	err = global.MYSQL["hz_eta"].Where("access_token = ? AND expired_time > NOW()", token).Order("expired_time DESC").First(&item).Error
 	return

+ 0 - 1
models/eta/sys_user_login_record.go

@@ -18,7 +18,6 @@ func (m *SysUserLoginRecord) TableName() string {
 	return "sys_user_login_record"
 }
 
-// AddSysUserLoginRecord 新增登录记录
 func AddSysUserLoginRecord(item *SysUserLoginRecord) (err error) {
 	err = global.MYSQL["hz_eta"].Create(item).Error
 	return

+ 0 - 1
models/gn/index.go

@@ -13,7 +13,6 @@ type IndexInfo struct {
 	SourceCode        string `description:"来源编码"`
 }
 
-// IndexData 指标数据
 type IndexData struct {
 	Val        float64 `json:"val"`
 	DataTime   string  `json:"data_time"`

+ 0 - 5
models/gn/mdm.go

@@ -8,7 +8,6 @@ import (
 	"time"
 )
 
-// MDM_COMSTRU MDM组织机构
 type MDM_COMSTRU struct {
 	Id                                int       `gorm:"column:Id;primaryKey;autoIncrement" json:"-"`
 	MainFieldComstruCode              string    `gorm:"column:Main_Field_Comstru_Code" json:"Main_Field_Comstru_Code"`
@@ -67,7 +66,6 @@ func (m *MDM_COMSTRU) GetItemsByCondition(condition string, pars []interface{},
 	return
 }
 
-// MDM_EMPLOYEE MDM员工表
 type MDM_EMPLOYEE struct {
 	Id                           int       `gorm:"column:Id;primaryKey;autoIncrement" json:"-"`
 	MainFieldEmployeeCode        string    `gorm:"column:Main_Field_Employee_Code" json:"Main_Field_Employee_Code"`
@@ -121,7 +119,6 @@ func (m *MDM_EMPLOYEE) GetItemsByCondition(condition string, pars []interface{},
 	return
 }
 
-// CreateEmployee 新增员工及组织关系
 func (m *MDM_EMPLOYEE) CreateEmployee(employee *MDM_EMPLOYEE, employeeRelation []*MDM_RELA_COMSTRU_EMPLOYEE) (err error) {
 	if employee == nil {
 		err = fmt.Errorf("employee is nil")
@@ -150,7 +147,6 @@ func (m *MDM_EMPLOYEE) CreateEmployee(employee *MDM_EMPLOYEE, employeeRelation [
 	return
 }
 
-// UpdateEmployee 更新员工及组织关系
 func (m *MDM_EMPLOYEE) UpdateEmployee(employee *MDM_EMPLOYEE, updateCols []string, employeeRelation []*MDM_RELA_COMSTRU_EMPLOYEE) (err error) {
 	if employee == nil {
 		err = fmt.Errorf("employee is nil")
@@ -184,7 +180,6 @@ func (m *MDM_EMPLOYEE) UpdateEmployee(employee *MDM_EMPLOYEE, updateCols []strin
 	return
 }
 
-// MDM_RELA_COMSTRU_EMPLOYEE MDM员工组织关系表
 type MDM_RELA_COMSTRU_EMPLOYEE struct {
 	Id                        int       `gorm:"column:Id;primaryKey;autoIncrement" json:"-"`
 	Main_Field_Employee_Code  string    `gorm:"column:Main_Field_Employee_Code" json:"Main_Field_Employee_Code"`

+ 0 - 31
models/gn/user.go

@@ -2,14 +2,12 @@ package gn
 
 import "eta_gn/eta_bridge/global"
 
-// OaDept OA部门
 type OaDept struct {
 	DepartmentId       string `json:"dept_id" description:"部门ID"`
 	DepartmentName     string `json:"deptname" description:"部门名称"`
 	ParentDepartmentId string `json:"pdeptid" description:"上级部门名称"`
 }
 
-// OaUser OA用户
 type OaUser struct {
 	AddrName               string `gorm:"column:addr_name" json:"addr_name" description:"姓名"`
 	AddrUserId             string `gorm:"column:addr_Userid" json:"addr_Userid" description:"用户ID"`
@@ -21,21 +19,18 @@ type OaUser struct {
 	OEmployeeNo            string `gorm:"column:o_EMPLOYEENO" json:"o_EMPLOYEENO" description:"OA工号"`
 }
 
-// GetGnOaDepartment 获取OA部门
 func GetGnOaDepartment() (items []*OaDept, err error) {
 	sql := `SELECT * FROM oa_dept `
 	err = global.MYSQL["oa_user"].Raw(sql).Find(&items).Error
 	return
 }
 
-// GetGnOaUser 获取OA用户
 func GetGnOaUser() (items []*OaUser, err error) {
 	sql := `SELECT * FROM oa_user `
 	err = global.MYSQL["oa_user"].Raw(sql).Find(&items).Error
 	return
 }
 
-// UserEntity枚举值
 const (
 	UserStatusActive  = "Active"
 	UserStatusDisable = "Disabled"
@@ -43,33 +38,7 @@ const (
 	UserIsByWorkPart  = "兼职"
 )
 
-// UserEntity 4A用户字段
-//type UserEntity11 struct {
-//	UserId         string                 `json:"userId" description:"登录账号标识[必填], string:256"`
-//	Password       string                 `json:"password" description:"密码(预留,4A平台不提供), string:256"`
-//	OrgCode        string                 `json:"orgCode" description:"对应MDM组织机构-单位的编号(预留,4A平台不提供), string:8"`
-//	OrgName        string                 `json:"orgName" description:"对应员工直接所属的MDM组织机构-单位名称(预留,4A平台不提供), string:40"`
-//	DepartmentNum  string                 `json:"departmentNum" description:"对应MDM组织机构-部门的编号(预留,4A平台不提供), string:8"`
-//	DepartmentName string                 `json:"departmentName" description:"对应员工直接所属的MDM组织机构-部门名称(预留,4A平台不提供), string:40"`
-//	FirstName      string                 `json:"firstName" description:"身份证中的名[必填], string:150"`
-//	LastName       string                 `json:"lastName" description:"身份证中的姓[必填], string:150"`
-//	Sex            string                 `json:"sex" description:"员工性别(预留,4A平台不提供), string:10"`
-//	UserType       string                 `json:"userType" description:"用户类型, 枚举值(预留,4A平台不提供), string:256"`
-//	Mail           string                 `json:"mail" description:"员工邮箱(预留,4A平台不提供), string: 256"`
-//	DisplayIndex   int                    `json:"displayIndex" description:"排序(预留,4A平台不提供), int: 256"`
-//	Mobile         string                 `json:"mobile" description:"员工手机号, 可能存在多值(预留,4A平台不提供), string:50"`
-//	Telephone      string                 `json:"telephone" description:"员工办公室电话, 可能存在多值(预留,4A平台不提供), string:50"`
-//	PID            string                 `json:"PID" description:"身份证号(预留,4A平台不提供), string: 50"`
-//	PassportId     string                 `json:"passportID" description:"护照号(预留,4A平台不提供), string:50"`
-//	UserStatus     string                 `json:"userStatus" description:"账号状态[必填], 枚举值: Active-激活; Disabled-禁用, string:256"`
-//	EmpNumber      string                 `json:"empNumber" description:"员工在ERP系统中的唯一编号, 默认与账号标识一致(预留,4A平台不提供), string:256"`
-//	Title          string                 `json:"title" description:"员工主职位编号(预留,4A平台不提供), string:40"`
-//	TitleName      string                 `json:"titleName" description:"员工主职位名称(预留,4A平台不提供), string:256"`
-//	IsByWork       string                 `json:"isBywork" description:"是否兼职(预留,4A平台不提供), 枚举值: 全职-MDM推送的全职人员信息, string:10"`
-//	Extensions     map[string]interface{} `json:"extensions" description:"扩展字段, key-value"`
-//}
 
-// UserEntity 4A用户字段
 type UserEntity struct {
 	UserId         *string `json:"userId" description:"登录账号标识[必填], string:256"`
 	Password       *string `json:"password" description:"密码(预留,4A平台不提供), string:256"`

+ 0 - 10
models/index/base.go

@@ -2,17 +2,11 @@ package index
 
 import "eta_gn/eta_bridge/global"
 
-// BinlogFormatStruct
-// @Description: 数据库的binlog格式
 type BinlogFormatStruct struct {
 	VariableName string `json:"Variable_name"`
 	Value        string `json:"Value"`
 }
 
-// GetBinlogFormat
-// @Description: 获取数据库的binlog格式
-// @return item
-// @return err
 func GetBinlogFormat() (item *BinlogFormatStruct, err error) {
 	sql := `SHOW VARIABLES LIKE 'binlog_format';`
 	err = global.MYSQL["index"].Raw(sql).First(&item).Error
@@ -24,10 +18,6 @@ type BinlogFileStruct struct {
 	Position uint32 `json:"Position"`
 }
 
-// GetShowMaster
-// @Description: 获取master的状态
-// @return item
-// @return err
 func GetShowMaster() (item *BinlogFileStruct, err error) {
 	sql := `show master status;`
 	err = global.MYSQL["index"].Raw(sql).First(&item).Error

+ 0 - 6
models/index/business_sys_interaction_log.go

@@ -5,7 +5,6 @@ import (
 	"time"
 )
 
-// BusinessSysInteractionLog 商家系统交互记录表
 type BusinessSysInteractionLog struct {
 	ID             uint32    `gorm:"primaryKey;column:id;type:int(10) unsigned;not null" json:"-"`
 	InteractionKey string    `gorm:"unique;column:interaction_key;type:varchar(128);not null;default:''" json:"interactionKey"` // 记录Key
@@ -15,12 +14,10 @@ type BusinessSysInteractionLog struct {
 	CreateTime     time.Time `gorm:"column:create_time;type:datetime;default:null" json:"createTime"`                           // 创建时间
 }
 
-// TableName get sql table name.获取数据库表名
 func (m *BusinessSysInteractionLog) TableName() string {
 	return "business_sys_interaction_log"
 }
 
-// BusinessSysInteractionLogColumns get sql column name.获取数据库列名
 var BusinessSysInteractionLogColumns = struct {
 	ID             string
 	InteractionKey string
@@ -37,13 +34,11 @@ var BusinessSysInteractionLogColumns = struct {
 	CreateTime:     "create_time",
 }
 
-// Create 添加数据
 func (m *BusinessSysInteractionLog) Create() (err error) {
 	err = global.MYSQL["index"].Create(m).Error
 	return
 }
 
-// Update 更新数据
 func (m *BusinessSysInteractionLog) Update(cols []string) (err error) {
 	err = global.MYSQL["index"].Model(m).Select(cols).Updates(m).Error
 	return
@@ -52,7 +47,6 @@ func (m *BusinessSysInteractionLog) Update(cols []string) (err error) {
 var BinlogFileNameKey = "binlog_filename"        // binlog文件名
 var BinlogPositionKey = "binlog_binlog_position" // binlog位置
 
-// GetBusinessSysInteractionLogByKey 根据记录key获取数据
 func GetBusinessSysInteractionLogByKey(key string) (item *BusinessSysInteractionLog, err error) {
 	err = global.MYSQL["index"].Where("interaction_key = ?", key).First(&item).Error
 	return

+ 0 - 11
models/index/edb_update_log.go

@@ -20,13 +20,11 @@ func (m *EdbUpdateLog) TableName() string {
 	return "edb_update_log"
 }
 
-// Create 添加数据
 func (m *EdbUpdateLog) Create() (err error) {
 	err = global.MYSQL["index"].Create(m).Error
 	return
 }
 
-// DeleteBeforeTenDayLog 清除n前的日志数据
 func (m *EdbUpdateLog) DeleteBeforeTenDayLog(beforeDate string) (err error) {
 	sql := fmt.Sprintf(`DELETE FROM %s WHERE create_time < ?`, m.TableName())
 	err = global.MYSQL["index"].Exec(sql, beforeDate).Error
@@ -86,10 +84,6 @@ type EdbInfo struct {
 	OriginalEdbCode  string    `description:"指标原始编码"`
 }
 
-// GetAllBaseEdbInfo
-// @Description: 获取所有基础指标(只有国能数据节点的数据)
-// @return item
-// @return err
 func GetAllBaseEdbInfo() (item []*EdbInfo, err error) {
 	sql := ` SELECT * FROM edb_info WHERE 1=1 AND "edb_info_type" = ? AND "edb_type" = ?`
 	pars := []interface{}{0, 1}
@@ -98,11 +92,6 @@ func GetAllBaseEdbInfo() (item []*EdbInfo, err error) {
 	return
 }
 
-// Update
-// @Description: 更新指定参数
-// @receiver m
-// @param cols
-// @return err
 func (m *EdbInfo) Update(cols []string) (err error) {
 	err = global.MYSQL["index"].Select(cols).Updates(m).Error
 	return

+ 0 - 3
models/rddp/sys_session.go

@@ -20,19 +20,16 @@ func (m *SysSession) TableName() string {
 	return "sys_session"
 }
 
-// AddSysSession 新增session
 func AddSysSession(item *SysSession) (err error) {
 	err = global.MYSQL["rddp"].Create(item).Error
 	return
 }
 
-// GetSysSessionByToken 根据Token获取session
 func GetSysSessionByToken(token string) (item *SysSession, err error) {
 	err = global.MYSQL["rddp"].Where("access_token = ? AND expired_time > NOW()", token).Order("expired_time DESC").First(&item).Error
 	return
 }
 
-// GetUserUnexpiredSysSession 获取用户未过期的Token
 func GetUserUnexpiredSysSession(userName, expiredTime string) (item *SysSession, err error) {
 	err = global.MYSQL["rddp"].Where("user_name = ? AND expired_time > ?", userName, expiredTime).Order("expired_time DESC").First(&item).Error
 	return

+ 0 - 1
models/rddp/sys_user_login_record.go

@@ -18,7 +18,6 @@ func (m *SysUserLoginRecord) TableName() string {
 	return "sys_user_login_record"
 }
 
-// AddSysUserLoginRecord 新增登录记录
 func AddSysUserLoginRecord(item *SysUserLoginRecord) (err error) {
 	err = global.MYSQL["rddp"].Create(item).Error
 	return

+ 0 - 3
models/request/gn/auth.go

@@ -1,12 +1,9 @@
 package gn
 
-// GetTokenReq 获取token请求体
 type GetTokenReq struct {
 	Code string `json:"code" form:"code" description:"code编码"`
 }
 
-// GetUserInfoReq
-// @Description: 获取用户信息请求体
 type GetUserInfoReq struct {
 	Token string `json:"token" form:"token" description:"SCI的token"`
 }

+ 0 - 2
models/request/gn/mdm.go

@@ -1,6 +1,5 @@
 package gn
 
-// SyncMdmEmployeeReq 同步mdm员工请求
 type SyncMdmEmployeeReq struct {
 	MainFieldEmployeeCode        string `json:"Main_Field_Employee_Code"`
 	MainFieldEmployeeFirstName   string `json:"Main_Field_Employee_FirstName"`
@@ -26,7 +25,6 @@ type SyncMdmEmployeeReq struct {
 	} `json:"MDM_MATERIAL_PROPS"`
 }
 
-// SyncMdmOrganizationReq 同步mdm组织部门请求
 type SyncMdmOrganizationReq struct {
 	MainFieldComstruCode              string `json:"Main_Field_Comstru_Code"`
 	MainFieldComstruCodeHR            string `json:"Main_Field_Comstru_Code_HR"`

+ 0 - 2
models/request/gn/oa.go

@@ -1,7 +1,5 @@
 package gn
 
-// PostOAReq
-// @Description: 请求oa待办参数
 type PostOAReq struct {
 	AppPersonId   string `json:"appPersonId" form:"appPersonId" description:"⽤户⼯号"`
 	AppPersonName string `json:"appPersonName" form:"appPersonName" description:"⽤户名"`

+ 0 - 6
models/request/gn/user.go

@@ -5,42 +5,36 @@ import (
 	"time"
 )
 
-// AddAccountReq 创建账号请求
 type AddAccountReq struct {
 	gnModel.UserEntity `description:"账号信息"`
 	RequestId          string    `json:"requestID" description:"请求唯一标识"`
 	TimeStamp          time.Time `json:"timeStamp" description:"时间戳"`
 }
 
-// ModifyAccountReq 编辑账号请求
 type ModifyAccountReq struct {
 	gnModel.UserEntity `description:"账号信息"`
 	RequestId          string    `json:"requestID" description:"请求唯一标识"`
 	TimeStamp          time.Time `json:"timeStamp" description:"时间戳"`
 }
 
-// DeleteAccountReq 删除账号请求
 type DeleteAccountReq struct {
 	UserId    string    `json:"userId" description:"用户名"`
 	RequestId string    `json:"requestID" description:"请求唯一标识"`
 	TimeStamp time.Time `json:"timeStamp" description:"时间戳"`
 }
 
-// SuspendAccountReq 禁用账号请求
 type SuspendAccountReq struct {
 	UserId    string    `json:"userId" description:"用户名"`
 	RequestId string    `json:"requestID" description:"请求唯一标识"`
 	TimeStamp time.Time `json:"timeStamp" description:"时间戳"`
 }
 
-// RestoreAccountReq 启用账号请求
 type RestoreAccountReq struct {
 	UserId    string    `json:"userId" description:"用户名"`
 	RequestId string    `json:"requestID" description:"请求唯一标识"`
 	TimeStamp time.Time `json:"timeStamp" description:"时间戳"`
 }
 
-// ChangePasswordReq 修改密码请求
 type ChangePasswordReq struct {
 	UserId      string    `json:"userId" description:"用户名"`
 	NewPassword string    `json:"newPassword" description:"新密码"`

+ 0 - 2
models/request/index_data/gn_index.go

@@ -1,6 +1,5 @@
 package index_data
 
-// GnPageIndexReq 指标列表请求体-分页
 type GnPageIndexReq struct {
 	LastModifyTime string `json:"last_modify_time" form:"last_modify_time" description:"最近一次更新时间"`
 	PageIndex      int    `json:"page_index" form:"page_index" description:"当前页码"`
@@ -8,7 +7,6 @@ type GnPageIndexReq struct {
 	IndexId        string `json:"index_id" form:"index_id" description:"指标ID,不为空时表示只取该指标"`
 }
 
-// GnDataReq 指标数据请求体
 type GnDataReq struct {
 	IndexCode string `json:"index_code" form:"index_code" description:"指标编码"`
 	StartDate string `json:"start_date" form:"start_date" description:"开始日期"`

+ 0 - 1
models/response/gn_index.go

@@ -5,7 +5,6 @@ import (
 	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
-// GnPageIndexResp 指标分页列表响应体
 type GnPageIndexResp struct {
 	Page *paging.PagingItem `description:"数据分页"`
 	List []gn.IndexInfo     `description:"列表数据"`

+ 0 - 1
routers/auth.go

@@ -7,7 +7,6 @@ import (
 )
 
 func InitAuth(r *gin.RouterGroup) {
-	//登录
 	authController := new(controller.AuthController)
 	authGroup := r.Group("auth/").Use(middleware.Token())
 	authGroup.POST("auth_code", authController.CreateAuthCode)

+ 0 - 4
routers/gn.go

@@ -5,18 +5,14 @@ import (
 	"github.com/gin-gonic/gin"
 )
 
-// InitGn 国能接口
 func InitGn(r *gin.RouterGroup) {
 	control := new(gn.GuoNengController)
 	group := r.Group("gn/")
 	group.GET("auth/getToken", control.GetToken)
 	group.GET("auth/getUserInfo", control.GetUserInfo)
-	//group.GET("user/sync", control.SyncUser)
 
-	// 4A身份供应接口
 	init4A(r)
 
-	// OA接口
 	initOA(r)
 }
 

+ 0 - 1
routers/index_data.go

@@ -6,7 +6,6 @@ import (
 	"github.com/gin-gonic/gin"
 )
 
-// InitIndexData 获取指标信息
 func InitIndexData(r *gin.RouterGroup) {
 	gnControl := new(index_data.GnIndexController)
 	gnGroup := r.Group("index_data/gn/").Use(middleware.InternalToken())

+ 0 - 6
services/alarm_msg/alarm_msg.go

@@ -10,11 +10,6 @@ var (
 	AlarmMsgUrl = "http://127.0.0.1:8606/api/alarm/send"
 )
 
-// SendAlarmMsg
-// projectName-项目名称
-// runMode-运行模式
-// msgBody-消息内容
-// level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
 func SendAlarmMsg(msgBody string, level int) {
 	params := make(map[string]interface{})
 	params["ProjectName"] = utils.APPNAME
@@ -27,5 +22,4 @@ func SendAlarmMsg(msgBody string, level int) {
 		return
 	}
 	global.FILE_LOG.Info(string(param))
-	//_, _ = http.Post(AlarmMsgUrl, string(param))
 }

+ 0 - 89
services/binlog/binlog.go

@@ -14,45 +14,7 @@ import (
 	"time"
 )
 
-//var mysqlHost, mysqlUser, mysqlPwd, mysqlDb string
 
-//func init() {
-//
-//	for _, sqlConfig := range global.CONFIG.Mysql.List {
-//		if sqlConfig.AliasName == `index` {
-//			// 找出用户
-//			tmpList := strings.Split(sqlConfig.Dsn, ":")
-//			mysqlUser = tmpList[0]
-//			// 找出密码
-//			tmpList = strings.Split(strings.Join(tmpList[1:], ":"), "@")
-//			lenTmp := len(tmpList)
-//			mysqlPwd = strings.Join(tmpList[:lenTmp-1], "@")
-//			// 找出地址
-//			tmpList = strings.Split(tmpList[lenTmp-1], "tcp(")
-//			tmpList = strings.Split(tmpList[1], ")")
-//			mysqlHost = tmpList[0]
-//
-//			// 找出数据库名称
-//			u, err := url.Parse(tmpList[1])
-//			if err != nil {
-//				panic(err) // 如果解析失败,处理错误
-//			}
-//
-//			// 获取Path部分的内容
-//			mysqlDb = u.Path[1:]
-//
-//		}
-//	}
-//
-//	if mysqlHost == "" {
-//		panic("mysqlHost is empty")
-//	}
-//
-//	//fmt.Println("HOST:", mysqlHost)
-//	//fmt.Println("user:", mysqlUser)
-//	//fmt.Println("password:", mysqlPwd)
-//
-//}
 
 func ListenMysql() {
 	var err error
@@ -63,8 +25,6 @@ func ListenMysql() {
 	}()
 	if global.CONFIG.Mysql.Binlog.Host == "" {
 		panic("mysqlHost is empty")
-		//err = errors.New("mysqlHost is empty")
-		//return
 	}
 
 	if global.CONFIG.Mysql.Binlog.User == "" {
@@ -76,9 +36,6 @@ func ListenMysql() {
 	if global.CONFIG.Mysql.Binlog.Db == "" {
 		panic("db is empty")
 	}
-	//includeTableRegex := []string{
-	//	"test_hz_data.edb_info",
-	//}
 
 	includeTableRegex := []string{
 		global.CONFIG.Mysql.Binlog.Db + ".edb_info$",
@@ -88,33 +45,21 @@ func ListenMysql() {
 		global.CONFIG.Mysql.Binlog.Db + ".edb_data*",
 	}
 
-	// 主从复制的身份id配置,必须全局唯一,如果没有配置的话,那么会随机生成一个
 	serverId := global.CONFIG.Mysql.Binlog.ServerID
 	if serverId == 0 {
 		serverId = uint32(rand.New(rand.NewSource(time.Now().Unix())).Intn(1000)) + 1001
 	}
 	cfg := &canal.Config{
-		// 一个32位无符号整数,用于标识当前 Canal 实例在 MySQL 主从复制体系中的身份。这里使用了一个随机数生成器确保每次启动时分配的 ServerID 是唯一的(在1001到1099之间)。在实际生产环境中,你需要手动指定一个全局唯一的 ServerID。
 		ServerID: serverId,
-		// 指定 Canal 要连接的数据库类型,默认为 "mysql",表明这是一个 MySQL 数据库。
 		Flavor: "mysql",
-		// 设置 MySQL 服务器地址(主机名或 IP 地址)和端口,例如 "127.0.0.1:3306"。
 		Addr:     global.CONFIG.Mysql.Binlog.Host,
 		User:     global.CONFIG.Mysql.Binlog.User,
 		Password: global.CONFIG.Mysql.Binlog.Password,
-		// 如果设置为 true,Canal 将以原始二进制格式获取 binlog,否则将以解析后的 SQL 语句形式提供。
-		//RawModeEnabled:  false,
-		// 是否启用半同步复制。当设置为 true 时,MySQL 主库在事务提交后会等待至少一个从库确认已接收并写入 binlog 才返回成功,提高了数据一致性。
 		SemiSyncEnabled: false,
-		//  是否将 MySQL 中的 decimal 类型字段解析为 Go 的 Decimal 类型,而不是 float 或者 string。如果业务中有精确小数计算的需求,应开启此选项以避免精度丢失问题。
 		UseDecimal: true,
-		// 用于控制初始数据导出的相关配置,在 Canal 启动时是否需要全量同步表数据。
-		//Dump:              dumpConf,
-		// 正则表达式字符串,用于定义 Canal 应该监听哪些表的 binlog 事件。只有名称匹配该正则表达式的表才会被 Canal 同步处理。
 		IncludeTableRegex: includeTableRegex,
 	}
 
-	// 校验mysql binlog format,目前仅支持row格式
 	{
 		binlogFormat, tmpErr := index.GetBinlogFormat()
 		if tmpErr != nil {
@@ -128,14 +73,11 @@ func ListenMysql() {
 		}
 	}
 
-	//  获取上一次启动时的binlog文件名称和位置
 	fileName, position, err := getBinlogNamePosition()
 	if err != nil {
 		return
 	}
-	// 修改记录本次启动时的binlog文件名称和位置
 	modifyBinlogNamePosition(fileName, position)
-	// 定时修改binlog文件名称和位置
 	go timingModifyBinlogNamePosition()
 
 	c, err := canal.NewCanal(cfg)
@@ -149,7 +91,6 @@ func ListenMysql() {
 	binlogHandler := &MyEventHandler{}
 	binlogHandler.SetBinlogFileName(fileName, position)
 	c.SetEventHandler(binlogHandler)
-	//c.Run()
 
 	pos := mysql.Position{
 		Name: fileName,
@@ -158,15 +99,7 @@ func ListenMysql() {
 	err = c.RunFrom(pos)
 }
 
-// getBinlogNamePosition
-// @Description: 获取当前binlog文件名称和位置
-// @author: Roc
-// @datetime 2024-05-17 13:18:19
-// @return fileName string
-// @return position uint32
-// @return err error
 func getBinlogNamePosition() (fileName string, position uint32, err error) {
-	// 优先从redis获取
 	fileName = global.Rc.GetStr(utils.CACHE_MYSQL_MASTER_FILENAME)
 	position64, err := global.Rc.GetUInt64(utils.CACHE_MYSQL_MASTER_POSITION)
 	if err != nil {
@@ -179,17 +112,14 @@ func getBinlogNamePosition() (fileName string, position uint32, err error) {
 
 	position = uint32(position64)
 
-	// 如果没有从redis中获取到上次监听到的binlog的文件名称,或者位置为0,则从mysql中获取,则从 MySQL 中获取最新的文件名和位置。
 	if fileName == `` || position == 0 {
 
-		// binlog文件名
 		fileNameKey := index.BinlogFileNameKey
 		fileNameLog, tmpErr := index.GetBusinessSysInteractionLogByKey(fileNameKey)
 		if tmpErr == nil {
 			fileName = fileNameLog.InteractionKey
 		}
 
-		// binlog位置
 		positionKey := index.BinlogPositionKey
 		positionLog, tmpErr := index.GetBusinessSysInteractionLogByKey(positionKey)
 		if tmpErr == nil {
@@ -201,7 +131,6 @@ func getBinlogNamePosition() (fileName string, position uint32, err error) {
 		}
 	}
 
-	// 如果从表中没有取到数据,则从mysql中获取,则从 MySQL 中获取最新的文件名和位置。
 	if fileName == `` || position == 0 {
 		item, tmpErr := index.GetShowMaster()
 		if tmpErr != nil {
@@ -215,35 +144,21 @@ func getBinlogNamePosition() (fileName string, position uint32, err error) {
 	return
 }
 
-// timingModifyBinlogNamePosition
-// @Description: 定时修改binlog文件名称和位置
-// @author: Roc
-// @datetime 2024-05-17 13:08:13
 func timingModifyBinlogNamePosition() {
 	for {
-		// 延时30s执行
 		time.Sleep(30 * time.Second)
 
-		// 获取最新的binlog文件名称和位置
 		fileName, position, err := getBinlogNamePosition()
 		if err != nil {
 			return
 		}
 
 		if fileName != `` && position != 0 {
-			// 修改记录本次启动时的binlog文件名称和位置
 			modifyBinlogNamePosition(fileName, position)
 		}
 	}
 }
 
-// modifyBinlogNamePosition
-// @Description: 修改记录本次启动时的binlog文件名称和位置
-// @author: Roc
-// @datetime 2024-05-17 11:32:32
-// @param fileName string
-// @param position uint32
-// @return err error
 func modifyBinlogNamePosition(fileName string, position uint32) {
 	var err error
 	defer func() {
@@ -252,7 +167,6 @@ func modifyBinlogNamePosition(fileName string, position uint32) {
 		}
 	}()
 
-	// fileName 变更
 	fileNameKey := index.BinlogFileNameKey
 	fileNameLog, err := index.GetBusinessSysInteractionLogByKey(fileNameKey)
 	if err != nil {
@@ -261,7 +175,6 @@ func modifyBinlogNamePosition(fileName string, position uint32) {
 		}
 		err = nil
 		fileNameLog = &index.BusinessSysInteractionLog{
-			//ID:             0,
 			InteractionKey: fileNameKey,
 			InteractionVal: fileName,
 			Remark:         "mysql中binlog的filename名称",
@@ -281,7 +194,6 @@ func modifyBinlogNamePosition(fileName string, position uint32) {
 		}
 	}
 
-	// position 变更
 	positionKey := index.BinlogPositionKey
 	positionLog, err := index.GetBusinessSysInteractionLogByKey(positionKey)
 	if err != nil {
@@ -290,7 +202,6 @@ func modifyBinlogNamePosition(fileName string, position uint32) {
 		}
 		err = nil
 		positionLog = &index.BusinessSysInteractionLog{
-			//ID:             0,
 			InteractionKey: positionKey,
 			InteractionVal: fmt.Sprint(position),
 			Remark:         "mysql中binlog的position位置",

+ 0 - 60
services/binlog/handler.go

@@ -21,9 +21,6 @@ type MyEventHandler struct {
 }
 
 func (h *MyEventHandler) OnRow(e *canal.RowsEvent) (err error) {
-	//fmt.Printf("%s %v\n", e.Action, e.Rows)
-	//fmt.Println(e.Table.Columns)
-	//fmt.Println(e.Action)
 
 	switch e.Action {
 	case canal.InsertAction:
@@ -38,7 +35,6 @@ func (h *MyEventHandler) OnRow(e *canal.RowsEvent) (err error) {
 
 	fmt.Println("fileName:", h.fileName, ";position:", h.position)
 
-	// 每次操作完成后都将当前位置记录到缓存
 	global.Rc.Put(utils.CACHE_MYSQL_MASTER_FILENAME, h.fileName, 31*24*time.Hour)
 	global.Rc.Put(utils.CACHE_MYSQL_MASTER_POSITION, h.position, 31*24*time.Hour)
 
@@ -49,7 +45,6 @@ func (h *MyEventHandler) OnPosSynced(header *replication.EventHeader, p mysql.Po
 	h.fileName = p.Name
 	h.position = p.Pos
 
-	// 旋转binlog日志的时候,需要将当前位置记录到缓存
 	global.Rc.Put(utils.CACHE_MYSQL_MASTER_FILENAME, h.fileName, 31*24*time.Hour)
 	global.Rc.Put(utils.CACHE_MYSQL_MASTER_POSITION, h.position, 31*24*time.Hour)
 
@@ -61,11 +56,6 @@ func (h *MyEventHandler) String() string {
 }
 
 func (h *MyEventHandler) Insert(e *canal.RowsEvent) error {
-	// 批量插入的时候,e.Rows的长度会大于0
-	//if len(e.Rows) != 1 {
-	//	fmt.Println("新增数据异常,没有新数据:", e.Rows)
-	//	return nil
-	//}
 	fmt.Println(e.Header.ServerID, ";", e.Table.Schema, ".", e.Table.Name)
 
 	for _, row := range e.Rows { // 遍历当前插入的数据列表(存在批量插入的情况,所以是list)
@@ -79,7 +69,6 @@ func (h *MyEventHandler) Insert(e *canal.RowsEvent) error {
 					tmpData = string(tmpOld)
 				}
 				logData[v.Name] = tmpData
-				//tmpV = fmt.Sprintf("%v", tmpData)
 			}
 		}
 		dataByte, _ := json.Marshal(logData)
@@ -95,24 +84,13 @@ func (h *MyEventHandler) Update(e *canal.RowsEvent) error {
 		return nil
 	}
 
-	//fmt.Println(e.Header.ServerID, ";", e.Table.Schema, ".", e.Table.Name)
 
 	logOldData := make(map[string]interface{})
 	logNewData := make(map[string]interface{})
 
 	oldDataLen := len(e.Rows[0])
 	newDataLen := len(e.Rows[0])
-	//maxDataLen := oldDataLen
-	//if maxDataLen < newDataLen {
-	//	maxDataLen = newDataLen
-	//}
 	for i, v := range e.Table.Columns {
-		//if v.IsUnsigned
-		//var tmpV string
-		//if i < dataLen {
-		//	tmpV = fmt.Sprintf("原数据:%v;新数据:%v", e.Rows[0][i], e.Rows[1][i])
-		//}
-		//fmt.Println(v.Name, ":", tmpV)
 
 		if i < oldDataLen {
 			oldData := e.Rows[0][i]
@@ -131,27 +109,6 @@ func (h *MyEventHandler) Update(e *canal.RowsEvent) error {
 			logNewData[v.Name] = newData
 		}
 
-		//if i < maxDataLen {
-		//	oldData := e.Rows[0][i]
-		//	newData := e.Rows[1][i]
-		//
-		//	if oldData != nil && reflect.TypeOf(oldData).Kind() == reflect.Slice {
-		//		tmpOld := oldData.([]byte)
-		//		oldData = string(tmpOld)
-		//	}
-		//	if newData != nil && reflect.TypeOf(newData).Kind() == reflect.Slice {
-		//		tmpNew := newData.([]byte)
-		//		newData = string(tmpNew)
-		//	}
-		//
-		//
-		//	//if oldData != newData {
-		//	//	tmpV = fmt.Sprintf("原数据:%v;新数据:%v", oldData, newData)
-		//	//}
-		//}
-		//if tmpV != `` {
-		//	fmt.Println(v.Name, ":", tmpV)
-		//}
 	}
 
 	logOldDataByte, _ := json.Marshal(logOldData)
@@ -162,11 +119,6 @@ func (h *MyEventHandler) Update(e *canal.RowsEvent) error {
 }
 
 func (h *MyEventHandler) Delete(e *canal.RowsEvent) error {
-	// 批量删除的时候,e.Rows的长度会大于0
-	//if len(e.Rows) != 1 {
-	//	fmt.Println("删除数据异常,没有原始数据:", e.Rows)
-	//	return nil
-	//}
 	fmt.Println(e.Header.ServerID, ";", e.Table.Schema, ".", e.Table.Name)
 
 	for _, row := range e.Rows { // 遍历当前插入的数据列表(存在批量插入的情况,所以是list)
@@ -180,7 +132,6 @@ func (h *MyEventHandler) Delete(e *canal.RowsEvent) error {
 					tmpData = string(tmpOld)
 				}
 				logData[v.Name] = tmpData
-				//tmpV = fmt.Sprintf("%v", tmpData)
 			}
 		}
 		dataByte, _ := json.Marshal(logData)
@@ -200,16 +151,13 @@ func (h *MyEventHandler) Delete3(e *canal.RowsEvent) error {
 	dataLen := len(e.Rows[0])
 	logData := make(map[string]interface{})
 	for i, v := range e.Table.Columns {
-		//var tmpV interface{}
 		if i < dataLen {
-			//tmpV = fmt.Sprintf("%v", e.Rows[0][i])
 			tmpData := e.Rows[0][i]
 			if tmpData != nil && reflect.TypeOf(tmpData).Kind() == reflect.Slice {
 				tmpOld := tmpData.([]byte)
 				tmpData = string(tmpOld)
 			}
 			logData[v.Name] = tmpData
-			//fmt.Println(oldData)
 		}
 	}
 
@@ -219,13 +167,6 @@ func (h *MyEventHandler) Delete3(e *canal.RowsEvent) error {
 	return nil
 }
 
-// SetBinlogFileName
-// @Description: 设置当前的binlog文件名和位置
-// @author: Roc
-// @receiver h
-// @datetime 2024-02-29 18:09:36
-// @param fileName string
-// @param position uint32
 func (h *MyEventHandler) SetBinlogFileName(fileName string, position uint32) {
 	h.fileName = fileName
 	h.position = position
@@ -233,7 +174,6 @@ func (h *MyEventHandler) SetBinlogFileName(fileName string, position uint32) {
 	fmt.Println("init fileName:", h.fileName, ";position:", h.position)
 }
 
-// log 简单的日志记录
 func log(dbName, tableName, opType, oldData, newData string) {
 	item := index.EdbUpdateLog{
 		OpDbName:    dbName,

+ 0 - 1
services/company.go

@@ -2,7 +2,6 @@ package services
 
 import "eta_gn/eta_bridge/utils"
 
-// GetProductId 根据角色类型获取对应的产品ID
 func GetProductId(roleTypeCode string) (productId int) {
 	if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER ||
 		roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN ||

+ 1 - 56
services/gn/auth.go

@@ -21,8 +21,6 @@ type AccessTokenResp struct {
 	TokenType        string `json:"token_type"`
 	NotBeforePolicy  int    `json:"not-before-policy"`
 	SessionState     string `json:"session_state"`
-	//Error            string `json:"error" description:"错误代码"`
-	//ErrorDescription string `json:"error_description" description:"错误描述"`
 }
 
 type UserBaseInfoResp struct {
@@ -34,27 +32,17 @@ type UserBaseInfoResp struct {
 	FamilyName        string `json:"family_name"`
 }
 
-// ErrResp
-// @Description: 错误信息返回
 type ErrResp struct {
 	Error            string `json:"error" description:"错误代码"`
 	ErrorDescription string `json:"error_description" description:"错误描述"`
 }
 
-// GetToken
-// @Description: 获取token信息
-// @author: Roc
-// @datetime 2024-01-23 15:40:56
-// @param code string
-// @return resp *AccessTokenResp
-// @return err error
 func GetToken(code string) (resp *AccessTokenResp, err error) {
 	code = strings.TrimSpace(code)
 	if code == "" {
 		err = fmt.Errorf("code不可为空")
 		return
 	}
-	//baseUrl := `%s?client_id=%s&client_secret=%s&redirect_uri=%s&code=%s&grant_type=authorization_code`
 
 	baseUrl := global.CONFIG.Gn.AuthTokenApiUrl
 	params := url.Values{}
@@ -64,21 +52,14 @@ func GetToken(code string) (resp *AccessTokenResp, err error) {
 	params.Add("code", code)
 	params.Add("grant_type", "authorization_code")
 
-	//callbackUrl := url.QueryEscape(global.CONFIG.Gn.AuthSSOCallbackUrl)
-	//fmt.Println("CallbackUrl: ", callbackUrl)
-	//urlPath := fmt.Sprintf(baseUrl, global.CONFIG.Gn.AuthTokenApiUrl, global.CONFIG.Gn.AuthClientId, global.CONFIG.Gn.AuthClientSecret, callbackUrl, code)
-	//fmt.Println("RequestUrl: ", urlPath)
 
 	result, e := HttpPostAuth(baseUrl, params, "")
-	//urlPath := fmt.Sprintf(`/idp/oauth2/getToken?client_id=%s&grant_type=authorization_code&code=%s&client_secret=%s`, global.CONFIG.Xiangyu.SystemCode, code, global.CONFIG.Xiangyu.UserKey)
-	//result, e := HttpPostAuth(urlPath, ``, "")
 	if e != nil {
 		err = fmt.Errorf("统一认证请求失败, %v", e)
 		return
 	}
 	fmt.Printf("Token RequestResult: %s\n", string(result))
 
-	//  解析响应结果
 	if e := json.Unmarshal(result, &resp); e != nil {
 		err = fmt.Errorf("解析响应失败, %v", e)
 		return
@@ -86,19 +67,11 @@ func GetToken(code string) (resp *AccessTokenResp, err error) {
 
 	if resp.Error != "" {
 		err = fmt.Errorf("Token请求失败, Err: %s, ErrMsg: %s ", resp.Error, resp.ErrorDescription)
-		//err = errors.New(fmt.Sprintf("响应代码:%s,错误信息:%s", resp.ErrCode, resp.Msg))
 		return
 	}
 	return
 }
 
-// GetUserInfo
-// @Description: 获取用户信息
-// @author: Roc
-// @datetime 2024-01-23 15:49:38
-// @param token string
-// @return resp *UserBaseInfoResp
-// @return err error
 func GetUserInfo(code, token string) (resp *UserBaseInfoResp, err error) {
 	code = strings.TrimSpace(code)
 	token = strings.TrimSpace(token)
@@ -112,21 +85,14 @@ func GetUserInfo(code, token string) (resp *UserBaseInfoResp, err error) {
 	params.Add("code", code)
 	params.Add("access_token", token)
 
-	//callbackUrl := url.QueryEscape(global.CONFIG.Gn.AuthSSOCallbackUrl)
-	//fmt.Println("CallbackUrl: ", callbackUrl)
-	//urlPath := fmt.Sprintf(baseUrl, global.CONFIG.Gn.AuthTokenApiUrl, global.CONFIG.Gn.AuthClientId, global.CONFIG.Gn.AuthClientSecret, callbackUrl, code)
-	//fmt.Println("RequestUrl: ", urlPath)
 
 	result, err := HttpPostAuth(baseUrl, params, "")
-	//urlPath := fmt.Sprintf(`/idp/oauth2/getUserInfo?client_id=%s&access_token=%s`, global.CONFIG.Xiangyu.SystemCode, token)
 
-	//result, err := HttpGetAuth(urlPath)
 	if err != nil {
 		return
 	}
 	fmt.Printf("UserInfoResult: %s\n", string(result))
 
-	//  解析响应结果
 	err = json.Unmarshal(result, &resp)
 	if err != nil {
 		return
@@ -139,17 +105,9 @@ func GetUserInfo(code, token string) (resp *UserBaseInfoResp, err error) {
 }
 
 func HttpPostAuth(postUrl string, params url.Values, contentTypes ...string) ([]byte, error) {
-	//if global.CONFIG.Xiangyu.UserAuthHost == `` {
-	//	return nil, errors.New("统一用户同步接口地址为空")
-	//}
-	// 请求地址
-	//postUrl := global.CONFIG.Xiangyu.UserAuthHost + urlPath
-	//postUrl := urlPath
-
-	//body := io.NopCloser(strings.NewReader(postData))
+
 	client := &http.Client{}
 	req, err := http.NewRequest("POST", postUrl, bytes.NewBufferString(params.Encode()))
-	//req, err := http.NewRequest("POST", postUrl, body)
 	if err != nil {
 		return nil, err
 	}
@@ -170,24 +128,15 @@ func HttpPostAuth(postUrl string, params url.Values, contentTypes ...string) ([]
 		return nil, err
 	}
 
-	// 日志记录
 	postData := fmt.Sprintf("%v", params)
 	global.FILE_LOG.Debug("统一认证:地址:" + postUrl + ";\n请求参数:" + postData + ";\n返回参数:" + string(result))
 
-	//  解析返回参数,判断是否是json
 	if !json.Valid(result) {
 		err = errors.New("返回参数不是json格式")
 	}
 	return result, err
 }
 
-// GetUserInfo
-// @Description: 获取用户信息
-// @author: Roc
-// @datetime 2024-01-23 15:49:38
-// @param token string
-// @return resp *UserBaseInfoResp
-// @return err error
 func GetUserInfoBySci(token string) (resp *UserBaseInfoResp, err error) {
 	token = strings.TrimSpace(token)
 	if token == "" {
@@ -200,7 +149,6 @@ func GetUserInfoBySci(token string) (resp *UserBaseInfoResp, err error) {
 	if err != nil {
 		return
 	}
-	//  解析响应结果
 	err = json.Unmarshal(result, &resp)
 	if err != nil {
 		return
@@ -216,7 +164,6 @@ func HttpGetAuth(urlPath string) ([]byte, error) {
 	if global.CONFIG.Gn.AuthUserApiUrl == `` {
 		return nil, errors.New("授权平台同步接口地址为空")
 	}
-	// 请求地址
 	getUrl := global.CONFIG.Gn.AuthUserApiUrl + urlPath
 	client := &http.Client{}
 	req, err := http.NewRequest("GET", getUrl, nil)
@@ -233,10 +180,8 @@ func HttpGetAuth(urlPath string) ([]byte, error) {
 		return nil, err
 	}
 
-	// 日志记录
 	global.FILE_LOG.Debug("授权平台:地址:" + getUrl + ";\n返回参数:" + string(result))
 
-	//  解析返回参数,判断是否是json
 	if !json.Valid(result) {
 		err = errors.New("返回参数不是json格式")
 	}

+ 0 - 24
services/gn/oa.go

@@ -11,15 +11,11 @@ import (
 	"strings"
 )
 
-// OABaseDataResp
-// @Description: 基础返回
 type OABaseDataResp struct {
 	Code int    `json:"code"`
 	Msg  string `json:"msg"`
 }
 
-// OASendDbResp
-// @Description: 指标列表请求返回结构体
 type OASendDbResp struct {
 	OABaseDataResp
 	Data struct {
@@ -28,8 +24,6 @@ type OASendDbResp struct {
 	} `json:"data"`
 }
 
-// OASendDbReq
-// @Description: oa审批请求参数
 type OASendDbReq struct {
 	AppTaskId     string `json:"appTaskId"`
 	AppPersonId   string `json:"appPersonId"`
@@ -40,11 +34,6 @@ type OASendDbReq struct {
 	Status        int    `json:"status"`
 }
 
-// OASendDb
-// @Description: 发送待办信息
-// @param param
-// @return resp
-// @return err
 func OASendDb(param OASendDbReq) (resp OASendDbResp, err error) {
 	defer func() {
 		if err != nil {
@@ -54,13 +43,11 @@ func OASendDb(param OASendDbReq) (resp OASendDbResp, err error) {
 
 	urlStr := global.CONFIG.Gn.OAHost + "/api/oa/sendDB"
 
-	// 请求
 	result, err := HttpPostOA(urlStr, param)
 	if err != nil {
 		return
 	}
 
-	//  解析响应结果
 	err = json.Unmarshal(result, &resp)
 	if err != nil {
 		return
@@ -69,18 +56,10 @@ func OASendDb(param OASendDbReq) (resp OASendDbResp, err error) {
 	return
 }
 
-// HttpPostOA
-// @Description: post请求
-// @param urlPath
-// @param token
-// @param postDataParams
-// @return []byte
-// @return error
 func HttpPostOA(urlPath string, postDataParams interface{}) ([]byte, error) {
 	if global.CONFIG.Gn.OAHost == `` {
 		return nil, errors.New("OA平台地址为空")
 	}
-	// 请求地址
 	postUrl := urlPath
 
 	var err error
@@ -114,17 +93,14 @@ func HttpPostOA(urlPath string, postDataParams interface{}) ([]byte, error) {
 		return nil, err
 	}
 
-	// 日志记录
 	global.FILE_LOG.Debug("OA审批:地址:" + postUrl + ";\n请求参数:" + postData + ";\n返回参数:" + string(result))
 
-	//  解析返回参数,判断是否是json
 	if !json.Valid(result) {
 		err = errors.New("返回参数不是json格式")
 		return []byte{}, err
 	}
 
 	var baseResp OASendDbResp
-	//  解析响应结果
 	err = json.Unmarshal(result, &baseResp)
 	if err != nil {
 		return []byte{}, err

+ 0 - 5
services/index_data/edb_update_log.go

@@ -7,14 +7,9 @@ import (
 	"time"
 )
 
-// DeleteBeforeTenDayLog
-// @Description: 定时删除10天前的指标更新日志
-// @author: Roc
-// @datetime 2024-03-07 20:01:04
 func DeleteBeforeTenDayLog() {
 	item := index.EdbUpdateLog{}
 	beforeDay := time.Now().AddDate(0, 0, -global.CONFIG.Mysql.Binlog.LogSaveDay).Format(utils.FormatDate)
-	//beforeDay := time.Now().AddDate(0, 0, -6).Format(utils.FormatDate)
 	err := item.DeleteBeforeTenDayLog(beforeDay)
 	if err != nil {
 		global.FILE_LOG.Error("定时删除10天前的指标更新日志失败:", err)

+ 0 - 99
services/index_data/gn_base_data_platform.go

@@ -16,16 +16,12 @@ import (
 	"time"
 )
 
-// GnBaseDataResp
-// @Description: 基础返回
 type GnBaseDataResp struct {
 	Code string `json:"code"`
 	Mesg string `json:"mesg"`
 	Time string `json:"time"`
 }
 
-// GnBaseListResp
-// @Description: 列表数据返回结构体
 type GnBaseListResp struct {
 	Result bool `json:"result"`
 	Total  int  `json:"total"`
@@ -33,26 +29,17 @@ type GnBaseListResp struct {
 	PageNo int  `json:"pageNo"`
 }
 
-// GnEdbIndexListResp
-// @Description: 指标列表请求返回结构体
 type GnEdbIndexListResp struct {
 	GnBaseDataResp
 	Data GnEdbIndexListDataResp `json:"data"`
 }
 
-// GnEdbIndexListDataResp
-// @Description: 指标列表返回结构体
 type GnEdbIndexListDataResp struct {
 	GnBaseListResp
 	Records []GnEdbIndexResp `json:"records"`
 }
 
-// GnEdbIndexResp
-// @Description: 单个指标响应结构体
 type GnEdbIndexResp struct {
-	//AREACODE          interface{} `json:"AREA_CODE"`
-	//AOYDILATATIONHIGH interface{} `json:"AOY_DILATATION_HIGH"`
-	//SULFURHIGH        interface{} `json:"SULFUR_HIGH"`
 	INDEXID         int         `json:"INDEX_ID" description:"指标ID"`
 	CREATETIME      string      `json:"CREATE_TIME" description:"创建时间"`
 	ISVALIDDATA     int         `json:"IS_VALID_DATA" description:"数据是否生效"`
@@ -66,29 +53,20 @@ type GnEdbIndexResp struct {
 	INDEXNAME       string      `json:"INDEX_NAME" description:"指标名称(系统内部使用)"`
 	INDEXORIGINCODE string      `json:"INDEX_ORIGIN_CODE" description:"原始指标编码"`
 	DATAUNIT        string      `json:"DATA_UNIT" description:"数据单位"`
-	//INDEXDESC        interface{} `json:"INDEX_DESC" description:"指标简介"`
 	CREATEORIGINTIME string `json:"CREATE_ORIGIN_TIME" description:"原始创建时间"`
 	UPDATEORIGINTIME string `json:"UPDATE_ORIGIN_TIME" description:"原始修改时间"`
 	UPDATETIME       string `json:"UPDATE_TIME" description:"修改时间"`
 	INDEXORIGINNAME  string `json:"INDEX_ORIGIN_NAME" description:"原始指标名称"`
-	//DES              interface{} `json:"DES" description:"备注"`
 	UNIQUE_ID string `json:"UNIQUE_ID" description:"唯一id"`
 }
 
 type IndexInfoReq struct {
-	//IndexId  string `json:"INDEX_ID"`
 	UpdateTime string `json:"UPDATE_TIME"`
 	Size       int    `json:"size"`
 	PageNo     int    `json:"pageNo"`
 	IndexId    string `json:"INDEX_ID"`
 }
 
-// GetIndexInfoList
-// @Description: 获取指标列表
-// @param param
-// @param num
-// @return resp
-// @return err
 func GetIndexInfoList(param IndexInfoReq) (resp GnEdbIndexListResp, err error) {
 	defer func() {
 		if err != nil {
@@ -98,21 +76,17 @@ func GetIndexInfoList(param IndexInfoReq) (resp GnEdbIndexListResp, err error) {
 
 	urlStr := global.CONFIG.Gn.DataEdbListUrl
 
-	// 获取token
 	token, err := GetGnAccessToken(false)
 	if err != nil {
 		return
 	}
 
-	// 请求
 	result, err := HttpPostGn(urlStr, token, param, 0)
 	if err != nil {
 		return
 	}
 
-	//result := getJson2()
 
-	//  解析响应结果
 	err = json.Unmarshal(result, &resp)
 	if err != nil {
 		return
@@ -121,32 +95,22 @@ func GetIndexInfoList(param IndexInfoReq) (resp GnEdbIndexListResp, err error) {
 	return
 }
 
-// GnEdbIndexValueListResp
-// @Description: 指标明细数据列表返回结构体
 type GnEdbIndexValueListResp struct {
 	GnBaseDataResp
 	Data GnEdbIndexValueListDataResp `json:"data"`
 }
 
-// GnEdbIndexValueListDataResp
-// @Description: 指标明细数据列表返回结构体
 type GnEdbIndexValueListDataResp struct {
 	GnBaseListResp
 	Records []GnEdbIndexValueResp `json:"records"`
 }
 
-// GnEdbIndexValueResp
-// @Description: 单个指标明细数据返回结构体
 type GnEdbIndexValueResp struct {
-	//UPDATEORIGINTIME interface{} `json:"UPDATE_ORIGIN_TIME" description:"原始修改时间"`
-	//VALUEDES         interface{} `json:"VALUE_DES" description:"指标值备注"`
 	ISVALIDDATA int    `json:"IS_VALID_DATA" description:"数据是否生效"`
 	DATADATE    string `json:"DATA_DATE" description:"数据日期"`
 	UPDATETIME  string `json:"UPDATE_TIME" description:"修改时间"`
 	VALUE       string `json:"VALUE" description:"指标值"`
 	INDEXID     int    `json:"INDEX_ID" description:"指标ID"`
-	//DES              interface{} `json:"DES" description:"备注"`
-	//CREATEORIGINTIME interface{} `json:"CREATE_ORIGIN_TIME" description:"原始创建时间"`
 	ID         int    `json:"ID" description:""`
 	CREATETIME string `json:"CREATE_TIME" description:"创建时间"`
 	UNIQUE_ID  string `json:"UNIQUE_ID" description:"唯一id"`
@@ -160,12 +124,6 @@ type IndexValueReq struct {
 	PageNo   int    `json:"pageNo"`
 }
 
-// GetIndexValueList
-// @Description: 获取指标明细列表
-// @param param
-// @param num
-// @return resp
-// @return err
 func GetIndexValueList(param IndexValueReq) (resp GnEdbIndexValueListResp, err error) {
 	defer func() {
 		if err != nil {
@@ -175,21 +133,17 @@ func GetIndexValueList(param IndexValueReq) (resp GnEdbIndexValueListResp, err e
 
 	urlStr := global.CONFIG.Gn.DataEdbValueListUrl
 
-	// 获取token
 	token, err := GetGnAccessToken(false)
 	if err != nil {
 		return
 	}
 
-	// 请求
 	result, err := HttpPostGn(urlStr, token, param, 0)
 	if err != nil {
 		return
 	}
 
-	//result := getJson3()
 
-	//  解析响应结果
 	err = json.Unmarshal(result, &resp)
 	if err != nil {
 		return
@@ -198,11 +152,6 @@ func GetIndexValueList(param IndexValueReq) (resp GnEdbIndexValueListResp, err e
 	return
 }
 
-// GetGnAccessToken
-// @Description: 获取AccessToken
-// @param isRefresh
-// @return token
-// @return err
 func GetGnAccessToken(isRefresh bool) (token string, err error) {
 	defer func() {
 		if err != nil {
@@ -211,7 +160,6 @@ func GetGnAccessToken(isRefresh bool) (token string, err error) {
 	}()
 	redisKey := utils.CACHE_EDB_GN_DATA_SERVER_TOKEN
 	token, redisErr := global.Rc.RedisString(redisKey)
-	//如果从redis中accessToken 获取失败或者token为空了,再或者需要强制刷新了,那么重新获取accessToken
 	if redisErr != nil || token == `` || isRefresh {
 		token, err = refreshGnAccessToken()
 		return
@@ -219,7 +167,6 @@ func GetGnAccessToken(isRefresh bool) (token string, err error) {
 	return
 }
 
-// refreshSmmAccessToken 强制刷新获取accessToken
 func refreshGnAccessToken() (token string, err error) {
 	defer func() {
 		if err != nil {
@@ -232,7 +179,6 @@ func refreshGnAccessToken() (token string, err error) {
 		return
 	}
 	token = tokenInfo.Data
-	//token存入redis
 	redisKey := utils.CACHE_EDB_GN_DATA_SERVER_TOKEN
 	err = global.Rc.Put(redisKey, token, time.Second*60*25)
 	if err != nil {
@@ -242,8 +188,6 @@ func refreshGnAccessToken() (token string, err error) {
 	return
 }
 
-// GnDataAccessResp
-// @Description: 国能数据节点accessToken相应结构体
 type GnDataAccessResp struct {
 	Code string `json:"code"`
 	Mesg string `json:"mesg"`
@@ -251,7 +195,6 @@ type GnDataAccessResp struct {
 	Data string `json:"data"`
 }
 
-// getGnAccessToken token内部请求接口
 func getGnAccessToken() (resp GnDataAccessResp, err error) {
 	defer func() {
 		if err != nil {
@@ -260,16 +203,13 @@ func getGnAccessToken() (resp GnDataAccessResp, err error) {
 	}()
 
 	timestamp, sign := GetSign()
-	// 请求地址
 	urlPath := fmt.Sprintf(`%s?accessKey=%s&timestamp=%d&sign=%s`, global.CONFIG.Gn.DataAccessTokenUrl, global.CONFIG.Gn.DataAccessKey, timestamp, sign)
 	result, err := HttpGetGn(urlPath)
 	if err != nil {
 		return
 	}
 
-	//result := getJson()
 
-	//  解析响应结果
 	err = json.Unmarshal(result, &resp)
 	if err != nil {
 		return
@@ -283,18 +223,10 @@ func getGnAccessToken() (resp GnDataAccessResp, err error) {
 	return
 }
 
-// HttpGetAuth
-// @Description: get请求
-// @author: Roc
-// @datetime 2024-01-23 16:20:16
-// @param urlPath string
-// @return []byte
-// @return error
 func HttpGetGn(urlPath string) ([]byte, error) {
 	if global.CONFIG.Gn.DataHost == `` {
 		return nil, errors.New("数据节点同步接口地址为空")
 	}
-	// 请求地址
 	getUrl := global.CONFIG.Gn.DataHost + urlPath
 	client := &http.Client{}
 	req, err := http.NewRequest("GET", getUrl, nil)
@@ -311,10 +243,8 @@ func HttpGetGn(urlPath string) ([]byte, error) {
 		return nil, err
 	}
 
-	// 日志记录
 	global.FILE_LOG.Debug("数据节点:地址:" + getUrl + ";\n返回参数:" + string(result))
 
-	//  解析返回参数,判断是否是json
 	if !json.Valid(result) {
 		err = errors.New("返回参数不是json格式")
 	}
@@ -322,19 +252,10 @@ func HttpGetGn(urlPath string) ([]byte, error) {
 	return result, err
 }
 
-// HttpPostGn
-// @Description: post请求
-// @param urlPath
-// @param token
-// @param postDataParams
-// @param num
-// @return []byte
-// @return error
 func HttpPostGn(urlPath, token string, postDataParams interface{}, num int) ([]byte, error) {
 	if global.CONFIG.Gn.DataHost == `` {
 		return nil, errors.New("国能数据平台地址为空")
 	}
-	// 请求地址
 	postUrl := global.CONFIG.Gn.DataHost + urlPath
 
 	var err error
@@ -355,7 +276,6 @@ func HttpPostGn(urlPath, token string, postDataParams interface{}, num int) ([]b
 	req.Header.Set("content-Type", "application/json; charset=utf-8")
 	req.Header.Set("Accept-Encoding", "application/json; charset=utf-8")
 	req.Header.Set("Accept", "application/json; charset=utf-8")
-	// 鉴权
 	req.Header.Set("Authorization", token)
 
 	resp, err := client.Do(req)
@@ -368,25 +288,20 @@ func HttpPostGn(urlPath, token string, postDataParams interface{}, num int) ([]b
 		return nil, err
 	}
 
-	// 日志记录
 	global.FILE_LOG.Debug("数据节点:地址:" + postUrl + ";\n Token:" + token + ";\n请求参数:" + postData + ";\n返回参数:" + string(result))
 
-	//  解析返回参数,判断是否是json
 	if !json.Valid(result) {
 		err = errors.New("返回参数不是json格式")
 		return []byte{}, err
 	}
 
 	var baseResp GnBaseDataResp
-	//  解析响应结果
 	err = json.Unmarshal(result, &baseResp)
 	if err != nil {
 		return []byte{}, err
 	}
 
-	//如果是token失效,同时只是第一次请求(没有尝试强制刷新token,那么重新请求)
 	if (utils.InArrayByStr([]string{""}, baseResp.Code) || strings.Contains(baseResp.Mesg, `无效token`)) && num <= 0 {
-		//token失效
 		token, err = refreshGnAccessToken()
 		if err != nil {
 			return []byte{}, err
@@ -403,12 +318,10 @@ func HttpPostGn(urlPath, token string, postDataParams interface{}, num int) ([]b
 	return result, err
 }
 
-// SHA256 计算给定字符串的SHA-256哈希值,并返回大写的十六进制表示形式。
 func SHA256(strSrc string) string {
 	return strings.ToUpper(hex.EncodeToString(encrypt([]byte(strSrc), sha256.New())))
 }
 
-// encrypt 使用指定的哈希算法计算输入字节的哈希值。
 func encrypt(strSrc []byte, hasher hash.Hash) []byte {
 	hasher.Write(strSrc)
 	return hasher.Sum(nil)
@@ -419,8 +332,6 @@ func GetSign() (timestamp int64, sign string) {
 	accessSecret := global.CONFIG.Gn.DataAccessSecret
 	timestamp = time.Now().UnixNano() / int64(time.Millisecond)
 	sign = SHA256(accessKey + fmt.Sprint(timestamp) + accessSecret)
-	//fmt.Printf("timestamp : %d\n", timestamp)
-	//fmt.Printf("sign: %s\n", sign)
 	return
 }
 
@@ -446,12 +357,6 @@ func getJson3() []byte {
 	return []byte(str)
 }
 
-// GetIndexInfoListV2
-// @Description: 获取指标列表
-// @param param
-// @param num
-// @return resp
-// @return err
 func GetIndexInfoListV2(param IndexInfoV2Req) (resp GnEdbIndexListResp, err error) {
 	defer func() {
 		if err != nil {
@@ -461,21 +366,17 @@ func GetIndexInfoListV2(param IndexInfoV2Req) (resp GnEdbIndexListResp, err erro
 
 	urlStr := global.CONFIG.Gn.DataEdbListUrl
 
-	// 获取token
 	token, err := GetGnAccessToken(false)
 	if err != nil {
 		return
 	}
 
-	// 请求
 	result, err := HttpPostGn(urlStr, token, param, 0)
 	if err != nil {
 		return
 	}
 
-	//result := getJson2()
 
-	//  解析响应结果
 	err = json.Unmarshal(result, &resp)
 	if err != nil {
 		return

+ 0 - 1
services/index_data/gn_base_data_platform_v2.go

@@ -1,7 +1,6 @@
 package index_data
 
 type IndexInfoV2Req struct {
-	//IndexId  string `json:"INDEX_ID"`
 	UpdateTime string `json:"UPDATE_TIME"`
 	Size       int    `json:"size"`
 	PageNo     int    `json:"pageNo"`

+ 1 - 40
services/index_data/gn_platform.go

@@ -13,9 +13,7 @@ import (
 	"time"
 )
 
-// TODO 过滤前后空格
 
-// GetPageIndexesFromGn 分页获取指标数据
 func GetPageIndexesFromGn(pageIndex, pageSize int, modifyTime, indexId string) (list []gn.IndexInfo, page *paging.PagingItem, err error) {
 	defer func() {
 		if err != nil {
@@ -42,21 +40,11 @@ func GetPageIndexesFromGn(pageIndex, pageSize int, modifyTime, indexId string) (
 	list = make([]gn.IndexInfo, 0)
 
 	for _, v := range resp.Data.Records {
-		//if v.INDEXLEVELTHREE == `` {
-		//	continue
-		//}
 
-		// 必须保证有一级目录
 		if v.INDEXLEVELONE == `` {
 			v.INDEXLEVELONE = `其它指标`
 		}
 
-		//if v.INDEXLEVELTWO == `` {
-		//	v.INDEXLEVELTWO = `其它指标`
-		//}
-		//if v.INDEXLEVELTHREE == `` {
-		//	v.INDEXLEVELTHREE = `其它指标`
-		//}
 
 		list = append(list, gn.IndexInfo{
 			ClassifyNameOne:   strings.TrimSpace(v.INDEXLEVELONE),
@@ -75,7 +63,6 @@ func GetPageIndexesFromGn(pageIndex, pageSize int, modifyTime, indexId string) (
 	return
 }
 
-// GetIndexAndDataFromGn 获取指标和数据
 func GetIndexAndDataFromGn(indexCode, startDate, endDate string) (list []gn.IndexData, err error) {
 	defer func() {
 		if err != nil {
@@ -88,13 +75,11 @@ func GetIndexAndDataFromGn(indexCode, startDate, endDate string) (list []gn.Inde
 	var dataDate string
 	dateList := make([]string, 0)
 
-	// 没有指定开始日期的话,那就默认当前日期
 	if startDate == `` {
 		startDate = `1901-01-01`
 	}
 	dateList = append(dateList, startDate)
 
-	// 没有的话,就默认往后找一个月
 	if endDate == `` {
 		endDate = time.Now().AddDate(0, 1, 0).Format(utils.FormatDate)
 	}
@@ -127,12 +112,6 @@ func GetIndexAndDataFromGn(indexCode, startDate, endDate string) (list []gn.Inde
 	return
 }
 
-// getIndexAndDataFromGn
-// @Description: 获取数据
-// @param req
-// @return list
-// @return page
-// @return err
 func getIndexAndDataFromGn(req IndexValueReq) (list []gn.IndexData, page *paging.PagingItem, err error) {
 	defer func() {
 		if err != nil {
@@ -151,20 +130,12 @@ func getIndexAndDataFromGn(req IndexValueReq) (list []gn.IndexData, page *paging
 	list = make([]gn.IndexData, 0)
 
 	for _, v := range resp.Data.Records {
-		// 非数值数据,过滤
-		//脏数据:
-		// 停产
-		// TODO、
-		// 1-2
-		// 空字符串
-
-		// 空数据,过滤
+
 		if v.VALUE == `` {
 			continue
 		}
 		valF, tmpErr := decimal.NewFromString(strings.TrimSpace(v.VALUE))
 		if tmpErr != nil {
-			//err = tmpErr
 			continue
 		}
 		val, _ := valF.Float64()
@@ -246,21 +217,11 @@ func getData(pageIndex, pageSize int, edbCode, dataSource string) (list []gn.Ind
 	list = make([]gn.IndexInfo, 0)
 
 	for _, v := range resp.Data.Records {
-		//if v.INDEXLEVELTHREE == `` {
-		//	continue
-		//}
 
-		// 必须保证有一级目录
 		if v.INDEXLEVELONE == `` {
 			v.INDEXLEVELONE = `其它指标`
 		}
 
-		//if v.INDEXLEVELTWO == `` {
-		//	v.INDEXLEVELTWO = `其它指标`
-		//}
-		//if v.INDEXLEVELTHREE == `` {
-		//	v.INDEXLEVELTHREE = `其它指标`
-		//}
 
 		list = append(list, gn.IndexInfo{
 			ClassifyNameOne:   strings.TrimSpace(v.INDEXLEVELONE),

+ 0 - 31
services/session.go

@@ -8,41 +8,12 @@ import (
 	"time"
 )
 
-// CreateEtaSession
-// @Description: 创建ETA会话session
-// @author: Roc
-// @datetime 2024-01-23 17:42:54
-// @param sysUser *eta.Admin
-// @return login *response.LoginResp
-// @return err error
-// @return errMsg string
 func CreateEtaSession(sysUser *eta.Admin) (login response.LoginResp, session *eta.SysSession, err error, errMsg string) {
 	errMsg = `登录失败`
 	login = response.LoginResp{}
 
 	var token string
 	account := utils.MD5(sysUser.AdminName)
-	//// 获取用户未过期的session, 避免过于频繁生成token
-	//expired := time.Now().AddDate(0, 0, 1).Format(utils.FormatDateTime)
-	//session, _ = eta.GetUserUnexpiredSysSession(sysUser.AdminName, expired)
-	//if session != nil && session.AccessToken != "" {
-	//	token = session.AccessToken
-	//} else {
-	//	token = utils.GenToken(account)
-	//	session = new(eta.SysSession)
-	//	session.UserName = sysUser.AdminName
-	//	session.SysUserId = sysUser.AdminId
-	//	session.ExpiredTime = time.Now().AddDate(0, 0, 90)
-	//	session.IsRemember = 1
-	//	session.CreatedTime = time.Now()
-	//	session.LastUpdatedTime = time.Now()
-	//	session.AccessToken = token
-	//	if e := eta.AddSysSession(session); e != nil {
-	//		errMsg = "新增session失败, err: "
-	//		err = errors.New("新增session失败, err: " + e.Error())
-	//		return
-	//	}
-	//}
 
 	token = utils.GenToken(account)
 	session = new(eta.SysSession)
@@ -69,7 +40,6 @@ func CreateEtaSession(sysUser *eta.Admin) (login response.LoginResp, session *et
 	login.RoleTypeCode = sysUser.RoleTypeCode
 	login.Authority = sysUser.Authority
 
-	// 判断实际的角色类型
 	if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP {
 		login.RoleTypeCode = utils.ROLE_TYPE_CODE_FICC_SELLER
 	}
@@ -89,7 +59,6 @@ func CreateEtaSession(sysUser *eta.Admin) (login response.LoginResp, session *et
 		login.RoleTypeCode = utils.ROLE_TYPE_CODE_FICC_SELLER
 	}
 
-	// 角色产品ID
 	productId := GetProductId(sysUser.RoleTypeCode)
 	productIdName := map[int]string{
 		0:                             "admin",

+ 0 - 3
task/task.go

@@ -52,12 +52,9 @@ func (e *Executor) Exec() { //执行任务
 					stack = stack + fmt.Sprintln(fmt.Sprintf("%s:%d</br>", file, line))
 				}
 				fmt.Println("stack:", stack)
-				//go services.SendEmail(utils.APPNAME+"崩了"+time.Now().Format("2006-01-02 15:04:05"), stack, utils.EmailSendToUsers)
 				go alarm_msg.SendAlarmMsg(utils.APPNAME+"崩了"+time.Now().Format("2006-01-02 15:04:05")+";Msg:"+stack, 2)
 			}
 		}()
-		//time.Sleep(60*time.Second)
-		//fmt.Println("i am here new")
 		e.f(e.params...)
 	}()
 

+ 0 - 117
utils/common.go

@@ -33,7 +33,6 @@ var (
 	KEY = []byte("5Mb5Gdmb5y")
 )
 
-// GenToken 发放token
 func GenToken(account string) string {
 	token := jwt.New(jwt.SigningMethodHS256)
 	token.Claims = &jwt.StandardClaims{
@@ -50,10 +49,8 @@ func GenToken(account string) string {
 	return ss
 }
 
-// 随机数种子
 var rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
 
-// GetRandString 获取随机字符串
 func GetRandString(size int) string {
 	allLetterDigit := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "!", "@", "#", "$", "%", "^", "&", "*"}
 	randomSb := ""
@@ -64,7 +61,6 @@ func GetRandString(size int) string {
 	return randomSb
 }
 
-// GetRandStringNoSpecialChar
 func GetRandStringNoSpecialChar(size int) string {
 	allLetterDigit := []string{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
 	randomSb := ""
@@ -75,7 +71,6 @@ func GetRandStringNoSpecialChar(size int) string {
 	return randomSb
 }
 
-// StringsToJSON
 func StringsToJSON(str string) string {
 	rs := []rune(str)
 	jsons := ""
@@ -90,29 +85,24 @@ func StringsToJSON(str string) string {
 	return jsons
 }
 
-// ToString 序列化
 func ToString(v interface{}) string {
 	data, _ := json.Marshal(v)
 	return string(data)
 }
 
-// MD5 md5加密
 func MD5(data string) string {
 	m := md5.Sum([]byte(data))
 	return hex.EncodeToString(m[:])
 }
 
-// GetRandDigit 获取数字随机字符
 func GetRandDigit(n int) string {
 	return fmt.Sprintf("%0"+strconv.Itoa(n)+"d", rnd.Intn(int(math.Pow10(n))))
 }
 
-// GetRandNumber 获取随机数
 func GetRandNumber(n int) int {
 	return rnd.Intn(n)
 }
 
-// GetRandInt
 func GetRandInt(min, max int) int {
 	if min >= max || min == 0 || max == 0 {
 		return max
@@ -120,20 +110,17 @@ func GetRandInt(min, max int) int {
 	return rand.Intn(max-min) + min
 }
 
-// GetToday 获取今天的随机字符
 func GetToday(format string) string {
 	today := time.Now().Format(format)
 	return today
 }
 
-// GetTodayLastSecond 获取今天剩余秒数
 func GetTodayLastSecond() time.Duration {
 	today := GetToday(FormatDate) + " 23:59:59"
 	end, _ := time.ParseInLocation(FormatDateTime, today, time.Local)
 	return time.Duration(end.Unix()-time.Now().Local().Unix()) * time.Second
 }
 
-// GetBrithDate 处理出生日期函数
 func GetBrithDate(idcard string) string {
 	l := len(idcard)
 	var s string
@@ -148,7 +135,6 @@ func GetBrithDate(idcard string) string {
 	return GetToday(FormatDate)
 }
 
-// WhichSexByIdcard 处理性别
 func WhichSexByIdcard(idcard string) string {
 	var sexs = [2]string{"女", "男"}
 	length := len(idcard)
@@ -162,7 +148,6 @@ func WhichSexByIdcard(idcard string) string {
 	return "男"
 }
 
-// SubFloatToString 截取小数点后几位
 func SubFloatToString(f float64, m int) string {
 	n := strconv.FormatFloat(f, 'f', -1, 64)
 	if n == "" {
@@ -181,20 +166,17 @@ func SubFloatToString(f float64, m int) string {
 	return newn[0] + "." + newn[1][:m]
 }
 
-// SubFloatToFloat 截取小数点后几位
 func SubFloatToFloat(f float64, m int) float64 {
 	newn := SubFloatToString(f, m)
 	newf, _ := strconv.ParseFloat(newn, 64)
 	return newf
 }
 
-// SubFloatToFloatStr 截取小数点后几位
 func SubFloatToFloatStr(f float64, m int) string {
 	newn := SubFloatToString(f, m)
 	return newn
 }
 
-// GetYearDiffer 获取相差时间-年
 func GetYearDiffer(start_time, end_time string) int {
 	t1, _ := time.ParseInLocation("2006-01-02", start_time, time.Local)
 	t2, _ := time.ParseInLocation("2006-01-02", end_time, time.Local)
@@ -205,20 +187,17 @@ func GetYearDiffer(start_time, end_time string) int {
 	return age
 }
 
-// GetSecondDifferByTime 获取相差时间-秒
 func GetSecondDifferByTime(start_time, end_time time.Time) int64 {
 	diff := end_time.Unix() - start_time.Unix()
 	return diff
 }
 
-// FixFloat
 func FixFloat(f float64, m int) float64 {
 	newn := SubFloatToString(f+0.00000001, m)
 	newf, _ := strconv.ParseFloat(newn, 64)
 	return newf
 }
 
-// StrListToString 将字符串数组转化为逗号分割的字符串形式  ["str1","str2","str3"] >>> "str1,str2,str3"
 func StrListToString(strList []string) (str string) {
 	if len(strList) > 0 {
 		for k, v := range strList {
@@ -233,25 +212,21 @@ func StrListToString(strList []string) (str string) {
 	return ""
 }
 
-// ValidateEmailFormatat 校验邮箱格式
 func ValidateEmailFormatat(email string) bool {
 	reg := regexp.MustCompile(RegularEmail)
 	return reg.MatchString(email)
 }
 
-// ValidateMobileFormatat 验证是否是手机号
 func ValidateMobileFormatat(mobileNum string) bool {
 	reg := regexp.MustCompile(RegularMobile)
 	return reg.MatchString(mobileNum)
 }
 
-// FileIsExist 判断文件是否存在
 func FileIsExist(filePath string) bool {
 	_, err := os.Stat(filePath)
 	return err == nil || os.IsExist(err)
 }
 
-// GetImgExt 获取图片扩展名
 func GetImgExt(file string) (ext string, err error) {
 	var headerByte []byte
 	headerByte = make([]byte, 8)
@@ -294,17 +269,13 @@ func GetImgExt(file string) (ext string, err error) {
 	return ext, nil
 }
 
-// SaveImage 保存图片
 func SaveImage(path string, img image.Image) (err error) {
-	//需要保持的文件
 	imgfile, err := os.Create(path)
 	defer imgfile.Close()
-	// 以PNG格式保存文件
 	err = png.Encode(imgfile, img)
 	return err
 }
 
-// DownloadImage 下载图片
 func DownloadImage(imgUrl string) (filePath string, err error) {
 	imgPath := "./static/imgs/"
 	fileName := path.Base(imgUrl)
@@ -314,7 +285,6 @@ func DownloadImage(imgUrl string) (filePath string, err error) {
 		return
 	}
 	defer res.Body.Close()
-	// 获得get请求响应的reader对象
 	reader := bufio.NewReaderSize(res.Body, 32*1024)
 
 	filePath = imgPath + fileName
@@ -322,7 +292,6 @@ func DownloadImage(imgUrl string) (filePath string, err error) {
 	if err != nil {
 		return
 	}
-	// 获得文件的writer对象
 	writer := bufio.NewWriter(file)
 
 	written, _ := io.Copy(writer, reader)
@@ -330,7 +299,6 @@ func DownloadImage(imgUrl string) (filePath string, err error) {
 	return
 }
 
-// SaveBase64ToFile 保存base64数据为文件
 func SaveBase64ToFile(content, path string) error {
 	data, err := base64.StdEncoding.DecodeString(content)
 	if err != nil {
@@ -345,7 +313,6 @@ func SaveBase64ToFile(content, path string) error {
 	return nil
 }
 
-// SaveBase64ToFileBySeek
 func SaveBase64ToFileBySeek(content, path string) (err error) {
 	data, err := base64.StdEncoding.DecodeString(content)
 	exist, err := PathExists(path)
@@ -358,7 +325,6 @@ func SaveBase64ToFileBySeek(content, path string) (err error) {
 			return err
 		}
 		n, _ := f.Seek(0, 2)
-		// 从末尾的偏移量开始写入内容
 		_, err = f.WriteAt([]byte(data), n)
 		defer f.Close()
 	} else {
@@ -367,7 +333,6 @@ func SaveBase64ToFileBySeek(content, path string) (err error) {
 			return err
 		}
 		n, _ := f.Seek(0, 2)
-		// 从末尾的偏移量开始写入内容
 		_, err = f.WriteAt([]byte(data), n)
 		defer f.Close()
 	}
@@ -375,7 +340,6 @@ func SaveBase64ToFileBySeek(content, path string) (err error) {
 	return nil
 }
 
-// StartIndex 开始下标
 func StartIndex(page, pagesize int) int {
 	if page > 1 {
 		return (page - 1) * pagesize
@@ -383,7 +347,6 @@ func StartIndex(page, pagesize int) int {
 	return 0
 }
 
-// PageCount
 func PageCount(count, pagesize int) int {
 	if count%pagesize > 0 {
 		return count/pagesize + 1
@@ -392,9 +355,7 @@ func PageCount(count, pagesize int) int {
 	}
 }
 
-// TrimHtml
 func TrimHtml(src string) string {
-	//将HTML标签全转换成小写
 	re, _ := regexp.Compile("\\<[\\S\\s]+?\\>")
 	src = re.ReplaceAllStringFunc(src, strings.ToLower)
 
@@ -408,9 +369,6 @@ func TrimHtml(src string) string {
 	return strings.TrimSpace(src)
 }
 
-// 1556164246  ->  2019-04-25 03:50:46 +0000
-// timestamp
-// TimeToTimestamp
 func TimeToTimestamp() {
 	fmt.Println(time.Unix(1556164246, 0).Format("2006-01-02 15:04:05"))
 }
@@ -424,21 +382,18 @@ func TimeTransferString(format string, t time.Time) string {
 	return str
 }
 
-// ToUnicode
 func ToUnicode(text string) string {
 	textQuoted := strconv.QuoteToASCII(text)
 	textUnquoted := textQuoted[1 : len(textQuoted)-1]
 	return textUnquoted
 }
 
-// VersionToInt
 func VersionToInt(version string) int {
 	version = strings.Replace(version, ".", "", -1)
 	n, _ := strconv.Atoi(version)
 	return n
 }
 
-// IsCheckInList
 func IsCheckInList(list []int, s int) bool {
 	for _, v := range list {
 		if v == s {
@@ -449,18 +404,15 @@ func IsCheckInList(list []int, s int) bool {
 
 }
 
-// round
 func round(num float64) int {
 	return int(num + math.Copysign(0.5, num))
 }
 
-// toFixed
 func toFixed(num float64, precision int) float64 {
 	output := math.Pow(10, float64(precision))
 	return float64(round(num*output)) / output
 }
 
-// GetWilsonScore returns Wilson Score
 func GetWilsonScore(p, n float64) float64 {
 	if p == 0 && n == 0 {
 		return 0
@@ -469,7 +421,6 @@ func GetWilsonScore(p, n float64) float64 {
 	return toFixed(((p+1.9208)/(p+n)-1.96*math.Sqrt(p*n/(p+n)+0.9604)/(p+n))/(1+3.8416/(p+n)), 2)
 }
 
-// 将中文数字转化成数字,比如 第三百四十五章,返回第345章 不支持一亿及以上
 func ChangeWordsToNum(str string) (numStr string) {
 	words := ([]rune)(str)
 	num := 0
@@ -547,14 +498,12 @@ func ChangeWordsToNum(str string) (numStr string) {
 	return
 }
 
-// Sha1
 func Sha1(data string) string {
 	sha1 := sha1.New()
 	sha1.Write([]byte(data))
 	return hex.EncodeToString(sha1.Sum([]byte("")))
 }
 
-// GetVideoPlaySeconds
 func GetVideoPlaySeconds(videoPath string) (playSeconds float64, err error) {
 	cmd := `ffmpeg -i ` + videoPath + `  2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//`
 	out, err := exec.Command("bash", "-c", cmd).Output()
@@ -588,7 +537,6 @@ func GetVideoPlaySeconds(videoPath string) (playSeconds float64, err error) {
 	return
 }
 
-// GetMaxTradeCode
 func GetMaxTradeCode(tradeCode string) (maxTradeCode string, err error) {
 	tradeCode = strings.Replace(tradeCode, "W", "", -1)
 	tradeCode = strings.Trim(tradeCode, " ")
@@ -601,25 +549,17 @@ func GetMaxTradeCode(tradeCode string) (maxTradeCode string, err error) {
 	return
 }
 
-// ConvertToFormatDay excel日期字段格式化 yyyy-mm-dd
 func ConvertToFormatDay(excelDaysString string) string {
-	// 2006-01-02 距离 1900-01-01的天数
 	baseDiffDay := 38719 //在网上工具计算的天数需要加2天,什么原因没弄清楚
 	curDiffDay := excelDaysString
 	b, _ := strconv.Atoi(curDiffDay)
-	// 获取excel的日期距离2006-01-02的天数
 	realDiffDay := b - baseDiffDay
-	//fmt.Println("realDiffDay:",realDiffDay)
-	// 距离2006-01-02 秒数
 	realDiffSecond := realDiffDay * 24 * 3600
-	//fmt.Println("realDiffSecond:",realDiffSecond)
-	// 2006-01-02 15:04:05距离1970-01-01 08:00:00的秒数 网上工具可查出
 	baseOriginSecond := 1136185445
 	resultTime := time.Unix(int64(baseOriginSecond+realDiffSecond), 0).Format("2006-01-02")
 	return resultTime
 }
 
-// CheckPwd
 func CheckPwd(pwd string) bool {
 	compile := `([0-9a-z]+){6,12}|(a-z0-9]+){6,12}`
 	reg := regexp.MustCompile(compile)
@@ -627,9 +567,7 @@ func CheckPwd(pwd string) bool {
 	return flag
 }
 
-// GetMonthStartAndEnd
 func GetMonthStartAndEnd(myYear string, myMonth string) (startDate, endDate string) {
-	// 数字月份必须前置补零
 	if len(myMonth) == 1 {
 		myMonth = "0" + myMonth
 	}
@@ -645,12 +583,10 @@ func GetMonthStartAndEnd(myYear string, myMonth string) (startDate, endDate stri
 	return t1, t2
 }
 
-// TrimStr 移除字符串中的空格
 func TrimStr(str string) (str2 string) {
 	return strings.Replace(str, " ", "", -1)
 }
 
-// StrTimeToTime 字符串转换为time
 func StrTimeToTime(strTime string) time.Time {
 	timeLayout := "2006-01-02 15:04:05"  //转化所需模板
 	loc, _ := time.LoadLocation("Local") //重要:获取时区
@@ -658,7 +594,6 @@ func StrTimeToTime(strTime string) time.Time {
 	return resultTime
 }
 
-// StrDateTimeToWeek 字符串类型时间转周几
 func StrDateTimeToWeek(strTime string) string {
 	var WeekDayMap = map[string]string{
 		"Monday":    "周一",
@@ -675,7 +610,6 @@ func StrDateTimeToWeek(strTime string) string {
 	return WeekDayMap[staweek_int]
 }
 
-// TimeToStrYmd 时间格式转年月日字符串
 func TimeToStrYmd(time2 time.Time) string {
 	var Ymd string
 	year := time2.Year()
@@ -685,7 +619,6 @@ func TimeToStrYmd(time2 time.Time) string {
 	return Ymd
 }
 
-// TimeRemoveHms 时间格式去掉时分秒
 func TimeRemoveHms(strTime string) string {
 	var Ymd string
 	var resultTime = StrTimeToTime(strTime)
@@ -696,7 +629,6 @@ func TimeRemoveHms(strTime string) string {
 	return Ymd
 }
 
-// ArticleLastTime 文章上一次编辑时间
 func ArticleLastTime(strTime string) string {
 	var newTime string
 	stamp, _ := time.ParseInLocation("2006-01-02 15:04:05", strTime, time.Local)
@@ -717,11 +649,9 @@ func ArticleLastTime(strTime string) string {
 	return newTime
 }
 
-// ConvertNumToCny 人民币小写转大写
 func ConvertNumToCny(num float64) (str string, err error) {
 	strNum := strconv.FormatFloat(num*100, 'f', 0, 64)
 	sliceUnit := []string{"仟", "佰", "拾", "亿", "仟", "佰", "拾", "万", "仟", "佰", "拾", "元", "角", "分"}
-	// log.Println(sliceUnit[:len(sliceUnit)-2])
 	s := sliceUnit[len(sliceUnit)-len(strNum):]
 	upperDigitUnit := map[string]string{"0": "零", "1": "壹", "2": "贰", "3": "叁", "4": "肆", "5": "伍", "6": "陆", "7": "柒", "8": "捌", "9": "玖"}
 	for k, v := range strNum[:] {
@@ -759,7 +689,6 @@ func ConvertNumToCny(num float64) (str string, err error) {
 	return
 }
 
-// GetNowWeekMonday 获取本周周一的时间
 func GetNowWeekMonday() time.Time {
 	offset := int(time.Monday - time.Now().Weekday())
 	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
@@ -770,7 +699,6 @@ func GetNowWeekMonday() time.Time {
 	return mondayTime
 }
 
-// GetNowWeekLastDay 获取本周最后一天的时间
 func GetNowWeekLastDay() time.Time {
 	offset := int(time.Monday - time.Now().Weekday())
 	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
@@ -783,28 +711,23 @@ func GetNowWeekLastDay() time.Time {
 	return lastDayTime
 }
 
-// GetNowMonthFirstDay 获取本月第一天的时间
 func GetNowMonthFirstDay() time.Time {
 	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location())
 	return nowMonthFirstDay
 }
 
-// GetNowMonthLastDay 获取本月最后一天的时间
 func GetNowMonthLastDay() time.Time {
 	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
 	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
 	return nowMonthLastDay
 }
 
-// GetNowQuarterFirstDay 获取本季度第一天的时间
 func GetNowQuarterFirstDay() time.Time {
 	month := int(time.Now().Month())
 	var nowQuarterFirstDay time.Time
 	if month >= 1 && month <= 3 {
-		//1月1号
 		nowQuarterFirstDay = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
 	} else if month >= 4 && month <= 6 {
-		//4月1号
 		nowQuarterFirstDay = time.Date(time.Now().Year(), 4, 1, 0, 0, 0, 0, time.Now().Location())
 	} else if month >= 7 && month <= 9 {
 		nowQuarterFirstDay = time.Date(time.Now().Year(), 7, 1, 0, 0, 0, 0, time.Now().Location())
@@ -814,96 +737,71 @@ func GetNowQuarterFirstDay() time.Time {
 	return nowQuarterFirstDay
 }
 
-// GetNowQuarterLastDay 获取本季度最后一天的时间
 func GetNowQuarterLastDay() time.Time {
 	month := int(time.Now().Month())
 	var nowQuarterLastDay time.Time
 	if month >= 1 && month <= 3 {
-		//03-31 23:59:59
 		nowQuarterLastDay = time.Date(time.Now().Year(), 3, 31, 23, 59, 59, 0, time.Now().Location())
 	} else if month >= 4 && month <= 6 {
-		//06-30 23:59:59
 		nowQuarterLastDay = time.Date(time.Now().Year(), 6, 30, 23, 59, 59, 0, time.Now().Location())
 	} else if month >= 7 && month <= 9 {
-		//09-30 23:59:59
 		nowQuarterLastDay = time.Date(time.Now().Year(), 9, 30, 23, 59, 59, 0, time.Now().Location())
 	} else {
-		//12-31 23:59:59
 		nowQuarterLastDay = time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
 	}
 	return nowQuarterLastDay
 }
 
-// GetNowHalfYearFirstDay 获取当前半年的第一天的时间
 func GetNowHalfYearFirstDay() time.Time {
 	month := int(time.Now().Month())
 	var nowHalfYearLastDay time.Time
 	if month >= 1 && month <= 6 {
-		//03-31 23:59:59
 		nowHalfYearLastDay = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
 	} else {
-		//12-31 23:59:59
 		nowHalfYearLastDay = time.Date(time.Now().Year(), 7, 1, 0, 0, 0, 0, time.Now().Location())
 	}
 	return nowHalfYearLastDay
 }
 
-// GetNowHalfYearLastDay 获取当前半年的最后一天的时间
 func GetNowHalfYearLastDay() time.Time {
 	month := int(time.Now().Month())
 	var nowHalfYearLastDay time.Time
 	if month >= 1 && month <= 6 {
-		//03-31 23:59:59
 		nowHalfYearLastDay = time.Date(time.Now().Year(), 6, 30, 23, 59, 59, 0, time.Now().Location())
 	} else {
-		//12-31 23:59:59
 		nowHalfYearLastDay = time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
 	}
 	return nowHalfYearLastDay
 }
 
-// GetNowYearFirstDay 获取当前年的最后一天的时间
 func GetNowYearFirstDay() time.Time {
-	//12-31 23:59:59
 	nowYearFirstDay := time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Now().Location())
 	return nowYearFirstDay
 }
 
-// GetNowYearLastDay 获取当前年的最后一天的时间
 func GetNowYearLastDay() time.Time {
-	//12-31 23:59:59
 	nowYearLastDay := time.Date(time.Now().Year(), 12, 31, 23, 59, 59, 0, time.Now().Location())
 	return nowYearLastDay
 }
 
-// CalculationDate 计算两个日期之间相差n年m月y天
 func CalculationDate(startDate, endDate time.Time) (beetweenDay string, err error) {
-	//startDate := time.Date(2021, 3, 28, 0, 0, 0, 0, time.Now().Location())
-	//endDate := time.Date(2022, 3, 31, 0, 0, 0, 0, time.Now().Location())
 	numYear := endDate.Year() - startDate.Year()
 
 	numMonth := int(endDate.Month()) - int(startDate.Month())
 
 	numDay := 0
-	//获取截止月的总天数
 	endDateDays := getMonthDay(endDate.Year(), int(endDate.Month()))
 
-	//获取截止月的前一个月
 	endDatePrevMonthDate := endDate.AddDate(0, -1, 0)
-	//获取截止日期的上一个月的总天数
 	endDatePrevMonthDays := getMonthDay(endDatePrevMonthDate.Year(), int(endDatePrevMonthDate.Month()))
-	//获取开始日期的的月份总天数
 	startDateMonthDays := getMonthDay(startDate.Year(), int(startDate.Month()))
 
-	//判断,截止月是否完全被选中,如果相等,那么代表截止月份全部天数被选择
 	if endDate.Day() == endDateDays {
 		numDay = startDateMonthDays - startDate.Day() + 1
 
-		//如果剩余天数正好与开始日期的天数是一致的,那么月份加1
 		if numDay == startDateMonthDays {
 			numMonth++
 			numDay = 0
-			//超过月份了,那么年份加1
 			if numMonth == 12 {
 				numYear++
 				numMonth = 0
@@ -913,21 +811,15 @@ func CalculationDate(startDate, endDate time.Time) (beetweenDay string, err erro
 		numDay = endDate.Day() - startDate.Day() + 1
 	}
 
-	//天数小于0,那么向月份借一位
 	if numDay < 0 {
-		//向上一个月借一个月的天数
 		numDay += endDatePrevMonthDays
 
-		//总月份减去一个月
 		numMonth = numMonth - 1
 	}
 
-	//月份小于0,那么向年份借一位
 	if numMonth < 0 {
-		//向上一个年借12个月
 		numMonth += 12
 
-		//总年份减去一年
 		numYear = numYear - 1
 	}
 	if numYear < 0 {
@@ -947,7 +839,6 @@ func CalculationDate(startDate, endDate time.Time) (beetweenDay string, err erro
 	return
 }
 
-// getMonthDay 获取某年某月有多少天
 func getMonthDay(year, month int) (days int) {
 	if month != 2 {
 		if month == 4 || month == 6 || month == 9 || month == 11 {
@@ -966,7 +857,6 @@ func getMonthDay(year, month int) (days int) {
 	return
 }
 
-// InArray 是否在切片(数组/map)中含有该值,目前只支持:string、int 、 int64,其他都是返回false
 func InArray(needle interface{}, hyStack interface{}) bool {
 	switch key := needle.(type) {
 	case string:
@@ -993,14 +883,12 @@ func InArray(needle interface{}, hyStack interface{}) bool {
 	return false
 }
 
-// bit转MB 保留小数
 func Bit2MB(bitSize int64, prec int) (size float64) {
 	mb := float64(bitSize) / float64(1024*1024)
 	size, _ = strconv.ParseFloat(strconv.FormatFloat(mb, 'f', prec, 64), 64)
 	return
 }
 
-// SubStr 截取字符串(中文)
 func SubStr(str string, subLen int) string {
 	strRune := []rune(str)
 	bodyRuneLen := len(strRune)
@@ -1054,13 +942,11 @@ func GetWeekZn(updateWeek string) (week string) {
 func GetWeekDay() (string, string) {
 	now := time.Now()
 	offset := int(time.Monday - now.Weekday())
-	//周日做特殊判断 因为time.Monday = 0
 	if offset > 0 {
 		offset = -6
 	}
 
 	lastoffset := int(time.Saturday - now.Weekday())
-	//周日做特殊判断 因为time.Monday = 0
 	if lastoffset == 6 {
 		lastoffset = -1
 	}
@@ -1072,7 +958,6 @@ func GetWeekDay() (string, string) {
 	return time.Unix(f, 0).Format("2006-01-02") + " 00:00:00", time.Unix(l, 0).Format("2006-01-02") + " 23:59:59"
 }
 
-// GetOracleInReplace 获取oracle sql的in查询替换:1的方法
 func GetOracleInReplace(num int) string {
 	template := make([]string, num)
 	for i := 0; i < num; i++ {
@@ -1081,7 +966,6 @@ func GetOracleInReplace(num int) string {
 	return strings.Join(template, ",")
 }
 
-// InArrayByInt php中的in_array(判断Int类型的切片中是否存在该Int值)
 func InArrayByInt(idStrList []int, searchId int) (has bool) {
 	for _, id := range idStrList {
 		if id == searchId {
@@ -1092,7 +976,6 @@ func InArrayByInt(idStrList []int, searchId int) (has bool) {
 	return
 }
 
-// InArrayByStr php中的in_array(判断String类型的切片中是否存在该Int值)
 func InArrayByStr(idStrList []string, searchId string) (has bool) {
 	for _, id := range idStrList {
 		if id == searchId {

+ 0 - 18
utils/constants.go

@@ -1,6 +1,5 @@
 package utils
 
-// 常量定义
 const (
 	FormatTime            = "15:04:05"                //时间格式
 	FormatDate            = "2006-01-02"              //日期格式
@@ -17,7 +16,6 @@ const (
 	PageSize30            = 30
 )
 
-// 手机号,电子邮箱正则
 const (
 	RegularMobile = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(18[0-9])|(17[0-9])|(16[0-9])|(19[0-9]))\\d{8}$" //手机号码
 	RegularEmail  = `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`                                             //匹配电子邮箱
@@ -33,8 +31,6 @@ const (
 	CACHE_EDB_GN_DATA_SERVER_TOKEN = "edb:gn_data_server_token"  // 国能数据节点调用凭证
 )
 
-// 管理员,ficc管理员,ficc销售,权益管理员,权益销售。
-// 角色类型/类型编码
 const (
 	ROLE_NAME_FICC_DIRECTOR = "ficc销售经理" // 实际角色类型为ficc销售主管
 
@@ -57,7 +53,6 @@ const (
 	COMPANY_PRODUCT_RAI_NAME  = "权益"
 )
 
-// 系统来源
 const (
 	SOURCE_CRM_FLAG = 1
 	SOURCE_ETA_FLAG = 2
@@ -68,18 +63,5 @@ const CrmEtaAuthorization = "NIi1RbEmH0C2rksXtPGDPBBgRgTZY87Q"
 const CACHE_MYSQL_MASTER_FILENAME = "eta:mysql:binlog:filename"
 const CACHE_MYSQL_MASTER_POSITION = "eta:mysql:binlog:position"
 
-// MultiAddNum 批量插入的数据量
 const MultiAddNum = 500
 
-// 4A接口错误编码
-//const (
-//	Gn4AErrCodeSuccess = "0"            // 操作成功
-//	Gn4AErrCode01      = "LoginErr-001" // 您没有权限登录该系统
-//	Gn4AErrCode02      = "LoginErr-002" // 系统内部无此用户
-//	Gn4AErrCode03      = "LoginErr-003" // 用户已被禁用
-//	Gn4AErrCode04      = "LoginErr-004" // 无法获取登录用户
-//	Gn4AErrCode05      = "LoginErr-005" // 用户来源非法
-//	Gn4AErrCode06      = "LoginErr-006" // 提交数据异常
-//	Gn4AErrCode07      = "LoginErr-007" // 认证服务无法访问
-//	Gn4AErrCode08      = "LoginErr-008" // 自定义错误文本
-//)

+ 0 - 11
utils/des3.go

@@ -1,4 +1,3 @@
-// 加密工具类,用了3des和base64
 package utils
 
 import (
@@ -11,7 +10,6 @@ import (
 	"strings"
 )
 
-// des3 + base64 encrypt
 func DesBase64Encrypt(origData []byte, desKey string) []byte {
 	result, err := TripleDesEncrypt(origData, []byte(desKey))
 	if err != nil {
@@ -36,21 +34,18 @@ func DesBase64Decrypt(crypted []byte, desKey string) []byte {
 	return origData
 }
 
-// 3DES加密
 func TripleDesEncrypt(origData, key []byte) ([]byte, error) {
 	block, err := des.NewTripleDESCipher(key)
 	if err != nil {
 		return nil, err
 	}
 	origData = PKCS5Padding(origData, block.BlockSize())
-	// origData = ZeroPadding(origData, block.BlockSize())
 	blockMode := cipher.NewCBCEncrypter(block, key[:8])
 	crypted := make([]byte, len(origData))
 	blockMode.CryptBlocks(crypted, origData)
 	return crypted, nil
 }
 
-// 3DES解密
 func TripleDesDecrypt(crypted, key []byte) ([]byte, error) {
 	block, err := des.NewTripleDESCipher(key)
 	if err != nil {
@@ -58,10 +53,8 @@ func TripleDesDecrypt(crypted, key []byte) ([]byte, error) {
 	}
 	blockMode := cipher.NewCBCDecrypter(block, key[:8])
 	origData := make([]byte, len(crypted))
-	// origData := crypted
 	blockMode.CryptBlocks(origData, crypted)
 	origData = PKCS5UnPadding(origData)
-	// origData = ZeroUnPadding(origData)
 	return origData, nil
 }
 
@@ -85,12 +78,10 @@ func PKCS5Padding(ciphertext []byte, blockSize int) []byte {
 
 func PKCS5UnPadding(origData []byte) []byte {
 	length := len(origData)
-	// 去掉最后一个字节 unpadding 次
 	unpadding := int(origData[length-1])
 	return origData[:(length - unpadding)]
 }
 
-// DES加密
 func DesEncrypt(content string, key string) string {
 	contents := []byte(content)
 	keys := []byte(key)
@@ -117,7 +108,6 @@ func byteToHexString(bytes []byte) string {
 	return str
 }
 
-// DES解密
 func DesDecrypt(content string, key string) string {
 	contentBytes, err := hex.DecodeString(content)
 	if err != nil {
@@ -135,7 +125,6 @@ func DesDecrypt(content string, key string) string {
 	return string(origData)
 }
 
-// DES ECB PKCK5Padding
 func EntryptDesECB(data, key []byte) (string, error) {
 	if len(key) > 8 {
 		key = key[:8]

+ 0 - 12
utils/directory.go

@@ -5,11 +5,6 @@ import (
 	"os"
 )
 
-// @title    PathExists
-// @description   文件目录是否存在
-// @auth                     (2020/04/05  20:22)
-// @param     path            string
-// @return    err             error
 
 func PathExists(path string) (bool, error) {
 	_, err := os.Stat(path)
@@ -22,11 +17,6 @@ func PathExists(path string) (bool, error) {
 	return false, err
 }
 
-// @title    createDir
-// @description   批量创建文件夹
-// @auth                     (2020/04/05  20:22)
-// @param     dirs            string
-// @return    err             error
 
 func CreateDir(dirs ...string) (err error) {
 	for _, v := range dirs {
@@ -36,11 +26,9 @@ func CreateDir(dirs ...string) (err error) {
 		}
 		if !exist {
 			fmt.Println("create directory ", v)
-			//global.LOG.Debug("create directory ", v)
 			err = os.MkdirAll(v, os.ModePerm)
 			if err != nil {
 				fmt.Println("create directory", v, " error:", err)
-				//global.LOG.Error("create directory", v, " error:", err)
 			}
 		}
 	}

+ 0 - 27
utils/drawtext.go

@@ -18,7 +18,6 @@ import (
 	"golang.org/x/image/font"
 )
 
-//DrawTextInfo 图片绘字信息
 type DrawTextInfo struct {
 	Text 		string
 	X    		int
@@ -26,7 +25,6 @@ type DrawTextInfo struct {
 	FontSize	int
 }
 
-//DrawRectInfo 图片画框信息
 type DrawRectInfo struct {
 	X1 int
 	Y1 int
@@ -34,7 +32,6 @@ type DrawRectInfo struct {
 	Y2 int
 }
 
-//TextBrush 字体相关
 type TextBrush struct {
 	FontType  *truetype.Font
 	FontSize  float64
@@ -42,7 +39,6 @@ type TextBrush struct {
 	TextWidth int
 }
 
-//NewTextBrush 新生成笔刷
 func NewTextBrush(FontFilePath string, FontSize float64, FontColor *image.Uniform, textWidth int) (*TextBrush, error) {
 	fontFile, err := ioutil.ReadFile(FontFilePath)
 	if err != nil {
@@ -58,7 +54,6 @@ func NewTextBrush(FontFilePath string, FontSize float64, FontColor *image.Unifor
 	return &TextBrush{FontType: fontType, FontSize: FontSize, FontColor: FontColor, TextWidth: textWidth}, nil
 }
 
-//DrawFontOnRGBA 图片插入文字
 func (fb *TextBrush) DrawFontOnRGBA(rgba *image.RGBA, pt image.Point, content string) {
 
 	c := freetype.NewContext()
@@ -74,7 +69,6 @@ func (fb *TextBrush) DrawFontOnRGBA(rgba *image.RGBA, pt image.Point, content st
 
 }
 
-//Image2RGBA Image2RGBA
 func Image2RGBA(img image.Image) *image.RGBA {
 
 	baseSrcBounds := img.Bounds().Max
@@ -83,7 +77,6 @@ func Image2RGBA(img image.Image) *image.RGBA {
 	newHeight := baseSrcBounds.Y
 
 	des := image.NewRGBA(image.Rect(0, 0, newWidth, newHeight)) // 底板
-	//首先将一个图片信息存入jpg
 	draw.Draw(des, des.Bounds(), img, img.Bounds().Min, draw.Over)
 
 	return des
@@ -96,9 +89,7 @@ type FontRGBA struct {
 	A uint8
 }
 
-//DrawStringOnImageAndSave 图片上写文字
 func DrawStringOnImageAndSave(imagePath string, imageData []byte, infos []*DrawTextInfo, colorRGBA FontRGBA) (err error) {
-	//判断图片类型
 	var backgroud image.Image
 	filetype := http.DetectContentType(imageData)
 	switch filetype {
@@ -125,12 +116,9 @@ func DrawStringOnImageAndSave(imagePath string, imageData []byte, infos []*DrawT
 	}
 	des := Image2RGBA(backgroud)
 
-	//新建笔刷
 	ttfPath := "static/ttf/songti.ttf"
 	textBrush, _ := NewTextBrush(ttfPath, 25, image.Black, 50)
 
-	//Px Py 绘图开始坐标 text要绘制的文字
-	//调整颜色
 	c := freetype.NewContext()
 	c.SetDPI(72)
 	c.SetFont(textBrush.FontType)
@@ -150,7 +138,6 @@ func DrawStringOnImageAndSave(imagePath string, imageData []byte, infos []*DrawT
 		c.DrawString(info.Text, freetype.Pt(info.X, info.Y))
 	}
 
-	//保存图片
 	fSave, err := os.Create(imagePath)
 	if err != nil {
 		return err
@@ -165,9 +152,7 @@ func DrawStringOnImageAndSave(imagePath string, imageData []byte, infos []*DrawT
 	return nil
 }
 
-//DrawRectOnImageAndSave 图片上画多个框
 func DrawRectOnImageAndSave(imagePath string, imageData []byte, infos []*DrawRectInfo) (err error) {
-	//判断图片类型
 	var backgroud image.Image
 	filetype := http.DetectContentType(imageData)
 	switch filetype {
@@ -193,7 +178,6 @@ func DrawRectOnImageAndSave(imagePath string, imageData []byte, infos []*DrawRec
 		return err
 	}
 	des := Image2RGBA(backgroud)
-	//新建笔刷
 	textBrush, _ := NewTextBrush("arial.ttf", 15, image.Black, 15)
 	for _, info := range infos {
 		var c *freetype.Context
@@ -222,7 +206,6 @@ func DrawRectOnImageAndSave(imagePath string, imageData []byte, infos []*DrawRec
 		}
 	}
 
-	//保存图片
 	fSave, err := os.Create(imagePath)
 	if err != nil {
 		return err
@@ -237,9 +220,7 @@ func DrawRectOnImageAndSave(imagePath string, imageData []byte, infos []*DrawRec
 	return nil
 }
 
-//DrawStringOnImage 生成图片
 func DrawStringOnImage(imageData []byte, infos []*DrawTextInfo, colorRGBA FontRGBA, fontSize float64, fontWidth int) (picBytes bytes.Buffer, err error) {
-	//判断图片类型
 	var backgroud image.Image
 	filetype := http.DetectContentType(imageData)
 	switch filetype {
@@ -266,12 +247,9 @@ func DrawStringOnImage(imageData []byte, infos []*DrawTextInfo, colorRGBA FontRG
 	}
 	des := Image2RGBA(backgroud)
 
-	//新建笔刷
 	ttfPath := "static/ttf/songti.ttf"
 	textBrush, _ := NewTextBrush(ttfPath, fontSize, image.Black, fontWidth)
 
-	//Px Py 绘图开始坐标 text要绘制的文字
-	//调整颜色
 	c := freetype.NewContext()
 	c.SetDPI(72)
 	c.SetFont(textBrush.FontType)
@@ -297,9 +275,7 @@ func DrawStringOnImage(imageData []byte, infos []*DrawTextInfo, colorRGBA FontRG
 }
 
 
-// DrawStringRowsOnImage 生成图片
 func DrawStringRowsOnImage(imageData []byte, infos []*DrawTextInfo, colorRGBA FontRGBA, fontSize float64, fontWidth int) (picBytes bytes.Buffer, err error) {
-	//判断图片类型
 	var backgroud image.Image
 	filetype := http.DetectContentType(imageData)
 	switch filetype {
@@ -326,12 +302,9 @@ func DrawStringRowsOnImage(imageData []byte, infos []*DrawTextInfo, colorRGBA Fo
 	}
 	des := Image2RGBA(backgroud)
 
-	//新建笔刷
 	ttfPath := "static/ttf/songti.ttf"
 	textBrush, _ := NewTextBrush(ttfPath, fontSize, image.Black, fontWidth)
 
-	//Px Py 绘图开始坐标 text要绘制的文字
-	//调整颜色
 
 	for _, info := range infos {
 		c := freetype.NewContext()

+ 0 - 14
utils/gin.go

@@ -2,12 +2,6 @@ package utils
 
 import "github.com/gin-gonic/gin"
 
-// SetBridgeLogListByClaims
-// @Description: 设置上下文中bridge日志
-// @author: Roc
-// @datetime 2024-10-31 10:55:15
-// @param c *gin.Context
-// @param logStr string
 func SetBridgeLogListByClaims(c *gin.Context, logStr string) {
 	bridgeLogList := GetBridgeLogListByClaims(c)
 	bridgeLogList = append(bridgeLogList, logStr)
@@ -16,16 +10,8 @@ func SetBridgeLogListByClaims(c *gin.Context, logStr string) {
 	return
 }
 
-// GetBridgeLogListByClaims
-// @Description: 从Claims中获取当前日志
-// @author: Roc
-// @datetime 2024-10-31 10:35:04
-// @param c *gin.Context
-// @return bridgeLogList []string
 func GetBridgeLogListByClaims(c *gin.Context) (bridgeLogList []string) {
-	//获取jwt数据失败
 	claims, exists := c.Get("bridge_log")
-	// 如果不存在,那么就是空切片
 	if !exists {
 		bridgeLogList = []string{}
 		return

+ 0 - 2
utils/redis.go

@@ -35,7 +35,5 @@ func InitRedis(redisType string, conf string) (redisClient RedisClient, err erro
 	return
 }
 
-// redis没有key的错误
 const RedisNoKeyErr = "redis: nil"
 
-//const redisNoKeyErr = redis2.Error(redis2.Nil)

+ 0 - 109
utils/redis/cluster_redis.go

@@ -10,30 +10,19 @@ import (
 	"time"
 )
 
-// ClusterRedisClient
-// @Description: 集群的redis客户端
 type ClusterRedisClient struct {
 	redisClient *redis.ClusterClient
 }
 
 var DefaultKey = "zcmRedis"
 
-// InitClusterRedis
-// @Description: 初始化集群redis客户端
-// @param config
-// @return clusterRedisClient
-// @return err
 func InitClusterRedis(config string) (clusterRedisClient *ClusterRedisClient, err error) {
 	var cf map[string]string
 	err = json.Unmarshal([]byte(config), &cf)
 	if err != nil {
 		return
 	}
-	//if _, ok := cf["key"]; !ok {
-	//	cf["key"] = DefaultKey
-	//}
 
-	// 集群地址
 	connList := make([]string, 0)
 	if _, ok := cf["conn"]; !ok {
 		err = errors.New("config has no conn key")
@@ -46,21 +35,17 @@ func InitClusterRedis(config string) (clusterRedisClient *ClusterRedisClient, er
 		}
 	}
 
-	// 密码
 	if _, ok := cf["password"]; !ok {
 		cf["password"] = ""
 	}
 
-	// 创建 Redis 客户端配置对象
 	clusterOptions := &redis.ClusterOptions{
 		Addrs:    connList, // 设置 Redis 节点的 IP 地址和端口号
 		Password: cf["password"],
 	}
 
-	// 创建 Redis 集群客户端
 	client := redis.NewClusterClient(clusterOptions)
 
-	// 测试连接并获取信息
 	_, err = client.Ping(context.TODO()).Result()
 	if err != nil {
 		err = errors.New("redis 链接失败:" + err.Error())
@@ -72,11 +57,6 @@ func InitClusterRedis(config string) (clusterRedisClient *ClusterRedisClient, er
 	return
 }
 
-// Get
-// @Description: 根据key获取数据(其实是返回的字节编码)
-// @receiver rc
-// @param key
-// @return interface{}
 func (rc *ClusterRedisClient) Get(key string) interface{} {
 	data, err := rc.redisClient.Get(context.TODO(), key).Bytes()
 	if err != nil {
@@ -86,78 +66,36 @@ func (rc *ClusterRedisClient) Get(key string) interface{} {
 	return data
 }
 
-// GetStr
-// @Description: 根据key获取字符串数据
-// @receiver rc
-// @param key
-// @return string
 func (rc *ClusterRedisClient) GetStr(key string) string {
 	return rc.redisClient.Get(context.TODO(), key).Val()
 }
 
-// GetInt
-// @Description: 根据key获取int数据
-// @receiver rc
-// @param key
-// @return int
-// @return error
 func (rc *ClusterRedisClient) GetInt64(key string) (int64, error) {
 	return rc.redisClient.Get(context.TODO(), key).Int64()
 }
 
-// GetInt
-// @Description: 根据key获取int数据
-// @receiver rc
-// @param key
-// @return int
-// @return error
 func (rc *ClusterRedisClient) GetUInt64(key string) (uint64, error) {
 	return rc.redisClient.Get(context.TODO(), key).Uint64()
 }
 
-// RedisBytes
-// @Description: 根据key获取字节编码数据
-// @receiver rc
-// @param key
-// @return data
-// @return err
 func (rc *ClusterRedisClient) RedisBytes(key string) (data []byte, err error) {
 	data, err = rc.redisClient.Get(context.TODO(), key).Bytes()
 
 	return
 }
 
-// RedisString
-// @Description: 根据key获取字符串数据
-// @receiver rc
-// @param key
-// @return data
-// @return err
 func (rc *ClusterRedisClient) RedisString(key string) (data string, err error) {
 	data, err = rc.redisClient.Get(context.TODO(), key).Result()
 
 	return
 }
 
-// RedisInt
-// @Description: 根据key获取int数据
-// @receiver rc
-// @param key
-// @return data
-// @return err
 func (rc *ClusterRedisClient) RedisInt(key string) (data int, err error) {
 	data, err = rc.redisClient.Get(context.TODO(), key).Int()
 
 	return
 }
 
-// Put
-// @Description: put一个数据到redis
-// @receiver rc
-// @param key
-// @param val
-// @param timeout
-// @return error
 func (rc *ClusterRedisClient) Put(key string, val interface{}, timeout time.Duration) error {
 	var err error
 	err = rc.redisClient.SetEX(context.TODO(), key, val, timeout).Err()
@@ -170,13 +108,6 @@ func (rc *ClusterRedisClient) Put(key string, val interface{}, timeout time.Dura
 	return err
 }
 
-// SetNX
-// @Description: 设置一个会过期时间的值
-// @receiver rc
-// @param key
-// @param val
-// @param timeout
-// @return bool
 func (rc *ClusterRedisClient) SetNX(key string, val interface{}, timeout time.Duration) bool {
 	result, err := rc.redisClient.SetEX(context.TODO(), key, val, timeout).Result()
 	if err != nil || result != "OK" {
@@ -186,11 +117,6 @@ func (rc *ClusterRedisClient) SetNX(key string, val interface{}, timeout time.Du
 	return true
 }
 
-// Delete
-// @Description: 删除redis中的键值对
-// @receiver rc
-// @param key
-// @return error
 func (rc *ClusterRedisClient) Delete(key string) error {
 	var err error
 
@@ -204,11 +130,6 @@ func (rc *ClusterRedisClient) Delete(key string) error {
 	return err
 }
 
-// IsExist
-// @Description: 根据key判断是否写入缓存中
-// @receiver rc
-// @param key
-// @return bool
 func (rc *ClusterRedisClient) IsExist(key string) bool {
 	result, err := rc.redisClient.Exists(context.TODO(), key).Result()
 	if err != nil {
@@ -222,12 +143,6 @@ func (rc *ClusterRedisClient) IsExist(key string) bool {
 	return true
 }
 
-// LPush
-// @Description: 写入list
-// @receiver rc
-// @param key
-// @param val
-// @return error
 func (rc *ClusterRedisClient) LPush(key string, val interface{}) error {
 	data, _ := json.Marshal(val)
 	err := rc.redisClient.LPush(context.TODO(), key, data).Err()
@@ -235,11 +150,6 @@ func (rc *ClusterRedisClient) LPush(key string, val interface{}) error {
 	return err
 }
 
-// Brpop
-// @Description: 从list中读取
-// @receiver rc
-// @param key
-// @param callback
 func (rc *ClusterRedisClient) Brpop(key string, callback func([]byte)) {
 	values, err := rc.redisClient.BRPop(context.TODO(), 1*time.Second, key).Result()
 	if err != nil {
@@ -254,11 +164,6 @@ func (rc *ClusterRedisClient) Brpop(key string, callback func([]byte)) {
 
 }
 
-// GetRedisTTL
-// @Description: 获取key的过期时间
-// @receiver rc
-// @param key
-// @return time.Duration
 func (rc *ClusterRedisClient) GetRedisTTL(key string) time.Duration {
 	value, err := rc.redisClient.TTL(context.TODO(), key).Result()
 	if err != nil {
@@ -269,24 +174,10 @@ func (rc *ClusterRedisClient) GetRedisTTL(key string) time.Duration {
 
 }
 
-// Incrby
-// @Description: 设置自增值
-// @receiver rc
-// @param key
-// @param num
-// @return interface{}
-// @return error
 func (rc *ClusterRedisClient) Incrby(key string, num int) (interface{}, error) {
 	return rc.redisClient.IncrBy(context.TODO(), key, int64(num)).Result()
 }
 
-// Do
-// @Description: cmd执行redis命令
-// @receiver rc
-// @param commandName
-// @param args
-// @return reply
-// @return err
 func (rc *ClusterRedisClient) Do(commandName string, args ...interface{}) (reply interface{}, err error) {
 	newArgs := []interface{}{commandName}
 	newArgs = append(newArgs, args...)

+ 0 - 103
utils/redis/standalone_redis.go

@@ -10,8 +10,6 @@ import (
 	"time"
 )
 
-// StandaloneRedisClient
-// @Description: 单机redis客户端
 type StandaloneRedisClient struct {
 	redisClient *redis.Client
 }
@@ -22,18 +20,13 @@ func InitStandaloneRedis(config string) (standaloneRedis *StandaloneRedisClient,
 	if err != nil {
 		return
 	}
-	//if _, ok := cf["key"]; !ok {
-	//	cf["key"] = DefaultKey
-	//}
 
 	if _, ok := cf["conn"]; !ok {
 		err = errors.New("config has no conn key")
 		return
 	}
 
-	// db库
 	dbNum := 0
-	// 如果指定了db库
 	if _, ok := cf["dbNum"]; ok {
 		dbNum, err = strconv.Atoi(cf["dbNum"])
 		if err != nil {
@@ -41,7 +34,6 @@ func InitStandaloneRedis(config string) (standaloneRedis *StandaloneRedisClient,
 		}
 	}
 
-	// 密码
 	if _, ok := cf["password"]; !ok {
 		cf["password"] = ""
 	}
@@ -50,7 +42,6 @@ func InitStandaloneRedis(config string) (standaloneRedis *StandaloneRedisClient,
 		Addr:     cf["conn"],
 		Password: cf["password"],
 		DB:       dbNum,
-		//PoolSize: 10, //连接池最大socket连接数,默认为10倍CPU数, 10 * runtime.NumCPU(暂不配置)
 	})
 
 	_, err = client.Ping(context.TODO()).Result()
@@ -64,11 +55,6 @@ func InitStandaloneRedis(config string) (standaloneRedis *StandaloneRedisClient,
 	return
 }
 
-// Get
-// @Description: 根据key获取数据(其实是返回的字节编码)
-// @receiver rc
-// @param key
-// @return interface{}
 func (rc *StandaloneRedisClient) Get(key string) interface{} {
 	data, err := rc.redisClient.Get(context.TODO(), key).Bytes()
 	if err != nil {
@@ -78,78 +64,36 @@ func (rc *StandaloneRedisClient) Get(key string) interface{} {
 	return data
 }
 
-// GetStr
-// @Description: 根据key获取字符串数据
-// @receiver rc
-// @param key
-// @return string
 func (rc *StandaloneRedisClient) GetStr(key string) string {
 	return rc.redisClient.Get(context.TODO(), key).Val()
 }
 
-// GetInt
-// @Description: 根据key获取int数据
-// @receiver rc
-// @param key
-// @return int
-// @return error
 func (rc *StandaloneRedisClient) GetInt64(key string) (int64, error) {
 	return rc.redisClient.Get(context.TODO(), key).Int64()
 }
 
-// GetInt
-// @Description: 根据key获取int数据
-// @receiver rc
-// @param key
-// @return int
-// @return error
 func (rc *StandaloneRedisClient) GetUInt64(key string) (uint64, error) {
 	return rc.redisClient.Get(context.TODO(), key).Uint64()
 }
 
-// RedisBytes
-// @Description: 根据key获取字节编码数据
-// @receiver rc
-// @param key
-// @return data
-// @return err
 func (rc *StandaloneRedisClient) RedisBytes(key string) (data []byte, err error) {
 	data, err = rc.redisClient.Get(context.TODO(), key).Bytes()
 
 	return
 }
 
-// RedisString
-// @Description: 根据key获取字符串数据
-// @receiver rc
-// @param key
-// @return data
-// @return err
 func (rc *StandaloneRedisClient) RedisString(key string) (data string, err error) {
 	data, err = rc.redisClient.Get(context.TODO(), key).Result()
 
 	return
 }
 
-// RedisInt
-// @Description: 根据key获取int数据
-// @receiver rc
-// @param key
-// @return data
-// @return err
 func (rc *StandaloneRedisClient) RedisInt(key string) (data int, err error) {
 	data, err = rc.redisClient.Get(context.TODO(), key).Int()
 
 	return
 }
 
-// Put
-// @Description: put一个数据到redis
-// @receiver rc
-// @param key
-// @param val
-// @param timeout
-// @return error
 func (rc *StandaloneRedisClient) Put(key string, val interface{}, timeout time.Duration) error {
 	var err error
 	err = rc.redisClient.SetEX(context.TODO(), key, val, timeout).Err()
@@ -162,13 +106,6 @@ func (rc *StandaloneRedisClient) Put(key string, val interface{}, timeout time.D
 	return err
 }
 
-// SetNX
-// @Description: 设置一个会过期时间的值
-// @receiver rc
-// @param key
-// @param val
-// @param timeout
-// @return bool
 func (rc *StandaloneRedisClient) SetNX(key string, val interface{}, timeout time.Duration) bool {
 	result, err := rc.redisClient.SetEX(context.TODO(), key, val, timeout).Result()
 	if err != nil || result != "OK" {
@@ -178,11 +115,6 @@ func (rc *StandaloneRedisClient) SetNX(key string, val interface{}, timeout time
 	return true
 }
 
-// Delete
-// @Description: 删除redis中的键值对
-// @receiver rc
-// @param key
-// @return error
 func (rc *StandaloneRedisClient) Delete(key string) error {
 	var err error
 
@@ -196,11 +128,6 @@ func (rc *StandaloneRedisClient) Delete(key string) error {
 	return err
 }
 
-// IsExist
-// @Description: 根据key判断是否写入缓存中
-// @receiver rc
-// @param key
-// @return bool
 func (rc *StandaloneRedisClient) IsExist(key string) bool {
 	result, err := rc.redisClient.Exists(context.TODO(), key).Result()
 	if err != nil {
@@ -214,12 +141,6 @@ func (rc *StandaloneRedisClient) IsExist(key string) bool {
 	return true
 }
 
-// LPush
-// @Description: 写入list
-// @receiver rc
-// @param key
-// @param val
-// @return error
 func (rc *StandaloneRedisClient) LPush(key string, val interface{}) error {
 	data, _ := json.Marshal(val)
 	err := rc.redisClient.LPush(context.TODO(), key, data).Err()
@@ -227,11 +148,6 @@ func (rc *StandaloneRedisClient) LPush(key string, val interface{}) error {
 	return err
 }
 
-// Brpop
-// @Description: 从list中读取
-// @receiver rc
-// @param key
-// @param callback
 func (rc *StandaloneRedisClient) Brpop(key string, callback func([]byte)) {
 	values, err := rc.redisClient.BRPop(context.TODO(), 1*time.Second, key).Result()
 	if err != nil {
@@ -246,11 +162,6 @@ func (rc *StandaloneRedisClient) Brpop(key string, callback func([]byte)) {
 
 }
 
-// GetRedisTTL
-// @Description: 获取key的过期时间
-// @receiver rc
-// @param key
-// @return time.Duration
 func (rc *StandaloneRedisClient) GetRedisTTL(key string) time.Duration {
 	value, err := rc.redisClient.TTL(context.TODO(), key).Result()
 	if err != nil {
@@ -261,24 +172,10 @@ func (rc *StandaloneRedisClient) GetRedisTTL(key string) time.Duration {
 
 }
 
-// Incrby
-// @Description: 设置自增值
-// @receiver rc
-// @param key
-// @param num
-// @return interface{}
-// @return error
 func (rc *StandaloneRedisClient) Incrby(key string, num int) (interface{}, error) {
 	return rc.redisClient.IncrBy(context.TODO(), key, int64(num)).Result()
 }
 
-// Do
-// @Description: cmd执行redis命令
-// @receiver rc
-// @param commandName
-// @param args
-// @return reply
-// @return err
 func (rc *StandaloneRedisClient) Do(commandName string, args ...interface{}) (reply interface{}, err error) {
 	newArgs := []interface{}{commandName}
 	newArgs = append(newArgs, args...)

+ 0 - 13
utils/validator.go

@@ -13,7 +13,6 @@ type RulesMap map[string]Rules
 
 var CustomizeMap = make(map[string]Rules)
 
-// 注册自定义规则方案建议在路由初始化层即注册
 func RegisterRule(key string, rule Rules) (err error) {
 	if CustomizeMap[key] != nil {
 		return errors.New(key + "已注册,无法重复注册")
@@ -23,42 +22,34 @@ func RegisterRule(key string, rule Rules) (err error) {
 	}
 }
 
-// 非空 不能为其对应类型的0值
 func NotEmpty() string {
 	return "notEmpty"
 }
 
-// 小于入参(<) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
 func Lt(mark string) string {
 	return "lt=" + mark
 }
 
-// 小于等于入参(<=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
 func Le(mark string) string {
 	return "le=" + mark
 }
 
-// 等于入参(==) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
 func Eq(mark string) string {
 	return "eq=" + mark
 }
 
-// 不等于入参(!=)  如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
 func Ne(mark string) string {
 	return "ne=" + mark
 }
 
-// 大于等于入参(>=) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
 func Ge(mark string) string {
 	return "ge=" + mark
 }
 
-// 大于入参(>) 如果为string array Slice则为长度比较 如果是 int uint float 则为数值比较
 func Gt(mark string) string {
 	return "gt=" + mark
 }
 
-// 校验方法 接收两个参数  入参实例,规则map
 func Verify(st interface{}, roleMap Rules) (err error) {
 	compareMap := map[string]bool{
 		"lt": true,
@@ -77,12 +68,10 @@ func Verify(st interface{}, roleMap Rules) (err error) {
 		return errors.New("expect struct")
 	}
 	num := val.NumField()
-	// 遍历结构体的所有字段
 	for i := 0; i < num; i++ {
 		tagVal := typ.Field(i)
 		val := val.Field(i)
 
-		//如果有填写form字段的话,那么返回提示使用该字段
 		tagName := tagVal.Tag.Get("form")
 		if tagName == "" {
 			tagName = tagVal.Name
@@ -106,7 +95,6 @@ func Verify(st interface{}, roleMap Rules) (err error) {
 	return nil
 }
 
-// 长度和数字的校验方法 根据类型自动校验
 func compareVerify(value reflect.Value, VerifyStr string) bool {
 	switch value.Kind() {
 	case reflect.String, reflect.Slice, reflect.Array:
@@ -122,7 +110,6 @@ func compareVerify(value reflect.Value, VerifyStr string) bool {
 	}
 }
 
-// 非空校验
 func isBlank(value reflect.Value) bool {
 	switch value.Kind() {
 	case reflect.String:

+ 0 - 4
utils/whereBuild.go

@@ -9,13 +9,10 @@ type NullType byte
 
 const (
 	_ NullType = iota
-	// IsNull the same as `is null`
 	IsNull
-	// IsNotNull the same as `is not null`
 	IsNotNull
 )
 
-// sql生成工具
 func WhereBuild(where map[string]interface{}) (whereSQL string, vals []interface{}, err error) {
 	for k, v := range where {
 		ks := strings.Split(k, " ")
@@ -29,7 +26,6 @@ func WhereBuild(where map[string]interface{}) (whereSQL string, vals []interface
 		strings.Join(ks, ",")
 		switch len(ks) {
 		case 1:
-			//fmt.Println(reflect.TypeOf(v))
 			switch v := v.(type) {
 			case NullType:
 				if v == IsNotNull {