Browse Source

新增初始化公共功能

master
herenshan112 9 months ago
parent
commit
3d6e1acb8b
  1. 2
      config/yamlConfig/app.yaml
  2. 9
      controller/stock/entry.go
  3. 69
      controller/stock/heavenlyStemsEarthlyBranches.go
  4. 6
      go.mod
  5. 12
      go.sum
  6. 1287
      publicmethod/publicControll.go
  7. 61
      publicmethod/type.go
  8. 10
      utils/formatoutput/hseb.go

2
config/yamlConfig/app.yaml

@ -1,6 +1,6 @@
#App主配置
appsetup:
port: 18888 #服务端口
port: 18889 #服务端口
readtime: 3600 #请求的读取操作在超时前的最大持续时间
writetime : 3600 #回复的写入操作在超时前的最大持续时间
appkey: 'application_platform_qin_dong' #应用程序密钥

9
controller/stock/entry.go

@ -0,0 +1,9 @@
package stock
type ApiMethod struct{}
// 获取天干地址
type GainHeavenlyEarthly struct {
HeavenlyStems string `json:"heavenlyStems"` //天干
EarthlyBranches string `json:"earthlyBranches"` //地支
}

69
controller/stock/heavenlyStemsEarthlyBranches.go

@ -0,0 +1,69 @@
package stock
import (
"appNewPlatform/generalmethod"
"appNewPlatform/utils"
"appNewPlatform/utils/formatoutput"
"github.com/gin-gonic/gin"
)
/*
*
@ 作者: 秦东
@ 时间: 2025-02-26 08:52:39
@ 功能: 入口
*/
func (a *ApiMethod) Index(c *gin.Context) {
sendMap := generalmethod.MapOut[string]()
token, _ := utils.ReleaseToken("300450")
sendMap["token"] = token
sendMap["tokenStr"], sendMap["claims"], sendMap["err"] = utils.ParseToken(token)
formatoutput.Result(0, sendMap, c)
}
/*
*
@ 作者: 秦东
@ 时间: 2025-02-26 08:51:04
@ 功能: 天干地址选股法
@ 参数
#
@ 返回值
#
@ 方法原型
#
*/
func (a *ApiMethod) appNewPlatform(c *gin.Context) {
var request GainHeavenlyEarthly
err := c.ShouldBindJSON(&request)
if err != nil {
formatoutput.Result(10, err, c)
return
}
if request.HeavenlyStems == "" || request.EarthlyBranches == "" {
formatoutput.Result(102, request, c)
return
}
// HeavenlyStemsStarIndex := 0 //天干起始计算位置
// for i, v := range formatoutput.HeavenlyStems {
// if v == request.HeavenlyStems {
// HeavenlyStemsStarIndex = i
// return
// }
// }
// EarthlyBranchesStarIndex := 0 //地支起始计算位置
// for i, v := range formatoutput.EarthlyBranches {
// if v == request.EarthlyBranches {
// EarthlyBranchesStarIndex = i
// return
// }
// }
// theSameDay := time.Now().Unix()
}

6
go.mod

@ -4,11 +4,11 @@ go 1.21.5
require (
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b
github.com/fsnotify/fsnotify v1.7.0
github.com/fsnotify/fsnotify v1.8.0
github.com/gin-gonic/gin v1.10.0
github.com/golang-jwt/jwt v3.2.2+incompatible
github.com/gorilla/websocket v1.5.3
github.com/redis/go-redis/v9 v9.6.1
github.com/redis/go-redis/v9 v9.7.1
github.com/spf13/viper v1.19.0
gorm.io/driver/mysql v1.5.7
gorm.io/gorm v1.25.12
@ -56,7 +56,7 @@ require (
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect

12
go.sum

@ -25,8 +25,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
@ -87,8 +87,8 @@ github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
github.com/redis/go-redis/v9 v9.7.1 h1:4LhKRCIduqXqtvCUlaq9c8bdHOkICjDMrr1+Zb3osAc=
github.com/redis/go-redis/v9 v9.7.1/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
@ -156,8 +156,8 @@ golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=

1287
publicmethod/publicControll.go

File diff suppressed because it is too large

61
publicmethod/type.go

@ -0,0 +1,61 @@
package publicmethod
// 全局函数处理
// 时间相关处理类
var (
timeLayoutMap = map[string]string{
"y": "2006",
"m": "2006-01",
"d": "2006-01-02",
"h": "2006-01-02 15",
"i": "2006-01-02 15:04",
"s": "2006-01-02 15:04:05",
}
weekDay = map[string]int{
"Monday": 1,
"Tuesday": 2,
"Wednesday": 3,
"Thursday": 4,
"Friday": 5,
"Saturday": 6,
"Sunday": 7,
}
)
// 泛型基础变量类型
type GenericityVariable interface {
int | int8 | int16 | int32 | int64 | float32 | float64 | string
}
// 数值泛型基础变量类型
type GenericityVariableNumber interface {
int | int8 | int16 | int32 | int64 | float32 | float64
}
/*
*加密算法
*/
type Md5Encryption struct {
Code string `json:"code"`
AppKey string `json:"appKey"`
}
//时间转换
type DateTimeTotimes struct {
Years string `json:"years"`
Quarter string `json:"quarter"`
Months string `json:"months"`
Week string `json:"week"`
Days string `json:"days"`
Hours string `json:"hours"`
Minutes string `json:"minutes"`
Second string `json:"second"`
AllTime int64 `json:"alltime"`
AllTimeString string `json:"alltimeStr"`
}
type BirthdayAge struct {
Birthday string
Age int
}

10
utils/formatoutput/hseb.go

@ -0,0 +1,10 @@
package formatoutput
/**
@ 作者: 秦东
@ 时间: 2025-02-26 08:41:30
@ 功能: 天干地址
*/
var HeavenlyStems = []string{"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}
var EarthlyBranches = []string{"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}
var BackgroundColor = []string{"红", "绿"}
Loading…
Cancel
Save