Skip to content

Commit

Permalink
feat(test): add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Insua committed Aug 20, 2020
1 parent aa1862b commit 7362c35
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
/.idea
config.toml
/test/test.go
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Fatih Arslan, John Guo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 16 additions & 1 deletion person/person.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ import (

const (
createUrl = "https://api2.hik-cloud.com/api/v1/estate/system/person"
deleteUrl = "https://api2.hik-cloud.com/api/v1/estate/system/person/"
listUrl = "https://api2.hik-cloud.com/api/v1/estate/system/person/actions/personInfoList"
)

type Gender int8

const (
None Gender = -1
Female Gender = 0
Male Gender = 1
)

type CreateData struct {
UnionId string `c:"unionId, omitempty" json:"union_id"` //关联ID,保留字段
PersonName string `c:"personName" json:"person_name"` //姓名
Gender int `c:"gender, omitempty" json:"gender"` //性别 [-1]无 [0]女 [1]男
Gender Gender `c:"gender" json:"gender"` //性别 [-1]无 [0]女 [1]男
CredentialType int `c:"credentialType" json:"credential_type"` //证件类型 [1]身份证 [2护照 [3]其他
CredentialNumber string `c:"credentialNumber" json:"credential_number"` //证件号码
Mobile string `c:"mobile" json:"mobile"` //手机号
Expand Down Expand Up @@ -61,3 +71,8 @@ func (p *Person) Create(data *CreateData, rels []CommunityRel) ([]byte, error) {
body, err := p.Http.Post(createUrl, mapData)
return body, err
}

func (p *Person) Delete(personId string) ([]byte, error) {
body, err := p.Http.Delete(deleteUrl+personId, gconv.Map(nil))
return body, err //
}
2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
21 changes: 21 additions & 0 deletions test/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package main

import (
"fmt"
"github.com/Insua/hik_cloud"
"github.com/Insua/hik_cloud/config"
"github.com/gogf/gf/frame/g"
)

func Client() *hik_cloud.HikCloud{
return hik_cloud.NewHikCloud(&config.Config{
ClientId: g.Cfg().GetString("hikCloud.clientId"),
ClientSecret: g.Cfg().GetString("hikCloud.clientSecret"),
Redis: g.Redis(),
})
}

func main() {
client := Client()
fmt.Println(client)
}

0 comments on commit 7362c35

Please sign in to comment.