作者 yangfu

增加:

1.增加日志记录
2.权限过期时间修改
3.客户端版本管理
4.操作日志
正在显示 48 个修改的文件 包含 1698 行增加10 行删除
@@ -12,4 +12,4 @@ require ( @@ -12,4 +12,4 @@ require (
12 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 12 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
13 ) 13 )
14 14
15 -//replace github.com/tiptok/gocomm v1.0.2 => F:\go\src\learn_project\gocomm 15 +replace github.com/tiptok/gocomm v1.0.3 => F:\go\src\learn_project\gocomm
@@ -2,6 +2,9 @@ package main @@ -2,6 +2,9 @@ package main
2 2
3 import ( 3 import (
4 "github.com/astaxie/beego" 4 "github.com/astaxie/beego"
  5 + "github.com/tiptok/gocomm/config"
  6 + "github.com/tiptok/gocomm/pkg/log"
  7 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/constant"
5 _ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/constant" 8 _ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/constant"
6 _ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/pg" 9 _ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/pg"
7 _ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/redis" 10 _ "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/redis"
@@ -13,5 +16,10 @@ func main() { @@ -13,5 +16,10 @@ func main() {
13 16
14 }() 17 }()
15 beego.BConfig.CopyRequestBody = true 18 beego.BConfig.CopyRequestBody = true
  19 +
  20 + log.InitLog(config.Logger{
  21 + Filename: constant.LOG_File,
  22 + Level: constant.LOG_LEVEL,
  23 + })
16 beego.Run() 24 beego.Run()
17 } 25 }
@@ -46,7 +46,7 @@ func (svr *AuthService) Login(header *protocol.RequestHeader, request *protocolx @@ -46,7 +46,7 @@ func (svr *AuthService) Login(header *protocol.RequestHeader, request *protocolx
46 err = protocol.NewCustomMessage(1, "密码有误!") 46 err = protocol.NewCustomMessage(1, "密码有误!")
47 return 47 return
48 } 48 }
49 - token, _ := common.GenerateToken(fmt.Sprintf("%v", user.Id), user.Passwd) 49 + token, _ := common.GenerateToken(fmt.Sprintf("%v", user.Id), user.Passwd, common.WithExpire(domain.TokenExpire), common.WithAddData(map[string]interface{}{"UserName": user.Name}))
50 rsp.Access = map[string]interface{}{ 50 rsp.Access = map[string]interface{}{
51 "accessToken": "Bearer " + token, 51 "accessToken": "Bearer " + token,
52 "expiresIn": domain.TokenExpire, 52 "expiresIn": domain.TokenExpire,
@@ -165,6 +165,7 @@ func (svr *AuthService) CaptchaInit(header *protocol.RequestHeader, request *pro @@ -165,6 +165,7 @@ func (svr *AuthService) CaptchaInit(header *protocol.RequestHeader, request *pro
165 func (svr *AuthService) ChangePassword(header *protocol.RequestHeader, request *protocolx.ChangePasswordRequest) (rsp *protocolx.ChangePasswordResponse, err error) { 165 func (svr *AuthService) ChangePassword(header *protocol.RequestHeader, request *protocolx.ChangePasswordRequest) (rsp *protocolx.ChangePasswordResponse, err error) {
166 var ( 166 var (
167 transactionContext, _ = factory.CreateTransactionContext(nil) 167 transactionContext, _ = factory.CreateTransactionContext(nil)
  168 + UserRepository, _ = factory.CreateUserRepository(transactionContext)
168 ) 169 )
169 rsp = &protocolx.ChangePasswordResponse{} 170 rsp = &protocolx.ChangePasswordResponse{}
170 if err = request.ValidateCommand(); err != nil { 171 if err = request.ValidateCommand(); err != nil {
@@ -178,6 +179,20 @@ func (svr *AuthService) ChangePassword(header *protocol.RequestHeader, request * @@ -178,6 +179,20 @@ func (svr *AuthService) ChangePassword(header *protocol.RequestHeader, request *
178 transactionContext.RollbackTransaction() 179 transactionContext.RollbackTransaction()
179 }() 180 }()
180 181
  182 + var user *domain.Users
  183 + if user, err = UserRepository.FindOne(map[string]interface{}{"phone": request.Phone}); err != nil {
  184 + err = protocol.NewCustomMessage(1, "用户不存在")
  185 + return
  186 + }
  187 + if user.Passwd != request.OldPwd {
  188 + err = protocol.NewCustomMessage(1, "旧密码输入有误")
  189 + return
  190 + }
  191 + user.Passwd = request.NewPwd
  192 + if _, err = UserRepository.Save(user); err != nil {
  193 + return
  194 + }
  195 +
181 err = transactionContext.CommitTransaction() 196 err = transactionContext.CommitTransaction()
182 return 197 return
183 } 198 }
@@ -76,7 +76,7 @@ func (svr *CacheService) ValidUserAccess(userId int64, object string, method str @@ -76,7 +76,7 @@ func (svr *CacheService) ValidUserAccess(userId int64, object string, method str
76 var userAccess []*domain.Access 76 var userAccess []*domain.Access
77 var isAdmin bool 77 var isAdmin bool
78 defer func() { 78 defer func() {
79 - log.Info(fmt.Sprintf("ValidUserAccess user:%v object:%v method:%v result:%v", userId, object, method, result)) 79 + //log.Info(fmt.Sprintf("ValidUserAccess user:%v object:%v method:%v result:%v", userId, object, method, result))
80 }() 80 }()
81 if isAdmin, err = svr.ValidUser(userId); err != nil { 81 if isAdmin, err = svr.ValidUser(userId); err != nil {
82 return 82 return
  1 +package client_version
  2 +
  3 +import (
  4 + "github.com/tiptok/gocomm/common"
  5 + "github.com/tiptok/gocomm/pkg/log"
  6 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
  7 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
  9 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
  10 + protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/client_version"
  11 + "time"
  12 +)
  13 +
  14 +type ClientVersionService struct {
  15 +}
  16 +
  17 +func (svr *ClientVersionService) CreateClientVersion(header *protocol.RequestHeader, request *protocolx.CreateClientVersionRequest) (rsp interface{}, err error) {
  18 + var (
  19 + transactionContext, _ = factory.CreateTransactionContext(nil)
  20 + )
  21 + rsp = &protocolx.CreateClientVersionResponse{}
  22 + if err = request.ValidateCommand(); err != nil {
  23 + err = protocol.NewCustomMessage(2, err.Error())
  24 + return
  25 + }
  26 + if err = transactionContext.StartTransaction(); err != nil {
  27 + log.Error(err)
  28 + return nil, err
  29 + }
  30 + defer func() {
  31 + transactionContext.RollbackTransaction()
  32 + }()
  33 + newClientVersion := &domain.ClientVersion{
  34 + Commiter: header.UserId,
  35 + ProjectName: request.ProjectName,
  36 + Version: request.Version,
  37 + Title: request.Title,
  38 + Remark: request.Remark,
  39 + ClientPackageInfo: request.ClientPackageInfo,
  40 + CreateTime: time.Now(),
  41 + }
  42 +
  43 + var ClientVersionRepository, _ = factory.CreateClientVersionRepository(transactionContext)
  44 + if m, err := ClientVersionRepository.Save(newClientVersion); err != nil {
  45 + return nil, err
  46 + } else {
  47 + rsp = m
  48 + }
  49 + err = transactionContext.CommitTransaction()
  50 + return
  51 +}
  52 +
  53 +func (svr *ClientVersionService) UpdateClientVersion(header *protocol.RequestHeader, request *protocolx.UpdateClientVersionRequest) (rsp interface{}, err error) {
  54 + var (
  55 + transactionContext, _ = factory.CreateTransactionContext(nil)
  56 + )
  57 + rsp = &protocolx.UpdateClientVersionResponse{}
  58 + if err = request.ValidateCommand(); err != nil {
  59 + err = protocol.NewCustomMessage(2, err.Error())
  60 + return
  61 + }
  62 + if err = transactionContext.StartTransaction(); err != nil {
  63 + log.Error(err)
  64 + return nil, err
  65 + }
  66 + defer func() {
  67 + transactionContext.RollbackTransaction()
  68 + }()
  69 +
  70 + var ClientVersionRepository, _ = factory.CreateClientVersionRepository(transactionContext)
  71 + var clientVersion *domain.ClientVersion
  72 + if clientVersion, err = ClientVersionRepository.FindOne(map[string]interface{}{"id": request.Id}); err != nil {
  73 + return
  74 + }
  75 + if err = clientVersion.Update(common.ObjectToMap(request)); err != nil {
  76 + return
  77 + }
  78 + if clientVersion, err = ClientVersionRepository.Save(clientVersion); err != nil {
  79 + return
  80 + }
  81 + err = transactionContext.CommitTransaction()
  82 + return
  83 +}
  84 +
  85 +func (svr *ClientVersionService) GetClientVersion(header *protocol.RequestHeader, request *protocolx.GetClientVersionRequest) (rsp interface{}, err error) {
  86 + var (
  87 + transactionContext, _ = factory.CreateTransactionContext(nil)
  88 + )
  89 + rsp = &protocolx.GetClientVersionResponse{}
  90 + if err = request.ValidateCommand(); err != nil {
  91 + err = protocol.NewCustomMessage(2, err.Error())
  92 + return
  93 + }
  94 + if err = transactionContext.StartTransaction(); err != nil {
  95 + log.Error(err)
  96 + return nil, err
  97 + }
  98 + defer func() {
  99 + transactionContext.RollbackTransaction()
  100 + }()
  101 +
  102 + var ClientVersionRepository, _ = factory.CreateClientVersionRepository(transactionContext)
  103 + var clientVersion *domain.ClientVersion
  104 + if clientVersion, err = ClientVersionRepository.FindOne(common.ObjectToMap(request)); err != nil {
  105 + return
  106 + }
  107 + rsp = clientVersion
  108 + err = transactionContext.CommitTransaction()
  109 + return
  110 +}
  111 +
  112 +func (svr *ClientVersionService) DeleteClientVersion(header *protocol.RequestHeader, request *protocolx.DeleteClientVersionRequest) (rsp interface{}, err error) {
  113 + var (
  114 + transactionContext, _ = factory.CreateTransactionContext(nil)
  115 + )
  116 + rsp = &protocolx.DeleteClientVersionResponse{}
  117 + if err = request.ValidateCommand(); err != nil {
  118 + err = protocol.NewCustomMessage(2, err.Error())
  119 + return
  120 + }
  121 + if err = transactionContext.StartTransaction(); err != nil {
  122 + log.Error(err)
  123 + return nil, err
  124 + }
  125 + defer func() {
  126 + transactionContext.RollbackTransaction()
  127 + }()
  128 +
  129 + var ClientVersionRepository, _ = factory.CreateClientVersionRepository(transactionContext)
  130 + var clientVersion *domain.ClientVersion
  131 + if clientVersion, err = ClientVersionRepository.FindOne(common.ObjectToMap(request)); err != nil {
  132 + return
  133 + }
  134 + if clientVersion, err = ClientVersionRepository.Remove(clientVersion); err != nil {
  135 + return
  136 + }
  137 + rsp = clientVersion
  138 + err = transactionContext.CommitTransaction()
  139 + return
  140 +}
  141 +
  142 +func (svr *ClientVersionService) ListClientVersion(header *protocol.RequestHeader, request *protocolx.ListClientVersionRequest) (rsp interface{}, err error) {
  143 + var (
  144 + transactionContext, _ = factory.CreateTransactionContext(nil)
  145 + )
  146 + rsp = &protocolx.ListClientVersionResponse{}
  147 + if err = request.ValidateCommand(); err != nil {
  148 + err = protocol.NewCustomMessage(2, err.Error())
  149 + return
  150 + }
  151 + if err = transactionContext.StartTransaction(); err != nil {
  152 + log.Error(err)
  153 + return nil, err
  154 + }
  155 + defer func() {
  156 + transactionContext.RollbackTransaction()
  157 + }()
  158 +
  159 + var ClientVersionRepository, _ = factory.CreateClientVersionRepository(transactionContext)
  160 + var clientVersion []*domain.ClientVersion
  161 + var total int64
  162 + if total, clientVersion, err = ClientVersionRepository.Find(common.ObjectToMap(request)); err != nil {
  163 + return
  164 + }
  165 + rsp = map[string]interface{}{
  166 + "totalRow": total,
  167 + "pageNumber": (request.Offset + request.Limit) / request.Limit,
  168 + "list": utils.LoadCustomField(clientVersion, "Id", "ProjectName", "Version", "Title", "Remark", "CreateTime"),
  169 + }
  170 + err = transactionContext.CommitTransaction()
  171 + return
  172 +}
  173 +
  174 +func NewClientVersionService(options map[string]interface{}) *ClientVersionService {
  175 + svr := &ClientVersionService{}
  176 + return svr
  177 +}
@@ -37,3 +37,11 @@ func CreateRoleRepository(transactionContext *transaction.TransactionContext) (d @@ -37,3 +37,11 @@ func CreateRoleRepository(transactionContext *transaction.TransactionContext) (d
37 func CreateUserRepository(transactionContext *transaction.TransactionContext) (domain.UsersRepository, error) { 37 func CreateUserRepository(transactionContext *transaction.TransactionContext) (domain.UsersRepository, error) {
38 return repository.NewUserRepository(transactionContext) 38 return repository.NewUserRepository(transactionContext)
39 } 39 }
  40 +
  41 +func CreateClientVersionRepository(transactionContext *transaction.TransactionContext) (domain.ClientVersionRepository, error) {
  42 + return repository.NewClientVersionRepository(transactionContext)
  43 +}
  44 +
  45 +func CreateOperatorLogRepository(transactionContext *transaction.TransactionContext) (domain.OperatorLogRepository, error) {
  46 + return repository.NewOperatorLogRepository(transactionContext)
  47 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "github.com/tiptok/gocomm/common"
  5 + "github.com/tiptok/gocomm/pkg/log"
  6 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
  7 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
  9 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
  10 + protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/operator_log"
  11 +)
  12 +
  13 +type OperatorLogService struct {
  14 +}
  15 +
  16 +func (svr *OperatorLogService) CreateOperatorLog(header *protocol.RequestHeader, request *protocolx.CreateOperatorLogRequest) (rsp interface{}, err error) {
  17 + var (
  18 + transactionContext, _ = factory.CreateTransactionContext(nil)
  19 + )
  20 + rsp = &protocolx.CreateOperatorLogResponse{}
  21 + if err = request.ValidateCommand(); err != nil {
  22 + err = protocol.NewCustomMessage(2, err.Error())
  23 + return
  24 + }
  25 + if err = transactionContext.StartTransaction(); err != nil {
  26 + log.Error(err)
  27 + return nil, err
  28 + }
  29 + defer func() {
  30 + transactionContext.RollbackTransaction()
  31 + }()
  32 + newOperatorLog := &domain.OperatorLog{
  33 + Operator: request.Commiter,
  34 + Code: request.Code,
  35 + Content: request.Content,
  36 + }
  37 +
  38 + var OperatorLogRepository, _ = factory.CreateOperatorLogRepository(transactionContext)
  39 + if m, err := OperatorLogRepository.Save(newOperatorLog); err != nil {
  40 + return nil, err
  41 + } else {
  42 + rsp = m
  43 + }
  44 + err = transactionContext.CommitTransaction()
  45 + return
  46 +}
  47 +
  48 +func (svr *OperatorLogService) UpdateOperatorLog(header *protocol.RequestHeader, request *protocolx.UpdateOperatorLogRequest) (rsp interface{}, err error) {
  49 + var (
  50 + transactionContext, _ = factory.CreateTransactionContext(nil)
  51 + )
  52 + rsp = &protocolx.UpdateOperatorLogResponse{}
  53 + if err = request.ValidateCommand(); err != nil {
  54 + err = protocol.NewCustomMessage(2, err.Error())
  55 + return
  56 + }
  57 + if err = transactionContext.StartTransaction(); err != nil {
  58 + log.Error(err)
  59 + return nil, err
  60 + }
  61 + defer func() {
  62 + transactionContext.RollbackTransaction()
  63 + }()
  64 +
  65 + var OperatorLogRepository, _ = factory.CreateOperatorLogRepository(transactionContext)
  66 + var operatorLog *domain.OperatorLog
  67 + if operatorLog, err = OperatorLogRepository.FindOne(common.ObjectToMap(request)); err != nil {
  68 + return
  69 + }
  70 + if err = operatorLog.Update(common.ObjectToMap(request)); err != nil {
  71 + return
  72 + }
  73 + if operatorLog, err = OperatorLogRepository.Save(operatorLog); err != nil {
  74 + return
  75 + }
  76 + err = transactionContext.CommitTransaction()
  77 + return
  78 +}
  79 +
  80 +func (svr *OperatorLogService) GetOperatorLog(header *protocol.RequestHeader, request *protocolx.GetOperatorLogRequest) (rsp interface{}, err error) {
  81 + var (
  82 + transactionContext, _ = factory.CreateTransactionContext(nil)
  83 + )
  84 + rsp = &protocolx.GetOperatorLogResponse{}
  85 + if err = request.ValidateCommand(); err != nil {
  86 + err = protocol.NewCustomMessage(2, err.Error())
  87 + return
  88 + }
  89 + if err = transactionContext.StartTransaction(); err != nil {
  90 + log.Error(err)
  91 + return nil, err
  92 + }
  93 + defer func() {
  94 + transactionContext.RollbackTransaction()
  95 + }()
  96 +
  97 + var OperatorLogRepository, _ = factory.CreateOperatorLogRepository(transactionContext)
  98 + var operatorLog *domain.OperatorLog
  99 + if operatorLog, err = OperatorLogRepository.FindOne(common.ObjectToMap(request)); err != nil {
  100 + return
  101 + }
  102 + rsp = operatorLog
  103 + err = transactionContext.CommitTransaction()
  104 + return
  105 +}
  106 +
  107 +func (svr *OperatorLogService) DeleteOperatorLog(header *protocol.RequestHeader, request *protocolx.DeleteOperatorLogRequest) (rsp interface{}, err error) {
  108 + var (
  109 + transactionContext, _ = factory.CreateTransactionContext(nil)
  110 + )
  111 + rsp = &protocolx.DeleteOperatorLogResponse{}
  112 + if err = request.ValidateCommand(); err != nil {
  113 + err = protocol.NewCustomMessage(2, err.Error())
  114 + return
  115 + }
  116 + if err = transactionContext.StartTransaction(); err != nil {
  117 + log.Error(err)
  118 + return nil, err
  119 + }
  120 + defer func() {
  121 + transactionContext.RollbackTransaction()
  122 + }()
  123 +
  124 + var OperatorLogRepository, _ = factory.CreateOperatorLogRepository(transactionContext)
  125 + var operatorLog *domain.OperatorLog
  126 + if operatorLog, err = OperatorLogRepository.FindOne(common.ObjectToMap(request)); err != nil {
  127 + return
  128 + }
  129 + if operatorLog, err = OperatorLogRepository.Remove(operatorLog); err != nil {
  130 + return
  131 + }
  132 + rsp = operatorLog
  133 + err = transactionContext.CommitTransaction()
  134 + return
  135 +}
  136 +
  137 +func (svr *OperatorLogService) ListOperatorLog(header *protocol.RequestHeader, request *protocolx.ListOperatorLogRequest) (rsp interface{}, err error) {
  138 + var (
  139 + transactionContext, _ = factory.CreateTransactionContext(nil)
  140 + )
  141 + rsp = &protocolx.ListOperatorLogResponse{}
  142 + if err = request.ValidateCommand(); err != nil {
  143 + err = protocol.NewCustomMessage(2, err.Error())
  144 + return
  145 + }
  146 + if err = transactionContext.StartTransaction(); err != nil {
  147 + log.Error(err)
  148 + return nil, err
  149 + }
  150 + defer func() {
  151 + transactionContext.RollbackTransaction()
  152 + }()
  153 +
  154 + var OperatorLogRepository, _ = factory.CreateOperatorLogRepository(transactionContext)
  155 + var operatorLog []*domain.OperatorLog
  156 + var total int64
  157 + if total, operatorLog, err = OperatorLogRepository.Find(common.ObjectToMap(request)); err != nil {
  158 + return
  159 + }
  160 + rsp = map[string]interface{}{
  161 + "total": total,
  162 + "list": utils.LoadCustomField(operatorLog, "Id", "Operator", "Content", "CreateTime"),
  163 + }
  164 + err = transactionContext.CommitTransaction()
  165 + return
  166 +}
  167 +
  168 +func NewOperatorLogService(options map[string]interface{}) *OperatorLogService {
  169 + svr := &OperatorLogService{}
  170 + return svr
  171 +}
1 package project_module_files 1 package project_module_files
2 2
3 import ( 3 import (
  4 + "bytes"
4 "github.com/tiptok/gocomm/common" 5 "github.com/tiptok/gocomm/common"
5 "github.com/tiptok/gocomm/pkg/log" 6 "github.com/tiptok/gocomm/pkg/log"
6 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory" 7 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/factory"
@@ -109,7 +110,25 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol. @@ -109,7 +110,25 @@ func (svr *ProjectModuleFilesService) UpdateProjectModuleFiles(header *protocol.
109 } 110 }
110 // TODO:移动文件文件夹时pid变更,底下路径需要都变掉 111 // TODO:移动文件文件夹时pid变更,底下路径需要都变掉
111 112
112 - // TODO:变更记录 113 + // 变更记录
  114 + var OperatorLogRepository, _ = factory.CreateOperatorLogRepository(transactionContext)
  115 + //var UserRepository, _ = factory.CreateUserRepository(transactionContext)
  116 + //user, _ := UserRepository.FindOne(map[string]interface{}{"id": header.UserId})
  117 + //if user == nil {
  118 + // return
  119 + //}
  120 + var OpLog *domain.OperatorLog = &domain.OperatorLog{
  121 + UserId: header.UserId,
  122 + Operator: header.UserName,
  123 + Code: domain.LogCodeEditModuleFile,
  124 + ResourceId: request.Id,
  125 + Content: changeLog(request, projectModuleFiles),
  126 + CreateTime: time.Now(),
  127 + }
  128 + if _, err = OperatorLogRepository.Save(OpLog); err != nil {
  129 + return
  130 + }
  131 +
113 err = transactionContext.CommitTransaction() 132 err = transactionContext.CommitTransaction()
114 return 133 return
115 } 134 }
@@ -361,6 +380,19 @@ func traverse(list []*protocolx.ModuleFiles, file *domain.ProjectModuleFiles) { @@ -361,6 +380,19 @@ func traverse(list []*protocolx.ModuleFiles, file *domain.ProjectModuleFiles) {
361 } 380 }
362 return 381 return
363 } 382 }
  383 +func changeLog(request *protocolx.UpdateProjectModuleFilesRequest, old *domain.ProjectModuleFiles) string {
  384 + buf := bytes.NewBuffer(nil)
  385 + if len(request.FileName) > 0 {
  386 + buf.WriteString(" 修改文件名为:" + request.FileName + "\n")
  387 + }
  388 + if len(request.Remark) > 0 {
  389 + buf.WriteString(" 修改描述信息为:" + request.Remark + "\n")
  390 + }
  391 + if len(request.CodeBlock) > 0 {
  392 + buf.WriteString(" 修改模板代码")
  393 + }
  394 + return buf.String()
  395 +}
364 func NewProjectModuleFilesService(options map[string]interface{}) *ProjectModuleFilesService { 396 func NewProjectModuleFilesService(options map[string]interface{}) *ProjectModuleFilesService {
365 svr := &ProjectModuleFilesService{} 397 svr := &ProjectModuleFilesService{}
366 return svr 398 return svr
  1 +package constant
  2 +
  3 +import (
  4 + "os"
  5 +)
  6 +
  7 +const SERVICE_NAME = "godevp"
  8 +
  9 +var LOG_LEVEL = "debug"
  10 +var LOG_File = "app.log"
  11 +
  12 +var MMM_SMS_SERVICE_HOST = "https://sms.fjmaimaimai.com:9897"
  13 +
  14 +//0:正式版 1:开发版 2:体验版
  15 +func init() {
  16 + if os.Getenv("LOG_LEVEL") != "" {
  17 + LOG_LEVEL = os.Getenv("LOG_LEVEL")
  18 + }
  19 +}
1 package domain 1 package domain
2 2
3 -const TokenExpire = 3 * 3600 3 +const TokenExpire = 24 * 3600
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +// ClientVersion
  6 +type ClientVersion struct {
  7 + // 唯一标识
  8 + Id int64 `json:"id"`
  9 + // 提交人
  10 + Commiter int64 `json:"commiter"`
  11 + // 项目名称
  12 + ProjectName string `json:"projectName"`
  13 + // 版本号
  14 + Version string `json:"version"`
  15 + // 标题
  16 + Title string `json:"title"`
  17 + // 其他备注信息
  18 + Remark string `json:"remark"`
  19 + // 客户端安装包信息
  20 + ClientPackageInfo []*ClientPackageInfo `json:"clientPackageInfo"`
  21 + // 创建时间
  22 + CreateTime time.Time `json:"createTime"`
  23 +}
  24 +
  25 +type ClientVersionRepository interface {
  26 + Save(dm *ClientVersion) (*ClientVersion, error)
  27 + Remove(dm *ClientVersion) (*ClientVersion, error)
  28 + FindOne(queryOptions map[string]interface{}) (*ClientVersion, error)
  29 + Find(queryOptions map[string]interface{}) (int64, []*ClientVersion, error)
  30 +}
  31 +
  32 +func (m *ClientVersion) Identify() interface{} {
  33 + if m.Id == 0 {
  34 + return nil
  35 + }
  36 + return m.Id
  37 +}
  38 +
  39 +func (m *ClientVersion) Update(data map[string]interface{}) error {
  40 + if projectName, ok := data["projectName"]; ok {
  41 + m.ProjectName = projectName.(string)
  42 + }
  43 + if version, ok := data["version"]; ok {
  44 + m.Version = version.(string)
  45 + }
  46 + if title, ok := data["title"]; ok {
  47 + m.Title = title.(string)
  48 + }
  49 + if remark, ok := data["remark"]; ok {
  50 + m.Remark = remark.(string)
  51 + }
  52 + if clientPackageInfo, ok := data["clientPackageInfo"]; ok {
  53 + m.ClientPackageInfo = clientPackageInfo.([]*ClientPackageInfo)
  54 + }
  55 + return nil
  56 +}
  1 +package domain
  2 +
  3 +import "time"
  4 +
  5 +const (
  6 + LogCodeEditModuleFile = "EditModuleFile"
  7 +)
  8 +
  9 +// OperatorLog
  10 +type OperatorLog struct {
  11 + // 唯一标识
  12 + Id int64 `json:"id"`
  13 + // 用户编号
  14 + UserId int64 `json:"userId"`
  15 + // 提交人
  16 + Operator string `json:"operator"`
  17 + // 日志编号码 : EditModuleFile
  18 + Code string `json:"code"`
  19 + // 关联资源id
  20 + ResourceId int64 `json:"resourceId"`
  21 + // 变更内容
  22 + Content string `json:"content"`
  23 + // 创建时间
  24 + CreateTime time.Time `json:"createTime"`
  25 +}
  26 +
  27 +type OperatorLogRepository interface {
  28 + Save(dm *OperatorLog) (*OperatorLog, error)
  29 + Remove(dm *OperatorLog) (*OperatorLog, error)
  30 + FindOne(queryOptions map[string]interface{}) (*OperatorLog, error)
  31 + Find(queryOptions map[string]interface{}) (int64, []*OperatorLog, error)
  32 +}
  33 +
  34 +func (m *OperatorLog) Identify() interface{} {
  35 + if m.Id == 0 {
  36 + return nil
  37 + }
  38 + return m.Id
  39 +}
  40 +
  41 +func (m *OperatorLog) Update(data map[string]interface{}) error {
  42 + return nil
  43 +}
  1 +package domain
  2 +
  3 +// ClientPackageInfo
  4 +type ClientPackageInfo struct {
  5 + // 文件名称
  6 + FileName string `json:"fileName"`
  7 + // 文件路径
  8 + Path string `json:"path"`
  9 +}
@@ -34,6 +34,8 @@ func init() { @@ -34,6 +34,8 @@ func init() {
34 (*models.Role)(nil), 34 (*models.Role)(nil),
35 (*models.RoleAccess)(nil), 35 (*models.RoleAccess)(nil),
36 (*models.Users)(nil), 36 (*models.Users)(nil),
  37 + (*models.ClientVersion)(nil),
  38 + (*models.OperatorLog)(nil),
37 } { 39 } {
38 err := DB.CreateTable(model, &orm.CreateTableOptions{ 40 err := DB.CreateTable(model, &orm.CreateTableOptions{
39 Temp: false, 41 Temp: false,
  1 +package models
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
  5 + "time"
  6 +)
  7 +
  8 +// ClientVersion
  9 +type ClientVersion struct {
  10 + tableName struct{} `pg:"client_version"`
  11 + // 唯一标识
  12 + Id int64
  13 + // 提交人
  14 + Commiter int64 `pg:",use_zero"`
  15 + // 项目名称
  16 + ProjectName string
  17 + // 版本号
  18 + Version string
  19 + // 标题
  20 + Title string
  21 + // 其他备注信息
  22 + Remark string
  23 + // 客户端安装包信息
  24 + ClientPackageInfo []*domain.ClientPackageInfo
  25 + // 创建时间
  26 + CreateTime time.Time
  27 +}
  1 +package models
  2 +
  3 +import "time"
  4 +
  5 +// OperatorLog
  6 +type OperatorLog struct {
  7 + tableName struct{} `pg:"operator_log"`
  8 + // 唯一标识
  9 + Id int64
  10 + // 用户编号
  11 + UserId int64
  12 + // 操作人
  13 + Operator string
  14 + // 日志编号码 : EditModuleFile
  15 + Code string
  16 + // 关联资源id
  17 + ResourceId int64
  18 + // 变更内容
  19 + Content string
  20 + // 创建时间
  21 + CreateTime time.Time
  22 +}
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/tiptok/gocomm/common"
  6 + "github.com/tiptok/gocomm/pkg/cache"
  7 + . "github.com/tiptok/gocomm/pkg/orm/pgx"
  8 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/constant"
  9 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/pg/models"
  11 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/pg/transaction"
  12 +)
  13 +
  14 +var (
  15 + cacheClientVersionIdKey = func(id int64) string {
  16 + return fmt.Sprintf("%v:cache:ClientVersion:id:%v", constant.POSTGRESQL_DB_NAME, id)
  17 + // 不需要执行缓存时,key设置为空
  18 + // return ""
  19 + }
  20 +)
  21 +
  22 +type ClientVersionRepository struct {
  23 + *cache.CachedRepository
  24 + transactionContext *transaction.TransactionContext
  25 +}
  26 +
  27 +func (repository *ClientVersionRepository) Save(dm *domain.ClientVersion) (*domain.ClientVersion, error) {
  28 + var (
  29 + err error
  30 + m = &models.ClientVersion{}
  31 + tx = repository.transactionContext.PgTx
  32 + )
  33 + if err = common.GobModelTransform(m, dm); err != nil {
  34 + return nil, err
  35 + }
  36 + if dm.Identify() == nil {
  37 + if err = tx.Insert(m); err != nil {
  38 + return nil, err
  39 + }
  40 + dm.Id = m.Id
  41 + return dm, nil
  42 + }
  43 + queryFunc := func() (interface{}, error) {
  44 + return nil, tx.Update(m)
  45 + }
  46 + if _, err = repository.Query(queryFunc, cacheClientVersionIdKey(dm.Id)); err != nil {
  47 + return nil, err
  48 + }
  49 + return dm, nil
  50 +}
  51 +
  52 +func (repository *ClientVersionRepository) Remove(ClientVersion *domain.ClientVersion) (*domain.ClientVersion, error) {
  53 + var (
  54 + tx = repository.transactionContext.PgTx
  55 + ClientVersionModel = &models.ClientVersion{Id: ClientVersion.Identify().(int64)}
  56 + )
  57 + queryFunc := func() (interface{}, error) {
  58 + return tx.Model(ClientVersionModel).Where("id = ?", ClientVersion.Id).Delete()
  59 + }
  60 + if _, err := repository.Query(queryFunc, cacheClientVersionIdKey(ClientVersion.Id)); err != nil {
  61 + return ClientVersion, err
  62 + }
  63 + return ClientVersion, nil
  64 +}
  65 +
  66 +func (repository *ClientVersionRepository) FindOne(queryOptions map[string]interface{}) (*domain.ClientVersion, error) {
  67 + tx := repository.transactionContext.PgDd
  68 + ClientVersionModel := new(models.ClientVersion)
  69 + queryFunc := func() (interface{}, error) {
  70 + query := NewQuery(tx.Model(ClientVersionModel), queryOptions)
  71 + query.SetWhere("id = ?", "id")
  72 + if err := query.First(); err != nil {
  73 + return nil, fmt.Errorf("query row not found")
  74 + }
  75 + return ClientVersionModel, nil
  76 + }
  77 + var options []cache.QueryOption
  78 + if _, ok := queryOptions["id"]; !ok {
  79 + options = append(options, cache.WithNoCacheFlag())
  80 + } else {
  81 + ClientVersionModel.Id = queryOptions["id"].(int64)
  82 + }
  83 + if err := repository.QueryCache(cacheClientVersionIdKey(ClientVersionModel.Id), ClientVersionModel, queryFunc, options...); err != nil {
  84 + return nil, err
  85 + }
  86 + if ClientVersionModel.Id == 0 {
  87 + return nil, fmt.Errorf("query row not found")
  88 + }
  89 + return repository.transformPgModelToDomainModel(ClientVersionModel)
  90 +}
  91 +
  92 +func (repository *ClientVersionRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ClientVersion, error) {
  93 + tx := repository.transactionContext.PgTx
  94 + var ClientVersionModels []*models.ClientVersion
  95 + ClientVersions := make([]*domain.ClientVersion, 0)
  96 + query := NewQuery(tx.Model(&ClientVersionModels), queryOptions).
  97 + SetOrder("create_time", "sortByCreateTime").
  98 + SetOrder("update_time", "sortByUpdateTime").
  99 + SetLimit()
  100 + var err error
  101 + if query.AffectRow, err = query.SelectAndCount(); err != nil {
  102 + return 0, ClientVersions, err
  103 + }
  104 + for _, ClientVersionModel := range ClientVersionModels {
  105 + if ClientVersion, err := repository.transformPgModelToDomainModel(ClientVersionModel); err != nil {
  106 + return 0, ClientVersions, err
  107 + } else {
  108 + ClientVersions = append(ClientVersions, ClientVersion)
  109 + }
  110 + }
  111 + return int64(query.AffectRow), ClientVersions, nil
  112 +}
  113 +
  114 +func (repository *ClientVersionRepository) transformPgModelToDomainModel(ClientVersionModel *models.ClientVersion) (*domain.ClientVersion, error) {
  115 + m := &domain.ClientVersion{}
  116 + err := common.GobModelTransform(m, ClientVersionModel)
  117 + return m, err
  118 +}
  119 +
  120 +func NewClientVersionRepository(transactionContext *transaction.TransactionContext) (*ClientVersionRepository, error) {
  121 + if transactionContext == nil {
  122 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  123 + }
  124 + return &ClientVersionRepository{transactionContext: transactionContext, CachedRepository: cache.NewDefaultCachedRepository()}, nil
  125 +}
  1 +package repository
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/tiptok/gocomm/common"
  6 + "github.com/tiptok/gocomm/pkg/cache"
  7 + . "github.com/tiptok/gocomm/pkg/orm/pgx"
  8 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/constant"
  9 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/pg/models"
  11 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/pg/transaction"
  12 +)
  13 +
  14 +var (
  15 + cacheOperatorLogIdKey = func(id int64) string {
  16 + return fmt.Sprintf("%v:cache:OperatorLog:id:%v", constant.POSTGRESQL_DB_NAME, id)
  17 + // 不需要执行缓存时,key设置为空
  18 + // return ""
  19 + }
  20 +)
  21 +
  22 +type OperatorLogRepository struct {
  23 + *cache.CachedRepository
  24 + transactionContext *transaction.TransactionContext
  25 +}
  26 +
  27 +func (repository *OperatorLogRepository) Save(dm *domain.OperatorLog) (*domain.OperatorLog, error) {
  28 + var (
  29 + err error
  30 + m = &models.OperatorLog{}
  31 + tx = repository.transactionContext.PgTx
  32 + )
  33 + if err = common.GobModelTransform(m, dm); err != nil {
  34 + return nil, err
  35 + }
  36 + if dm.Identify() == nil {
  37 + if err = tx.Insert(m); err != nil {
  38 + return nil, err
  39 + }
  40 + return dm, nil
  41 + }
  42 + queryFunc := func() (interface{}, error) {
  43 + return nil, tx.Update(m)
  44 + }
  45 + if _, err = repository.Query(queryFunc, cacheOperatorLogIdKey(dm.Id)); err != nil {
  46 + return nil, err
  47 + }
  48 + return dm, nil
  49 +}
  50 +
  51 +func (repository *OperatorLogRepository) Remove(OperatorLog *domain.OperatorLog) (*domain.OperatorLog, error) {
  52 + var (
  53 + tx = repository.transactionContext.PgTx
  54 + OperatorLogModel = &models.OperatorLog{Id: OperatorLog.Identify().(int64)}
  55 + )
  56 + queryFunc := func() (interface{}, error) {
  57 + return tx.Model(OperatorLogModel).Where("id = ?", OperatorLog.Id).Delete()
  58 + }
  59 + if _, err := repository.Query(queryFunc, cacheOperatorLogIdKey(OperatorLog.Id)); err != nil {
  60 + return OperatorLog, err
  61 + }
  62 + return OperatorLog, nil
  63 +}
  64 +
  65 +func (repository *OperatorLogRepository) FindOne(queryOptions map[string]interface{}) (*domain.OperatorLog, error) {
  66 + tx := repository.transactionContext.PgDd
  67 + OperatorLogModel := new(models.OperatorLog)
  68 + queryFunc := func() (interface{}, error) {
  69 + query := NewQuery(tx.Model(OperatorLogModel), queryOptions)
  70 + query.SetWhere("id = ?", "id")
  71 + if err := query.First(); err != nil {
  72 + return nil, fmt.Errorf("query row not found")
  73 + }
  74 + return OperatorLogModel, nil
  75 + }
  76 + var options []cache.QueryOption
  77 + if _, ok := queryOptions["id"]; !ok {
  78 + options = append(options, cache.WithNoCacheFlag())
  79 + } else {
  80 + OperatorLogModel.Id = queryOptions["id"].(int64)
  81 + }
  82 + if err := repository.QueryCache(cacheOperatorLogIdKey(OperatorLogModel.Id), OperatorLogModel, queryFunc, options...); err != nil {
  83 + return nil, err
  84 + }
  85 + if OperatorLogModel.Id == 0 {
  86 + return nil, fmt.Errorf("query row not found")
  87 + }
  88 + return repository.transformPgModelToDomainModel(OperatorLogModel)
  89 +}
  90 +
  91 +func (repository *OperatorLogRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OperatorLog, error) {
  92 + tx := repository.transactionContext.PgTx
  93 + var OperatorLogModels []*models.OperatorLog
  94 + OperatorLogs := make([]*domain.OperatorLog, 0)
  95 + query := NewQuery(tx.Model(&OperatorLogModels), queryOptions).
  96 + SetOrder("create_time", "sortByCreateTime").
  97 + SetOrder("update_time", "sortByUpdateTime").SetLimit()
  98 +
  99 + query.SetWhere("resource_id=?", "resourceId")
  100 + query.SetWhere("id<?", "lastId")
  101 + query.SetOrder("id", "sortById").SetLimit()
  102 + var err error
  103 + if query.AffectRow, err = query.SelectAndCount(); err != nil {
  104 + return 0, OperatorLogs, err
  105 + }
  106 + for _, OperatorLogModel := range OperatorLogModels {
  107 + if OperatorLog, err := repository.transformPgModelToDomainModel(OperatorLogModel); err != nil {
  108 + return 0, OperatorLogs, err
  109 + } else {
  110 + OperatorLogs = append(OperatorLogs, OperatorLog)
  111 + }
  112 + }
  113 + return int64(query.AffectRow), OperatorLogs, nil
  114 +}
  115 +
  116 +func (repository *OperatorLogRepository) transformPgModelToDomainModel(OperatorLogModel *models.OperatorLog) (*domain.OperatorLog, error) {
  117 + m := &domain.OperatorLog{}
  118 + err := common.GobModelTransform(m, OperatorLogModel)
  119 + return m, err
  120 +}
  121 +
  122 +func NewOperatorLogRepository(transactionContext *transaction.TransactionContext) (*OperatorLogRepository, error) {
  123 + if transactionContext == nil {
  124 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  125 + }
  126 + return &OperatorLogRepository{transactionContext: transactionContext, CachedRepository: cache.NewDefaultCachedRepository()}, nil
  127 +}
@@ -16,10 +16,14 @@ func init() { @@ -16,10 +16,14 @@ func init() {
16 AllowCredentials: true, 16 AllowCredentials: true,
17 })) 17 }))
18 18
  19 + beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequstLogFilter())
  20 + beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(), false)
  21 +
19 beego.InsertFilter("/v1/auth/profile", beego.BeforeExec, middleware.CheckAuthorization) 22 beego.InsertFilter("/v1/auth/profile", beego.BeforeExec, middleware.CheckAuthorization)
20 beego.InsertFilter("/v1/user/*", beego.BeforeExec, middleware.InspectRoleAccess("")) 23 beego.InsertFilter("/v1/user/*", beego.BeforeExec, middleware.InspectRoleAccess(""))
21 beego.InsertFilter("/v1/role/*", beego.BeforeExec, middleware.InspectRoleAccess("")) 24 beego.InsertFilter("/v1/role/*", beego.BeforeExec, middleware.InspectRoleAccess(""))
22 beego.InsertFilter("/v1/project_module/*", beego.BeforeExec, middleware.InspectRoleAccess("")) 25 beego.InsertFilter("/v1/project_module/*", beego.BeforeExec, middleware.InspectRoleAccess(""))
  26 + beego.InsertFilter("/v1/client_version/*", beego.BeforeExec, middleware.InspectRoleAccess(""))
23 beego.InsertFilter("/v1/project_module_version/*", beego.BeforeExec, middleware.InspectRoleAccess("/project_module/*")) 27 beego.InsertFilter("/v1/project_module_version/*", beego.BeforeExec, middleware.InspectRoleAccess("/project_module/*"))
24 beego.InsertFilter("/v1/project_module_files/*", beego.BeforeExec, middleware.InspectRoleAccess("/project_module/*")) 28 beego.InsertFilter("/v1/project_module_files/*", beego.BeforeExec, middleware.InspectRoleAccess("/project_module/*"))
25 beego.InsertFilter("/v1/rbac/*", beego.BeforeExec, middleware.InspectRoleAccess("/role/*")) 29 beego.InsertFilter("/v1/rbac/*", beego.BeforeExec, middleware.InspectRoleAccess("/role/*"))
@@ -33,17 +33,24 @@ func (controller *BaseController) Resp(msg *protocol.ResponseMessage) { @@ -33,17 +33,24 @@ func (controller *BaseController) Resp(msg *protocol.ResponseMessage) {
33 } 33 }
34 34
35 func (controller BaseController) GetLimitInfo() (offset int, limit int) { 35 func (controller BaseController) GetLimitInfo() (offset int, limit int) {
36 - offset, _ = controller.GetInt("offset")  
37 - limit, _ = controller.GetInt("limit") 36 + offset, _ = controller.GetInt("pageNumber")
  37 + limit, _ = controller.GetInt("pageSize")
  38 + if offset > 0 {
  39 + offset = (offset - 1) * limit
  40 + }
38 return 41 return
39 } 42 }
40 43
41 //获取请求头信息 44 //获取请求头信息
42 func (controller *BaseController) GetRequestHeader(ctx *context.Context) *protocol.RequestHeader { 45 func (controller *BaseController) GetRequestHeader(ctx *context.Context) *protocol.RequestHeader {
43 h := &protocol.RequestHeader{} 46 h := &protocol.RequestHeader{}
44 - if ctx.Input.GetData("x-mmm-id") != nil {  
45 - v := ctx.Input.GetData("x-mmm-id") 47 +
  48 + if v := ctx.Input.GetData("x-mmm-id"); v != nil {
46 h.UserId = int64(v.(int)) 49 h.UserId = int64(v.(int))
47 } 50 }
  51 + if v := ctx.Input.GetData("x-mmm-uname"); v != nil {
  52 + h.UserName = v.(string)
  53 + }
  54 +
48 return h 55 return h
49 } 56 }
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/tiptok/gocomm/pkg/log"
  5 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/client_version"
  6 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
  7 + protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/client_version"
  8 +)
  9 +
  10 +type ClientVersionController struct {
  11 + BaseController
  12 +}
  13 +
  14 +// CreateClientVersion
  15 +// CreateClientVersion execute command create ClientVersion
  16 +func (controller *ClientVersionController) CreateClientVersion() {
  17 + var (
  18 + msg *protocol.ResponseMessage
  19 + svr = client_version.NewClientVersionService(nil)
  20 + request *protocolx.CreateClientVersionRequest
  21 + )
  22 + defer func() {
  23 + controller.Resp(msg)
  24 + }()
  25 + if err := controller.JsonUnmarshal(&request); err != nil {
  26 + msg = protocol.NewResponseMessage(2, err.Error())
  27 + return
  28 + }
  29 + header := controller.GetRequestHeader(controller.Ctx)
  30 + data, err := svr.CreateClientVersion(header, request)
  31 + if err != nil {
  32 + log.Error(err)
  33 + }
  34 + msg = protocol.NewResponseMessageData(data, err)
  35 +}
  36 +
  37 +// UpdateClientVersion
  38 +// UpdateClientVersion execute command update ClientVersion
  39 +func (controller *ClientVersionController) UpdateClientVersion() {
  40 + var (
  41 + msg *protocol.ResponseMessage
  42 + svr = client_version.NewClientVersionService(nil)
  43 + request = &protocolx.UpdateClientVersionRequest{}
  44 + )
  45 + defer func() {
  46 + controller.Resp(msg)
  47 + }()
  48 + request.Id, _ = controller.GetInt64(":clientVersionId")
  49 + header := controller.GetRequestHeader(controller.Ctx)
  50 + data, err := svr.UpdateClientVersion(header, request)
  51 + if err != nil {
  52 + log.Error(err)
  53 + }
  54 + msg = protocol.NewResponseMessageData(data, err)
  55 +}
  56 +
  57 +// GetClientVersion
  58 +// GetClientVersion execute query get ClientVersion
  59 +func (controller *ClientVersionController) GetClientVersion() {
  60 + var (
  61 + msg *protocol.ResponseMessage
  62 + svr = client_version.NewClientVersionService(nil)
  63 + request = &protocolx.GetClientVersionRequest{}
  64 + )
  65 + defer func() {
  66 + controller.Resp(msg)
  67 + }()
  68 + request.Id, _ = controller.GetInt64(":clientVersionId")
  69 + header := controller.GetRequestHeader(controller.Ctx)
  70 + data, err := svr.GetClientVersion(header, request)
  71 + if err != nil {
  72 + log.Error(err)
  73 + }
  74 + msg = protocol.NewResponseMessageData(data, err)
  75 +}
  76 +
  77 +// DeleteClientVersion
  78 +// DeleteClientVersion execute command delete ClientVersion
  79 +func (controller *ClientVersionController) DeleteClientVersion() {
  80 + var (
  81 + msg *protocol.ResponseMessage
  82 + svr = client_version.NewClientVersionService(nil)
  83 + request = &protocolx.DeleteClientVersionRequest{}
  84 + )
  85 + defer func() {
  86 + controller.Resp(msg)
  87 + }()
  88 + request.Id, _ = controller.GetInt64(":clientVersionId")
  89 + header := controller.GetRequestHeader(controller.Ctx)
  90 + data, err := svr.DeleteClientVersion(header, request)
  91 + if err != nil {
  92 + log.Error(err)
  93 + }
  94 + msg = protocol.NewResponseMessageData(data, err)
  95 +}
  96 +
  97 +// ListClientVersion
  98 +// ListClientVersion execute query list ClientVersion
  99 +func (controller *ClientVersionController) ListClientVersion() {
  100 + var (
  101 + msg *protocol.ResponseMessage
  102 + svr = client_version.NewClientVersionService(nil)
  103 + request = &protocolx.ListClientVersionRequest{}
  104 + )
  105 + defer func() {
  106 + controller.Resp(msg)
  107 + }()
  108 + request.Offset, request.Limit = controller.GetLimitInfo()
  109 + header := controller.GetRequestHeader(controller.Ctx)
  110 + data, err := svr.ListClientVersion(header, request)
  111 + if err != nil {
  112 + log.Error(err)
  113 + }
  114 + msg = protocol.NewResponseMessageListData(data, err)
  115 +}
  1 +package controllers
  2 +
  3 +import (
  4 + "github.com/tiptok/gocomm/pkg/log"
  5 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/operator_log"
  6 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
  7 + protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/operator_log"
  8 +)
  9 +
  10 +type OperatorLogController struct {
  11 + BaseController
  12 +}
  13 +
  14 +// CreateOperatorLog
  15 +// CreateOperatorLog execute command create OperatorLog
  16 +func (controller *OperatorLogController) CreateOperatorLog() {
  17 + var (
  18 + msg *protocol.ResponseMessage
  19 + svr = operator_log.NewOperatorLogService(nil)
  20 + request *protocolx.CreateOperatorLogRequest
  21 + )
  22 + defer func() {
  23 + controller.Resp(msg)
  24 + }()
  25 + if err := controller.JsonUnmarshal(&request); err != nil {
  26 + msg = protocol.NewResponseMessage(2, err.Error())
  27 + return
  28 + }
  29 + header := controller.GetRequestHeader(controller.Ctx)
  30 + data, err := svr.CreateOperatorLog(header, request)
  31 + if err != nil {
  32 + log.Error(err)
  33 + }
  34 + msg = protocol.NewResponseMessageData(data, err)
  35 +}
  36 +
  37 +// UpdateOperatorLog
  38 +// UpdateOperatorLog execute command update OperatorLog
  39 +func (controller *OperatorLogController) UpdateOperatorLog() {
  40 + var (
  41 + msg *protocol.ResponseMessage
  42 + svr = operator_log.NewOperatorLogService(nil)
  43 + request *protocolx.UpdateOperatorLogRequest
  44 + )
  45 + defer func() {
  46 + controller.Resp(msg)
  47 + }()
  48 + if err := controller.JsonUnmarshal(&request); err != nil {
  49 + msg = protocol.NewResponseMessage(2, err.Error())
  50 + return
  51 + }
  52 + header := controller.GetRequestHeader(controller.Ctx)
  53 + data, err := svr.UpdateOperatorLog(header, request)
  54 + if err != nil {
  55 + log.Error(err)
  56 + }
  57 + msg = protocol.NewResponseMessageData(data, err)
  58 +}
  59 +
  60 +// GetOperatorLog
  61 +// GetOperatorLog execute query get OperatorLog
  62 +func (controller *OperatorLogController) GetOperatorLog() {
  63 + var (
  64 + msg *protocol.ResponseMessage
  65 + svr = operator_log.NewOperatorLogService(nil)
  66 + request *protocolx.GetOperatorLogRequest
  67 + )
  68 + defer func() {
  69 + controller.Resp(msg)
  70 + }()
  71 + if err := controller.JsonUnmarshal(&request); err != nil {
  72 + msg = protocol.NewResponseMessage(2, err.Error())
  73 + return
  74 + }
  75 + header := controller.GetRequestHeader(controller.Ctx)
  76 + data, err := svr.GetOperatorLog(header, request)
  77 + if err != nil {
  78 + log.Error(err)
  79 + }
  80 + msg = protocol.NewResponseMessageData(data, err)
  81 +}
  82 +
  83 +// DeleteOperatorLog
  84 +// DeleteOperatorLog execute command delete OperatorLog
  85 +func (controller *OperatorLogController) DeleteOperatorLog() {
  86 + var (
  87 + msg *protocol.ResponseMessage
  88 + svr = operator_log.NewOperatorLogService(nil)
  89 + request *protocolx.DeleteOperatorLogRequest
  90 + )
  91 + defer func() {
  92 + controller.Resp(msg)
  93 + }()
  94 + if err := controller.JsonUnmarshal(&request); err != nil {
  95 + msg = protocol.NewResponseMessage(2, err.Error())
  96 + return
  97 + }
  98 + header := controller.GetRequestHeader(controller.Ctx)
  99 + data, err := svr.DeleteOperatorLog(header, request)
  100 + if err != nil {
  101 + log.Error(err)
  102 + }
  103 + msg = protocol.NewResponseMessageData(data, err)
  104 +}
  105 +
  106 +// ListOperatorLog
  107 +// ListOperatorLog execute query list OperatorLog
  108 +func (controller *OperatorLogController) ListOperatorLog() {
  109 + var (
  110 + msg *protocol.ResponseMessage
  111 + svr = operator_log.NewOperatorLogService(nil)
  112 + request = &protocolx.ListOperatorLogRequest{}
  113 + )
  114 + defer func() {
  115 + controller.Resp(msg)
  116 + }()
  117 + //if err := controller.JsonUnmarshal(&request); err != nil {
  118 + // msg = protocol.NewResponseMessage(2,err.Error())
  119 + // return
  120 + //}
  121 + request.Offset, request.Limit = controller.GetLimitInfo()
  122 + header := controller.GetRequestHeader(controller.Ctx)
  123 + data, err := svr.ListOperatorLog(header, request)
  124 + if err != nil {
  125 + log.Error(err)
  126 + }
  127 + msg = protocol.NewResponseMessageData(data, err)
  128 +}
1 package middleware 1 package middleware
2 2
3 import ( 3 import (
  4 + "encoding/json"
4 "errors" 5 "errors"
  6 + "fmt"
5 "github.com/astaxie/beego/context" 7 "github.com/astaxie/beego/context"
6 "github.com/tiptok/gocomm/common" 8 "github.com/tiptok/gocomm/common"
  9 + "github.com/tiptok/gocomm/pkg/log"
7 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/cachex" 10 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/cachex"
8 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol" 11 "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
9 "strconv" 12 "strconv"
10 "strings" 13 "strings"
  14 + "time"
11 ) 15 )
12 16
13 var ( 17 var (
@@ -43,6 +47,7 @@ func CheckAuthorization(ctx *context.Context) { @@ -43,6 +47,7 @@ func CheckAuthorization(ctx *context.Context) {
43 } 47 }
44 userId, _ := strconv.Atoi(claim.Username) 48 userId, _ := strconv.Atoi(claim.Username)
45 ctx.Input.SetData("x-mmm-id", userId) 49 ctx.Input.SetData("x-mmm-id", userId)
  50 + ctx.Input.SetData("x-mmm-uname", claim.AddData["UserName"])
46 return 51 return
47 } 52 }
48 53
@@ -92,3 +97,26 @@ func InspectRoleAccess(parentObject string, skipUrl ...string) func(*context.Con @@ -92,3 +97,26 @@ func InspectRoleAccess(parentObject string, skipUrl ...string) func(*context.Con
92 CheckRoleAccess(c, c.Input.URL(), c.Input.Method()) 97 CheckRoleAccess(c, c.Input.URL(), c.Input.Method())
93 } 98 }
94 } 99 }
  100 +
  101 +func CreateRequstLogFilter() func(ctx *context.Context) {
  102 + return func(ctx *context.Context) {
  103 + requestId := fmt.Sprintf("%v.%v.%v ", ctx.Input.Method(), ctx.Input.URI(), time.Now().UnixNano())
  104 + ctx.Request.Header.Add("requestId", requestId)
  105 + var body string = "{}"
  106 + if ctx.Input.GetData("requestBody") != nil {
  107 + body = string(ctx.Input.GetData("requestBody").([]byte))
  108 + }
  109 + log.Debug(fmt.Sprintf("====>Recv RequestId:%s \nBodyData:%s", requestId, body))
  110 + }
  111 +}
  112 +
  113 +func CreateResponseLogFilter() func(ctx *context.Context) {
  114 + return func(ctx *context.Context) {
  115 + requestId := ctx.Request.Header.Get("requestId")
  116 + body, _ := json.Marshal(ctx.Input.GetData("outputData"))
  117 + if len(body) > 1000 {
  118 + body = body[:1000]
  119 + }
  120 + log.Debug(fmt.Sprintf("<====Send User:%v RequestId:%v BodyData:%s", ctx.Input.GetData("x-mmm-id"), requestId, body))
  121 + }
  122 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/astaxie/beego"
  5 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + beego.Router("/v1/client_version/", &controllers.ClientVersionController{}, "POST:CreateClientVersion")
  10 + beego.Router("/v1/client_version/:clientVersionId", &controllers.ClientVersionController{}, "PUT:UpdateClientVersion")
  11 + beego.Router("/v1/client_version/:clientVersionId", &controllers.ClientVersionController{}, "GET:GetClientVersion")
  12 + beego.Router("/v1/client_version/:clientVersionId", &controllers.ClientVersionController{}, "DELETE:DeleteClientVersion")
  13 + beego.Router("/v1/client_version/", &controllers.ClientVersionController{}, "GET:ListClientVersion")
  14 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/astaxie/beego"
  5 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + //beego.Router("/v1/operator_log/", &controllers.OperatorLogController{}, "POST:CreateOperatorLog")
  10 + //beego.Router("/v1/operator_log/:operatorLogId", &controllers.OperatorLogController{}, "PUT:UpdateOperatorLog")
  11 + //beego.Router("/v1/operator_log/:operatorLogId", &controllers.OperatorLogController{}, "GET:GetOperatorLog")
  12 + //beego.Router("/v1/operator_log/:operatorLogId", &controllers.OperatorLogController{}, "DELETE:DeleteOperatorLog")
  13 + beego.Router("/v1/operator_log/", &controllers.OperatorLogController{}, "GET:ListOperatorLog")
  14 +}
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/astaxie/beego"
  5 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/constant"
  6 +)
  7 +
  8 +func init() {
  9 + beego.SetStaticPath("/log", constant.LOG_File)
  10 +}
1 package auth 1 package auth
2 2
3 import ( 3 import (
  4 + "errors"
4 "fmt" 5 "fmt"
5 "github.com/astaxie/beego/validation" 6 "github.com/astaxie/beego/validation"
6 ) 7 )
7 8
8 type ChangePasswordRequest struct { 9 type ChangePasswordRequest struct {
  10 + Phone string `json:"phone" valid:"Required"`
  11 + OldPwd string `json:"oldPassword" valid:"Required"`
  12 + NewPwd string `json:"newPassword" valid:"Required"`
9 } 13 }
10 14
11 func (ChangePasswordRequest *ChangePasswordRequest) ValidateCommand() error { 15 func (ChangePasswordRequest *ChangePasswordRequest) ValidateCommand() error {
@@ -14,6 +18,9 @@ func (ChangePasswordRequest *ChangePasswordRequest) ValidateCommand() error { @@ -14,6 +18,9 @@ func (ChangePasswordRequest *ChangePasswordRequest) ValidateCommand() error {
14 if err != nil { 18 if err != nil {
15 return err 19 return err
16 } 20 }
  21 + if ChangePasswordRequest.OldPwd == ChangePasswordRequest.NewPwd {
  22 + return errors.New("新旧密码不能相同")
  23 + }
17 if !b { 24 if !b {
18 for _, validErr := range valid.Errors { 25 for _, validErr := range valid.Errors {
19 return fmt.Errorf("%s %s", validErr.Key, validErr.Message) 26 return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
  7 +)
  8 +
  9 +type CreateClientVersionRequest struct {
  10 + // 提交人
  11 + //Commiter int64 `json:"commiter,omitempty"`
  12 + // 项目名称
  13 + ProjectName string `json:"projectName,omitempty"`
  14 + // 版本号
  15 + Version string `json:"version,omitempty"`
  16 + // 标题
  17 + Title string `json:"title,omitempty"`
  18 + // 其他备注信息
  19 + Remark string `json:"remark,omitempty"`
  20 + // 客户端安装包信息
  21 + ClientPackageInfo []*domain.ClientPackageInfo `json:"clientPackageInfo,omitempty"`
  22 +}
  23 +
  24 +func (CreateClientVersionRequest *CreateClientVersionRequest) ValidateCommand() error {
  25 + valid := validation.Validation{}
  26 + b, err := valid.Valid(CreateClientVersionRequest)
  27 + if err != nil {
  28 + return err
  29 + }
  30 + if !b {
  31 + for _, validErr := range valid.Errors {
  32 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  33 + }
  34 + }
  35 + return nil
  36 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type CreateClientVersionResponse struct {
  9 +}
  10 +
  11 +func (CreateClientVersionResponse *CreateClientVersionResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(CreateClientVersionResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type DeleteClientVersionRequest struct {
  9 + // 唯一标识
  10 + Id int64 `json:"id,omitempty"`
  11 +}
  12 +
  13 +func (DeleteClientVersionRequest *DeleteClientVersionRequest) ValidateCommand() error {
  14 + valid := validation.Validation{}
  15 + b, err := valid.Valid(DeleteClientVersionRequest)
  16 + if err != nil {
  17 + return err
  18 + }
  19 + if !b {
  20 + for _, validErr := range valid.Errors {
  21 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  22 + }
  23 + }
  24 + return nil
  25 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type DeleteClientVersionResponse struct {
  9 +}
  10 +
  11 +func (DeleteClientVersionResponse *DeleteClientVersionResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(DeleteClientVersionResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/domain"
  7 +)
  8 +
  9 +type UpdateClientVersionRequest struct {
  10 + Id int64 `json:"-"`
  11 + // 提交人
  12 + Commiter int64 `json:"commiter,omitempty"`
  13 + // 项目名称
  14 + ProjectName int64 `json:"projectName,omitempty"`
  15 + // 版本号
  16 + Version string `json:"version,omitempty"`
  17 + // 标题
  18 + Title string `json:"title,omitempty"`
  19 + // 其他备注信息
  20 + Remark string `json:"remark,omitempty"`
  21 + // 客户端安装包信息
  22 + ClientPackageInfo []*domain.ClientPackageInfo `json:"clientPackageInfo,omitempty"`
  23 +}
  24 +
  25 +func (UpdateClientVersionRequest *UpdateClientVersionRequest) ValidateCommand() error {
  26 + valid := validation.Validation{}
  27 + b, err := valid.Valid(UpdateClientVersionRequest)
  28 + if err != nil {
  29 + return err
  30 + }
  31 + if !b {
  32 + for _, validErr := range valid.Errors {
  33 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  34 + }
  35 + }
  36 + return nil
  37 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type UpdateClientVersionResponse struct {
  9 +}
  10 +
  11 +func (UpdateClientVersionResponse *UpdateClientVersionResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(UpdateClientVersionResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type GetClientVersionRequest struct {
  9 + // 唯一标识
  10 + Id int64 `json:"id,omitempty" valid:"Required"`
  11 +}
  12 +
  13 +func (GetClientVersionRequest *GetClientVersionRequest) ValidateCommand() error {
  14 + valid := validation.Validation{}
  15 + b, err := valid.Valid(GetClientVersionRequest)
  16 + if err != nil {
  17 + return err
  18 + }
  19 + if !b {
  20 + for _, validErr := range valid.Errors {
  21 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  22 + }
  23 + }
  24 + return nil
  25 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type GetClientVersionResponse struct {
  9 +}
  10 +
  11 +func (GetClientVersionResponse *GetClientVersionResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(GetClientVersionResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type ListClientVersionRequest struct {
  9 + Offset int `json:"offset"`
  10 + Limit int `json:"limit"`
  11 +}
  12 +
  13 +func (ListClientVersionRequest *ListClientVersionRequest) ValidateCommand() error {
  14 + valid := validation.Validation{}
  15 + b, err := valid.Valid(ListClientVersionRequest)
  16 + if err != nil {
  17 + return err
  18 + }
  19 + if !b {
  20 + for _, validErr := range valid.Errors {
  21 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  22 + }
  23 + }
  24 + return nil
  25 +}
  1 +package client_version
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type ListClientVersionResponse struct {
  9 +}
  10 +
  11 +func (ListClientVersionResponse *ListClientVersionResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(ListClientVersionResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type CreateOperatorLogRequest struct {
  9 + // 提交人
  10 + Commiter string `json:"commiter,omitempty"`
  11 + // 日志编号码 : EditModuleFile
  12 + Code string `json:"code,omitempty"`
  13 + // 变更内容
  14 + Content string `json:"content,omitempty"`
  15 +}
  16 +
  17 +func (CreateOperatorLogRequest *CreateOperatorLogRequest) ValidateCommand() error {
  18 + valid := validation.Validation{}
  19 + b, err := valid.Valid(CreateOperatorLogRequest)
  20 + if err != nil {
  21 + return err
  22 + }
  23 + if !b {
  24 + for _, validErr := range valid.Errors {
  25 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  26 + }
  27 + }
  28 + return nil
  29 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type CreateOperatorLogResponse struct {
  9 +}
  10 +
  11 +func (CreateOperatorLogResponse *CreateOperatorLogResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(CreateOperatorLogResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type DeleteOperatorLogRequest struct {
  9 + // 唯一标识
  10 + Id int64 `json:"id,omitempty"`
  11 +}
  12 +
  13 +func (DeleteOperatorLogRequest *DeleteOperatorLogRequest) ValidateCommand() error {
  14 + valid := validation.Validation{}
  15 + b, err := valid.Valid(DeleteOperatorLogRequest)
  16 + if err != nil {
  17 + return err
  18 + }
  19 + if !b {
  20 + for _, validErr := range valid.Errors {
  21 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  22 + }
  23 + }
  24 + return nil
  25 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type DeleteOperatorLogResponse struct {
  9 +}
  10 +
  11 +func (DeleteOperatorLogResponse *DeleteOperatorLogResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(DeleteOperatorLogResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type UpdateOperatorLogRequest struct {
  9 + // 用户编号
  10 + UserId int64 `json:"userId,omitempty"`
  11 + // 提交人
  12 + Commiter string `json:"commiter,omitempty"`
  13 + // 日志编号码 : EditModuleFile
  14 + Code string `json:"code,omitempty"`
  15 + // 关联资源id
  16 + ResourceId int64 `json:"resourceId,omitempty"`
  17 + // 变更内容
  18 + Content string `json:"content,omitempty"`
  19 +}
  20 +
  21 +func (UpdateOperatorLogRequest *UpdateOperatorLogRequest) ValidateCommand() error {
  22 + valid := validation.Validation{}
  23 + b, err := valid.Valid(UpdateOperatorLogRequest)
  24 + if err != nil {
  25 + return err
  26 + }
  27 + if !b {
  28 + for _, validErr := range valid.Errors {
  29 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  30 + }
  31 + }
  32 + return nil
  33 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type UpdateOperatorLogResponse struct {
  9 +}
  10 +
  11 +func (UpdateOperatorLogResponse *UpdateOperatorLogResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(UpdateOperatorLogResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type GetOperatorLogRequest struct {
  9 + // 唯一标识
  10 + Id int64 `json:"id,omitempty"`
  11 +}
  12 +
  13 +func (GetOperatorLogRequest *GetOperatorLogRequest) ValidateCommand() error {
  14 + valid := validation.Validation{}
  15 + b, err := valid.Valid(GetOperatorLogRequest)
  16 + if err != nil {
  17 + return err
  18 + }
  19 + if !b {
  20 + for _, validErr := range valid.Errors {
  21 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  22 + }
  23 + }
  24 + return nil
  25 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type GetOperatorLogResponse struct {
  9 +}
  10 +
  11 +func (GetOperatorLogResponse *GetOperatorLogResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(GetOperatorLogResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type ListOperatorLogRequest struct {
  9 + SortById string `json:"sortById,omitempty"`
  10 + LastId int64 `json:"lastId,omitempty"`
  11 + ResourceId int64 `json:"resourceId,omitempty"`
  12 + Offset int `json:"offset"`
  13 + Limit int `json:"limit"`
  14 +}
  15 +
  16 +func (ListOperatorLogRequest *ListOperatorLogRequest) ValidateCommand() error {
  17 + valid := validation.Validation{}
  18 + b, err := valid.Valid(ListOperatorLogRequest)
  19 + ListOperatorLogRequest.SortById = "DESC"
  20 + if err != nil {
  21 + return err
  22 + }
  23 + if !b {
  24 + for _, validErr := range valid.Errors {
  25 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  26 + }
  27 + }
  28 + return nil
  29 +}
  1 +package operator_log
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/astaxie/beego/validation"
  6 +)
  7 +
  8 +type ListOperatorLogResponse struct {
  9 +}
  10 +
  11 +func (ListOperatorLogResponse *ListOperatorLogResponse) ValidateCommand() error {
  12 + valid := validation.Validation{}
  13 + b, err := valid.Valid(ListOperatorLogResponse)
  14 + if err != nil {
  15 + return err
  16 + }
  17 + if !b {
  18 + for _, validErr := range valid.Errors {
  19 + return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
  20 + }
  21 + }
  22 + return nil
  23 +}
@@ -131,5 +131,6 @@ var errmessge ErrorMap = map[int]string{ @@ -131,5 +131,6 @@ var errmessge ErrorMap = map[int]string{
131 } 131 }
132 132
133 type RequestHeader struct { 133 type RequestHeader struct {
134 - UserId int64 //UserId 唯一标识 134 + UserId int64 //UserId 唯一标识
  135 + UserName string
135 } 136 }