正在显示
5 个修改的文件
包含
88 行增加
和
18 行删除
@@ -3,6 +3,7 @@ module gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway | @@ -3,6 +3,7 @@ module gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway | ||
3 | go 1.16 | 3 | go 1.16 |
4 | 4 | ||
5 | require ( | 5 | require ( |
6 | + github.com/astaxie/beego v1.12.3 | ||
6 | github.com/beego/beego/v2 v2.0.1 | 7 | github.com/beego/beego/v2 v2.0.1 |
7 | github.com/boombuler/barcode v1.0.1 | 8 | github.com/boombuler/barcode v1.0.1 |
8 | github.com/dgrijalva/jwt-go v3.2.0+incompatible | 9 | github.com/dgrijalva/jwt-go v3.2.0+incompatible |
1 | package domain | 1 | package domain |
2 | 2 | ||
3 | +import "time" | ||
4 | + | ||
3 | const ( | 5 | const ( |
4 | loginTokenSecret string = "bbe35ad433dd8e67" | 6 | loginTokenSecret string = "bbe35ad433dd8e67" |
5 | ) | 7 | ) |
6 | 8 | ||
7 | type LoginToken struct { | 9 | type LoginToken struct { |
8 | - Account string `json:"account"` | ||
9 | - CompanyId int64 `json:"companyId"` | ||
10 | - DepartmentId int64 `json:"departmentId"` | 10 | + // 账号 |
11 | + Account string `json:"account"` | ||
12 | + // 对应平台 | ||
13 | + Platform string `json:"platform"` | ||
14 | + // 公司id | ||
15 | + CompanyId int64 `json:"companyId"` | ||
16 | + // 组织id | ||
17 | + OrganizationId int64 `json:"organizationId"` | ||
18 | + // 登录凭证存储 | ||
19 | + AccessToken string `json:"accessToken"` | ||
20 | + // 刷新登录凭证 | ||
21 | + RefreshToken string `json:"refreshToken"` | ||
22 | + // 登录凭证过期时间,时间戳精度秒 | ||
23 | + AccessExpired int64 `json:"accessExpired"` | ||
24 | + // 刷新登录凭证过期时间,时间戳精度秒 | ||
25 | + RefreshExpired int64 `json:"refreshExpired"` | ||
26 | + // 创建时间 | ||
27 | + CreatedTime time.Time `json:"createdTime"` | ||
28 | + // 更新时间 | ||
29 | + UpdatedTime time.Time `json:"updatedTime"` | ||
11 | } | 30 | } |
12 | 31 | ||
13 | func (t *LoginToken) GenerateAccessToken() error { | 32 | func (t *LoginToken) GenerateAccessToken() error { |
1 | +package service_gateway | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | + | ||
6 | + "github.com/astaxie/beego/httplib" | ||
7 | +) | ||
8 | + | ||
9 | +type HttplibAlliedCreationBasic struct { | ||
10 | + connectTimeout time.Duration | ||
11 | + readWriteTimeout time.Duration | ||
12 | + BaseUrL string | ||
13 | +} | ||
14 | + | ||
15 | +func (gateway HttplibAlliedCreationBasic) createRequest(url string, method string) *httplib.BeegoHTTPRequest { | ||
16 | + var request *httplib.BeegoHTTPRequest | ||
17 | + switch method { | ||
18 | + case "get": | ||
19 | + request = httplib.Get(url) | ||
20 | + case "post": | ||
21 | + request = httplib.Post(url) | ||
22 | + case "put": | ||
23 | + request = httplib.Put(url) | ||
24 | + case "delete": | ||
25 | + request = httplib.Delete(url) | ||
26 | + case "head": | ||
27 | + request = httplib.Head(url) | ||
28 | + | ||
29 | + default: | ||
30 | + request = httplib.Get(url) | ||
31 | + } | ||
32 | + return request.SetTimeout(gateway.connectTimeout, gateway.readWriteTimeout) | ||
33 | +} | ||
34 | + | ||
35 | +func (gateway HttplibAlliedCreationBasic) getResponseData(result GatewayResponse) { | ||
36 | + | ||
37 | +} | ||
38 | + | ||
39 | +//GetDictionarysByCode 根据code获取字典数据 | ||
40 | +func (gateway HttplibAlliedCreationBasic) GetDictionarysByCode(param map[string]interface{}) error { | ||
41 | + url := gateway.BaseUrL + "/dictionarys/dictionary-code" | ||
42 | + req := gateway.createRequest(url, "post") | ||
43 | + req, err := req.JSONBody(param) | ||
44 | + if err != nil { | ||
45 | + return err | ||
46 | + } | ||
47 | + var result GatewayResponse | ||
48 | + err = req.ToJSON(&result) | ||
49 | + if err != nil { | ||
50 | + return err | ||
51 | + } | ||
52 | + return nil | ||
53 | +} |
1 | -package snowflake | ||
2 | - | ||
3 | -import ( | ||
4 | - "github.com/linmadan/egglib-go/utils/snowflake" | ||
5 | -) | ||
6 | - | ||
7 | -// 这里workId进行分组防止数组序列化时报错 | ||
8 | -func NextIdentify(workId int64) (int64, error) { | ||
9 | - IdWorker, err := snowflake.NewIdWorker(workId) | ||
10 | - if err != nil { | ||
11 | - return 0, err | ||
12 | - } | ||
13 | - id, err := IdWorker.NextId() | ||
14 | - return id, err | ||
15 | -} |
-
请 注册 或 登录 后发表评论