|
|
|
@ -16,6 +16,12 @@ type Rpc struct{} //服务对象
|
|
|
|
|
|
|
|
|
|
//选择单条
|
|
|
|
|
func (s *Rpc) Get{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.ModelArg) (*{{.tableName}}Proto.Reply, error) {
|
|
|
|
|
//异常处理
|
|
|
|
|
defer func() {
|
|
|
|
|
if err := recover(); err != nil {
|
|
|
|
|
fmt.Printf("%s\n", err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
//rpc响应
|
|
|
|
|
var reply {{.tableName}}Proto.Reply
|
|
|
|
|
//通用获取单条
|
|
|
|
@ -31,6 +37,12 @@ func (s *Rpc) Get{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.Mod
|
|
|
|
|
|
|
|
|
|
//增加
|
|
|
|
|
func (s *Rpc) Add{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.ModelArg) (*{{.tableName}}Proto.Reply, error) {
|
|
|
|
|
//异常处理
|
|
|
|
|
defer func() {
|
|
|
|
|
if err := recover(); err != nil {
|
|
|
|
|
fmt.Printf("%s\n", err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
//rpc响应
|
|
|
|
|
var reply {{.tableName}}Proto.Reply
|
|
|
|
|
//调用dao
|
|
|
|
@ -51,6 +63,12 @@ func (s *Rpc) Add{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.Mod
|
|
|
|
|
|
|
|
|
|
//删除
|
|
|
|
|
func (s *Rpc) Delete{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.DeleteIdsArg) (*{{.tableName}}Proto.Reply, error) {
|
|
|
|
|
//异常处理
|
|
|
|
|
defer func() {
|
|
|
|
|
if err := recover(); err != nil {
|
|
|
|
|
fmt.Printf("%s\n", err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
//rpc响应
|
|
|
|
|
var reply {{.tableName}}Proto.Reply
|
|
|
|
|
|
|
|
|
@ -71,6 +89,12 @@ func (s *Rpc) Delete{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.
|
|
|
|
|
|
|
|
|
|
//修改
|
|
|
|
|
func (s *Rpc) Update{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.ModelArg) (*{{.tableName}}Proto.Reply, error) {
|
|
|
|
|
//异常处理
|
|
|
|
|
defer func() {
|
|
|
|
|
if err := recover(); err != nil {
|
|
|
|
|
fmt.Printf("%s\n", err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
//rpc响应
|
|
|
|
|
var reply {{.tableName}}Proto.Reply
|
|
|
|
|
//3、修改
|
|
|
|
@ -92,6 +116,12 @@ func (s *Rpc) Update{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.
|
|
|
|
|
|
|
|
|
|
//分页查询
|
|
|
|
|
func (s *Rpc) Page{{.tableName}}(ctx context.Context, in *{{.tableName}}Proto.QueryArg) (*{{.tableName}}Proto.Reply, error) {
|
|
|
|
|
//异常处理
|
|
|
|
|
defer func() {
|
|
|
|
|
if err := recover(); err != nil {
|
|
|
|
|
fmt.Printf("%s\n", err)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
//rpc响应
|
|
|
|
|
var reply {{.tableName}}Proto.Reply
|
|
|
|
|
|
|
|
|
|