wangxingcheng 3 лет назад
Родитель
Сommit
fd755bf598

+ 24 - 3
opms_parent/README.md

@@ -29,12 +29,12 @@
 - **文件命名:** 应一律使用小写, 不同单词之间用下划线分割。
 - **变量命名:** 一般采用驼峰式,当遇到特有名词(缩写或简称,如DNS)的时候,特有名词根据是否私有全部大写或小写。
 - **函数/方法命名:**
-采用驼峰式。将功能及必要的参数体现在名字中, 不要嫌长, 如updateById,getUserInfo.
+采用驼峰式。将功能及必要的参数体现在名字中, 不要嫌长, 如UpdateById,GetUserInfo.
 如果包外不需要访问请用小写开头的函数
 如果需要暴露出去给包外访问需要使用大写开头的函数名称
 
 
-### 快速开始
+### 开发环境配置
 #### 1、开发环境配置
 ![img.png](img.png)
 
@@ -47,11 +47,32 @@ Git:GOPROXY=https://goproxy.cn,direct;GOSUMDB=off;GOPRIVATE=code.dashoo.cn
 ```lua
 go mod tidy
 ```
-#### 3、数据库映射
+
+#### 3、数据库映射工具
+```lua
+如果Go版本为1.18以上,需要先执行:go get -u golang.org/x/sys
+git clone http://code.dashoo.cn/dashoo/modi_v2.git cd gf-cli && go build main.go && ./main install 
 ```
+
+### 快速开始
+#### 1、数据库表结构映射
+```lua
 gf gen dao -t base_table  -l "mysql:root:123456@(192.168.0.2:3306)/modi"
 -t 表名
 -l 数据库链接
 ```
+#### 2、创建Service、Handler类
+```lua
+
+
+```
+#### 3、配置路由信息
+```lua
+main.go
+// 注册服务对象
+s.RegisterName("Auth", new(handler.Auth), "")
+```
+
+
 
 

+ 2 - 2
opms_parent/app/dao/base_product.go → opms_parent/app/dao/base/base_product.go

@@ -2,10 +2,10 @@
 // This is auto-generated by gf cli tool only once. Fill this file as you wish.
 // ============================================================================
 
-package dao
+package base
 
 import (
-	"dashoo.cn/micro/app/dao/internal"
+	"dashoo.cn/micro/app/dao/base/internal"
 )
 
 // baseProductDao is the manager for logic model data accessing

+ 14 - 12
opms_parent/app/dao/internal/base_product.go → opms_parent/app/dao/base/internal/base_product.go

@@ -7,11 +7,13 @@ package internal
 import (
 	"context"
 	"database/sql"
+	"time"
+
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/frame/gmvc"
-	"time"
-	"dashoo.cn/micro/app/model"
+
+	"dashoo.cn/micro/app/model/base"
 )
 
 // BaseProductDao is the manager for logic model data accessing
@@ -290,12 +292,12 @@ func (d *BaseProductDao) Data(data ...interface{}) *BaseProductDao {
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *BaseProductDao) All(where ...interface{}) ([]*model.BaseProduct, error) {
+func (d *BaseProductDao) All(where ...interface{}) ([]*base.BaseProduct, error) {
 	all, err := d.M.All(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.BaseProduct
+	var entities []*base.BaseProduct
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -307,12 +309,12 @@ func (d *BaseProductDao) All(where ...interface{}) ([]*model.BaseProduct, error)
 //
 // The optional parameter <where> is the same as the parameter of M.Where function,
 // see M.Where.
-func (d *BaseProductDao) One(where ...interface{}) (*model.BaseProduct, error) {
+func (d *BaseProductDao) One(where ...interface{}) (*base.BaseProduct, error) {
 	one, err := d.M.One(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.BaseProduct
+	var entity *base.BaseProduct
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -321,12 +323,12 @@ func (d *BaseProductDao) One(where ...interface{}) (*model.BaseProduct, error) {
 
 // FindOne retrieves and returns a single Record by M.WherePri and M.One.
 // Also see M.WherePri and M.One.
-func (d *BaseProductDao) FindOne(where ...interface{}) (*model.BaseProduct, error) {
+func (d *BaseProductDao) FindOne(where ...interface{}) (*base.BaseProduct, error) {
 	one, err := d.M.FindOne(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entity *model.BaseProduct
+	var entity *base.BaseProduct
 	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -335,12 +337,12 @@ func (d *BaseProductDao) FindOne(where ...interface{}) (*model.BaseProduct, erro
 
 // FindAll retrieves and returns Result by by M.WherePri and M.All.
 // Also see M.WherePri and M.All.
-func (d *BaseProductDao) FindAll(where ...interface{}) ([]*model.BaseProduct, error) {
+func (d *BaseProductDao) FindAll(where ...interface{}) ([]*base.BaseProduct, error) {
 	all, err := d.M.FindAll(where...)
 	if err != nil {
 		return nil, err
 	}
-	var entities []*model.BaseProduct
+	var entities []*base.BaseProduct
 	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
 		return nil, err
 	}
@@ -413,9 +415,9 @@ func (d *BaseProductDao) Scan(pointer interface{}, where ...interface{}) error {
 }
 
 // Chunk iterates the table with given size and callback function.
-func (d *BaseProductDao) Chunk(limit int, callback func(entities []*model.BaseProduct, err error) bool) {
+func (d *BaseProductDao) Chunk(limit int, callback func(entities []*base.BaseProduct, err error) bool) {
 	d.M.Chunk(limit, func(result gdb.Result, err error) bool {
-		var entities []*model.BaseProduct
+		var entities []*base.BaseProduct
 		err = result.Structs(&entities)
 		if err == sql.ErrNoRows {
 			return false

+ 0 - 0
opms_parent/app/dao/.gitkeep → opms_parent/app/dao/cust/.gitkeep


+ 27 - 22
opms_parent/app/handler/product.go → opms_parent/app/handler/base/product.go

@@ -1,27 +1,30 @@
-package handler
+package base
 
 import (
 	"context"
+
 	"dashoo.cn/common_definition/comm_def"
-	"dashoo.cn/micro/app/model"
-	"dashoo.cn/micro/app/service"
 	"dashoo.cn/opms_libary/myerrors"
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/util/gvalid"
+
+	model "dashoo.cn/micro/app/model/base"
+	server "dashoo.cn/micro/app/service/base"
 )
 
 type ProductHandler struct{}
 
 // GetList 获取列表
 func (p *ProductHandler) GetList(ctx context.Context, req *model.BaseProductSearchReq, rsp *comm_def.CommonMsg) error {
-	productServer, err := service.NewBaseProductService(ctx)
+
+	productServer, err := server.NewProductService(ctx) //service.NewBaseProductService(ctx)
 	if err != nil {
 		g.Log().Error(err)
 		return err
 	}
-	g.Log().Info("搜索值",req)
-	total, list, err:=productServer.GetList(req)
+	g.Log().Info("搜索值", req)
+	total, list, err := productServer.GetList(req)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)
@@ -37,7 +40,7 @@ func (p *ProductHandler) Create(ctx context.Context, req *model.AddBaseProductRe
 	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {
 		return err
 	}
-	productServer, err := service.NewBaseProductService(ctx)
+	productServer, err := server.NewProductService(ctx)
 	if err != nil {
 		g.Log().Error(err)
 		return err
@@ -50,19 +53,19 @@ func (p *ProductHandler) Create(ctx context.Context, req *model.AddBaseProductRe
 	}
 	return nil
 }
-//单条删除数据
-func (p *ProductHandler)Delete(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
+
+//批量删除数据
+func (p *ProductHandler) DeleteByIds(ctx context.Context, req *model.DeIds, rsp *comm_def.CommonMsg) error {
 	// 参数校验
-	if req.Id == 0{
-		return gerror.New("参数有误!")
+	if len(req.Ids) == 0 {
+		return gerror.New("参数为空,操作失败")
 	}
-	productServer, err := service.NewBaseProductService(ctx)
+	productServer, err := server.NewProductService(ctx)
 	if err != nil {
 		g.Log().Error(err)
 		return gerror.New("系统异常,请重新尝试")
 	}
-
-	err = productServer.Delete(req.Id)
+	err = productServer.DeleteByIds(req.Ids)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)
@@ -70,18 +73,19 @@ func (p *ProductHandler)Delete(ctx context.Context, req *comm_def.IdReq, rsp *co
 	}
 	return nil
 }
+
 //编辑
-func (p *ProductHandler)Editinfo(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
+func (p *ProductHandler) GetEntityById(ctx context.Context, req *comm_def.IdReq, rsp *comm_def.CommonMsg) error {
 	// 参数校验
-	if req.Id == 0{
+	if req.Id == 0 {
 		return gerror.New("参数有误!")
 	}
-	productServer, err := service.NewBaseProductService(ctx)
+	productServer, err := server.NewProductService(ctx)
 	if err != nil {
 		g.Log().Error(err)
 		return gerror.New("系统异常,请重新尝试")
 	}
-	_,err = productServer.GetProductInfo(req.Id)
+	_, err = productServer.GetEntityById(req.Id)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)
@@ -89,14 +93,15 @@ func (p *ProductHandler)Editinfo(ctx context.Context, req *comm_def.IdReq, rsp *
 	}
 	return nil
 }
+
 //更新信息
-func (p *ProductHandler)UpdateInfo(ctx context.Context, req *model.UpdateBaseProductReq, rsp *comm_def.CommonMsg) error {
-	productServer, err := service.NewBaseProductService(ctx)
+func (p *ProductHandler) UpdateById(ctx context.Context, req *model.UpdateBaseProductReq, rsp *comm_def.CommonMsg) error {
+	productServer, err := server.NewProductService(ctx)
 	if err != nil {
 		g.Log().Error(err)
 		return gerror.New("系统异常,请重新尝试")
 	}
-	err = productServer.Update(req)
+	err = productServer.UpdateById(req)
 	_, err, rsp.Code, rsp.Msg = myerrors.CheckError(err)
 	if err != nil {
 		g.Log().Error(err)
@@ -104,4 +109,4 @@ func (p *ProductHandler)UpdateInfo(ctx context.Context, req *model.UpdateBasePro
 	}
 	return nil
 
-}
+}

+ 0 - 0
opms_parent/app/handler/.gitkeep → opms_parent/app/handler/cust/.gitkeep


+ 44 - 0
opms_parent/app/model/base/base_product.go

@@ -0,0 +1,44 @@
+// ==========================================================================
+// This is auto-generated by gf cli tool. Fill this file as you wish.
+// ==========================================================================
+
+package base
+
+import (
+	"dashoo.cn/opms_libary/request"
+
+	"dashoo.cn/micro/app/model/base/internal"
+)
+
+// BaseProduct is the golang structure for table base_product.
+type BaseProduct internal.BaseProduct
+
+// Fill with you ideas below.
+
+type BaseProductSearchReq struct {
+	KeyWords string `json:"prodCode"`
+	request.PageReq
+}
+
+//添加数据
+type AddBaseProductReq struct {
+	ProdCode    string `p:"prodCode"    json:"prodCode"   v:"required#产品编号不能为空"`
+	ProdName    string `p:"prodName"    json:"prodName"   v:"required#产品名称不能为空"`
+	ProdClass   string `p:"prodClass"   json:"prodClass"  v:"required#产品分类不能为空"`
+	GuidPrice   string `p:"guidPrice"   json:"guidPrice"      v:"required#建议成交价"`
+	DistPrice   string `p:"distPrice"   json:"distPrice"      v:"required#经销商价"`
+	AgentPrice  string `p:"agentPrice"  json:"agentPrice"    v:"required#签约代理价"`
+	MarketPrice string `p:"marketPrice" json:"marketPrice"   v:"required#市场报价"`
+	Remark      string
+}
+
+//修改数据
+type UpdateBaseProductReq struct {
+	*AddBaseProductReq
+	Id int `p:"id" v:"required# id不能为空"`
+}
+
+//批量删除
+type DeIds struct {
+	Ids []int64 `json:"ids,omitempty,string"`
+}

+ 0 - 0
opms_parent/app/model/internal/base_product.go → opms_parent/app/model/base/internal/base_product.go


+ 0 - 33
opms_parent/app/model/base_product.go

@@ -1,33 +0,0 @@
-// ==========================================================================
-// This is auto-generated by gf cli tool. Fill this file as you wish.
-// ==========================================================================
-
-package model
-
-import (
-	"dashoo.cn/micro/app/model/internal"
-	"dashoo.cn/opms_libary/request"
-)
-
-// BaseProduct is the golang structure for table base_product.
-type BaseProduct internal.BaseProduct
-
-// Fill with you ideas below.
-
-type BaseProductSearchReq struct {
-	KeyWords string `json:"prodCode"`
-	request.PageReq
-}
-//添加数据
-type AddBaseProductReq struct {
-	ProdCode  string     `p:"prodCode" v:"required#产品编号不能为空"`
-	ProdName  string     `p:"prodName" v:"required#产品名称不能为空"`
-	ProdClass string     `p:"prodClass" v:"required#产品分类不能为空"`
-	GuidPrice float64    `p:"guidPrice" json:"guidPrice,string" v:"required#建议成交价"`
-	Remark    string
-}
-//修改数据
-type UpdateBaseProductReq struct{
-	AddBaseProductReq
-	Id int `p:"id" v:"required# id不能为空"`
-}

+ 0 - 0
opms_parent/app/model/.gitkeep → opms_parent/app/model/cust/.gitkeep


+ 3 - 2
opms_parent/app/service/base.go

@@ -7,8 +7,9 @@ import (
 )
 
 var (
-	// UpdateFieldEx 更新过滤字段
-	UpdateFieldEx = []string{"CreatedBy", "CreatedName", "CreatedTime"}
+	// CommonUpdateFieldEx, UpdateFieldEx 更新过滤字段
+	CommonUpdateFieldEx = []interface{}{"created_by", "created_name", "created_time"}
+	UpdateFieldEx       = []interface{}{"id", "created_by", "created_name", "created_time"}
 )
 
 // SetCreatedInfo 插入数据库时设置创建信息

+ 126 - 0
opms_parent/app/service/base/base_product.go

@@ -0,0 +1,126 @@
+package base
+
+import (
+	"context"
+	"fmt"
+
+	"github.com/gogf/gf/errors/gerror"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/util/gconv"
+	"github.com/gogf/gf/util/gvalid"
+
+	"dashoo.cn/micro/app/dao/base"
+	model "dashoo.cn/micro/app/model/base"
+	"dashoo.cn/micro/app/service"
+)
+
+type productService struct {
+	*contextService
+
+	Dao *base.BaseProductDao
+}
+
+func NewProductService(ctx context.Context) (svc *productService, err error) {
+	svc = new(productService)
+	if svc.contextService, err = svc.Init(ctx); err != nil {
+		return nil, err
+	}
+	svc.Dao = base.NewBaseProductDao(svc.Tenant)
+	return svc, nil
+}
+
+//产品信息列表
+func (p *productService) GetList(req *model.BaseProductSearchReq) (total int, productList []*model.BaseProduct, err error) {
+
+	productModel := p.Dao.M
+	if req.KeyWords != "" {
+		productModel = productModel.Where("prod_code", req.KeyWords)
+
+	}
+	total, err = productModel.Count()
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("获取总行数失败")
+		return
+	}
+	if req.PageNum == 0 {
+		req.PageNum = 1
+	}
+
+	err = productModel.Page(req.PageNum, req.PageSize).Order("id asc").Scan(&productList)
+	return
+}
+
+//添加信息
+func (p *productService) Create(req *model.AddBaseProductReq) (err error) {
+	productData := new(model.BaseProduct)
+	if err = gconv.Struct(req, productData); err != nil {
+		return
+	}
+	service.SetCreatedInfo(productData, p.GetCxtUserId(), p.GetCxtUserName())
+	Model := p.Dao.M
+	res, err := Model.Insert(productData)
+	if err != nil {
+		return
+	}
+	InsertId, _ := res.LastInsertId()
+	fmt.Println(InsertId)
+	return
+}
+
+//删掉数据
+func (p *productService) DeleteByIds(dicIds []int64) (err error) {
+	_, err = base.BaseProduct.Fields(base.BaseProduct.Columns.CreatedTime).
+		Where(base.BaseProduct.Columns.Id+" in (?) ", dicIds).All()
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("没有要删除的数据")
+		return
+	}
+	_, err = p.Dao.Delete(base.BaseProduct.Columns.Id+" in (?) ", dicIds)
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("删除数据失败")
+		return err
+	}
+	return
+}
+
+//修改数据
+func (p *productService) UpdateById(req *model.UpdateBaseProductReq) (err error) {
+	//uptime := gtime.New(time.Now())
+	db := p.Dao.M
+	record, err := db.FindOne("Id", req.Id)
+	if err != nil || record.IsEmpty() {
+		err = gerror.New("该数据不存在")
+		return err
+	}
+	gvalid.CheckValue()
+	g.Validator().CheckValue()
+	proInfo := record.Map()
+	fmt.Println(proInfo["created_time"])
+	productData := new(model.BaseProduct)
+	if err = gconv.Struct(req, productData); err != nil {
+		return
+	}
+	service.SetUpdatedInfo(productData, p.GetCxtUserId(), p.GetCxtUserName())
+	_, err = db.FieldsEx(base.BaseProduct.Columns.CreatedTime, base.BaseProduct.Columns.CreatedBy, base.BaseProduct.Columns.CreatedName).
+		WherePri(base.BaseProduct.Columns.Id, req.Id).Update(productData)
+
+	if err != nil {
+		g.Log().Error(err)
+		err = gerror.New("修改用户信息失败")
+		return
+	}
+	return
+}
+
+//编辑查询单条查询
+func (p *productService) GetEntityById(id int64) (product *model.BaseProduct, err error) {
+	err = p.Dao.Where(base.BaseProduct.Columns.Id, id).Scan(&product)
+	if err != nil {
+		g.Log().Error(err)
+		return nil, gerror.New("获取用户数据失败")
+	}
+	return
+}

+ 2 - 1
opms_parent/app/service/context.go → opms_parent/app/service/base/context.go

@@ -1,7 +1,8 @@
-package service
+package base
 
 import (
 	"context"
+
 	"dashoo.cn/opms_libary/micro_srv"
 	"dashoo.cn/opms_libary/request"
 	"github.com/gogf/gf/os/glog"

+ 0 - 112
opms_parent/app/service/base_product.go

@@ -1,112 +0,0 @@
-package service
-import (
-	"context"
-	"dashoo.cn/micro/app/dao"
-	"dashoo.cn/micro/app/model"
-	"fmt"
-	"github.com/gogf/gf/errors/gerror"
-	"github.com/gogf/gf/frame/g"
-	"github.com/gogf/gf/os/gtime"
-	"github.com/gogf/gf/util/gconv"
-	"time"
-)
-
-type baseProductService struct {
-	*contextService
-	Dao *dao.BaseProductDao
-}
-
-func NewBaseProductService(ctx context.Context) (svc *baseProductService, err error) {
-	svc = new(baseProductService)
-	if svc.contextService, err = svc.Init(ctx); err != nil {
-		return nil, err
-	}
-	svc.Dao = dao.NewBaseProductDao(svc.Tenant)
-	return svc, nil
-}
-//产品信息列表
-func (p *baseProductService)GetList (req *model.BaseProductSearchReq)(total int, productList []*model.BaseProduct, err error){
-	productModel := dao.BaseProduct.M
-	if req.KeyWords != "" {
-		productModel = productModel.Where("prod_code =", req.KeyWords)
-
-	}
-	total, err = productModel.Count()
-	if err != nil {
-		g.Log().Error(err)
-		err = gerror.New("获取总行数失败")
-		return
-	}
-	if req.PageNum == 0 {
-		req.PageNum = 1
-	}
-	err = productModel.Page(req.PageNum, req.PageSize).Order("id asc").Scan(&productList)
-	return
-}
-//添加信息
-func (p *baseProductService)Create (req *model.AddBaseProductReq) (err error){
-	t1 := gtime.New(time.Now())
-	fmt.Println(t1)
-	productData := new(model.BaseProduct)
-	if err = gconv.Struct(req, productData); err != nil {
-		return
-	}
-	Model := dao.BaseProduct.M
-	productData.CreatedTime = t1
-	productData.UpdatedTime = t1
-	res, err := Model.Insert(productData)
-	if err != nil {
-		return
-	}
-	InsertId, _ := res.LastInsertId()
-	fmt.Println(InsertId)
-	return
-}
-//删掉数据
-func (p *baseProductService)Delete(id int64)(err error){
-	db := dao.BaseProduct.M
-	record, err := db.FindOne("Id", id)
-	if err != nil {
-		return err
-	}
-	if record.IsEmpty() {
-		return gerror.New("该数据不存在")
-	}
-	_, err = db.Delete("Id", id)
-	return err
-}
-//修改数据
-func(p *baseProductService)Update(req *model.UpdateBaseProductReq)(err error){
-	uptime := gtime.New(time.Now())
-	db := dao.BaseProduct.M
-	record, err := db.FindOne("Id", req.Id)
-	if err != nil || record.IsEmpty(){
-		err = gerror.New("该数据不存在")
-		return err
-	}
-	fmt.Println(record.Map())
-	productData := new(model.BaseProduct)
-	if err = gconv.Struct(req, productData); err != nil {
-		return
-	}
-	mapinfo:=record.Map()
-	productData.CreatedTime = mapinfo[""]
-	productData.UpdatedTime = uptime
-	_,err=db.Where(req.Id).Update(productData)
-	if err!=nil{
-		g.Log().Error(err)
-		err = gerror.New("修改用户信息失败")
-		return
-	}
-	return
-}
-//编辑查询单条查询
-func (p *baseProductService)GetProductInfo(id int64)(product *model.BaseProduct,err error){
-	err = dao.BaseProduct.Where(dao.BaseProduct.Columns.Id, id).Scan(&product)
-	if err != nil {
-		g.Log().Error(err)
-		return nil, gerror.New("获取用户数据失败")
-	}
-	return
-}
-

+ 0 - 0
opms_parent/app/service/.gitkeep → opms_parent/app/service/cust/.gitkeep


+ 6 - 4
opms_parent/main.go

@@ -2,7 +2,9 @@ package main
 
 import (
 	"context"
-	"dashoo.cn/micro/app/handler"
+
+	"dashoo.cn/micro/app/handler/base"
+
 	"dashoo.cn/opms_libary/micro_srv"
 	"github.com/gogf/gf/frame/g"
 	"github.com/smallnest/rpcx/protocol"
@@ -13,7 +15,7 @@ func main() {
 	basePath := g.Config().GetString("setting.srv-name")
 	// 创建总服务包
 	s := micro_srv.CreateAndInitService(basePath)
-	s.RegisterName("Product", new(handler.ProductHandler), "")
+	s.RegisterName("Product", new(base.ProductHandler), "")
 
 	// 注册服务对象
 	//s.RegisterName("Auth", new(handler.Auth), "")
@@ -21,7 +23,7 @@ func main() {
 	// 注册文件处理Service对象
 	//dynamic.BeanFactory.BeanRegister(service.NewRoleService())
 	// 注册auth处理
-	//s.AuthFunc = handleAuth
+	s.AuthFunc = handleAuth
 	// 运行服务
 	if err := s.Serve("tcp", srvAddr); err != nil {
 		g.Log().Fatal(err)
@@ -41,6 +43,6 @@ var AuthExcludePaths = []string{
 
 // 处理Auth
 func handleAuth(ctx context.Context, req *protocol.Message, token string) error {
-	return  micro_srv.HandleAuth(ctx, req, token, AuthExcludePaths)
+	return micro_srv.HandleAuth(ctx, req, token, AuthExcludePaths)
 
 }