This commit is contained in:
MickMake 2022-02-19 10:56:49 +11:00
parent f229330d29
commit 6d09f20734
8 changed files with 74 additions and 80 deletions

42
.idea/workspace.xml generated
View File

@ -6,46 +6,13 @@
<component name="ChangeListManager">
<list default="true" id="7d634523-07a9-40e1-bec3-1dc036abc5e9" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/cmd_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/cmd_api.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/commands.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/commands.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmd/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/cmd/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/api.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/apiReflect/reflect.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/api_endpoints.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/interface_endpoint.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/interface_endpoint.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_endpoint.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_endpoint.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_request.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_request.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/struct_url.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/struct_url.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/utils.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/utils.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api/web.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/api/web.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api_init.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api_resource_handler.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/api_resource_type.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/cmd.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/content_types.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/pkgreflect.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/something.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AliSmsService/pkgreflect.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPowerDevicePointNames/const.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPowerDevicePointNames/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPowerDevicePointNames/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPowerDevicePointNames/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPowerDevicePointNames/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPowerStatistics/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPowerStatistics/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPsDetailWithPsType/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPsDetailWithPsType/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPsList/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/getPsList/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/login/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/login/auth.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/login/data.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/login/data.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/login/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/login/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/nullEndPoint/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/nullEndPoint/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/pkgreflect.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/AppService/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/MttvScreenService/pkgreflect.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/PowerPointService/pkgreflect.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/WebAppService/pkgreflect.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/WebIscmAppService/pkgreflect.go" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/struct.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/struct.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/sungro/sungro.go" beforeDir="false" afterPath="$PROJECT_DIR$/iSolarCloud/sungro/sungro.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/iSolarCloud/utils.go" beforeDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -231,12 +198,7 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/sungro/AppService/login/struct.go</url>
<line>64</line>
<option name="timeStamp" value="330" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/sungro/AppService/login/struct.go</url>
<line>36</line>
<line>35</line>
<option name="timeStamp" value="332" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
@ -266,7 +228,7 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">
<url>file://$PROJECT_DIR$/iSolarCloud/sungro/AppService/nullEndPoint/struct.go</url>
<line>201</line>
<line>206</line>
<option name="timeStamp" value="432" />
</line-breakpoint>
<line-breakpoint enabled="true" type="DlvLineBreakpoint">

View File

@ -29,7 +29,7 @@ func (rd *RequestData) IsValid() error {
var err error
for range Only.Once {
if rd == nil {
err = errors.New("empty device type")
err = errors.New("empty request data")
break
}
err = apiReflect.VerifyOptionsRequired(*rd)

View File

@ -151,7 +151,6 @@ func (e EndPoint) IsRequestValid() error {
}
e.Error = req.RequestData.IsValid()
if e.Error != nil {
// e.Error = errors.New(fmt.Sprintf("%s\n%s\n", e.Error, e.Help()))
break
}
}

View File

@ -7,7 +7,6 @@ import (
"encoding/json"
"errors"
"fmt"
"net/url"
)
@ -35,7 +34,7 @@ func Init(apiRoot *api.Web) EndPoint {
ApiRoot: apiRoot,
Area: api.GetArea(EndPoint{}),
Name: api.GetName(EndPoint{}),
Url: api.GetUrl(Url),
Url: api.SetUrl(Url),
Request: Request{},
Response: Response{},
Error: nil,
@ -68,6 +67,13 @@ func Assert(e api.EndPoint) EndPoint {
// ****************************************
// Methods defined by api.EndPoint interface type
func (e EndPoint) Help() string {
ret := apiReflect.HelpOptions(e.Request.RequestData)
ret += "JSON request:\n"
ret += e.GetRequestJson().String()
return ret
}
func (e EndPoint) GetArea() api.AreaName {
return e.Area
}
@ -94,7 +100,7 @@ func (e EndPoint) SetError(format string, a ...interface{}) api.EndPoint {
}
func (e EndPoint) GetError() error {
return e.Error
return e.EndPointStruct.Error
}
func (e EndPoint) IsError() bool {
@ -113,6 +119,7 @@ func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
if apiReflect.GetType(ref) == "RequestData" {
e.Request.RequestData = ref.(RequestData)
e.Error = e.IsRequestValid()
break
}
@ -131,7 +138,7 @@ func (e EndPoint) RequestRef() interface{} {
}
func (e EndPoint) GetRequestJson() api.Json {
return api.GetAsJson(e.Request)
return api.GetAsJson(e.Request.RequestData)
}
func (e EndPoint) IsRequestValid() error {
@ -144,6 +151,7 @@ func (e EndPoint) IsRequestValid() error {
}
e.Error = req.RequestData.IsValid()
if e.Error != nil {
// e.Error = errors.New(fmt.Sprintf("%s\n%s\n", e.Error, e.Help()))
break
}
}

View File

@ -7,7 +7,6 @@ import (
"encoding/json"
"errors"
"fmt"
"net/url"
)
@ -35,7 +34,7 @@ func Init(apiRoot *api.Web) EndPoint {
ApiRoot: apiRoot,
Area: api.GetArea(EndPoint{}),
Name: api.GetName(EndPoint{}),
Url: api.GetUrl(Url),
Url: api.SetUrl(Url),
Request: Request{},
Response: Response{},
Error: nil,
@ -68,6 +67,13 @@ func Assert(e api.EndPoint) EndPoint {
// ****************************************
// Methods defined by api.EndPoint interface type
func (e EndPoint) Help() string {
ret := apiReflect.HelpOptions(e.Request.RequestData)
ret += "JSON request:\n"
ret += e.GetRequestJson().String()
return ret
}
func (e EndPoint) GetArea() api.AreaName {
return e.Area
}
@ -90,10 +96,11 @@ func (e EndPoint) GetData() api.Json {
func (e EndPoint) SetError(format string, a ...interface{}) api.EndPoint {
e.EndPointStruct.Error = errors.New(fmt.Sprintf(format, a...))
return e
}
func (e EndPoint) GetError() error {
return e.Error
return e.EndPointStruct.Error
}
func (e EndPoint) IsError() bool {
@ -112,6 +119,7 @@ func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
if apiReflect.GetType(ref) == "RequestData" {
e.Request.RequestData = ref.(RequestData)
e.Error = e.IsRequestValid()
break
}
@ -130,7 +138,7 @@ func (e EndPoint) RequestRef() interface{} {
}
func (e EndPoint) GetRequestJson() api.Json {
return api.GetAsJson(e.Request)
return api.GetAsJson(e.Request.RequestData)
}
func (e EndPoint) IsRequestValid() error {
@ -143,6 +151,7 @@ func (e EndPoint) IsRequestValid() error {
}
e.Error = req.RequestData.IsValid()
if e.Error != nil {
// e.Error = errors.New(fmt.Sprintf("%s\n%s\n", e.Error, e.Help()))
break
}
}

View File

@ -7,9 +7,9 @@ import (
"encoding/json"
"errors"
"fmt"
"net/url"
)
var _ api.EndPoint = (*EndPoint)(nil)
type EndPoint struct {
@ -34,7 +34,7 @@ func Init(apiRoot *api.Web) EndPoint {
ApiRoot: apiRoot,
Area: api.GetArea(EndPoint{}),
Name: api.GetName(EndPoint{}),
Url: api.GetUrl(Url),
Url: api.SetUrl(Url),
Request: Request{},
Response: Response{},
Error: nil,
@ -67,6 +67,13 @@ func Assert(e api.EndPoint) EndPoint {
// ****************************************
// Methods defined by api.EndPoint interface type
func (e EndPoint) Help() string {
ret := apiReflect.HelpOptions(e.Request.RequestData)
ret += "JSON request:\n"
ret += e.GetRequestJson().String()
return ret
}
func (e EndPoint) GetArea() api.AreaName {
return e.Area
}
@ -93,7 +100,7 @@ func (e EndPoint) SetError(format string, a ...interface{}) api.EndPoint {
}
func (e EndPoint) GetError() error {
return e.Error
return e.EndPointStruct.Error
}
func (e EndPoint) IsError() bool {
@ -112,6 +119,7 @@ func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
if apiReflect.GetType(ref) == "RequestData" {
e.Request.RequestData = ref.(RequestData)
e.Error = e.IsRequestValid()
break
}
@ -130,7 +138,7 @@ func (e EndPoint) RequestRef() interface{} {
}
func (e EndPoint) GetRequestJson() api.Json {
return api.GetAsJson(e.Request)
return api.GetAsJson(e.Request.RequestData)
}
func (e EndPoint) IsRequestValid() error {
@ -143,6 +151,7 @@ func (e EndPoint) IsRequestValid() error {
}
e.Error = req.RequestData.IsValid()
if e.Error != nil {
// e.Error = errors.New(fmt.Sprintf("%s\n%s\n", e.Error, e.Help()))
break
}
}

View File

@ -16,13 +16,13 @@ var _ api.EndPoint = (*EndPoint)(nil)
type EndPoint struct {
api.EndPointStruct
Auth *SunGroAuth
Request Request
Response Response
Auth *SunGroAuth
}
type Request struct {
api.RequestCommon // login is special as it doesn't have the usual fields.
api.RequestCommon
RequestData
}
@ -31,12 +31,10 @@ type Response struct {
ResultData ResultData `json:"result_data"`
}
func Init(apiRoot *api.Web) EndPoint {
return EndPoint {
EndPointStruct: api.EndPointStruct {
ApiRoot: apiRoot,
Area: api.GetArea(EndPoint{}),
Name: api.GetName(EndPoint{}),
Url: api.SetUrl(Url),
@ -83,7 +81,10 @@ func Assert(e api.EndPoint) EndPoint {
// Methods defined by api.EndPoint interface type
func (e EndPoint) Help() string {
return apiReflect.HelpOptions(e.Request.RequestData)
ret := apiReflect.HelpOptions(e.Request.RequestData)
ret += "JSON request:\n"
ret += e.GetRequestJson().String()
return ret
}
func (e EndPoint) GetArea() api.AreaName {
@ -112,7 +113,7 @@ func (e EndPoint) SetError(format string, a ...interface{}) api.EndPoint {
}
func (e EndPoint) GetError() error {
return e.Error
return e.EndPointStruct.Error
}
func (e EndPoint) IsError() bool {
@ -131,6 +132,7 @@ func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
if apiReflect.GetType(ref) == "RequestData" {
e.Request.RequestData = ref.(RequestData)
e.Error = e.IsRequestValid()
break
}
@ -149,7 +151,7 @@ func (e EndPoint) RequestRef() interface{} {
}
func (e EndPoint) GetRequestJson() api.Json {
return api.GetAsJson(e.Request)
return api.GetAsJson(e.Request.RequestData)
}
func (e EndPoint) IsRequestValid() error {
@ -214,21 +216,21 @@ func (e EndPoint) ResponseString() string {
}
func (e EndPoint) MarshalJSON() ([]byte, error) {
// return api.MarshalJSON(e)
return api.MarshalJSON(e)
return json.Marshal(&struct {
Area string `json:"area"`
EndPoint string `json:"endpoint"`
Host string `json:"api_host"`
Url string `json:"endpoint_url"`
Request interface{} `json:"request"`
Response interface{} `json:"response"`
}{
Area: string(e.Area),
EndPoint: string(e.Name),
Host: e.ApiRoot.Url.String(),
Url: e.Url.String(),
Request: e.Request,
Response: e.Response,
})
// return json.Marshal(&struct {
// Area string `json:"area"`
// EndPoint string `json:"endpoint"`
// Host string `json:"api_host"`
// Url string `json:"endpoint_url"`
// Request interface{} `json:"request"`
// Response interface{} `json:"response"`
// }{
// Area: string(e.Area),
// EndPoint: string(e.Name),
// Host: e.ApiRoot.Url.String(),
// Url: e.Url.String(),
// Request: e.Request,
// Response: e.Response,
// })
}

View File

@ -68,7 +68,10 @@ func Assert(e api.EndPoint) EndPoint {
// Methods defined by api.EndPoint interface type
func (e EndPoint) Help() string {
return apiReflect.HelpOptions(e.Request.RequestData)
ret := apiReflect.HelpOptions(e.Request.RequestData)
ret += "JSON request:\n"
ret += e.GetRequestJson().String()
return ret
}
func (e EndPoint) GetArea() api.AreaName {
@ -97,7 +100,7 @@ func (e EndPoint) SetError(format string, a ...interface{}) api.EndPoint {
}
func (e EndPoint) GetError() error {
return e.Error
return e.EndPointStruct.Error
}
func (e EndPoint) IsError() bool {
@ -116,6 +119,7 @@ func (e EndPoint) SetRequest(ref interface{}) api.EndPoint {
if apiReflect.GetType(ref) == "RequestData" {
e.Request.RequestData = ref.(RequestData)
e.Error = e.IsRequestValid()
break
}
@ -134,7 +138,7 @@ func (e EndPoint) RequestRef() interface{} {
}
func (e EndPoint) GetRequestJson() api.Json {
return api.GetAsJson(e.Request)
return api.GetAsJson(e.Request.RequestData)
}
func (e EndPoint) IsRequestValid() error {
@ -147,6 +151,7 @@ func (e EndPoint) IsRequestValid() error {
}
e.Error = req.RequestData.IsValid()
if e.Error != nil {
// e.Error = errors.New(fmt.Sprintf("%s\n%s\n", e.Error, e.Help()))
break
}
}