Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: chyroc/lark
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.112
Choose a base ref
...
head repository: chyroc/lark
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Oct 7, 2023

  1. Copy the full SHA
    e94d28c View commit details
  2. add: CreateLingoDraft

    chyroc committed Oct 7, 2023
    Copy the full SHA
    caf6b2a View commit details
  3. add: UpdateLingoDraft

    chyroc committed Oct 7, 2023
    Copy the full SHA
    b7cb729 View commit details
  4. add: CreateLingoEntity

    chyroc committed Oct 7, 2023
    Copy the full SHA
    141976b View commit details
  5. add: UpdateLingoEntity

    chyroc committed Oct 7, 2023
    Copy the full SHA
    5d8f6d8 View commit details
  6. add: GetLingoEntity

    chyroc committed Oct 7, 2023
    Copy the full SHA
    f0af751 View commit details
  7. add: GetLingoEntityList

    chyroc committed Oct 7, 2023
    Copy the full SHA
    bbbc847 View commit details
  8. add: MatchLingoEntity

    chyroc committed Oct 7, 2023
    Copy the full SHA
    d56669f View commit details
  9. add: SearchLingoEntity

    chyroc committed Oct 7, 2023
    Copy the full SHA
    40325ad View commit details
  10. add: HighlightLingoEntity

    chyroc committed Oct 7, 2023
    Copy the full SHA
    cf6c674 View commit details
  11. add: ExtractLingoEntity

    chyroc committed Oct 7, 2023
    Copy the full SHA
    a5bbd39 View commit details
  12. Copy the full SHA
    3e367e2 View commit details
  13. add: GetLingoRepoList

    chyroc committed Oct 7, 2023
    Copy the full SHA
    cf64e83 View commit details
  14. add: UploadLingoFile

    chyroc committed Oct 7, 2023
    Copy the full SHA
    72a2f15 View commit details
  15. add: DownloadLingoFile

    chyroc committed Oct 7, 2023
    Copy the full SHA
    c11c0f8 View commit details
  16. add: SearchCoreHRContract

    chyroc committed Oct 7, 2023
    Copy the full SHA
    ae588a5 View commit details
  17. add: BatchGetCoreHRJobData

    chyroc committed Oct 7, 2023
    Copy the full SHA
    d0fa0c6 View commit details
  18. Copy the full SHA
    1ab06f1 View commit details
  19. Copy the full SHA
    a153581 View commit details
  20. add: GetMailGroupManagerList

    chyroc committed Oct 7, 2023
    Copy the full SHA
    d15b1c1 View commit details

Commits on Oct 10, 2023

  1. Copy the full SHA
    3eb3b51 View commit details
  2. add: BatchGetCoreHRCompany

    chyroc committed Oct 10, 2023
    Copy the full SHA
    c06abf2 View commit details
  3. add: GetCoreHRJobV2

    chyroc committed Oct 10, 2023
    Copy the full SHA
    d657821 View commit details
  4. add: GetCoreHRJobListV2

    chyroc committed Oct 10, 2023
    Copy the full SHA
    ffe7ee2 View commit details
  5. add: BatchGetCoreHRJobFamily

    chyroc committed Oct 10, 2023
    Copy the full SHA
    5c757fa View commit details
  6. add: BatchGetCoreHRJobLevel

    chyroc committed Oct 10, 2023
    Copy the full SHA
    a8df0d4 View commit details
  7. add: BatchGetCoreHRLocation

    chyroc committed Oct 10, 2023
    Copy the full SHA
    eb34e18 View commit details

Commits on Oct 25, 2023

  1. update: CreateBaikeDraft, CreateLingoDraft, CreateLingoEntity, Create…

    …OKRProgressRecord, GetHireReferralWebsiteJobPost, GetHireReferralWebsiteJobPostList, GetLingoClassificationList, GetLingoEntity, GetLingoEntityList, SearchLingoEntity, UpdateLingoDraft, UpdateLingoEntity, GetDriveFileList, GetSheetProtectedDimension
    chyroc committed Oct 25, 2023
    Copy the full SHA
    b0f4db0 View commit details
  2. add: SetApplicationAppBadge

    chyroc committed Oct 25, 2023
    Copy the full SHA
    e5ce605 View commit details
  3. Copy the full SHA
    cdc2801 View commit details
  4. add: GetCoreHRBPByDepartment

    chyroc committed Oct 25, 2023
    Copy the full SHA
    49237b3 View commit details
  5. add: GetCoreHRBPList

    chyroc committed Oct 25, 2023
    Copy the full SHA
    c2ad1ef View commit details
  6. add: SearchCoreHRProbation

    chyroc committed Oct 25, 2023
    Copy the full SHA
    e79f0e3 View commit details
  7. Copy the full SHA
    4599260 View commit details
  8. Copy the full SHA
    0767d96 View commit details
  9. Copy the full SHA
    14902e3 View commit details
  10. Copy the full SHA
    801bf82 View commit details
  11. Copy the full SHA
    828c916 View commit details
  12. Copy the full SHA
    829c43b View commit details
  13. Copy the full SHA
    d2d7819 View commit details
  14. Copy the full SHA
    934aecf View commit details
  15. Copy the full SHA
    5f0c6dd View commit details
  16. Copy the full SHA
    aecbbe6 View commit details
  17. Copy the full SHA
    df9fc2d View commit details
  18. Copy the full SHA
    a29b8c1 View commit details
  19. add: BatchHighlightLingoEntity

    chyroc committed Oct 25, 2023
    Copy the full SHA
    c30eaff View commit details
  20. Copy the full SHA
    83bfb32 View commit details
  21. Copy the full SHA
    5ae9648 View commit details
  22. Copy the full SHA
    043ba13 View commit details

Commits on Oct 26, 2023

  1. Copy the full SHA
    f68e4b6 View commit details
Showing 1,372 changed files with 65,720 additions and 9,504 deletions.
3 changes: 3 additions & 0 deletions .github/script/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
go build -o ~/Downloads/bin/generate_iface_unmarshal generate_iface_unmarshal/main.go
go build -o ~/Downloads/bin/generate_set_attrs generate_set_attrs/main.go
go build -o ~/Downloads/bin/generate_to_map generate_to_map/main.go
138 changes: 138 additions & 0 deletions .github/script/generate_iface_unmarshal/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package main

import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"

"github.com/davecgh/go-spew/spew"

"github.com/chyroc/lark/.github/script/helper"
)

func main() {
typ := flag.String("type", "", "")
flag.Parse()
fileName := os.Getenv("GOFILE")
structName := *typ

ast, err := helper.ParseAST(filepath.Dir(fileName))
if err != nil {
log.Fatalln(err)
}

err = rewritePath(fileName, structName, ast)
if err != nil {
log.Fatalln(err)
}
}

func rewritePath(path string, structName string, ast *helper.ASTResult) error {
bs, err := ioutil.ReadFile(path)
if err != nil {
return err
}
structType, ok := ast.Structs[structName]
if !ok {
return fmt.Errorf("not found struct %s", structName)
}
content := clearGenerate(string(bs), structName)
attrs := generate(structName, structType)

return ioutil.WriteFile(path, []byte(helper.ClearString(content+attrs, "\n\n\n", "\n\n")), 0o644)
}

func clearGenerate(s, structName string) string {
l := strings.Split(s, "\n")
res := []string{}
start := false
for i := 0; i < len(l); i++ {
v := l[i]
if strings.Contains(v, fmt.Sprintf("generated to unmarshal %s", structName)) {
start = true
continue
} else if v == "}" && start {
start = false
continue
}

if start {
continue
}
res = append(res, v)
}
return strings.Join(res, "\n")
}

func generate(structName string, structType *helper.Struct) string {
return generateNewType(structName, structType.Fields) + "\n\n" + generateUnmarshal(structName, structType.Fields)
}

func generateNewType(structName string, fields []*helper.Field) string {
res := []string{}
res = append(res, "// unmarshal"+structName+" generated to unmarshal "+structName+" iface")
res = append(res, "type unmarshal"+structName+" struct {")
for _, v := range fields {
if v.UnmarshalTool != "" {
typ := "json.RawMessage"
if strings.HasPrefix(v.RealType, "[]") {
typ = "[]json.RawMessage"
} else if strings.HasPrefix(v.RealType, "map[string][]") {
typ = "map[string][]json.RawMessage"
}
res = append(res, fmt.Sprintf("\t%s %s `json:\"%s,omitempty\"`", v.Name, typ, v.JSONTag))
} else {
res = append(res, fmt.Sprintf("\t%s %s `json:\"%s,omitempty\"`", v.Name, v.NameType, v.JSONTag))
}
}
res = append(res, "}")
return strings.Join(res, "\n")
}

func generateUnmarshal(structName string, fields []*helper.Field) string {
res := []string{}
res = append(res, "\n")
res = append(res, fmt.Sprintf(`// UnmarshalJSON generated to unmarshal %s iface`, structName))
res = append(res, fmt.Sprintf(`func (r *%s) UnmarshalJSON(bs []byte) error {`, structName))
res = append(res, fmt.Sprintf("\tobj := new(unmarshal%s)", structName))
res = append(res, "\terr := json.Unmarshal(bs, obj)")
res = append(res, "\tif err != nil {")
res = append(res, "\t\treturn err")
res = append(res, "\t}")
for _, v := range fields {
if v.UnmarshalTool == "" {
res = append(res, fmt.Sprintf("\tr.%s = obj.%s", v.Name, v.Name))
} else {
if strings.HasPrefix(v.RealType, "[]") {
res = append(res, fmt.Sprintf("\tr.%s = make(%s, len(obj.%s))", v.Name, v.NameType, v.Name))
res = append(res, fmt.Sprintf("\tfor i, v := range obj.%s {", v.Name))
res = append(res, fmt.Sprintf("\t\tr.%s[i], err = %s(v)", v.Name, v.UnmarshalTool))
res = append(res, "\t\tif err != nil {")
res = append(res, "\t\t\treturn err")
res = append(res, "\t\t}")
res = append(res, "\t}")
} else if strings.HasPrefix(v.RealType, "map[string][]") {
res = append(res, fmt.Sprintf("\tr.%s = make(%s, len(obj.%s))", v.Name, v.NameType, v.Name))
res = append(res, fmt.Sprintf("\tfor k, v := range obj.%s {", v.Name))
res = append(res, fmt.Sprintf("\t\tfor _, vv := range v {"))
res = append(res, fmt.Sprintf("\t\t\ttmp, err := %s(vv)", v.UnmarshalTool))
res = append(res, "\t\t\tif err != nil {")
res = append(res, "\t\t\t\treturn err")
res = append(res, "\t\t\t}")
res = append(res, fmt.Sprintf("\t\t\tr.%s[k] = append(r.%s[k], tmp)", v.Name, v.Name))
res = append(res, "\t\t}")
res = append(res, "\t}")
} else {
spew.Dump(v.Name, v.RealType, v.NameType)
panic(v)
}
}
}
res = append(res, "\treturn nil")
res = append(res, "}")
return strings.Join(res, "\n")
}
119 changes: 119 additions & 0 deletions .github/script/generate_set_attrs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package main

import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"

"github.com/chyroc/lark/.github/script/helper"
)

func main() {
typ := flag.String("type", "", "")
flag.Parse()
fileName := os.Getenv("GOFILE")
structName := *typ

ast, err := helper.ParseAST(filepath.Dir(fileName))
if err != nil {
log.Fatalln(err)
}

err = rewritePath(fileName, structName, ast)
if err != nil {
log.Fatalln(err)
}
}

func rewritePath(path string, structName string, ast *helper.ASTResult) error {
bs, err := ioutil.ReadFile(path)
if err != nil {
return err
}

struct_, ok := ast.Structs[structName]
if !ok {
return fmt.Errorf("not found struct %s", structName)
}

content := clearSetAttr(string(bs), structName)
attrs := genSetAttrs(structName, struct_, ast)

return ioutil.WriteFile(path, []byte(helper.ClearString(content+attrs, "\n\n\n", "\n\n")), 0o644)
}

func clearSetAttr(s, structName string) string {
l := strings.Split(s, "\n")
// SetTextTagList set ComponentHeader.TextTagList attribute
res := []string{}
start := false
for i := 0; i < len(l); i++ {

v := l[i]
if strings.HasPrefix(v, "// Set") && strings.Contains(v, "set "+structName) {
start = true
continue
} else if v == "}" && start {
start = false
continue
}

if start {
continue
}
res = append(res, v)
}
return strings.Join(res, "\n")
}

func genSetAttrs(structName string, structType *helper.Struct, ast *helper.ASTResult) string {
res := []string{}
for _, v := range structType.Fields {
res = append(res, genSetAttr(structName, v, ast))
}
return strings.Join(res, "")
}

func genSetAttr(structName string, field *helper.Field, ast *helper.ASTResult) string {
consts := ast.Consts[field.NameType]
nameType := field.NameType
if strings.HasPrefix(nameType, "[]") {
nameType = "..." + nameType[2:]
}
res := []string{
fmt.Sprintf(`
// Set%s set %s.%s attribute
func (r *%s) Set%s(val %s) *%s {
r.%s = val
return r
}
`, field.Name, structName, field.Name, structName, field.Name, nameType, structName, field.Name),
}
for _, const_ := range unique(consts) {
constSuffix := const_.NameType[len(field.NameType):]
method := field.Name + constSuffix
res = append(res, fmt.Sprintf(`
// Set%s set %s.%s attribute to %s
func (r *%s) Set%s() *%s {
r.%s = %s
return r
}`, method, structName, field.Name, const_.NameType, structName, method, structName, field.Name, const_.NameType))
}
return strings.Join(res, "\n")
}

func unique(l []helper.Const) []helper.Const {
res := []helper.Const{}
done := map[string]bool{}
for _, v := range l {
if !done[v.NameType] {
res = append(res, v)
done[v.NameType] = true
}
}
return res
}
103 changes: 103 additions & 0 deletions .github/script/generate_to_map/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package main

import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"

"github.com/chyroc/lark/.github/script/helper"
)

func main() {
typ := flag.String("type", "", "")
flag.Parse()
fileName := os.Getenv("GOFILE")
structName := *typ

ast, err := helper.ParseAST(filepath.Dir(fileName))
if err != nil {
log.Fatalln(err)
}

err = rewritePath(fileName, structName, ast)
if err != nil {
log.Fatalln(err)
}
}

func rewritePath(path string, structName string, ast *helper.ASTResult) error {
bs, err := ioutil.ReadFile(path)
if err != nil {
return err
}

structType, ok := ast.Structs[structName]
if !ok {
return fmt.Errorf("not found struct %s", structName)
}

content := clearGenerate(string(bs), structName)
attrs := generate(structName, structType.Fields)

return ioutil.WriteFile(path, []byte(helper.ClearString(content+attrs, "\n\n\n", "\n\n")), 0o644)
}

func clearGenerate(s, structName string) string {
l := strings.Split(s, "\n")
res := []string{}
start := false
for i := 0; i < len(l); i++ {
v := l[i]
if strings.HasPrefix(v, "// toMap conv "+structName+" to map") {
start = true
continue
} else if v == "}" && start {
start = false
continue
}

if start {
continue
}
res = append(res, v)
}
return strings.Join(res, "\n")
}

func generate(structName string, fields []*helper.Field) string {
fieldCount := 0
for _, v := range fields {
if v.JSONTag == "" || v.JSONTag == "-" {
continue
}
fieldCount++
}
res := []string{}
res = append(res, "\n")
res = append(res, fmt.Sprintf(`// toMap conv %s to map`, structName))
res = append(res, fmt.Sprintf(`func (r *%s) toMap() map[string]interface{} {`, structName))
res = append(res, fmt.Sprintf("\tres := make(map[string]interface{}, %d)", fieldCount))
for _, v := range fields {
if v.JSONTag == "" || v.JSONTag == "-" {
continue
}
if v.JSONOmitempty {
if v.ZeroString() == "len" {
res = append(res, fmt.Sprintf("\tif len(r.%s) != 0 {", v.Name))
} else {
res = append(res, fmt.Sprintf("\tif r.%s != %s {", v.Name, v.ZeroString()))
}
res = append(res, fmt.Sprintf("\t\tres[\"%s\"] = r.%s", v.JSONTag, v.Name))
res = append(res, "\t}")
} else {
res = append(res, fmt.Sprintf("\tres[\"%s\"] = r.%s", v.JSONTag, v.Name))
}
}
res = append(res, "\treturn res")
res = append(res, "}")
return strings.Join(res, "\n")
}
10 changes: 10 additions & 0 deletions .github/script/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/chyroc/lark/.github/script

go 1.17

replace github.com/chyroc/lark => ../../

require (
github.com/chyroc/lark v0.0.113
github.com/davecgh/go-spew v1.1.1
)
13 changes: 13 additions & 0 deletions .github/script/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading