forked from unionj-cloud/go-doudou
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
233 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package dto | ||
|
||
import "encoding/json" | ||
|
||
//go:generate go-doudou name --file $GOFILE -o | ||
|
||
// 筛选条件 | ||
type PageFilter struct { | ||
// 真实姓名,前缀匹配 | ||
Name string | ||
// 所属部门ID | ||
Dept int | ||
} | ||
|
||
// 排序条件 | ||
type Order struct { | ||
Col string | ||
Sort string | ||
} | ||
|
||
type Page struct { | ||
// 排序规则 | ||
Orders []Order | ||
// 页码 | ||
PageNo int | ||
// 每页行数 | ||
Size int | ||
User UserVo | ||
} | ||
|
||
// 分页筛选条件 | ||
type PageQuery struct { | ||
Filter PageFilter | ||
Page Page | ||
Options []struct { | ||
Label string `json:"label" form:"label"` | ||
Value string `json:"value" form:"value"` | ||
} `json:"options" form:"options"` | ||
} | ||
|
||
type PageRet struct { | ||
Items interface{} | ||
PageNo int | ||
PageSize int | ||
Total int | ||
HasNext bool | ||
} | ||
|
||
type UserVo struct { | ||
Id int | ||
Name string | ||
Phone string | ||
Dept string | ||
} | ||
|
||
type KeyboardLayout int | ||
|
||
const ( | ||
UNKNOWN KeyboardLayout = iota | ||
QWERTZ | ||
AZERTY | ||
QWERTY | ||
) | ||
|
||
func (k *KeyboardLayout) StringSetter(value string) { | ||
switch value { | ||
case "UNKNOWN": | ||
*k = UNKNOWN | ||
case "QWERTY": | ||
*k = QWERTY | ||
case "QWERTZ": | ||
*k = QWERTZ | ||
case "AZERTY": | ||
*k = AZERTY | ||
default: | ||
*k = UNKNOWN | ||
} | ||
} | ||
|
||
func (k *KeyboardLayout) StringGetter() string { | ||
switch *k { | ||
case UNKNOWN: | ||
return "UNKNOWN" | ||
case QWERTY: | ||
return "QWERTY" | ||
case QWERTZ: | ||
return "QWERTZ" | ||
case AZERTY: | ||
return "AZERTY" | ||
default: | ||
return "UNKNOWN" | ||
} | ||
} | ||
|
||
func (k *KeyboardLayout) UnmarshalJSON(bytes []byte) error { | ||
var _k string | ||
err := json.Unmarshal(bytes, &_k) | ||
if err != nil { | ||
return err | ||
} | ||
k.StringSetter(_k) | ||
return nil | ||
} | ||
|
||
func (k KeyboardLayout) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(k.StringGetter()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
cmd/internal/svc/testdata/outputanonystruct/transport/grpc/usersvc.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Generated by go-doudou v2.4.2. | ||
* Don't edit! | ||
* | ||
* Version No.: v20240918 | ||
*/ | ||
syntax = "proto3"; | ||
|
||
package usersvc; | ||
option go_package = "github.com/unionj-cloud/go-doudou/v2/cmd/internal/svc/testdata/outputanonystruct/transport/grpc"; | ||
|
||
import "google/protobuf/any.proto"; | ||
|
||
enum KeyboardLayout { | ||
UNKNOWN = 0; | ||
QWERTZ = 1; | ||
AZERTY = 2; | ||
QWERTY = 3; | ||
} | ||
|
||
message Anonystructkfvagz8uXPWVpn5z9xyjWS { | ||
optional string label = 1 [json_name="label"]; | ||
optional string value = 2 [json_name="value"]; | ||
} | ||
|
||
// 排序条件 | ||
message Order { | ||
optional string col = 1 [json_name="col"]; | ||
optional string sort = 2 [json_name="sort"]; | ||
} | ||
|
||
message Page { | ||
// 排序规则 | ||
repeated Order orders = 1 [json_name="orders"]; | ||
// 页码 | ||
optional int32 page_no = 2 [json_name="page_no"]; | ||
// 每页行数 | ||
optional int32 size = 3 [json_name="size"]; | ||
optional UserVo user = 4 [json_name="user"]; | ||
} | ||
|
||
// 筛选条件 | ||
message PageFilter { | ||
// 真实姓名,前缀匹配 | ||
optional string name = 1 [json_name="name"]; | ||
// 所属部门ID | ||
optional int32 dept = 2 [json_name="dept"]; | ||
} | ||
|
||
// 分页筛选条件 | ||
message PageQuery { | ||
optional PageFilter filter = 1 [json_name="filter"]; | ||
optional Page page = 2 [json_name="page"]; | ||
repeated Anonystructkfvagz8uXPWVpn5z9xyjWS options = 3 [json_name="options"]; | ||
} | ||
|
||
message PageRet { | ||
optional google.protobuf.Any items = 1 [json_name="items"]; | ||
optional int32 page_no = 2 [json_name="page_no"]; | ||
optional int32 page_size = 3 [json_name="page_size"]; | ||
optional int32 total = 4 [json_name="total"]; | ||
optional bool has_next = 5 [json_name="has_next"]; | ||
} | ||
|
||
message UserVo { | ||
optional int32 id = 1 [json_name="id"]; | ||
optional string name = 2 [json_name="name"]; | ||
optional string phone = 3 [json_name="phone"]; | ||
optional string dept = 4 [json_name="dept"]; | ||
} | ||
|
||
service UsersvcService { | ||
// You can define your service methods as your need. Below is an example. | ||
rpc PageUsersRpc(PageQuery) returns (Page); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters