Documentation
¶
Index ¶
- Constants
- Variables
- func ErrProductAppFoundFail(msg ...string) *ecode.ErrorV2
- func ErrProductModuleNotFound(msg ...string) *ecode.ErrorV2
- func ErrProductNotFound(msg ...string) *ecode.ErrorV2
- func ErrRegisterDeviceBatchFaile(msg ...string) *ecode.ErrorV2
- func ErrRegisterDeviceLimit(msg ...string) *ecode.ErrorV2
- func ErrRegisterDeviceSingleFaile(msg ...string) *ecode.ErrorV2
- func ErrSaasDeviceBindFail(msg ...string) *ecode.ErrorV2
- func GetHostUrl(isPrivate bool, envStrs ...string) string
- func IsErrProductAppFoundFail(err error) bool
- func IsErrProductAppFoundFailDEEP(err error) bool
- func IsErrProductModuleNotFound(err error) bool
- func IsErrProductModuleNotFoundDEEP(err error) bool
- func IsErrProductNotFound(err error) bool
- func IsErrProductNotFoundDEEP(err error) bool
- func IsErrRegisterDeviceBatchFaile(err error) bool
- func IsErrRegisterDeviceBatchFaileDEEP(err error) bool
- func IsErrRegisterDeviceLimit(err error) bool
- func IsErrRegisterDeviceLimitDEEP(err error) bool
- func IsErrRegisterDeviceSingleFaile(err error) bool
- func IsErrRegisterDeviceSingleFaileDEEP(err error) bool
- func IsErrSaasDeviceBindFail(err error) bool
- func IsErrSaasDeviceBindFailDEEP(err error) bool
- func IsUnknowError(err error) bool
- func IsUnknowErrorDEEP(err error) bool
- func MustCode200(cli *resty.Client, resp *resty.Response) error
- func RegisterAuthServiceHTTPServer(s *gin.Engine, srv AuthServiceHTTPServer)
- func RegisterBlogServiceHTTPServer(s *gin.Engine, srv BlogServiceHTTPServer)
- func SetAutoValidate(disable bool, validatErr error, releaseShowDetail bool)
- func SetCustomReturn(ctx *api.Context)
- func SetValidateCode(code int)
- func UnknowError(msg ...string) *ecode.ErrorV2
- type Article
- type AuthServiceHTTPClient
- type AuthServiceHTTPClientImpl
- func (c *AuthServiceHTTPClientImpl) GetOneArticlePure(ctx context.Context, req *GetOneArticlePureReq, opts ...calloption.CallOption) (*GetOneArticlePureResp, error)
- func (c *AuthServiceHTTPClientImpl) PostOneArticlePure(ctx context.Context, req *GetOneArticlePureReq, opts ...calloption.CallOption) (*GetOneArticlePureResp, error)
- func (c *AuthServiceHTTPClientImpl) Pull(ctx context.Context, req *PushReq, opts ...calloption.CallOption) (*TResponse[RealResp], error)
- func (c *AuthServiceHTTPClientImpl) Push(ctx context.Context, req *PushReq, opts ...calloption.CallOption) (*TResponse[PushReply], error)
- type AuthServiceHTTPServer
- type BlogServiceHTTPClient
- type BlogServiceHTTPClientImpl
- func (c *BlogServiceHTTPClientImpl) CreateArticle(ctx context.Context, req *Article, opts ...calloption.CallOption) (*TResponse[Article], error)
- func (c *BlogServiceHTTPClientImpl) GetArticles(ctx context.Context, req *GetArticlesReq, opts ...calloption.CallOption) (*TResponse[GetArticlesReply], error)
- func (c *BlogServiceHTTPClientImpl) GetOneArticle(ctx context.Context, req *GetArticlesReq, opts ...calloption.CallOption) (*TResponse[GetArticlesReply], error)
- type BlogServiceHTTPServer
- type GetArticlesReply
- type GetArticlesReq
- type GetArticlesReq_Location
- type GetOneArticlePureReq
- type GetOneArticlePureResp
- type PushReply
- type PushReq
- type RealResp
- type TResponse
- type UploadOssdk3RdReq
Constants ¶
const ( UNKNOW_ERROR = 0 ERR_PRODUCT_NOT_FOUND = 16050030 ERR_PRODUCT_MODULE_NOT_FOUND = 16050033 ERR_SAAS_DEVICE_BIND_FAIL = 16050031 ERR_PRODUCT_APP_FOUND_FAIL = 16050032 ERR_REGISTER_DEVICE_LIMIT = 16050016 ERR_REGISTER_DEVICE_SINGLE_FAILE = 16050017 ERR_REGISTER_DEVICE_BATCH_FAILE = 16050018 )
Variables ¶
var ( PrivateHosts = map[string]string{ "onl": "http://vpc-eco-iotlink-gateway.sunmi.com", "uat": "http://vpc-eco-iotlink-gateway.uat.sunmi.com", "test": "http://vpc-eco-iotlink-gateway.test.sunmi.com", "dev": "http://vpc-eco-iotlink-gateway.dev.sunmi.com", "local": "http://localhost:20080", } PublicHosts = map[string]string{ "onl": "http://api.sunmi.com", "uat": "http://api.uat.sunmi.com", "test": "http://api.test.sunmi.com", "dev": "http://api.dev.sunmi.com", "local": "http://localhost:20080", } )
var DefaultClient = NewClient()
var ErrIncorrectCode = errors.New("incorrect http status")
var ( ErrMap = map[int]string{ UNKNOW_ERROR: "unknow error", ERR_PRODUCT_NOT_FOUND: "product not found(English comment)", ERR_PRODUCT_MODULE_NOT_FOUND: "product module not found", ERR_SAAS_DEVICE_BIND_FAIL: "saas device bind fail", ERR_PRODUCT_APP_FOUND_FAIL: "product app found fail", ERR_REGISTER_DEVICE_LIMIT: "register device limit", ERR_REGISTER_DEVICE_SINGLE_FAILE: "register device single faile", ERR_REGISTER_DEVICE_BATCH_FAILE: "Register device batch fail !", } )
var PubClient = NewPublicClient()
Functions ¶
func ErrProductAppFoundFail ¶
code: 16050032 msg: "product app found fail"
func ErrProductModuleNotFound ¶
code: 16050033 msg: "product module not found"
func ErrProductNotFound ¶
code: 16050030 msg: "product not found(English comment)"
func ErrRegisterDeviceBatchFaile ¶
code: 16050018 msg: "Register device batch fail !"
func ErrRegisterDeviceLimit ¶
code: 16050016 msg: "register device limit"
func ErrRegisterDeviceSingleFaile ¶
code: 16050017 msg: "register device single faile"
func ErrSaasDeviceBindFail ¶
code: 16050031 msg: "saas device bind fail"
func GetHostUrl ¶
func IsErrProductNotFound ¶
func IsErrSaasDeviceBindFail ¶
func IsUnknowError ¶
func IsUnknowErrorDEEP ¶
func MustCode200 ¶
func MustCode200(cli *resty.Client, resp *resty.Response) error
func RegisterAuthServiceHTTPServer ¶
func RegisterAuthServiceHTTPServer(s *gin.Engine, srv AuthServiceHTTPServer)
func RegisterBlogServiceHTTPServer ¶
func RegisterBlogServiceHTTPServer(s *gin.Engine, srv BlogServiceHTTPServer)
func SetAutoValidate ¶
set you error or use api.ErrorBind(diable:是否启用自动validate, 如果启用则返回 defaultValidateErr or 原始错误)
func SetCustomReturn ¶
func SetValidateCode ¶ added in v1.2.0
func SetValidateCode(code int)
Types ¶
type Article ¶
type Article struct { // 标题名称上注释 Title string `json:"title,omitempty"` // 标题名称右注释 Content string `json:"content" binding:"required"` AuthorId int32 `json:"author_id,omitempty"` }
func (*Article) MarshalString ¶
func (*Article) UnmarshalString ¶
type AuthServiceHTTPClient ¶
type AuthServiceHTTPClient interface { // Push发送1 ||商米助手 // 发送1<br> // 发送2<br> // > 发送3 // 发送4 // `import from json` // 这是一个链接 [Markdown语法](https://markdown.com.cn "最好的markdown教程")。 // // | 错误码 | 错误消息 | 错误描述 | // | --- | ---- | ---- | // | 10207 | ath not match | 服务端token不一致 | // | 10224 | device not found | 设备不存在 | // | 10114 | task not found | 自动下载密钥任务不存在 | // | 10208 | binding key not found | 绑定密钥不存在 | // | 10212 | no available license | 没有可用license | // | 10213 | license download times not enough | license 下载次数不足 | // | 500 | | 程序异常 | Push(context.Context, *PushReq, ...calloption.CallOption) (*TResponse[PushReply], error) Pull(context.Context, *PushReq, ...calloption.CallOption) (*TResponse[RealResp], error) // 测试特殊的返回 GetOneArticlePure(context.Context, *GetOneArticlePureReq, ...calloption.CallOption) (*GetOneArticlePureResp, error) PostOneArticlePure(context.Context, *GetOneArticlePureReq, ...calloption.CallOption) (*GetOneArticlePureResp, error) }
AuthServiceHTTPClient is the client API for AuthService service.
func NewAuthServiceHTTPClient ¶
func NewAuthServiceHTTPClient(hh *http_request.HttpClient) AuthServiceHTTPClient
type AuthServiceHTTPClientImpl ¶
type AuthServiceHTTPClientImpl struct {
// contains filtered or unexported fields
}
func (*AuthServiceHTTPClientImpl) GetOneArticlePure ¶ added in v1.0.9
func (c *AuthServiceHTTPClientImpl) GetOneArticlePure(ctx context.Context, req *GetOneArticlePureReq, opts ...calloption.CallOption) (*GetOneArticlePureResp, error)
func (*AuthServiceHTTPClientImpl) PostOneArticlePure ¶ added in v1.1.9
func (c *AuthServiceHTTPClientImpl) PostOneArticlePure(ctx context.Context, req *GetOneArticlePureReq, opts ...calloption.CallOption) (*GetOneArticlePureResp, error)
func (*AuthServiceHTTPClientImpl) Pull ¶ added in v1.0.5
func (c *AuthServiceHTTPClientImpl) Pull(ctx context.Context, req *PushReq, opts ...calloption.CallOption) (*TResponse[RealResp], error)
func (*AuthServiceHTTPClientImpl) Push ¶
func (c *AuthServiceHTTPClientImpl) Push(ctx context.Context, req *PushReq, opts ...calloption.CallOption) (*TResponse[PushReply], error)
type AuthServiceHTTPServer ¶
type AuthServiceHTTPServer interface { // Push发送1 ||商米助手 // 发送1<br> // 发送2<br> // > 发送3 // 发送4 // `import from json` // 这是一个链接 [Markdown语法](https://markdown.com.cn "最好的markdown教程")。 // // | 错误码 | 错误消息 | 错误描述 | // | --- | ---- | ---- | // | 10207 | ath not match | 服务端token不一致 | // | 10224 | device not found | 设备不存在 | // | 10114 | task not found | 自动下载密钥任务不存在 | // | 10208 | binding key not found | 绑定密钥不存在 | // | 10212 | no available license | 没有可用license | // | 10213 | license download times not enough | license 下载次数不足 | // | 500 | | 程序异常 | Push(*api.Context, *PushReq) (*PushReply, error) Pull(*api.Context, *PushReq) (*RealResp, error) // 测试特殊的返回 GetOneArticlePure(*api.Context, *GetOneArticlePureReq) *GetOneArticlePureResp PostOneArticlePure(*api.Context, *GetOneArticlePureReq) *GetOneArticlePureResp }
AuthServiceHTTPServer is the server API for AuthService service.
type BlogServiceHTTPClient ¶
type BlogServiceHTTPClient interface { // 获取文章列表 // 可以读取不多于999个文章列表 GetArticles(context.Context, *GetArticlesReq, ...calloption.CallOption) (*TResponse[GetArticlesReply], error) // 新建文章 CreateArticle(context.Context, *Article, ...calloption.CallOption) (*TResponse[Article], error) // 获取文章详情(TODO get方法还未支持) GetOneArticle(context.Context, *GetArticlesReq, ...calloption.CallOption) (*TResponse[GetArticlesReply], error) }
BlogServiceHTTPClient is the client API for BlogService service.
func NewBlogServiceHTTPClient ¶
func NewBlogServiceHTTPClient(hh *http_request.HttpClient) BlogServiceHTTPClient
func NewClient ¶
func NewClient(strs ...string) BlogServiceHTTPClient
NewClient 使用者也可以根据需要,自己生成newClient方法,然后调用NewBlogHTTPClient方法
func NewPublicClient ¶
func NewPublicClient(strs ...string) BlogServiceHTTPClient
type BlogServiceHTTPClientImpl ¶
type BlogServiceHTTPClientImpl struct {
// contains filtered or unexported fields
}
func (*BlogServiceHTTPClientImpl) CreateArticle ¶
func (c *BlogServiceHTTPClientImpl) CreateArticle(ctx context.Context, req *Article, opts ...calloption.CallOption) (*TResponse[Article], error)
func (*BlogServiceHTTPClientImpl) GetArticles ¶
func (c *BlogServiceHTTPClientImpl) GetArticles(ctx context.Context, req *GetArticlesReq, opts ...calloption.CallOption) (*TResponse[GetArticlesReply], error)
func (*BlogServiceHTTPClientImpl) GetOneArticle ¶
func (c *BlogServiceHTTPClientImpl) GetOneArticle(ctx context.Context, req *GetArticlesReq, opts ...calloption.CallOption) (*TResponse[GetArticlesReply], error)
type BlogServiceHTTPServer ¶
type BlogServiceHTTPServer interface { // 获取文章列表 // 可以读取不多于999个文章列表 GetArticles(*api.Context, *GetArticlesReq) (*GetArticlesReply, error) // 新建文章 CreateArticle(*api.Context, *Article) (*Article, error) // 获取文章详情(TODO get方法还未支持) GetOneArticle(*api.Context, *GetArticlesReq) (*GetArticlesReply, error) }
BlogServiceHTTPServer is the server API for BlogService service.
type GetArticlesReply ¶
type GetArticlesReply struct { Total int64 `json:"total" binding:"required"` Articles []*Article `json:"articles"` }
重要注释1
func (*GetArticlesReply) Marshal ¶
func (m *GetArticlesReply) Marshal() ([]byte, error)
func (*GetArticlesReply) MarshalString ¶
func (m *GetArticlesReply) MarshalString() (string, error)
func (*GetArticlesReply) Unmarshal ¶
func (m *GetArticlesReply) Unmarshal(buf []byte) error
func (*GetArticlesReply) UnmarshalString ¶
func (m *GetArticlesReply) UnmarshalString(str string) error
type GetArticlesReq ¶
type GetArticlesReq struct { // 文章标题 Title string `json:"title" binding:"required"` // 标题名称右注释 Page int32 `json:"page,omitempty" binding:"lt=999"` // 字段名使用小写下划线的风格,例如 string status_code = 1 PageSize int32 `json:"page_size,omitempty" binding:"lte=101"` // 作者id AuthorId int32 `json:"author_id,omitempty"` Email string `json:"email,omitempty" binding:"email"` Name string `json:"name,omitempty"` Home *GetArticlesReq_Location `json:"home" binding:"required"` TestStr string `json:"test_str" binding:"required"` }
消息名使用首字母大写驼峰风格(CamelCase),例如message StudentReq { ... }
func (*GetArticlesReq) Marshal ¶
func (m *GetArticlesReq) Marshal() ([]byte, error)
func (*GetArticlesReq) MarshalString ¶
func (m *GetArticlesReq) MarshalString() (string, error)
func (*GetArticlesReq) Unmarshal ¶
func (m *GetArticlesReq) Unmarshal(buf []byte) error
func (*GetArticlesReq) UnmarshalString ¶
func (m *GetArticlesReq) UnmarshalString(str string) error
type GetArticlesReq_Location ¶
type GetOneArticlePureReq ¶ added in v1.0.9
type GetOneArticlePureReq struct { }
func (*GetOneArticlePureReq) Marshal ¶ added in v1.0.9
func (m *GetOneArticlePureReq) Marshal() ([]byte, error)
func (*GetOneArticlePureReq) MarshalString ¶ added in v1.0.9
func (m *GetOneArticlePureReq) MarshalString() (string, error)
func (*GetOneArticlePureReq) Unmarshal ¶ added in v1.0.9
func (m *GetOneArticlePureReq) Unmarshal(buf []byte) error
func (*GetOneArticlePureReq) UnmarshalString ¶ added in v1.0.9
func (m *GetOneArticlePureReq) UnmarshalString(str string) error
type GetOneArticlePureResp ¶ added in v1.0.9
type GetOneArticlePureResp struct { Code int64 `json:"Code,omitempty"` Message string `json:"Message,omitempty"` Data []*UploadOssdk3RdReq `json:"Data,omitempty"` }
func (*GetOneArticlePureResp) Marshal ¶ added in v1.0.9
func (m *GetOneArticlePureResp) Marshal() ([]byte, error)
func (*GetOneArticlePureResp) MarshalString ¶ added in v1.0.9
func (m *GetOneArticlePureResp) MarshalString() (string, error)
func (*GetOneArticlePureResp) Unmarshal ¶ added in v1.0.9
func (m *GetOneArticlePureResp) Unmarshal(buf []byte) error
func (*GetOneArticlePureResp) UnmarshalString ¶ added in v1.0.9
func (m *GetOneArticlePureResp) UnmarshalString(str string) error
type PushReply ¶
type PushReply struct {
SdkUrlUuid string `json:"sdk_url_uuid,omitempty"` // 后面的备注
}
上面的备注1 上面的备注2 上面的备注3
func (*PushReply) MarshalString ¶
func (*PushReply) UnmarshalString ¶
type PushReq ¶
type PushReq struct { // name上面的备注 Name string `json:"name" binding:"required"` PageCount int64 `json:"page_count" binding:"required"` DataCount int32 `json:"data_count,omitempty"` }
这个是PushReq的标题2
func (*PushReq) MarshalString ¶
func (*PushReq) UnmarshalString ¶
type RealResp ¶
type RealResp struct { Data interface{} `json:"data,omitempty"` Code int32 `json:"code,omitempty"` Message string `json:"message,omitempty"` }
func (*RealResp) MarshalString ¶
func (*RealResp) UnmarshalString ¶
type UploadOssdk3RdReq ¶ added in v1.0.9
type UploadOssdk3RdReq struct { Operator string `json:"operator,omitempty"` SdkUrlUuid string `json:"sdk_url_uuid,omitempty"` SdkOs string `json:"sdk_os,omitempty"` FileName string `json:"file_name,omitempty"` }
func (*UploadOssdk3RdReq) Marshal ¶ added in v1.0.9
func (m *UploadOssdk3RdReq) Marshal() ([]byte, error)
func (*UploadOssdk3RdReq) MarshalString ¶ added in v1.0.9
func (m *UploadOssdk3RdReq) MarshalString() (string, error)
func (*UploadOssdk3RdReq) Unmarshal ¶ added in v1.0.9
func (m *UploadOssdk3RdReq) Unmarshal(buf []byte) error
func (*UploadOssdk3RdReq) UnmarshalString ¶ added in v1.0.9
func (m *UploadOssdk3RdReq) UnmarshalString(str string) error