init project
This commit is contained in:
parent
c04c0e7e54
commit
acd5976a9e
|
@ -0,0 +1,6 @@
|
|||
.idea/
|
||||
go.sum
|
||||
account/
|
||||
gen_result/
|
||||
etc/service.yaml
|
||||
client/
|
|
@ -0,0 +1,140 @@
|
|||
run:
|
||||
timeout: 3m
|
||||
# Exit code when at least one issue was found.
|
||||
# Default: 1
|
||||
issues-exit-code: 2
|
||||
# Include test files or not.
|
||||
# Default: true
|
||||
tests: false
|
||||
|
||||
# Reference URL: https://golangci-lint.run/usage/linters/
|
||||
linters:
|
||||
# Disable everything by default so upgrades to not include new - default
|
||||
# enabled- linters.
|
||||
disable-all: true
|
||||
# Specifically enable linters we want to use.
|
||||
enable:
|
||||
# - depguard
|
||||
- errcheck
|
||||
# - godot
|
||||
- gofmt
|
||||
- goimports
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- revive
|
||||
# - staticcheck
|
||||
- typecheck
|
||||
- unused
|
||||
# - wsl
|
||||
- asasalint
|
||||
- asciicheck
|
||||
- bidichk
|
||||
- bodyclose
|
||||
# - containedctx
|
||||
- contextcheck
|
||||
# - cyclop
|
||||
# - varnamelen
|
||||
# - gci
|
||||
- wastedassign
|
||||
- whitespace
|
||||
# - wrapcheck
|
||||
- thelper
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unparam
|
||||
- usestdlibvars
|
||||
- tenv
|
||||
- testableexamples
|
||||
- stylecheck
|
||||
- sqlclosecheck
|
||||
- nosprintfhostport
|
||||
- paralleltest
|
||||
- prealloc
|
||||
- predeclared
|
||||
- promlinter
|
||||
- reassign
|
||||
- rowserrcheck
|
||||
- nakedret
|
||||
- nestif
|
||||
- nilerr
|
||||
- nilnil
|
||||
- nlreturn
|
||||
- noctx
|
||||
- nolintlint
|
||||
- nonamedreturns
|
||||
- decorder
|
||||
- dogsled
|
||||
# - dupl
|
||||
- dupword
|
||||
- durationcheck
|
||||
- errchkjson
|
||||
- errname
|
||||
- errorlint
|
||||
# - execinquery
|
||||
- exhaustive
|
||||
- exportloopref
|
||||
- forbidigo
|
||||
- forcetypeassert
|
||||
# - gochecknoglobals
|
||||
- gochecknoinits
|
||||
- gocognit
|
||||
- goconst
|
||||
- gocritic
|
||||
- gocyclo
|
||||
# - godox
|
||||
# - goerr113
|
||||
# - gofumpt
|
||||
- goheader
|
||||
- gomoddirectives
|
||||
# - gomodguard always failed
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- grouper
|
||||
- importas
|
||||
- interfacebloat
|
||||
# - ireturn
|
||||
- lll
|
||||
- loggercheck
|
||||
- maintidx
|
||||
- makezero
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- funlen
|
||||
- goconst
|
||||
- interfacer
|
||||
- dupl
|
||||
- lll
|
||||
- goerr113
|
||||
- errcheck
|
||||
- gocritic
|
||||
- cyclop
|
||||
- wrapcheck
|
||||
- gocognit
|
||||
- contextcheck
|
||||
|
||||
linters-settings:
|
||||
gci:
|
||||
sections:
|
||||
- standard # Standard section: captures all standard packages.
|
||||
- default # Default section: contains all imports that could not be matched to another section type.
|
||||
gocognit:
|
||||
# Minimal code complexity to report.
|
||||
# Default: 30 (but we recommend 10-20)
|
||||
min-complexity: 40
|
||||
nestif:
|
||||
# Minimal complexity of if statements to report.
|
||||
# Default: 5
|
||||
min-complexity: 10
|
||||
lll:
|
||||
# Max line length, lines longer will be reported.
|
||||
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
|
||||
# Default: 120.
|
||||
line-length: 200
|
||||
# Tab width in spaces.
|
||||
# Default: 1
|
||||
tab-width: 1
|
|
@ -0,0 +1 @@
|
|||
DROP TABLE IF EXISTS `account`;
|
|
@ -0,0 +1,10 @@
|
|||
CREATE TABLE `account` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`account` VARCHAR(50) NOT NULL,
|
||||
`token` VARCHAR(255) NOT NULL,
|
||||
`platform` INT NOT NULL COMMENT '平台類型 1. ark 2. google',
|
||||
`create_time` BIGINT NOT NULL DEFAULT 0,
|
||||
`update_time` BIGINT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `uk_account` (`account` ASC)
|
||||
)ENGINE=InnoDB COMMENT='帳號';
|
|
@ -0,0 +1 @@
|
|||
DROP TABLE IF EXISTS `account_to_uid`;
|
|
@ -0,0 +1,8 @@
|
|||
CREATE TABLE `account_to_uid` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`account` VARCHAR(50) NOT NULL,
|
||||
`uid` VARCHAR(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `uk_account` (`account` ASC),
|
||||
INDEX `idx_uid` (`uid` ASC)
|
||||
)ENGINE=InnoDB COMMENT='帳號轉換表';
|
|
@ -0,0 +1 @@
|
|||
DROP TABLE IF EXISTS `user_table`;
|
|
@ -0,0 +1,17 @@
|
|||
CREATE TABLE `user_table` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT,
|
||||
`verify_type` tinyint DEFAULT 0 NOT NULL COMMENT '驗證類型 0. 異常 1.信箱 2.手機 3. GA 4.不驗證',
|
||||
`alarm_type` tinyint DEFAULT 0 NOT NULL COMMENT '告警狀態 0. 異常 1. 正常(未告警) 2.系統告警中',
|
||||
`status` tinyint DEFAULT 0 NOT NULL COMMENT '會員狀態 0. 異常 1. 尚未驗證 2. 啟用 3. 停權中 4. 信箱以驗證 5. 手機以驗證 6. GA 以驗證',
|
||||
`uid` VARCHAR(255) NOT NULL,
|
||||
`language` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`currency` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`nick_name` VARCHAR(255) DEFAULT '',
|
||||
`gender` tinyint DEFAULT 0 NOT NULL COMMENT '0. 不願透露, 1 男 2 女',
|
||||
`birthday` INT NOT NULL DEFAULT 0,
|
||||
`create_time` BIGINT NOT NULL DEFAULT 0,
|
||||
`update_time` BIGINT NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_create_time` (`create_time` ASC),
|
||||
UNIQUE INDEX `uk_uid` (`uid` ASC)
|
||||
)ENGINE=InnoDB COMMENT='使用者資訊';
|
|
@ -0,0 +1 @@
|
|||
DROP TABLE IF EXISTS `machine_node`;
|
|
@ -0,0 +1,7 @@
|
|||
CREATE TABLE `machine_node` (
|
||||
`id` bigint AUTO_INCREMENT NOT NULL COMMENT '流水號',
|
||||
`create_time` bigint DEFAULT 0 NOT NULL COMMENT '創建時間',
|
||||
`update_time` bigint DEFAULT 0 NOT NULL COMMENT '更新時間',
|
||||
`host_name` varchar(200) DEFAULT '' NOT NULL COMMENT 'host name',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB COMMENT='machineID Assigner for Generator';
|
|
@ -0,0 +1 @@
|
|||
DROP DATABASE IF EXISTS `ark_member`;
|
|
@ -0,0 +1 @@
|
|||
CREATE DATABASE IF NOT EXISTS `ark_member`;
|
|
@ -0,0 +1,39 @@
|
|||
# migrate
|
||||
數據庫遷移工具
|
||||
|
||||
[golang-migrate](https://github.com/golang-migrate/migrate)
|
||||
|
||||
## 安裝 make
|
||||
```shell
|
||||
brew install Makefile
|
||||
```
|
||||
|
||||
## 安裝 golang-migrate
|
||||
```shell
|
||||
brew install golang-migrate
|
||||
```
|
||||
|
||||
## 執行刪除 mysql schema
|
||||
|
||||
```shell
|
||||
migrate -source file://database/migrations/mysql -database 'mysql://account:password@tcp(127.0.0.1:3306)/esc_c2c' down
|
||||
```
|
||||
|
||||
## 執行安裝 mysql schema
|
||||
|
||||
```shell
|
||||
migrate -source file://database/migrations/mysql -database 'mysql://account:password@tcp(127.0.0.1:3306)/esc_c2c' up
|
||||
```
|
||||
|
||||
## 執行刪除 mongo schema
|
||||
|
||||
```shell
|
||||
migrate -source file://database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/esc_c2c' down
|
||||
```
|
||||
|
||||
## 執行安裝 mongo schema
|
||||
|
||||
```shell
|
||||
migrate -source file://database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/esc_c2c' up
|
||||
```
|
||||
|
|
@ -0,0 +1,214 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package member;
|
||||
option go_package="./member";
|
||||
|
||||
// ================ enum ================
|
||||
enum VerifyType {
|
||||
VERIFY_NONE = 0; // 初始(異常)
|
||||
VERIFY_EMAIL = 1;
|
||||
VERIFY_PHONE = 2;
|
||||
VERIFY_GOOGLE = 3;
|
||||
}
|
||||
|
||||
enum AlarmType {
|
||||
ALARM_NONE = 0; // 初始(異常)
|
||||
ALARM_NOT = 1; // 未告警
|
||||
ALARM_SYSTEM = 2; // 系統告警中
|
||||
}
|
||||
|
||||
enum MemberStatus {
|
||||
STATUS_NONE = 0; // 初始(異常)
|
||||
STATUS_VERIFY = 1; // 尚未驗證
|
||||
STATUS_COMPLETE = 2; // 帳號啟用中
|
||||
STATUS_DISABLE = 3; // 帳號停權中
|
||||
STATUS_EMAIL = 4; // 信箱以驗證
|
||||
STATUS_PHONE = 5; // 手機以驗證
|
||||
STATUS_GA = 6; // GA 已綁定
|
||||
}
|
||||
|
||||
enum Gender {
|
||||
GENDER_NONE = 0; // 初始(未提供)
|
||||
GENDER_MALE = 1; // 男性
|
||||
GENDER_FEMALE = 2; // 女性
|
||||
}
|
||||
// ================ enum ================
|
||||
|
||||
|
||||
// ================ common ================
|
||||
message Pager {
|
||||
int64 total =1;
|
||||
int64 size=2;
|
||||
int64 index=3;
|
||||
}
|
||||
|
||||
message Response {
|
||||
BaseResp status=1;
|
||||
}
|
||||
|
||||
message BaseResp {
|
||||
string code = 1;
|
||||
string message = 2;
|
||||
string error = 3;
|
||||
}
|
||||
|
||||
// ================ common ================
|
||||
|
||||
|
||||
// ================ account ================
|
||||
message CreateLoginUserReq {
|
||||
string login_id = 1;
|
||||
int64 platform = 2;
|
||||
string token = 3;
|
||||
}
|
||||
|
||||
message BindingUserReq {
|
||||
string uid = 1;
|
||||
string login_id = 2;
|
||||
}
|
||||
|
||||
message CreateUserInfoReq {
|
||||
string uid = 1;
|
||||
VerifyType verify_type = 2;
|
||||
AlarmType alarm_type = 3;
|
||||
MemberStatus status = 4;
|
||||
string language = 5;
|
||||
string currency = 6;
|
||||
optional string nick_name = 7;
|
||||
optional uint32 gender = 8;
|
||||
optional int64 birthday = 9;
|
||||
}
|
||||
|
||||
message GetAccountInfoResp {
|
||||
BaseResp status = 1;
|
||||
CreateLoginUserReq data = 2;
|
||||
}
|
||||
|
||||
// UpdateUserInfoReq 不處理邏輯給不給改,這裡只關新增修改刪除
|
||||
message UpdateUserInfoReq {
|
||||
string uid = 1;
|
||||
optional string language = 2;
|
||||
optional string currency = 3;
|
||||
optional string nick_name = 4;
|
||||
optional uint32 gender = 5;
|
||||
optional int64 birthday = 6;
|
||||
optional VerifyType verify_type = 7;
|
||||
optional AlarmType alarm_type = 8;
|
||||
optional MemberStatus status = 9;
|
||||
}
|
||||
|
||||
message GetUIDByAccountReq {
|
||||
string account = 1;
|
||||
}
|
||||
|
||||
message UID {
|
||||
string uid = 1;
|
||||
}
|
||||
|
||||
message GetUidByAccountResp {
|
||||
BaseResp status = 1;
|
||||
UID data = 2;
|
||||
}
|
||||
|
||||
message UpdateTokenReq {
|
||||
string account = 1;
|
||||
string token = 2;
|
||||
}
|
||||
|
||||
message GenerateRefreshCodeReq {
|
||||
string account = 1;
|
||||
int32 code_type =2;
|
||||
}
|
||||
|
||||
message VerifyCode {
|
||||
string verify_code = 1;
|
||||
}
|
||||
|
||||
message GenerateRefreshCodeResp {
|
||||
BaseResp status = 1;
|
||||
VerifyCode data = 2;
|
||||
}
|
||||
|
||||
message VerifyRefreshCodeReq {
|
||||
string account = 1;
|
||||
int32 code_type =2;
|
||||
string verify_code = 3;
|
||||
}
|
||||
|
||||
message UpdateStatusReq {
|
||||
string uid = 1;
|
||||
MemberStatus status = 2;
|
||||
}
|
||||
|
||||
message GetUserInfoReq {
|
||||
string uid = 1;
|
||||
optional string nick_name =2;
|
||||
}
|
||||
|
||||
message UserInfo {
|
||||
string uid = 1;
|
||||
VerifyType verify_type = 2;
|
||||
AlarmType alarm_type = 3;
|
||||
MemberStatus status = 4;
|
||||
string language = 5;
|
||||
string currency = 6;
|
||||
optional string nick_name = 7;
|
||||
optional uint32 gender = 8;
|
||||
optional int64 birthday = 9;
|
||||
}
|
||||
|
||||
message GetUserInfoResp {
|
||||
BaseResp status = 1;
|
||||
UserInfo data = 2;
|
||||
}
|
||||
|
||||
message ListUserInfoReq {
|
||||
optional VerifyType verify_type = 1;
|
||||
optional AlarmType alarm_type = 2;
|
||||
optional MemberStatus status = 3;
|
||||
optional int64 create_start_time = 4;
|
||||
optional int64 create_end_time = 5;
|
||||
int64 page_size =6;
|
||||
int64 page_index=7;
|
||||
}
|
||||
|
||||
message ListUserInfoResp {
|
||||
BaseResp status = 1;
|
||||
repeated UserInfo data = 2;
|
||||
Pager page =3;
|
||||
}
|
||||
|
||||
|
||||
service Account {
|
||||
// CreateUserAccount 建立帳號與密碼 -> 可登入,但可不可以做其他事情看業務流程,也可以只註冊就好
|
||||
rpc CreateUserAccount(CreateLoginUserReq) returns(Response);
|
||||
// GetUserAccountInfo 取得帳號密碼資料
|
||||
rpc GetUserAccountInfo(GetUIDByAccountReq) returns(GetAccountInfoResp);
|
||||
// UpdateUserToken 更新密碼
|
||||
rpc UpdateUserToken(UpdateTokenReq) returns(Response);
|
||||
|
||||
|
||||
// GetUidByAccount 用帳號換取 UID
|
||||
rpc GetUidByAccount(GetUIDByAccountReq) returns(GetUidByAccountResp);
|
||||
// BindAccount 綁定帳號 -> account bind to UID
|
||||
rpc BindAccount(BindingUserReq) returns(Response);
|
||||
|
||||
|
||||
// BindUserInfo 初次,綁定 User Info
|
||||
rpc BindUserInfo(CreateUserInfoReq) returns(Response);
|
||||
// UpdateUserInfo 更新 User Info
|
||||
rpc UpdateUserInfo(UpdateUserInfoReq) returns(Response);
|
||||
// UpdateStatus 修改狀態
|
||||
rpc UpdateStatus(UpdateStatusReq) returns(Response);
|
||||
// UpdateStatus 取得會員資訊
|
||||
rpc GetUserInfo(GetUserInfoReq) returns(GetUserInfoResp);
|
||||
// ListMember 取得會員列表
|
||||
rpc ListMember(ListUserInfoReq) returns(ListUserInfoResp);
|
||||
|
||||
// GenerateRefreshCode 這個帳號驗證碼(十分鐘),通用的
|
||||
rpc GenerateRefreshCode(GenerateRefreshCodeReq) returns(GenerateRefreshCodeResp);
|
||||
// VerifyRefreshCode 驗證忘記密碼 token
|
||||
rpc VerifyRefreshCode(VerifyRefreshCodeReq) returns(Response);
|
||||
|
||||
}
|
||||
// ================ account ================
|
Loading…
Reference in New Issue