You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.3 KiB
70 lines
2.3 KiB
type Rpc struct{} //服务对象
|
|
|
|
/*
|
|
功能:{{.description}}
|
|
作者:{{.authorName}}
|
|
时间:{{.currenttime}}
|
|
*/
|
|
{{if .ModelArg}}
|
|
func (s *Rpc) {{.interfaceName}}(ctx context.Context, in *{{.tableName}}Proto.ModelArg) (*{{.tableName}}Proto.Reply, error) {
|
|
//rpc响应
|
|
var reply {{.tableName}}Proto.Reply
|
|
//调用dao层
|
|
list, err := {{.tableName}}Dao.{{.interfaceName}}(in.OrgId)
|
|
//错误处理
|
|
if err != nil {
|
|
//记录错误日志
|
|
LogUtil.Error(ErrorConst.SqlQueryError, "执行{{.interfaceName}}时发生严重错误:"+err.Error())
|
|
//返回结果
|
|
reply.Success = false
|
|
reply.Message = Const.DataBaseActionError
|
|
return &reply, err
|
|
}
|
|
//将结果序列化
|
|
reply.Success = true
|
|
reply.Count = int32(len(list))
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
reply.List = CommonUtil.SerializeToString(list)
|
|
return &reply, err
|
|
}
|
|
{{end}}
|
|
|
|
{{if .QueryArg}}
|
|
func (s *Rpc) {{.interfaceName}}(ctx context.Context, in *{{.tableName}}Proto.QueryArg) (*{{.tableName}}Proto.Reply, error) {
|
|
//rpc响应
|
|
var reply{{.tableName}}Proto.Reply
|
|
|
|
list, count, err := {{.tableName}}Dao.Page{{.tableName}}(in)
|
|
//错误处理
|
|
if err != nil {
|
|
reply.Success = false
|
|
reply.Message = Const.DataBaseActionError
|
|
LogUtil.Error(ErrorConst.SqlQueryError, "执行{{.interfaceName}}时发生严重错误:"+err.Error())
|
|
return &reply, err
|
|
}
|
|
reply.Count = count
|
|
reply.Success = true
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
reply.List = CommonUtil.SerializeToString(list)
|
|
return &reply, nil
|
|
}
|
|
{{end}}
|
|
|
|
{{if .DeleteIdsArg}}
|
|
func (s *Rpc) {{.interfaceName}}(ctx context.Context, in *{{.tableName}}Proto.DeleteIdsArg) (*{{.tableName}}Proto.Reply, error) {
|
|
//rpc响应
|
|
var reply {{.tableName}}Proto.Reply
|
|
//调用通用删除命令进行删除
|
|
err := CommonDao.DeleteIds("xxxxxx",in.Ids)
|
|
//错误处理
|
|
if err != nil {
|
|
LogUtil.Error(ErrorConst.SqlUpdateError, "执行{{.interfaceName}}时发生严重错误:"+err.Error())
|
|
reply.Success = false
|
|
reply.Message = Const.DataBaseActionError
|
|
return &reply, err
|
|
}
|
|
reply.Success = true
|
|
reply.Message = Const.SuccessDataBaseAction
|
|
return &reply, err
|
|
}
|
|
{{end}} |