소스 검색

rpc 设置完成

caipin 4 년 전
부모
커밋
cc74584db6

+ 3 - 0
comm/functions.go

@@ -41,6 +41,9 @@ func MakeProjectAccountVM(modelsAccount *models.CmProjectAccount) viewmodels.Pro
 	viewAccountData.Mobile = modelsAccount.Mobile
 	viewAccountData.Telephone = modelsAccount.Telephone
 	viewAccountData.IsAdmin = modelsAccount.IsAdmin
+	viewAccountData.AccountGroup = modelsAccount.AccountGroup
+	viewAccountData.Enable = modelsAccount.Enable
+	viewAccountData.Position = modelsAccount.Position
 	return viewAccountData
 }
 

+ 2 - 29
conf/project.go

@@ -21,35 +21,8 @@ var SignSecret = "cpcm005687gokaif"
 // cookie中的加密验证密钥
 var CookieSecret = "cm_login_account"
 
-const UserPrizeMax = 3000 //
-
-// 定义24小时的奖品分配权重
-var PrizeDataRandomDayTime = [100]int{
-	0, 0, 0,
-	1, 1, 1,
-	2, 2, 2,
-	3, 3, 3,
-	4, 4, 4,
-	5, 5, 5,
-	6, 6, 6,
-	7, 7, 7,
-	8, 8, 8,
-	9, 9, 9, 9, 9, 9, 9,
-	10, 10, 10, 10, 10, 10, 10,
-	11, 11, 11,
-	12, 12, 12,
-	13, 13, 13,
-	14, 14, 14,
-	15, 15, 15, 15, 15, 15, 15,
-	16, 16, 16, 16, 16, 16, 16,
-	17, 17, 17, 17, 17, 17, 17,
-	18, 18, 18,
-	19, 19, 19,
-	20, 20, 20, 20, 20, 20, 20,
-	21, 21, 21, 21, 21, 21, 21,
-	22, 22, 22,
-	23, 23, 23,
-}
+// nodejs rpc 服务端
+const NodeRpcHost = "192.168.1.26:5001"
 
 // 是否需要启动全局计划任务服务
 var RunningCrontabService = false

+ 21 - 5
dao/project_account_dao.go

@@ -25,11 +25,27 @@ func NewProjectAccountDao(engine *xorm.Engine) *ProjectAccountDao {
 	}
 }
 
-//CmProjectAccount 设置的值获得数据
-func (d *ProjectAccountDao) GetOne(data *models.CmProjectAccount) *models.CmProjectAccount {
-	//data := data
-	//Get取到值后,会自动赋值到data中
-	ok, err := d.engine.Get(data)
+//CmProjectAccount 设置的值获得数据-弃用
+// func (d *ProjectAccountDao) GetOne(data *models.CmProjectAccount) *models.CmProjectAccount {
+// 	//data := data
+// 	//Get取到值后,会自动赋值到data中
+// 	ok, err := d.engine.
+// 		Where("account = ?", data.Account).
+// 		Get(data)
+// 	if ok && err == nil {
+// 		return data
+// 	} else {
+// 		data.Id = 0
+// 		return data
+// 	}
+// }
+
+// 根据账号获得数据
+func (d *ProjectAccountDao) GetAccount(account string) *models.CmProjectAccount {
+	data := &models.CmProjectAccount{}
+	ok, err := d.engine.
+		Where("account = ?", account).
+		Get(data)
 	if ok && err == nil {
 		return data
 	} else {

+ 19 - 5
dao/project_dao.go

@@ -26,14 +26,28 @@ func NewProjectDao(engine *xorm.Engine) *ProjectDao {
 }
 
 //CmProjectAccount 设置的值获得数据
-func (d *ProjectDao) Get(data *models.CmProject) {
-	//data := data
-	ok, err := d.engine.Get(data)
+// func (d *ProjectDao) Get(data *models.CmProject) {
+// 	//data := data
+// 	ok, err := d.engine.Get(data)
+// 	if ok && err == nil {
+// 		//return nil
+// 	} else {
+// 		data.Id = 0
+// 		//return err
+// 	}
+// }
+
+//设置的值获得数据
+func (d *ProjectDao) GetCode(code string) *models.CmProject {
+	data := &models.CmProject{}
+	ok, err := d.engine.
+		Where("code = ?", code).
+		Get(data)
 	if ok && err == nil {
-		//return nil
+		return data
 	} else {
 		data.Id = 0
-		//return err
+		return data
 	}
 }
 

+ 307 - 0
proto/rpc.pb.go

@@ -0,0 +1,307 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// 	protoc-gen-go v1.25.0
+// 	protoc        v3.9.0
+// source: rpc.proto
+
+// option go_package = "google.golang.org/grpc/examples/helloworld/helloworld";
+// option java_multiple_files = true;
+// option java_package = "io.grpc.examples.helloworld";
+// option java_outer_classname = "HelloWorldProto";
+
+package proto
+
+import (
+	context "context"
+	proto "github.com/golang/protobuf/proto"
+	grpc "google.golang.org/grpc"
+	codes "google.golang.org/grpc/codes"
+	status "google.golang.org/grpc/status"
+	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+	reflect "reflect"
+	sync "sync"
+)
+
+const (
+	// Verify that this generated code is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+	// Verify that runtime/protoimpl is sufficiently up-to-date.
+	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+// This is a compile-time assertion that a sufficiently up-to-date version
+// of the legacy proto package is being used.
+const _ = proto.ProtoPackageIsVersion4
+
+// The request message containing the user's name.
+type HelloRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (x *HelloRequest) Reset() {
+	*x = HelloRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_rpc_proto_msgTypes[0]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *HelloRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*HelloRequest) ProtoMessage() {}
+
+func (x *HelloRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_rpc_proto_msgTypes[0]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
+func (*HelloRequest) Descriptor() ([]byte, []int) {
+	return file_rpc_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *HelloRequest) GetName() string {
+	if x != nil {
+		return x.Name
+	}
+	return ""
+}
+
+// The response message containing the greetings
+type HelloReply struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
+}
+
+func (x *HelloReply) Reset() {
+	*x = HelloReply{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_rpc_proto_msgTypes[1]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *HelloReply) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*HelloReply) ProtoMessage() {}
+
+func (x *HelloReply) ProtoReflect() protoreflect.Message {
+	mi := &file_rpc_proto_msgTypes[1]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.
+func (*HelloReply) Descriptor() ([]byte, []int) {
+	return file_rpc_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *HelloReply) GetMessage() string {
+	if x != nil {
+		return x.Message
+	}
+	return ""
+}
+
+var File_rpc_proto protoreflect.FileDescriptor
+
+var file_rpc_proto_rawDesc = []byte{
+	0x0a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f,
+	0x74, 0x6f, 0x22, 0x22, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65,
+	0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52,
+	0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18,
+	0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x3f,
+	0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x08, 0x53, 0x61, 0x79,
+	0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x65,
+	0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f,
+	0x74, 0x6f, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x62,
+	0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+	file_rpc_proto_rawDescOnce sync.Once
+	file_rpc_proto_rawDescData = file_rpc_proto_rawDesc
+)
+
+func file_rpc_proto_rawDescGZIP() []byte {
+	file_rpc_proto_rawDescOnce.Do(func() {
+		file_rpc_proto_rawDescData = protoimpl.X.CompressGZIP(file_rpc_proto_rawDescData)
+	})
+	return file_rpc_proto_rawDescData
+}
+
+var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_rpc_proto_goTypes = []interface{}{
+	(*HelloRequest)(nil), // 0: proto.HelloRequest
+	(*HelloReply)(nil),   // 1: proto.HelloReply
+}
+var file_rpc_proto_depIdxs = []int32{
+	0, // 0: proto.Greeter.SayHello:input_type -> proto.HelloRequest
+	1, // 1: proto.Greeter.SayHello:output_type -> proto.HelloReply
+	1, // [1:2] is the sub-list for method output_type
+	0, // [0:1] is the sub-list for method input_type
+	0, // [0:0] is the sub-list for extension type_name
+	0, // [0:0] is the sub-list for extension extendee
+	0, // [0:0] is the sub-list for field type_name
+}
+
+func init() { file_rpc_proto_init() }
+func file_rpc_proto_init() {
+	if File_rpc_proto != nil {
+		return
+	}
+	if !protoimpl.UnsafeEnabled {
+		file_rpc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*HelloRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_rpc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*HelloReply); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+	}
+	type x struct{}
+	out := protoimpl.TypeBuilder{
+		File: protoimpl.DescBuilder{
+			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+			RawDescriptor: file_rpc_proto_rawDesc,
+			NumEnums:      0,
+			NumMessages:   2,
+			NumExtensions: 0,
+			NumServices:   1,
+		},
+		GoTypes:           file_rpc_proto_goTypes,
+		DependencyIndexes: file_rpc_proto_depIdxs,
+		MessageInfos:      file_rpc_proto_msgTypes,
+	}.Build()
+	File_rpc_proto = out.File
+	file_rpc_proto_rawDesc = nil
+	file_rpc_proto_goTypes = nil
+	file_rpc_proto_depIdxs = nil
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConnInterface
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion6
+
+// GreeterClient is the client API for Greeter service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
+type GreeterClient interface {
+	// Sends a greeting
+	SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
+}
+
+type greeterClient struct {
+	cc grpc.ClientConnInterface
+}
+
+func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient {
+	return &greeterClient{cc}
+}
+
+func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) {
+	out := new(HelloReply)
+	err := c.cc.Invoke(ctx, "/proto.Greeter/SayHello", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+// GreeterServer is the server API for Greeter service.
+type GreeterServer interface {
+	// Sends a greeting
+	SayHello(context.Context, *HelloRequest) (*HelloReply, error)
+}
+
+// UnimplementedGreeterServer can be embedded to have forward compatible implementations.
+type UnimplementedGreeterServer struct {
+}
+
+func (*UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
+}
+
+func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) {
+	s.RegisterService(&_Greeter_serviceDesc, srv)
+}
+
+func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(HelloRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(GreeterServer).SayHello(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/proto.Greeter/SayHello",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+var _Greeter_serviceDesc = grpc.ServiceDesc{
+	ServiceName: "proto.Greeter",
+	HandlerType: (*GreeterServer)(nil),
+	Methods: []grpc.MethodDesc{
+		{
+			MethodName: "SayHello",
+			Handler:    _Greeter_SayHello_Handler,
+		},
+	},
+	Streams:  []grpc.StreamDesc{},
+	Metadata: "rpc.proto",
+}

+ 24 - 0
proto/rpc.proto

@@ -0,0 +1,24 @@
+syntax = "proto3";
+
+// option go_package = "google.golang.org/grpc/examples/helloworld/helloworld";
+// option java_multiple_files = true;
+// option java_package = "io.grpc.examples.helloworld";
+// option java_outer_classname = "HelloWorldProto";
+
+package proto;
+
+// The greeting service definition.
+service Greeter {
+  // Sends a greeting
+  rpc SayHello (HelloRequest) returns (HelloReply) {}
+}
+
+// The request message containing the user's name.
+message HelloRequest {
+  string name = 1;
+}
+
+// The response message containing the greetings
+message HelloReply {
+  string message = 1;
+}

+ 2 - 4
services/login_service.go

@@ -19,7 +19,6 @@ import (
 	"go.mod/dao"
 	"go.mod/datasource"
 	"go.mod/lib"
-	"go.mod/models"
 	"go.mod/web/viewmodels"
 )
 
@@ -63,10 +62,9 @@ func (s *loginService) ValidRule(ctx iris.Context) (viewmodels.Login, error) {
 
 // 验证项目用户登陆相关
 func (s *loginService) ValidProjectAccount(loginData viewmodels.Login, writer http.ResponseWriter) (*viewmodels.ProjectAccount, error) {
-	projectInfo := models.CmProject{}
+
 	// 工程项目是否存在
-	projectInfo.Code = loginData.Code
-	s.projectDao.Get(&projectInfo)
+	projectInfo := s.projectDao.GetCode(loginData.Code)
 	if projectInfo.Id == 0 {
 		return nil, errors.New("工程建设管理员还未创建项目,禁止登录")
 	}

+ 5 - 5
services/project_account_service.go

@@ -52,7 +52,7 @@ func NewProjectAccountService() ProjectAccountService {
 	return &projectAccountService{
 		dao:           dao.NewProjectAccountDao(datasource.InstanceDbMaster()),
 		bidAccountDao: dao.NewBidAccountDao(datasource.InstanceDbMaster()),
-		validSave:     "/api/projectSetting/account/save",
+		validSave:     "/api/projectSetting/account/create",
 		validAdd:      "/api/projectSetting/account/add",
 		validPassword: "/api/projectSetting/account/change",
 	}
@@ -74,7 +74,8 @@ func (s *projectAccountService) ValidRule(ctx iris.Context) (viewmodels.ProjectA
 	} else if ctx.Path() == s.validPassword {
 		err = accountVaild.ValidatePassword()
 	} else {
-		return accountVaild, errors.New("验证错误")
+		log.Println("请求路径找不到对应的验证规则")
+		return accountVaild, errors.New("验证错误-未找到验证规则")
 	}
 
 	if err != nil {
@@ -168,9 +169,8 @@ func (s *projectAccountService) Search(name string, projectId int) []viewmodels.
 // 新增账号
 func (s *projectAccountService) Add(viewAccount viewmodels.ProjectAccount, projectId int) error {
 
-	// 验证该项目下是否有同名账号--TODO
-	accountValid := &models.CmProjectAccount{}
-	s.dao.GetOne(accountValid)
+	// 验证该项目下是否有同名账号
+	accountValid := s.dao.GetAccount(viewAccount.Account)
 	if accountValid.Id != 0 {
 		return errors.New("已存在相同的账号")
 	}

+ 65 - 0
services/rpc_service.go

@@ -0,0 +1,65 @@
+/*
+ * @description: rpc services 实例
+ * @Author: CP
+ * @Date: 2020-11-12 22:53:14
+ * @FilePath: \construction_management\services\rpc_service.go
+ */
+package services
+
+import (
+	"context"
+	"log"
+	"time"
+
+	"go.mod/conf"
+	rpc "go.mod/proto"
+	"google.golang.org/grpc"
+)
+
+type RpcService interface {
+	Test()
+}
+
+//返回service操作类
+type rpcService struct {
+	// address     string
+	// defaultName string
+	rpcClient *grpc.ClientConn
+	// 定义proto 接口文件- /proto/rpc.proto
+	// pb.UnimplementedGreeterServer
+}
+
+//创建项目用户service
+func NewRpcService() RpcService {
+	return &rpcService{
+		// address:     "192.168.1.26:5001",
+		rpcClient: newGrpcClient(conf.NodeRpcHost),
+	}
+}
+
+func newGrpcClient(address string) *grpc.ClientConn {
+	// 启动grpc客户端,连接grpc服务端
+	conn, err := grpc.Dial(address, grpc.WithInsecure())
+	if err != nil {
+		log.Fatalf("did not connect: %v", err)
+	}
+	// defer conn.Close()
+	return conn
+}
+
+// 具体的业务逻辑
+func (s *rpcService) Test() {
+	// 1.结束后关闭
+	defer s.rpcClient.Close()
+	// 使用连接,创建HelloService实例
+	rpcClient := rpc.NewGreeterClient(s.rpcClient)
+	// c := pb.NewGreeterClient(conn)
+
+	ctx, cancel := context.WithTimeout(context.Background(), time.Second)
+	defer cancel()
+	r, err := rpcClient.SayHello(ctx, &rpc.HelloRequest{Name: "caipin"})
+	if err != nil {
+		log.Fatalf("could not greet: %v", err)
+	}
+	log.Printf("Greeting: %s", r.GetMessage())
+}

+ 2 - 1
web/api/project_setting_api.go

@@ -128,7 +128,7 @@ func (c *ProjectSettingApi) PostAccountCreate() {
 
 	if err != nil {
 		ErrMsg = utils.FormValidError(err)
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": ErrMsg})
+		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", ErrMsg)})
 		return
 	} else {
 		projectId, err := utils.GetProjectId(c.Ctx)
@@ -202,6 +202,7 @@ func (c *ProjectSettingApi) PostAccountSave() {
 // @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
 // @Router /api/projectSetting/account/enable [post]
 func (c *ProjectSettingApi) PostAccountEnable() {
+	// 修改验证方式——TODO
 	accountVaild := viewmodels.ProjectAccount{}
 	err := c.Ctx.ReadJSON(&accountVaild)
 	if err != nil {

+ 24 - 0
web/api/rpc_api.go

@@ -0,0 +1,24 @@
+/*
+ * @description: rpc 实例
+ * @Author: CP
+ * @Date: 2020-11-12 22:49:59
+ * @FilePath: \construction_management\web\api\rpc_api.go
+ */
+package api
+
+import (
+	"github.com/kataras/iris/v12"
+	"go.mod/services"
+)
+
+type RpcApi struct {
+	//框架-web应用上下文环境
+	Ctx iris.Context
+	// 需要用的service
+	ServiceRpc services.RpcService
+}
+
+// 实例1
+func (c *RpcApi) Get() {
+	c.ServiceRpc.Test()
+}

+ 8 - 0
web/routes/routes.go

@@ -24,6 +24,7 @@ func Configure(b *bootstrap.Bootstrapper) {
 	BidsectionService := services.NewBidsectionService()
 	BidAccountService := services.NewBidAccountService()
 	ContractService := services.NewContractService()
+	RpcService := services.NewRpcService()
 	//CSRF相关
 	b.Use(middleware.SetCsrf)
 
@@ -121,4 +122,11 @@ func Configure(b *bootstrap.Bootstrapper) {
 	apiContract.Router.Use(middleware.SessionsAuth)
 	apiContract.Router.Use(middleware.AccessAuth)
 	apiContract.Handle(new(api.ContractApi))
+
+	// rpc相关
+	rpc := mvc.New(b.Party("/api/rpc/test"))
+	rpc.Register(RpcService)
+	rpc.Router.Use(middleware.SessionsAuth)
+	rpc.Router.Use(middleware.AccessAuth)
+	rpc.Handle(new(api.RpcApi))
 }

+ 1 - 1
web/viewmodels/project_account.go

@@ -14,7 +14,7 @@ import (
 
 type ProjectAccount struct {
 	Id           string `form:"id" json:"id"`
-	ProjectId    string `form:"projectid" json:"projectid"`
+	ProjectId    string `form:"projectId" json:"projectId"`
 	Account      string `form:"account" json:"account"`
 	Password     string `form:"password" json:"password"`
 	Name         string `form:"name" json:"name"`