diff --git a/app/caches/bannerlistcache/banner_list.go b/app/caches/bannerlistcache/banner_list.go index b6c8167..04329c9 100644 --- a/app/caches/bannerlistcache/banner_list.go +++ b/app/caches/bannerlistcache/banner_list.go @@ -3,7 +3,7 @@ package bannerlistcache import ( "sync" - "qteam/app/caches" + "cron_admin/app/caches" "github.com/qit-team/snow-core/cache" ) @@ -21,7 +21,7 @@ type bannerListCache struct { cache.BaseCache } -//单例模式 +// 单例模式 func GetInstance() *bannerListCache { once.Do(func() { instance = new(bannerListCache) diff --git a/app/caches/bannerlistcache/banner_list_test.go b/app/caches/bannerlistcache/banner_list_test.go index 7b22176..aa5b52a 100644 --- a/app/caches/bannerlistcache/banner_list_test.go +++ b/app/caches/bannerlistcache/banner_list_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "qteam/config" + "cron_admin/config" "github.com/qit-team/snow-core/cache" _ "github.com/qit-team/snow-core/cache/rediscache" diff --git a/app/http/controllers/backend/base_controller.go b/app/http/controllers/backend/base_controller.go new file mode 100644 index 0000000..bd13b11 --- /dev/null +++ b/app/http/controllers/backend/base_controller.go @@ -0,0 +1,10 @@ +package backend + +import ( + "cron_admin/app/http/controllers" + "github.com/gin-gonic/gin" +) + +func Empty(c *gin.Context) { + controllers.HandRes(c, gin.H{"bool": true}, nil) +} diff --git a/app/http/controllers/backend/user_controller.go b/app/http/controllers/backend/user_controller.go new file mode 100644 index 0000000..5fc2462 --- /dev/null +++ b/app/http/controllers/backend/user_controller.go @@ -0,0 +1,42 @@ +package backend + +import ( + "cron_admin/app/constants/errorcode" + "cron_admin/app/http/controllers" + "cron_admin/app/http/entities/backend" + "cron_admin/app/models/userinfomodel" + "cron_admin/app/services" + "github.com/ahmetb/go-linq/v3" + "github.com/gin-gonic/gin" +) + +func Login(c *gin.Context) { + +} + +func List(c *gin.Context) { + request := controllers.GetRequest(c).(*backend.UserListRequest) + count, list, err := services.GetListByWhere(request, request.Page, request.PageSize) + if err != nil { + controllers.HandCodeRes(c, nil, errorcode.NotFound) + } else { + UserList := make([]backend.UserListResponse, 0) + linq.From(list).SelectT(func(in userinfomodel.UserInfo) (d backend.UserListResponse) { + d.ResponseFromDb(in) + return d + }).ToSlice(&UserList) + controllers.HandRes(c, gin.H{"data": UserList, "count": count}, err) + } +} + +func GerUserInfoHandler(c *gin.Context) { + request := controllers.GetRequest(c).(*backend.UserInfoRequest) + has, userInfo, err := services.UserInfo(request.Id) + if err != nil || has == false { + controllers.HandCodeRes(c, nil, errorcode.NotFound) + } else { + UserInfoResponse := backend.UserListResponse{} + UserInfoResponse.ResponseFromDb(userInfo) + controllers.HandRes(c, UserInfoResponse, nil) + } +} diff --git a/app/http/controllers/base.go b/app/http/controllers/base.go index 887be73..a6743b7 100644 --- a/app/http/controllers/base.go +++ b/app/http/controllers/base.go @@ -3,6 +3,8 @@ package controllers import ( "bytes" "context" + "cron_admin/app/utils" + "cron_admin/config" "encoding/base64" "encoding/json" "errors" @@ -13,10 +15,8 @@ import ( zh_translations "gopkg.in/go-playground/validator.v9/translations/zh" "io/ioutil" "net/http" - "qteam/app/utils" - "qteam/config" - "qteam/app/constants/errorcode" + "cron_admin/app/constants/errorcode" "github.com/gin-gonic/gin" ) diff --git a/app/http/entities/backend/user.go b/app/http/entities/backend/user.go new file mode 100644 index 0000000..a6f9254 --- /dev/null +++ b/app/http/entities/backend/user.go @@ -0,0 +1,35 @@ +package backend + +import ( + "cron_admin/app/models/userinfomodel" + "time" +) + +type UserListRequest struct { + Page int `json:"page" validate:"required" form:"page" example:"1"` + PageSize int `json:"page_size" validate:"required" form:"page_size" example:"10"` + Mobile string `json:"mobile" form:"mobile" example:"155555555"` + Status int `json:"status" form:"status" example:"1"` + Clientuniqueidentification string `json:"Clientuniqueidentification" form:"Clientuniqueidentification" example:"46516"` +} + +type UserInfoRequest struct { + Id int `json:"id" form:"id" validate:"required" example:"1"` +} + +type UserListResponse struct { + Id int `json:"id" form:"id"` + Clientuniqueidentification string `json:"clientuniqueidentification"` + Mobile string `json:"mobile"` + Status int `json:"status"` + Createtime string `json:"createtime"` +} + +func (response *UserListResponse) ResponseFromDb(l userinfomodel.UserInfo) { + response.Id = l.Id + response.Clientuniqueidentification = l.Clientuniqueidentification + response.Mobile = l.Mobile + response.Status = l.Status + response.Createtime = l.Createtime.Format(time.DateTime) + return +} diff --git a/app/http/entities/common.go b/app/http/entities/common.go index e34775a..8d385d2 100644 --- a/app/http/entities/common.go +++ b/app/http/entities/common.go @@ -5,8 +5,8 @@ type IdRequest struct { } type PageRequest struct { - Page int64 `json:"page"` - PageSize int64 `json:"pageSize"` + Page int `json:"page"` + PageSize int `json:"pageSize"` } type PageRsp struct { diff --git a/app/http/metric/metric.go b/app/http/metric/metric.go index 208cced..f61a46c 100644 --- a/app/http/metric/metric.go +++ b/app/http/metric/metric.go @@ -3,7 +3,7 @@ package metric import ( "net/http" - "qteam/app/utils/metric" + "cron_admin/app/utils/metric" "github.com/prometheus/client_golang/prometheus" ) diff --git a/app/http/middlewares/base.go b/app/http/middlewares/base.go index f992a6c..8b6fc66 100644 --- a/app/http/middlewares/base.go +++ b/app/http/middlewares/base.go @@ -2,14 +2,14 @@ package middlewares import ( "context" + "cron_admin/app/constants/common" + "cron_admin/app/constants/errorcode" + "cron_admin/app/http/controllers" + "cron_admin/app/http/requestmapping" + "cron_admin/app/utils" "errors" "github.com/gin-gonic/gin" "github.com/qit-team/snow-core/redis" - "qteam/app/constants/common" - "qteam/app/constants/errorcode" - "qteam/app/http/controllers" - "qteam/app/http/requestmapping" - "qteam/app/utils" "strings" ) diff --git a/app/http/middlewares/metric.go b/app/http/middlewares/metric.go index 2b8f0a2..c47c42f 100644 --- a/app/http/middlewares/metric.go +++ b/app/http/middlewares/metric.go @@ -3,7 +3,7 @@ package middlewares import ( "time" - "qteam/app/http/metric" + "cron_admin/app/http/metric" "github.com/gin-gonic/gin" ) diff --git a/app/http/middlewares/server_recovery.go b/app/http/middlewares/server_recovery.go index 9a74ae2..e94c361 100644 --- a/app/http/middlewares/server_recovery.go +++ b/app/http/middlewares/server_recovery.go @@ -6,8 +6,8 @@ import ( "net/http/httputil" "runtime/debug" - "qteam/app/constants/logtype" - "qteam/config" + "cron_admin/app/constants/logtype" + "cron_admin/config" "github.com/gin-gonic/gin" "github.com/qit-team/snow-core/log/logger" diff --git a/app/http/middlewares/tracer.go b/app/http/middlewares/tracer.go index d0158d6..0af2717 100644 --- a/app/http/middlewares/tracer.go +++ b/app/http/middlewares/tracer.go @@ -1,9 +1,9 @@ package middlewares import ( + "cron_admin/app/http/trace" + "cron_admin/app/utils" "github.com/gin-gonic/gin" - "qteam/app/http/trace" - "qteam/app/utils" "strconv" ) diff --git a/app/http/routes/admin.go b/app/http/routes/admin.go index ea01006..8b02160 100644 --- a/app/http/routes/admin.go +++ b/app/http/routes/admin.go @@ -1,13 +1,14 @@ package routes import ( + "cron_admin/app/http/controllers" + "cron_admin/app/http/controllers/backend" + "cron_admin/app/http/middlewares" + "cron_admin/app/http/trace" + "cron_admin/app/utils" + "cron_admin/config" "github.com/gin-gonic/gin" "github.com/qit-team/snow-core/http/middleware" - "qteam/app/http/controllers" - "qteam/app/http/middlewares" - "qteam/app/http/trace" - "qteam/app/utils" - "qteam/config" ) func RegisterAdminRoute(router *gin.Engine) { @@ -22,9 +23,54 @@ func RegisterAdminRoute(router *gin.Engine) { } } - //v1 := router.Group("/admin/api/v1") - //{ - // - //} + adminApi := router.Group("/admin/api", middlewares.ValidateRequest()) + { + oauth := adminApi.Group("/oauth") + { + v1 := oauth.Group("/v1") + { + //用户管理 + user := v1.Group("/user") + { + user.GET("/list", backend.List) + user.GET("/info", backend.Empty) + } + //数据库管理 + sql := v1.Group("/sql") + { + sql.GET("/list", backend.Empty) + } + //任务 + cmd := v1.Group("/cmd") + { + cmd.GET("/query", backend.Empty) + cmd.GET("/info", backend.Empty) + cmd.PUT("/update", backend.Empty) + cmd.DELETE("/delete", backend.Empty) + } + //消息管理 + mes := v1.Group("/channel") + { + mes.GET("/list", backend.Empty) + } + + //日志 + log := v1.Group("/log") + { + //任务日志 + cmdLog := log.Group("/cmd") + { + cmdLog.GET("/list", backend.Empty) + } + //消息日志 + mesLog := log.Group("/mes") + { + mesLog.GET("/list", backend.Empty) + } + } + + } + } + } } diff --git a/app/http/routes/route.go b/app/http/routes/route.go index 54b5230..0e8069f 100644 --- a/app/http/routes/route.go +++ b/app/http/routes/route.go @@ -4,11 +4,11 @@ package routes * 配置路由 */ import ( - "qteam/app/http/controllers" - "qteam/app/http/middlewares" - "qteam/app/http/trace" - "qteam/app/utils/metric" - "qteam/config" + "cron_admin/app/http/controllers" + "cron_admin/app/http/middlewares" + "cron_admin/app/http/trace" + "cron_admin/app/utils/metric" + "cron_admin/config" "github.com/gin-gonic/gin" "github.com/qit-team/snow-core/http/middleware" diff --git a/app/http/trace/trace.go b/app/http/trace/trace.go index 2594f3f..2db9317 100644 --- a/app/http/trace/trace.go +++ b/app/http/trace/trace.go @@ -1,10 +1,10 @@ package trace import ( + "cron_admin/config" "github.com/openzipkin/zipkin-go" zkHttp "github.com/openzipkin/zipkin-go/reporter/http" "log" - "qteam/config" "sync" ) diff --git a/app/jobs/kernel.go b/app/jobs/kernel.go index 83f7491..f42fd8a 100644 --- a/app/jobs/kernel.go +++ b/app/jobs/kernel.go @@ -3,8 +3,8 @@ package jobs import ( "strings" - "qteam/app/jobs/basejob" - "qteam/config" + "cron_admin/app/jobs/basejob" + "cron_admin/config" "github.com/qit-team/snow-core/log/logger" "github.com/qit-team/snow-core/queue" diff --git a/app/models/common.go b/app/models/common.go new file mode 100644 index 0000000..1b443d5 --- /dev/null +++ b/app/models/common.go @@ -0,0 +1,4 @@ +package models + +type PO interface { +} diff --git a/app/models/userinfomodel/user_info.go b/app/models/userinfomodel/user_info.go new file mode 100644 index 0000000..d480afd --- /dev/null +++ b/app/models/userinfomodel/user_info.go @@ -0,0 +1,41 @@ +package userinfomodel + +import ( + "github.com/qit-team/snow-core/db" + "sync" + "time" +) + +var ( + once sync.Once + m *UserInfoModel +) + +// 实体 +type UserInfo struct { + Id int `xorm:"'Id' int(0)"` + Clientuniqueidentification string `xorm:"'ClientUniqueIdentification' varchar(255)"` + Mobile string `xorm:"'Mobile' varchar(13)"` + Status int `xorm:"'Status' TINYINT"` + Lastupdatetime time.Time `xorm:"'LastUpdateTime' datetime"` + Createtime time.Time `xorm:"'CreateTime' datetime"` +} + +// 表名 +func (m *UserInfo) TableName() string { + return "UserInfo" +} + +// 私有化,防止被外部new +type UserInfoModel struct { + db.Model //组合基础Model,集成基础Model的属性和方法 +} + +// 单例模式 +func GetInstance() *UserInfoModel { + once.Do(func() { + m = new(UserInfoModel) + //m.DiName = "" //设置数据库实例连接,默认db.SingletonMain + }) + return m +} diff --git a/app/mq/quenue.go b/app/mq/quenue.go index c93ebee..f86c9f2 100644 --- a/app/mq/quenue.go +++ b/app/mq/quenue.go @@ -1,7 +1,7 @@ package mq import ( - "qteam/app/utils/mq" + "cron_admin/app/utils/mq" ) func startQunue(name string, method interface{}, mqTp string, tp int, exhange string) { diff --git a/app/repository/common.go b/app/repository/common.go new file mode 100644 index 0000000..0a2a74c --- /dev/null +++ b/app/repository/common.go @@ -0,0 +1,84 @@ +package repository + +import ( + "cron_admin/app/http/entities" + "cron_admin/app/models" + "github.com/pkg/errors" + + "time" + "xorm.io/xorm" +) + +type CommonRepo[P models.PO] struct { + repo *xorm.Session +} + +type ICommonRepo[P models.PO] interface { + FindAll(list *[]P, opts ...DBOption) error + FindAndCount(list *[]P, opts ...DBOption) (int64, error) + Get(db *P, opts ...DBOption) (bool, error) + Update(db *P, opts ...DBOption) (int64, error) + Delete(db *P, opts ...DBOption) (int64, error) + InsertOne(db *P, opts ...DBOption) (int64, error) + InsertBatch(db *[]P, opts ...DBOption) (int64, error) + + WithByID(id uint) DBOption + WithByUserId(userId uint) DBOption + WithByBrandId(id int) DBOption + WithByDate(startTime, endTime time.Time) DBOption + WithByStartDate(startTime time.Time) DBOption + WithByEndDate(startTime time.Time) DBOption + WithDesc(orderStr string) DBOption + WithByStatus(status int) DBOption + WithIdsIn(ids []uint) DBOption + WithPage(pageFilter entities.PageRequest) DBOption + WithByCouponId(couponId uint) DBOption + WithByProductId(productId uint) DBOption +} + +func NewCommonRepo[P models.PO](repo *xorm.Session) ICommonRepo[P] { + return &CommonRepo[P]{repo: repo} +} + +func (this *CommonRepo[P]) FindAll(list *[]P, opts ...DBOption) error { + return getDb(this.repo, opts...).Find(list) +} + +func (this *CommonRepo[P]) FindAndCount(list *[]P, opts ...DBOption) (int64, error) { + return getDb(this.repo, opts...).FindAndCount(list) +} + +func (this *CommonRepo[P]) Get(db *P, opts ...DBOption) (bool, error) { + return getDb(this.repo, opts...).Get(db) +} + +func (this *CommonRepo[P]) Update(db *P, opts ...DBOption) (int64, error) { + if len(opts) == 0 { + return 0, errors.New("不允许不带条件的更新") + } + return getDb(this.repo, opts...).Update(db) +} + +// 不允许不带条件的删除 +func (this *CommonRepo[P]) Delete(db *P, opts ...DBOption) (int64, error) { + if len(opts) == 0 { + return 0, errors.New("不允许不带条件的删除") + } + return getDb(this.repo, opts...).Delete(db) +} + +func (this *CommonRepo[P]) InsertOne(db *P, opts ...DBOption) (int64, error) { + return getDb(this.repo, opts...).Insert(db) +} + +// 批量插入 +func (this *CommonRepo[P]) InsertBatch(db *[]P, opts ...DBOption) (int64, error) { + return getDb(this.repo, opts...).Insert(db) +} + +func getDb(repo *xorm.Session, opts ...DBOption) *xorm.Session { + for _, opt := range opts { + repo = opt(repo) + } + return repo +} diff --git a/app/repository/common_opt.go b/app/repository/common_opt.go new file mode 100644 index 0000000..778cf35 --- /dev/null +++ b/app/repository/common_opt.go @@ -0,0 +1,104 @@ +package repository + +import ( + "cron_admin/app/http/entities" + "time" + "xorm.io/xorm" +) + +type DBOption func(session *xorm.Session) *xorm.Session + +func (c *CommonRepo[P]) WithByID(id uint) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("id = ?", id) + } +} + +func (c *CommonRepo[P]) WithByUserId(userId uint) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("user_id = ?", userId) + } +} + +func (c *CommonRepo[P]) WithByBrandId(id int) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("brand_id = ?", id) + } +} + +func (c *CommonRepo[P]) WithByDate(startTime, endTime time.Time) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("create_time > ? AND create_time < ?", startTime, endTime) + } +} + +func (c *CommonRepo[P]) WithByStartDate(startTime time.Time) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("create_time > ?", startTime) + } +} + +func (c *CommonRepo[P]) WithByEndDate(endTime time.Time) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("create_time < ?", endTime) + } +} + +func (c *CommonRepo[P]) WithByStatus(status int) DBOption { + return func(g *xorm.Session) *xorm.Session { + if status == 0 { + return g + } + return g.Where("status = ?", status) + } +} + +func (c *CommonRepo[P]) WithByFrom(from string) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("`from` = ?", from) + } +} + +func (c *CommonRepo[P]) WithLikeName(name string) DBOption { + return func(g *xorm.Session) *xorm.Session { + if len(name) == 0 { + return g + } + return g.Where("name like ?", "%"+name+"%") + } +} + +func (c *CommonRepo[P]) WithDesc(orderStr string) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Desc(orderStr) + } +} + +func (c *CommonRepo[P]) WithIdsIn(ids []uint) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.In("id", ids) + } +} + +func (c *CommonRepo[P]) WithIdsNotIn(ids []uint) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("id not in (?)", ids) + } +} + +func (c *CommonRepo[P]) WithPage(pageFilter entities.PageRequest) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Limit(pageFilter.PageSize, pageFilter.PageSize*(pageFilter.Page-1)) + } +} +func (c *CommonRepo[P]) WithByCouponId(couponId uint) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("coupon_id =?", couponId) + } +} + +func (c *CommonRepo[P]) WithByProductId(productId uint) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("product_id =?", productId) + } +} diff --git a/app/repository/user.go b/app/repository/user.go new file mode 100644 index 0000000..caaca4f --- /dev/null +++ b/app/repository/user.go @@ -0,0 +1,22 @@ +package repository + +import ( + "cron_admin/app/models" + "xorm.io/xorm" +) + +type UserRepo[P models.PO] struct { + repo *xorm.Session + CommonRepo ICommonRepo[P] +} + +func NewUserRepo[P models.PO](repo *xorm.Session) *UserRepo[P] { + commonRepo := NewCommonRepo[P](repo) + return &UserRepo[P]{repo: repo, CommonRepo: commonRepo} +} + +func (c *UserRepo[P]) WithByCustNo(custNo string) DBOption { + return func(g *xorm.Session) *xorm.Session { + return g.Where("custNo = ?", custNo) + } +} diff --git a/app/services/user_service.go b/app/services/user_service.go new file mode 100644 index 0000000..98dc6f0 --- /dev/null +++ b/app/services/user_service.go @@ -0,0 +1,37 @@ +package services + +import ( + "cron_admin/app/http/entities/backend" + "cron_admin/app/models/userinfomodel" + "xorm.io/builder" +) + +func GetListByWhere(request *backend.UserListRequest, page int, limit int) (count int64, UserListInfo []userinfomodel.UserInfo, err error) { + conn := builder.NewCond() + + if request.Mobile != "" { + conn = conn.And(builder.Like{"Mobile", request.Mobile}) + } + if request.Status != 0 { + conn = conn.And(builder.Eq{"Status": request.Status}) + } + session := userinfomodel.GetInstance().GetDb().Where(conn) + + if page != 0 && limit != 0 { + session = session.Limit(page, (page-1)*limit) + } + count, err = session.FindAndCount(&UserListInfo) + + if err != nil { + return + } + return +} + +func UserInfo(id int) (has bool, UserCouponModel userinfomodel.UserInfo, err error) { + has, err = userinfomodel.GetInstance().GetDb().Where("id =?", id).Get(&UserCouponModel) + if err != nil { + return + } + return +} diff --git a/app/third/market/config.go b/app/third/market/config.go index b75ad06..71588b3 100644 --- a/app/third/market/config.go +++ b/app/third/market/config.go @@ -2,11 +2,11 @@ package market import ( "bytes" + "cron_admin/config" "encoding/json" "github.com/pkg/errors" "io/ioutil" "net/http" - "qteam/config" ) type MarketClient struct { diff --git a/app/third/market/market_api.go b/app/third/market/market_api.go index ddf0605..553d8a0 100644 --- a/app/third/market/market_api.go +++ b/app/third/market/market_api.go @@ -1,9 +1,9 @@ package market import ( + "cron_admin/app/utils/encrypt" + "cron_admin/config" "encoding/json" - "qteam/app/utils/encrypt" - "qteam/config" "time" ) diff --git a/app/third/market/market_api_test.go b/app/third/market/market_api_test.go index 6dca249..a507d3c 100644 --- a/app/third/market/market_api_test.go +++ b/app/third/market/market_api_test.go @@ -1,11 +1,11 @@ package market import ( + "cron_admin/app/utils" + "cron_admin/config" "fmt" "github.com/qit-team/snow-core/kernel/server" "os" - "qteam/app/utils" - "qteam/config" "testing" ) diff --git a/app/third/openapiService/openapi_service.go b/app/third/openapiService/openapi_service.go index 64be38b..f32a79f 100644 --- a/app/third/openapiService/openapi_service.go +++ b/app/third/openapiService/openapi_service.go @@ -2,16 +2,16 @@ package openapiService import ( "context" + "cron_admin/app/models/orderdetailsmodel" + "cron_admin/app/models/ordersmodel" + "cron_admin/app/models/usercouponmodel" + "cron_admin/app/utils" + "cron_admin/config" "crypto/aes" "encoding/base64" "gitee.com/chengdu_blue_brothers/openapi-go-sdk/api" "gitee.com/chengdu_blue_brothers/openapi-go-sdk/notify" "net/http" - "qteam/app/models/orderdetailsmodel" - "qteam/app/models/ordersmodel" - "qteam/app/models/usercouponmodel" - "qteam/app/utils" - "qteam/config" "time" ) diff --git a/app/utils/httpclient/fasthttp.go b/app/utils/httpclient/fasthttp.go index da80c53..99e82ac 100644 --- a/app/utils/httpclient/fasthttp.go +++ b/app/utils/httpclient/fasthttp.go @@ -1,8 +1,8 @@ package httpclient import ( + "cron_admin/app/utils" "fmt" - "qteam/app/utils" "github.com/valyala/fasthttp" "time" diff --git a/app/utils/mq/mqmanager.go b/app/utils/mq/mqmanager.go index 7247e1f..2cfd41d 100644 --- a/app/utils/mq/mqmanager.go +++ b/app/utils/mq/mqmanager.go @@ -1,8 +1,8 @@ package mq import ( - common3 "qteam/app/constants/common" - mq "qteam/app/utils/mq/mqs" + common3 "cron_admin/app/constants/common" + mq "cron_admin/app/utils/mq/mqs" "sync" ) diff --git a/app/utils/mq/mqs/kafka.go b/app/utils/mq/mqs/kafka.go index 3103cf1..bd96863 100644 --- a/app/utils/mq/mqs/kafka.go +++ b/app/utils/mq/mqs/kafka.go @@ -2,12 +2,12 @@ package mq import ( "context" + "cron_admin/app/utils" + "cron_admin/config" "encoding/json" "fmt" "github.com/Shopify/sarama" "github.com/qit-team/snow-core/redis" - "qteam/app/utils" - "qteam/config" "strconv" "sync" diff --git a/app/utils/mq/mqs/nats.go b/app/utils/mq/mqs/nats.go index 3805f81..8706380 100644 --- a/app/utils/mq/mqs/nats.go +++ b/app/utils/mq/mqs/nats.go @@ -1,13 +1,13 @@ package mq import ( + "cron_admin/app/utils" + "cron_admin/config" "encoding/json" "fmt" "github.com/nats-io/nats.go" _ "github.com/nats-io/nats.go" "github.com/streadway/amqp" - "qteam/app/utils" - "qteam/config" ) type NatsMq struct { diff --git a/app/utils/nacos.go b/app/utils/nacos.go index 2237642..8a5e484 100644 --- a/app/utils/nacos.go +++ b/app/utils/nacos.go @@ -1,12 +1,12 @@ package utils import ( + "cron_admin/config" "fmt" "github.com/nacos-group/nacos-sdk-go/v2/clients" "github.com/nacos-group/nacos-sdk-go/v2/clients/naming_client" "github.com/nacos-group/nacos-sdk-go/v2/common/constant" "github.com/nacos-group/nacos-sdk-go/v2/vo" - "qteam/config" "sync" ) diff --git a/app/utils/sm2/sm2.go b/app/utils/sm2/sm2.go index 9f40a90..5cc08eb 100644 --- a/app/utils/sm2/sm2.go +++ b/app/utils/sm2/sm2.go @@ -1,13 +1,13 @@ package sm2 import ( + "cron_admin/config" "crypto/rand" "encoding/base64" "encoding/hex" "fmt" "github.com/tjfoc/gmsm/sm2" "math/big" - "qteam/config" "strings" ) diff --git a/app/utils/util.go b/app/utils/util.go index 633149d..ad9211d 100644 --- a/app/utils/util.go +++ b/app/utils/util.go @@ -2,6 +2,8 @@ package utils import ( "context" + "cron_admin/app/constants/common" + "cron_admin/config" "crypto/md5" "crypto/rand" "crypto/sha256" @@ -19,8 +21,6 @@ import ( "net" "os" "path/filepath" - "qteam/app/constants/common" - "qteam/config" "reflect" "regexp" "runtime" diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 785b058..25ca23d 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -1,10 +1,10 @@ package bootstrap import ( + "cron_admin/app/jobs" + "cron_admin/app/jobs/basejob" + "cron_admin/config" "github.com/qit-team/snow-core/log/accesslogger" - "qteam/app/jobs" - "qteam/app/jobs/basejob" - "qteam/config" "github.com/qit-team/snow-core/db" "github.com/qit-team/snow-core/kernel/close" diff --git a/event/EventManger.go b/event/EventManger.go index 87bc6ab..001c5ad 100644 --- a/event/EventManger.go +++ b/event/EventManger.go @@ -1,6 +1,6 @@ package event -import "qteam/app/utils" +import "cron_admin/app/utils" type EventHandler interface { Handle(param interface{}) diff --git a/event/event.go b/event/event.go index 3f3799b..462cfd8 100644 --- a/event/event.go +++ b/event/event.go @@ -1,8 +1,8 @@ package event import ( - "qteam/app/constants/common" - "qteam/event/observers" + "cron_admin/app/constants/common" + "cron_admin/event/observers" ) /** diff --git a/go.mod b/go.mod index 11ba3a8..6006b94 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module qteam +module cron_admin go 1.21 @@ -6,6 +6,7 @@ require ( gitee.com/chengdu_blue_brothers/openapi-go-sdk v0.0.2 github.com/BurntSushi/toml v0.4.1 github.com/Shopify/sarama v1.19.0 + github.com/ahmetb/go-linq/v3 v3.2.0 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/forgoer/openssl v1.6.0 github.com/gin-gonic/gin v1.7.7 @@ -29,6 +30,8 @@ require ( google.golang.org/grpc v1.56.3 google.golang.org/protobuf v1.30.0 gopkg.in/go-playground/validator.v9 v9.31.0 + xorm.io/builder v0.3.9 + xorm.io/xorm v1.2.5 ) require ( @@ -52,6 +55,7 @@ require ( github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/emirpasic/gods v1.12.0 // indirect + github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.19.6 // indirect @@ -110,7 +114,5 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect stathat.com/c/consistent v1.0.0 // indirect - xorm.io/builder v0.3.9 // indirect xorm.io/core v0.7.3 // indirect - xorm.io/xorm v1.2.5 // indirect ) diff --git a/go.sum b/go.sum index a3fda71..becba70 100644 --- a/go.sum +++ b/go.sum @@ -61,6 +61,8 @@ github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/ github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/agiledragon/gomonkey/v2 v2.3.1 h1:k+UnUY0EMNYUFUAQVETGY9uUTxjMdnUkP0ARyJS1zzs= github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= +github.com/ahmetb/go-linq/v3 v3.2.0 h1:BEuMfp+b59io8g5wYzNoFe9pWPalRklhlhbiU3hYZDE= +github.com/ahmetb/go-linq/v3 v3.2.0/go.mod h1:haQ3JfOeWK8HpVxMtHHEMPVgBKiYyQ+f1/kLZh/cj9U= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -173,6 +175,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 h1:6VSn3hB5U5GeA6kQw4TwWIWbOhtvR2hmbBJnTOtqTWc= github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6/go.mod h1:YxOVT5+yHzKvwhsiSIWmbAYM3Dr9AEEbER2dVayfBkg= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/gzip v0.0.3 h1:etUaeesHhEORpZMp18zoOhepboiWnFtXrBZxszWUn4k= diff --git a/main.go b/main.go index 736894f..3e7ca8f 100644 --- a/main.go +++ b/main.go @@ -1,16 +1,16 @@ package main import ( + "cron_admin/app/console" + "cron_admin/app/http/routes" + "cron_admin/app/jobs" + "cron_admin/bootstrap" + "cron_admin/config" + _ "cron_admin/docs" + "cron_admin/rpc" "errors" "fmt" "os" - "qteam/app/console" - "qteam/app/http/routes" - "qteam/app/jobs" - "qteam/bootstrap" - "qteam/config" - _ "qteam/docs" - "qteam/rpc" _ "github.com/go-sql-driver/mysql" _ "github.com/qit-team/snow-core/cache/rediscache" diff --git a/rpc/server.go b/rpc/server.go index 20dd716..3ba8f64 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -1,8 +1,8 @@ package rpc import ( + __ "cron_admin/rpc/user" "github.com/qit-team/snow-core/kernel/server" - __ "qteam/rpc/user" ) func StartRpc() error { @@ -10,7 +10,7 @@ func StartRpc() error { //等待停止信号 server.WaitStop() - + return nil } diff --git a/rpc/user/user.server.go b/rpc/user/user.server.go index 19b5109..f0d8c9d 100644 --- a/rpc/user/user.server.go +++ b/rpc/user/user.server.go @@ -2,11 +2,11 @@ package __ import ( "context" + "cron_admin/app/utils" + "cron_admin/config" "google.golang.org/grpc" "log" "net" - "qteam/app/utils" - "qteam/config" ) // 服务定义