diff --git a/app/user/cmd/api/desc/agent.api b/app/user/cmd/api/desc/agent.api deleted file mode 100644 index 3050ed9..0000000 --- a/app/user/cmd/api/desc/agent.api +++ /dev/null @@ -1,31 +0,0 @@ -syntax = "v1" - -info ( - title: "代理服务" - desc: "代理服务接口" - author: "Liangzai" - email: "2440983361@qq.com" - version: "v1" -) - -import ( - "agent/agent.api" -) - -@server ( - prefix: api/v1/agent - group: agent -) -service main { - @handler GetAgentInfo - get /info returns (AgentInfoResp) - - // 提交代理申请 - @handler ApplyForAgent - post /apply (AgentApplyReq) returns (AgentApplyResp) - - // 查询代理申请状态 - @handler GetAgentAuditStatus - get /audit/status (AgentAuditStatusReq) returns (AgentAuditStatusResp) -} - diff --git a/app/user/cmd/api/desc/agent/agent.api b/app/user/cmd/api/desc/agent/agent.api deleted file mode 100644 index e1f301d..0000000 --- a/app/user/cmd/api/desc/agent/agent.api +++ /dev/null @@ -1,41 +0,0 @@ -syntax = "v1" - -info ( - title: "代理服务" - desc: "代理服务接口" - author: "Liangzai" - email: "2440983361@qq.com" - version: "v1" -) - -type ( - AgentInfoResp { - isAgent bool `json:"is_agent"` - region string `json:"region"` - mobile string `json:"mobile"` - wechatID string `json:"wechat_id"` - } - - // 代理申请请求参数 - AgentApplyReq { - UserID int64 `json:"user_id"` - Region string `json:"region"` - Mobile string `json:"mobile"` - WechatID string `json:"wechat_id"` - } - // 代理申请响应 - AgentApplyResp { - Status string `json:"status"` - Message string `json:"message"` - } - // 查询代理申请状态请求参数 - AgentAuditStatusReq { - UserID int64 `json:"user_id"` - } - // 查询代理申请状态响应 - AgentAuditStatusResp { - Status int `json:"status"` // 0=待审核,1=审核通过,2=审核未通过 - AuditReason string `json:"audit_reason"` - } -) - diff --git a/app/user/cmd/api/desc/main.api b/app/user/cmd/api/desc/main.api index 0832ccd..b735f1d 100644 --- a/app/user/cmd/api/desc/main.api +++ b/app/user/cmd/api/desc/main.api @@ -12,4 +12,3 @@ import "user.api" import "query.api" import "pay.api" import "product.api" -import "agent.api" diff --git a/app/user/cmd/api/etc/main.dev.yaml b/app/user/cmd/api/etc/main.dev.yaml index 3558f83..ef02f50 100644 --- a/app/user/cmd/api/etc/main.dev.yaml +++ b/app/user/cmd/api/etc/main.dev.yaml @@ -1,7 +1,7 @@ Name: main Host: 0.0.0.0 Port: 8888 -DataSource: "qnc:5vg67b3UNHu8@tcp(127.0.0.1:20001)/qnc?charset=utf8mb4&parseTime=True&loc=Local" +DataSource: "tyc:5vg67b3UNHu8@tcp(127.0.0.1:20001)/tyc?charset=utf8mb4&parseTime=True&loc=Local" CacheRedis: - Host: "127.0.0.1:20002" Pass: "3m3WsgyCKWqz" # Redis 密码,如果未设置则留空 diff --git a/app/user/cmd/api/etc/main.yaml b/app/user/cmd/api/etc/main.yaml index 0f96dc7..f44d8fe 100644 --- a/app/user/cmd/api/etc/main.yaml +++ b/app/user/cmd/api/etc/main.yaml @@ -1,9 +1,9 @@ Name: main Host: 0.0.0.0 Port: 8888 -DataSource: "qnc:5vg67b3UNHu8@tcp(qnc_mysql:3306)/qnc?charset=utf8mb4&parseTime=True&loc=Local" +DataSource: "tyc:5vg67b3UNHu8@tcp(tyc_mysql:3306)/tyc?charset=utf8mb4&parseTime=True&loc=Local" CacheRedis: - - Host: "qnc_redis:6379" + - Host: "tyc_redis:6379" Pass: "3m3WsgyCKWqz" # Redis 密码,如果未设置则留空 Type: "node" # 单节点模式 diff --git a/app/user/cmd/api/internal/handler/agent/applyforagenthandler.go b/app/user/cmd/api/internal/handler/agent/applyforagenthandler.go deleted file mode 100644 index 4ec382f..0000000 --- a/app/user/cmd/api/internal/handler/agent/applyforagenthandler.go +++ /dev/null @@ -1,29 +0,0 @@ -package agent - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/agent" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" -) - -func ApplyForAgentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AgentApplyReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - if err := validator.Validate(req); err != nil { - result.ParamValidateErrorResult(r, w, err) - return - } - l := agent.NewApplyForAgentLogic(r.Context(), svcCtx) - resp, err := l.ApplyForAgent(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/app/user/cmd/api/internal/handler/agent/getagentauditstatushandler.go b/app/user/cmd/api/internal/handler/agent/getagentauditstatushandler.go deleted file mode 100644 index f2aa2ca..0000000 --- a/app/user/cmd/api/internal/handler/agent/getagentauditstatushandler.go +++ /dev/null @@ -1,29 +0,0 @@ -package agent - -import ( - "net/http" - - "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/agent" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" -) - -func GetAgentAuditStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req types.AgentAuditStatusReq - if err := httpx.Parse(r, &req); err != nil { - result.ParamErrorResult(r, w, err) - return - } - if err := validator.Validate(req); err != nil { - result.ParamValidateErrorResult(r, w, err) - return - } - l := agent.NewGetAgentAuditStatusLogic(r.Context(), svcCtx) - resp, err := l.GetAgentAuditStatus(&req) - result.HttpResult(r, w, resp, err) - } -} diff --git a/app/user/cmd/api/internal/handler/agent/getagentinfohandler.go b/app/user/cmd/api/internal/handler/agent/getagentinfohandler.go deleted file mode 100644 index 2897fb3..0000000 --- a/app/user/cmd/api/internal/handler/agent/getagentinfohandler.go +++ /dev/null @@ -1,17 +0,0 @@ -package agent - -import ( - "net/http" - - "qnc-server/app/user/cmd/api/internal/logic/agent" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/common/result" -) - -func GetAgentInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - l := agent.NewGetAgentInfoLogic(r.Context(), svcCtx) - resp, err := l.GetAgentInfo() - result.HttpResult(r, w, resp, err) - } -} diff --git a/app/user/cmd/api/internal/handler/auth/sendsmshandler.go b/app/user/cmd/api/internal/handler/auth/sendsmshandler.go index 02b65e3..0bdccc2 100644 --- a/app/user/cmd/api/internal/handler/auth/sendsmshandler.go +++ b/app/user/cmd/api/internal/handler/auth/sendsmshandler.go @@ -3,12 +3,13 @@ package auth import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/auth" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/auth" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func SendSmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/notification/getnotificationshandler.go b/app/user/cmd/api/internal/handler/notification/getnotificationshandler.go index 6dc313f..1d7e335 100644 --- a/app/user/cmd/api/internal/handler/notification/getnotificationshandler.go +++ b/app/user/cmd/api/internal/handler/notification/getnotificationshandler.go @@ -3,9 +3,9 @@ package notification import ( "net/http" - "qnc-server/app/user/cmd/api/internal/logic/notification" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/common/result" + "tyc-server/app/user/cmd/api/internal/logic/notification" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/common/result" ) func GetNotificationsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/pay/alipaycallbackhandler.go b/app/user/cmd/api/internal/handler/pay/alipaycallbackhandler.go index 6ddda20..2256922 100644 --- a/app/user/cmd/api/internal/handler/pay/alipaycallbackhandler.go +++ b/app/user/cmd/api/internal/handler/pay/alipaycallbackhandler.go @@ -3,9 +3,9 @@ package pay import ( "net/http" - "qnc-server/app/user/cmd/api/internal/logic/pay" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/common/result" + "tyc-server/app/user/cmd/api/internal/logic/pay" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/common/result" ) func AlipayCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/pay/iapcallbackhandler.go b/app/user/cmd/api/internal/handler/pay/iapcallbackhandler.go index 4b96a1a..2d274c0 100644 --- a/app/user/cmd/api/internal/handler/pay/iapcallbackhandler.go +++ b/app/user/cmd/api/internal/handler/pay/iapcallbackhandler.go @@ -3,12 +3,13 @@ package pay import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/pay" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/pay" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func IapCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/pay/paymenthandler.go b/app/user/cmd/api/internal/handler/pay/paymenthandler.go index 696328b..35f1ccb 100644 --- a/app/user/cmd/api/internal/handler/pay/paymenthandler.go +++ b/app/user/cmd/api/internal/handler/pay/paymenthandler.go @@ -3,12 +3,13 @@ package pay import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/pay" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/pay" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func PaymentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/pay/wechatpaycallbackhandler.go b/app/user/cmd/api/internal/handler/pay/wechatpaycallbackhandler.go index 68397d0..420eb8c 100644 --- a/app/user/cmd/api/internal/handler/pay/wechatpaycallbackhandler.go +++ b/app/user/cmd/api/internal/handler/pay/wechatpaycallbackhandler.go @@ -3,9 +3,9 @@ package pay import ( "net/http" - "qnc-server/app/user/cmd/api/internal/logic/pay" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/common/result" + "tyc-server/app/user/cmd/api/internal/logic/pay" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/common/result" ) func WechatPayCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/pay/wechatpayrefundcallbackhandler.go b/app/user/cmd/api/internal/handler/pay/wechatpayrefundcallbackhandler.go index b9bfa0a..2cdc4d5 100644 --- a/app/user/cmd/api/internal/handler/pay/wechatpayrefundcallbackhandler.go +++ b/app/user/cmd/api/internal/handler/pay/wechatpayrefundcallbackhandler.go @@ -3,9 +3,9 @@ package pay import ( "net/http" - "qnc-server/app/user/cmd/api/internal/logic/pay" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/common/result" + "tyc-server/app/user/cmd/api/internal/logic/pay" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/common/result" ) func WechatPayRefundCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/product/getproductbyenhandler.go b/app/user/cmd/api/internal/handler/product/getproductbyenhandler.go index c972025..31ecda6 100644 --- a/app/user/cmd/api/internal/handler/product/getproductbyenhandler.go +++ b/app/user/cmd/api/internal/handler/product/getproductbyenhandler.go @@ -3,12 +3,13 @@ package product import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/product" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/product" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func GetProductByEnHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/product/getproductbyidhandler.go b/app/user/cmd/api/internal/handler/product/getproductbyidhandler.go index f772005..f556fdd 100644 --- a/app/user/cmd/api/internal/handler/product/getproductbyidhandler.go +++ b/app/user/cmd/api/internal/handler/product/getproductbyidhandler.go @@ -3,12 +3,13 @@ package product import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/product" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/product" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func GetProductByIDHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/product/getproductrenderlisthandler.go b/app/user/cmd/api/internal/handler/product/getproductrenderlisthandler.go index 8ab932e..0dc038d 100644 --- a/app/user/cmd/api/internal/handler/product/getproductrenderlisthandler.go +++ b/app/user/cmd/api/internal/handler/product/getproductrenderlisthandler.go @@ -3,12 +3,13 @@ package product import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/product" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/product" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func GetProductRenderListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/querydetailbyorderidhandler.go b/app/user/cmd/api/internal/handler/query/querydetailbyorderidhandler.go index 7f221c7..147be36 100644 --- a/app/user/cmd/api/internal/handler/query/querydetailbyorderidhandler.go +++ b/app/user/cmd/api/internal/handler/query/querydetailbyorderidhandler.go @@ -3,12 +3,13 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func QueryDetailByOrderIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/querydetailbyordernohandler.go b/app/user/cmd/api/internal/handler/query/querydetailbyordernohandler.go index ee15def..d23ebc8 100644 --- a/app/user/cmd/api/internal/handler/query/querydetailbyordernohandler.go +++ b/app/user/cmd/api/internal/handler/query/querydetailbyordernohandler.go @@ -3,12 +3,13 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func QueryDetailByOrderNoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/querydetailhandler.go b/app/user/cmd/api/internal/handler/query/querydetailhandler.go index 718c9cb..0d45bea 100644 --- a/app/user/cmd/api/internal/handler/query/querydetailhandler.go +++ b/app/user/cmd/api/internal/handler/query/querydetailhandler.go @@ -3,12 +3,13 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func QueryDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/queryexamplehandler.go b/app/user/cmd/api/internal/handler/query/queryexamplehandler.go index 2285e79..13ee035 100644 --- a/app/user/cmd/api/internal/handler/query/queryexamplehandler.go +++ b/app/user/cmd/api/internal/handler/query/queryexamplehandler.go @@ -3,12 +3,13 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func QueryExampleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/querylisthandler.go b/app/user/cmd/api/internal/handler/query/querylisthandler.go index e35089c..539e07e 100644 --- a/app/user/cmd/api/internal/handler/query/querylisthandler.go +++ b/app/user/cmd/api/internal/handler/query/querylisthandler.go @@ -3,12 +3,13 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func QueryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/queryprovisionalorderhandler.go b/app/user/cmd/api/internal/handler/query/queryprovisionalorderhandler.go index f98d84b..a22e990 100644 --- a/app/user/cmd/api/internal/handler/query/queryprovisionalorderhandler.go +++ b/app/user/cmd/api/internal/handler/query/queryprovisionalorderhandler.go @@ -3,12 +3,13 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func QueryProvisionalOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/queryretryhandler.go b/app/user/cmd/api/internal/handler/query/queryretryhandler.go index 57972a5..3bf2cd4 100644 --- a/app/user/cmd/api/internal/handler/query/queryretryhandler.go +++ b/app/user/cmd/api/internal/handler/query/queryretryhandler.go @@ -3,12 +3,13 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func QueryRetryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/queryservicehandler.go b/app/user/cmd/api/internal/handler/query/queryservicehandler.go index 0fd3e01..f2e042c 100644 --- a/app/user/cmd/api/internal/handler/query/queryservicehandler.go +++ b/app/user/cmd/api/internal/handler/query/queryservicehandler.go @@ -3,11 +3,12 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" ) func QueryServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/query/querysingletesthandler.go b/app/user/cmd/api/internal/handler/query/querysingletesthandler.go index 2e51879..e846b72 100644 --- a/app/user/cmd/api/internal/handler/query/querysingletesthandler.go +++ b/app/user/cmd/api/internal/handler/query/querysingletesthandler.go @@ -3,12 +3,13 @@ package query import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/query" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/query" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func QuerySingleTestHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/routes.go b/app/user/cmd/api/internal/handler/routes.go index 87c141e..e02f718 100644 --- a/app/user/cmd/api/internal/handler/routes.go +++ b/app/user/cmd/api/internal/handler/routes.go @@ -4,40 +4,18 @@ package handler import ( "net/http" - agent "qnc-server/app/user/cmd/api/internal/handler/agent" - auth "qnc-server/app/user/cmd/api/internal/handler/auth" - notification "qnc-server/app/user/cmd/api/internal/handler/notification" - pay "qnc-server/app/user/cmd/api/internal/handler/pay" - product "qnc-server/app/user/cmd/api/internal/handler/product" - query "qnc-server/app/user/cmd/api/internal/handler/query" - user "qnc-server/app/user/cmd/api/internal/handler/user" - "qnc-server/app/user/cmd/api/internal/svc" + auth "tyc-server/app/user/cmd/api/internal/handler/auth" + notification "tyc-server/app/user/cmd/api/internal/handler/notification" + pay "tyc-server/app/user/cmd/api/internal/handler/pay" + product "tyc-server/app/user/cmd/api/internal/handler/product" + query "tyc-server/app/user/cmd/api/internal/handler/query" + user "tyc-server/app/user/cmd/api/internal/handler/user" + "tyc-server/app/user/cmd/api/internal/svc" "github.com/zeromicro/go-zero/rest" ) func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { - server.AddRoutes( - []rest.Route{ - { - Method: http.MethodPost, - Path: "/apply", - Handler: agent.ApplyForAgentHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/audit/status", - Handler: agent.GetAgentAuditStatusHandler(serverCtx), - }, - { - Method: http.MethodGet, - Path: "/info", - Handler: agent.GetAgentInfoHandler(serverCtx), - }, - }, - rest.WithPrefix("/api/v1/agent"), - ) - server.AddRoutes( []rest.Route{ { diff --git a/app/user/cmd/api/internal/handler/user/decryptmobilehandler.go b/app/user/cmd/api/internal/handler/user/decryptmobilehandler.go index ab11636..08ae769 100644 --- a/app/user/cmd/api/internal/handler/user/decryptmobilehandler.go +++ b/app/user/cmd/api/internal/handler/user/decryptmobilehandler.go @@ -2,9 +2,9 @@ package user import ( "net/http" - "qnc-server/app/user/cmd/api/internal/logic/user" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/common/result" + "tyc-server/app/user/cmd/api/internal/logic/user" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/common/result" ) func DecryptMobileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/user/detailhandler.go b/app/user/cmd/api/internal/handler/user/detailhandler.go index 109adc1..51bcbbf 100644 --- a/app/user/cmd/api/internal/handler/user/detailhandler.go +++ b/app/user/cmd/api/internal/handler/user/detailhandler.go @@ -3,9 +3,9 @@ package user import ( "net/http" - "qnc-server/app/user/cmd/api/internal/logic/user" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/common/result" + "tyc-server/app/user/cmd/api/internal/logic/user" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/common/result" ) func DetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/user/gettokenhandler.go b/app/user/cmd/api/internal/handler/user/gettokenhandler.go index dce90e1..b6ded03 100644 --- a/app/user/cmd/api/internal/handler/user/gettokenhandler.go +++ b/app/user/cmd/api/internal/handler/user/gettokenhandler.go @@ -3,9 +3,9 @@ package user import ( "net/http" - "qnc-server/app/user/cmd/api/internal/logic/user" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/common/result" + "tyc-server/app/user/cmd/api/internal/logic/user" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/common/result" ) func GetTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/user/mobilecodeloginhandler.go b/app/user/cmd/api/internal/handler/user/mobilecodeloginhandler.go index e38c606..faa71e8 100644 --- a/app/user/cmd/api/internal/handler/user/mobilecodeloginhandler.go +++ b/app/user/cmd/api/internal/handler/user/mobilecodeloginhandler.go @@ -3,12 +3,13 @@ package user import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/user" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/user" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func MobileCodeLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/user/mobileloginhandler.go b/app/user/cmd/api/internal/handler/user/mobileloginhandler.go index 2559263..23c873e 100644 --- a/app/user/cmd/api/internal/handler/user/mobileloginhandler.go +++ b/app/user/cmd/api/internal/handler/user/mobileloginhandler.go @@ -3,12 +3,13 @@ package user import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/user" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/user" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func MobileLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/user/registerhandler.go b/app/user/cmd/api/internal/handler/user/registerhandler.go index 12db94e..4441cbe 100644 --- a/app/user/cmd/api/internal/handler/user/registerhandler.go +++ b/app/user/cmd/api/internal/handler/user/registerhandler.go @@ -3,12 +3,13 @@ package user import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/user" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/user" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func RegisterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/user/wxh5authhandler.go b/app/user/cmd/api/internal/handler/user/wxh5authhandler.go index 54ed1e7..05de7e9 100644 --- a/app/user/cmd/api/internal/handler/user/wxh5authhandler.go +++ b/app/user/cmd/api/internal/handler/user/wxh5authhandler.go @@ -3,12 +3,13 @@ package user import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/user" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/user" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func WxH5AuthHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/handler/user/wxminiauthhandler.go b/app/user/cmd/api/internal/handler/user/wxminiauthhandler.go index d53d5fe..88c6da4 100644 --- a/app/user/cmd/api/internal/handler/user/wxminiauthhandler.go +++ b/app/user/cmd/api/internal/handler/user/wxminiauthhandler.go @@ -3,12 +3,13 @@ package user import ( "net/http" + "tyc-server/app/user/cmd/api/internal/logic/user" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" + "github.com/zeromicro/go-zero/rest/httpx" - "qnc-server/app/user/cmd/api/internal/logic/user" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" ) func WxMiniAuthHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { diff --git a/app/user/cmd/api/internal/logic/agent/applyforagentlogic.go b/app/user/cmd/api/internal/logic/agent/applyforagentlogic.go deleted file mode 100644 index 8212729..0000000 --- a/app/user/cmd/api/internal/logic/agent/applyforagentlogic.go +++ /dev/null @@ -1,52 +0,0 @@ -package agent - -import ( - "context" - "github.com/pkg/errors" - "qnc-server/app/user/model" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/lzUtils" - "time" - - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ApplyForAgentLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewApplyForAgentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApplyForAgentLogic { - return &ApplyForAgentLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *types.AgentApplyResp, err error) { - var agentAudit model.AgentAudit - agentAudit.Mobile = req.Mobile - agentAudit.Region = req.Region - agentAudit.WechatId = lzUtils.StringToNullString(req.WechatID) - agentAudit.Status = 0 - agentAuditInsert, err := l.svcCtx.AgentAuditModel.Insert(l.ctx, nil, &agentAudit) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "代理申请, 保存代理信息失败: %+v", err) - } - - go func() { - // 延迟 10 秒 - <-time.After(10 * time.Second) - // 查找刚刚插入的数据 - agentAuditID, _ := agentAuditInsert.LastInsertId() - agentAuditRow, _ := l.svcCtx.AgentAuditModel.FindOne(l.ctx, agentAuditID) - - l.svcCtx.AgentAuditModel.UpdateWithVersion(l.ctx, nil, agentAuditRow) - }() - return nil, nil -} diff --git a/app/user/cmd/api/internal/logic/agent/getagentauditstatuslogic.go b/app/user/cmd/api/internal/logic/agent/getagentauditstatuslogic.go deleted file mode 100644 index 1cd0318..0000000 --- a/app/user/cmd/api/internal/logic/agent/getagentauditstatuslogic.go +++ /dev/null @@ -1,30 +0,0 @@ -package agent - -import ( - "context" - - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetAgentAuditStatusLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetAgentAuditStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAgentAuditStatusLogic { - return &GetAgentAuditStatusLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetAgentAuditStatusLogic) GetAgentAuditStatus(req *types.AgentAuditStatusReq) (resp *types.AgentAuditStatusResp, err error) { - // todo: add your logic here and delete this line - - return -} diff --git a/app/user/cmd/api/internal/logic/agent/getagentinfologic.go b/app/user/cmd/api/internal/logic/agent/getagentinfologic.go deleted file mode 100644 index b478767..0000000 --- a/app/user/cmd/api/internal/logic/agent/getagentinfologic.go +++ /dev/null @@ -1,48 +0,0 @@ -package agent - -import ( - "context" - "database/sql" - "github.com/jinzhu/copier" - "github.com/pkg/errors" - "qnc-server/common/ctxdata" - "qnc-server/common/xerr" - - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - - "github.com/zeromicro/go-zero/core/logx" -) - -type GetAgentInfoLogic struct { - logx.Logger - ctx context.Context - svcCtx *svc.ServiceContext -} - -func NewGetAgentInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAgentInfoLogic { - return &GetAgentInfoLogic{ - Logger: logx.WithContext(ctx), - ctx: ctx, - svcCtx: svcCtx, - } -} - -func (l *GetAgentInfoLogic) GetAgentInfo() (resp *types.AgentInfoResp, err error) { - userID, err := ctxdata.GetUidFromCtx(l.ctx) - if err != nil { - return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理信息, %+v", err) - } - agent, err := l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID) - if err != nil { - if errors.Is(err, sql.ErrNoRows) { - return &types.AgentInfoResp{ - IsAgent: false, - }, nil - } - return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "获取代理信息, %+v", err) - } - copier.Copy(&resp, agent) - resp.IsAgent = true - return resp, nil -} diff --git a/app/user/cmd/api/internal/logic/auth/sendsmslogic.go b/app/user/cmd/api/internal/logic/auth/sendsmslogic.go index d8be020..ce389fe 100644 --- a/app/user/cmd/api/internal/logic/auth/sendsmslogic.go +++ b/app/user/cmd/api/internal/logic/auth/sendsmslogic.go @@ -3,13 +3,14 @@ package auth import ( "context" "fmt" - "github.com/pkg/errors" "math/rand" - "qnc-server/common/xerr" "time" + "tyc-server/common/xerr" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "github.com/pkg/errors" + + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" dysmsapi "github.com/alibabacloud-go/dysmsapi-20170525/v3/client" diff --git a/app/user/cmd/api/internal/logic/notification/getnotificationslogic.go b/app/user/cmd/api/internal/logic/notification/getnotificationslogic.go index 92ffd33..fedc113 100644 --- a/app/user/cmd/api/internal/logic/notification/getnotificationslogic.go +++ b/app/user/cmd/api/internal/logic/notification/getnotificationslogic.go @@ -2,13 +2,14 @@ package notification import ( "context" + "time" + "tyc-server/common/xerr" + "github.com/jinzhu/copier" "github.com/pkg/errors" - "qnc-server/common/xerr" - "time" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/pay/alipaycallbacklogic.go b/app/user/cmd/api/internal/logic/pay/alipaycallbacklogic.go index 9e001e1..19dbc9a 100644 --- a/app/user/cmd/api/internal/logic/pay/alipaycallbacklogic.go +++ b/app/user/cmd/api/internal/logic/pay/alipaycallbacklogic.go @@ -2,13 +2,15 @@ package pay import ( "context" - "github.com/smartwalle/alipay/v3" "net/http" - "qnc-server/pkg/lzkit/lzUtils" "time" + "tyc-server/pkg/lzkit/lzUtils" + + "github.com/smartwalle/alipay/v3" + + "tyc-server/app/user/cmd/api/internal/svc" "github.com/zeromicro/go-zero/core/logx" - "qnc-server/app/user/cmd/api/internal/svc" ) type AlipayCallbackLogic struct { diff --git a/app/user/cmd/api/internal/logic/pay/iapcallbacklogic.go b/app/user/cmd/api/internal/logic/pay/iapcallbacklogic.go index a2960ab..788ddde 100644 --- a/app/user/cmd/api/internal/logic/pay/iapcallbacklogic.go +++ b/app/user/cmd/api/internal/logic/pay/iapcallbacklogic.go @@ -2,12 +2,13 @@ package pay import ( "context" - "github.com/pkg/errors" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/lzUtils" "time" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/xerr" + "tyc-server/pkg/lzkit/lzUtils" + + "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/pay/paymentlogic.go b/app/user/cmd/api/internal/logic/pay/paymentlogic.go index e3d0b81..4325506 100644 --- a/app/user/cmd/api/internal/logic/pay/paymentlogic.go +++ b/app/user/cmd/api/internal/logic/pay/paymentlogic.go @@ -5,12 +5,12 @@ import ( "encoding/hex" "encoding/json" "fmt" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/app/user/model" - "qnc-server/common/ctxdata" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/crypto" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/model" + "tyc-server/common/ctxdata" + "tyc-server/common/xerr" + "tyc-server/pkg/lzkit/crypto" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/logx" diff --git a/app/user/cmd/api/internal/logic/pay/wechatpaycallbacklogic.go b/app/user/cmd/api/internal/logic/pay/wechatpaycallbacklogic.go index ff1e812..6fbdcaa 100644 --- a/app/user/cmd/api/internal/logic/pay/wechatpaycallbacklogic.go +++ b/app/user/cmd/api/internal/logic/pay/wechatpaycallbacklogic.go @@ -3,12 +3,13 @@ package pay import ( "context" "net/http" - "qnc-server/app/user/cmd/api/internal/service" - "qnc-server/pkg/lzkit/lzUtils" "time" + "tyc-server/app/user/cmd/api/internal/service" + "tyc-server/pkg/lzkit/lzUtils" + + "tyc-server/app/user/cmd/api/internal/svc" "github.com/zeromicro/go-zero/core/logx" - "qnc-server/app/user/cmd/api/internal/svc" ) type WechatPayCallbackLogic struct { diff --git a/app/user/cmd/api/internal/logic/pay/wechatpayrefundcallbacklogic.go b/app/user/cmd/api/internal/logic/pay/wechatpayrefundcallbacklogic.go index 54cf99a..bfc91b9 100644 --- a/app/user/cmd/api/internal/logic/pay/wechatpayrefundcallbacklogic.go +++ b/app/user/cmd/api/internal/logic/pay/wechatpayrefundcallbacklogic.go @@ -2,10 +2,11 @@ package pay import ( "context" + "net/http" + "tyc-server/app/user/cmd/api/internal/svc" + "github.com/wechatpay-apiv3/wechatpay-go/services/refunddomestic" "github.com/zeromicro/go-zero/core/logx" - "net/http" - "qnc-server/app/user/cmd/api/internal/svc" ) type WechatPayRefundCallbackLogic struct { diff --git a/app/user/cmd/api/internal/logic/product/getproductbyenlogic.go b/app/user/cmd/api/internal/logic/product/getproductbyenlogic.go index 5edbfe0..eecf23e 100644 --- a/app/user/cmd/api/internal/logic/product/getproductbyenlogic.go +++ b/app/user/cmd/api/internal/logic/product/getproductbyenlogic.go @@ -2,15 +2,16 @@ package product import ( "context" + "tyc-server/app/user/model" + "tyc-server/common/xerr" + "github.com/Masterminds/squirrel" "github.com/jinzhu/copier" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/mr" - "qnc-server/app/user/model" - "qnc-server/common/xerr" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/product/getproductbyidlogic.go b/app/user/cmd/api/internal/logic/product/getproductbyidlogic.go index 17382d1..55a548d 100644 --- a/app/user/cmd/api/internal/logic/product/getproductbyidlogic.go +++ b/app/user/cmd/api/internal/logic/product/getproductbyidlogic.go @@ -3,8 +3,8 @@ package product import ( "context" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/product/getproductrenderlistlogic.go b/app/user/cmd/api/internal/logic/product/getproductrenderlistlogic.go index 532cc75..931eb28 100644 --- a/app/user/cmd/api/internal/logic/product/getproductrenderlistlogic.go +++ b/app/user/cmd/api/internal/logic/product/getproductrenderlistlogic.go @@ -2,14 +2,15 @@ package product import ( "context" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/model" + "tyc-server/common/xerr" + "github.com/Masterminds/squirrel" "github.com/jinzhu/copier" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/mr" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/app/user/model" - "qnc-server/common/xerr" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/query/querydetailbyorderidlogic.go b/app/user/cmd/api/internal/logic/query/querydetailbyorderidlogic.go index e6bed27..c023bb0 100644 --- a/app/user/cmd/api/internal/logic/query/querydetailbyorderidlogic.go +++ b/app/user/cmd/api/internal/logic/query/querydetailbyorderidlogic.go @@ -5,16 +5,17 @@ import ( "database/sql" "encoding/hex" "encoding/json" + "time" + "tyc-server/common/xerr" + "tyc-server/pkg/lzkit/crypto" + "tyc-server/pkg/lzkit/delay" + "tyc-server/pkg/lzkit/lzUtils" + "github.com/jinzhu/copier" "github.com/pkg/errors" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/crypto" - "qnc-server/pkg/lzkit/delay" - "qnc-server/pkg/lzkit/lzUtils" - "time" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/query/querydetailbyordernologic.go b/app/user/cmd/api/internal/logic/query/querydetailbyordernologic.go index 5a4adee..1121aa3 100644 --- a/app/user/cmd/api/internal/logic/query/querydetailbyordernologic.go +++ b/app/user/cmd/api/internal/logic/query/querydetailbyordernologic.go @@ -3,14 +3,15 @@ package query import ( "context" "encoding/hex" + "time" + "tyc-server/common/xerr" + "tyc-server/pkg/lzkit/delay" + "github.com/jinzhu/copier" "github.com/pkg/errors" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/delay" - "time" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/query/querydetaillogic.go b/app/user/cmd/api/internal/logic/query/querydetaillogic.go index c557611..5b4abf6 100644 --- a/app/user/cmd/api/internal/logic/query/querydetaillogic.go +++ b/app/user/cmd/api/internal/logic/query/querydetaillogic.go @@ -4,14 +4,15 @@ import ( "context" "encoding/hex" "encoding/json" + "tyc-server/common/xerr" + "tyc-server/pkg/lzkit/crypto" + "tyc-server/pkg/lzkit/lzUtils" + "github.com/jinzhu/copier" "github.com/pkg/errors" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/crypto" - "qnc-server/pkg/lzkit/lzUtils" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/query/queryexamplelogic.go b/app/user/cmd/api/internal/logic/query/queryexamplelogic.go index f3f0516..fe6a3bf 100644 --- a/app/user/cmd/api/internal/logic/query/queryexamplelogic.go +++ b/app/user/cmd/api/internal/logic/query/queryexamplelogic.go @@ -3,9 +3,9 @@ package query import ( "context" "encoding/hex" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/xerr" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/xerr" "github.com/jinzhu/copier" "github.com/pkg/errors" diff --git a/app/user/cmd/api/internal/logic/query/querylistlogic.go b/app/user/cmd/api/internal/logic/query/querylistlogic.go index 0fdb03f..1397de7 100644 --- a/app/user/cmd/api/internal/logic/query/querylistlogic.go +++ b/app/user/cmd/api/internal/logic/query/querylistlogic.go @@ -2,14 +2,15 @@ package query import ( "context" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/ctxdata" + "tyc-server/common/xerr" + "github.com/Masterminds/squirrel" "github.com/jinzhu/copier" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/logx" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/ctxdata" - "qnc-server/common/xerr" ) type QueryListLogic struct { diff --git a/app/user/cmd/api/internal/logic/query/queryprovisionalorderlogic.go b/app/user/cmd/api/internal/logic/query/queryprovisionalorderlogic.go index 7c9ce0b..e25cb03 100644 --- a/app/user/cmd/api/internal/logic/query/queryprovisionalorderlogic.go +++ b/app/user/cmd/api/internal/logic/query/queryprovisionalorderlogic.go @@ -4,12 +4,13 @@ import ( "context" "encoding/json" "fmt" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/ctxdata" + "tyc-server/common/xerr" + "github.com/jinzhu/copier" "github.com/pkg/errors" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/ctxdata" - "qnc-server/common/xerr" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/query/queryretrylogic.go b/app/user/cmd/api/internal/logic/query/queryretrylogic.go index 6fd1b57..6efbbb0 100644 --- a/app/user/cmd/api/internal/logic/query/queryretrylogic.go +++ b/app/user/cmd/api/internal/logic/query/queryretrylogic.go @@ -2,11 +2,12 @@ package query import ( "context" - "github.com/pkg/errors" - "qnc-server/common/xerr" + "tyc-server/common/xerr" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "github.com/pkg/errors" + + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/query/queryservicelogic.go b/app/user/cmd/api/internal/logic/query/queryservicelogic.go index 4363b6d..5847316 100644 --- a/app/user/cmd/api/internal/logic/query/queryservicelogic.go +++ b/app/user/cmd/api/internal/logic/query/queryservicelogic.go @@ -5,18 +5,18 @@ import ( "encoding/hex" "encoding/json" "fmt" - "qnc-server/app/user/cmd/api/internal/service" - "qnc-server/common/ctxdata" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/crypto" - "qnc-server/pkg/lzkit/validator" "time" + "tyc-server/app/user/cmd/api/internal/service" + "tyc-server/common/ctxdata" + "tyc-server/common/xerr" + "tyc-server/pkg/lzkit/crypto" + "tyc-server/pkg/lzkit/validator" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/stores/redis" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/query/querysingletestlogic.go b/app/user/cmd/api/internal/logic/query/querysingletestlogic.go index 67d002e..8cdecc6 100644 --- a/app/user/cmd/api/internal/logic/query/querysingletestlogic.go +++ b/app/user/cmd/api/internal/logic/query/querysingletestlogic.go @@ -3,13 +3,13 @@ package query import ( "context" "encoding/json" - "qnc-server/common/xerr" "time" + "tyc-server/common/xerr" "github.com/pkg/errors" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/user/decryptmobilelogic.go b/app/user/cmd/api/internal/logic/user/decryptmobilelogic.go index bcb125c..77b7323 100644 --- a/app/user/cmd/api/internal/logic/user/decryptmobilelogic.go +++ b/app/user/cmd/api/internal/logic/user/decryptmobilelogic.go @@ -3,8 +3,9 @@ package user import ( "context" + "tyc-server/app/user/cmd/api/internal/svc" + "github.com/zeromicro/go-zero/core/logx" - "qnc-server/app/user/cmd/api/internal/svc" ) type DecryptMobileLogic struct { diff --git a/app/user/cmd/api/internal/logic/user/detaillogic.go b/app/user/cmd/api/internal/logic/user/detaillogic.go index f4a66cd..6202997 100644 --- a/app/user/cmd/api/internal/logic/user/detaillogic.go +++ b/app/user/cmd/api/internal/logic/user/detaillogic.go @@ -2,12 +2,13 @@ package user import ( "context" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/common/ctxdata" + "tyc-server/common/xerr" + "github.com/jinzhu/copier" "github.com/pkg/errors" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/common/ctxdata" - "qnc-server/common/xerr" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/user/gettokenlogic.go b/app/user/cmd/api/internal/logic/user/gettokenlogic.go index eaf56d6..babe275 100644 --- a/app/user/cmd/api/internal/logic/user/gettokenlogic.go +++ b/app/user/cmd/api/internal/logic/user/gettokenlogic.go @@ -2,14 +2,15 @@ package user import ( "context" - "github.com/pkg/errors" - "qnc-server/common/ctxdata" - jwtx "qnc-server/common/jwt" - "qnc-server/common/xerr" "time" + "tyc-server/common/ctxdata" + jwtx "tyc-server/common/jwt" + "tyc-server/common/xerr" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "github.com/pkg/errors" + + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/user/mobilecodeloginlogic.go b/app/user/cmd/api/internal/logic/user/mobilecodeloginlogic.go index 457f172..cb7e844 100644 --- a/app/user/cmd/api/internal/logic/user/mobilecodeloginlogic.go +++ b/app/user/cmd/api/internal/logic/user/mobilecodeloginlogic.go @@ -3,15 +3,16 @@ package user import ( "context" "fmt" + "time" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/model" + jwtx "tyc-server/common/jwt" + "tyc-server/common/xerr" + "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/stores/redis" "github.com/zeromicro/go-zero/core/stores/sqlx" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/app/user/model" - jwtx "qnc-server/common/jwt" - "qnc-server/common/xerr" - "time" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/user/mobileloginlogic.go b/app/user/cmd/api/internal/logic/user/mobileloginlogic.go index 7c96a76..cab1ab3 100644 --- a/app/user/cmd/api/internal/logic/user/mobileloginlogic.go +++ b/app/user/cmd/api/internal/logic/user/mobileloginlogic.go @@ -2,16 +2,17 @@ package user import ( "context" - "github.com/pkg/errors" - "qnc-server/app/user/model" - jwtx "qnc-server/common/jwt" - "qnc-server/common/tool" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/lzUtils" "time" + "tyc-server/app/user/model" + jwtx "tyc-server/common/jwt" + "tyc-server/common/tool" + "tyc-server/common/xerr" + "tyc-server/pkg/lzkit/lzUtils" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "github.com/pkg/errors" + + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/user/registerlogic.go b/app/user/cmd/api/internal/logic/user/registerlogic.go index e13963d..060bcc9 100644 --- a/app/user/cmd/api/internal/logic/user/registerlogic.go +++ b/app/user/cmd/api/internal/logic/user/registerlogic.go @@ -3,17 +3,18 @@ package user import ( "context" "fmt" + "time" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/model" + jwtx "tyc-server/common/jwt" + "tyc-server/common/tool" + "tyc-server/common/xerr" + "tyc-server/pkg/lzkit/lzUtils" + "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/stores/redis" "github.com/zeromicro/go-zero/core/stores/sqlx" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/app/user/model" - jwtx "qnc-server/common/jwt" - "qnc-server/common/tool" - "qnc-server/common/xerr" - "qnc-server/pkg/lzkit/lzUtils" - "time" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/user/wxh5authlogic.go b/app/user/cmd/api/internal/logic/user/wxh5authlogic.go index db39fdc..089140c 100644 --- a/app/user/cmd/api/internal/logic/user/wxh5authlogic.go +++ b/app/user/cmd/api/internal/logic/user/wxh5authlogic.go @@ -4,16 +4,17 @@ import ( "context" "encoding/json" "fmt" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/stores/sqlx" "io" "net/http" - "qnc-server/app/user/model" - jwtx "qnc-server/common/jwt" "time" + "tyc-server/app/user/model" + jwtx "tyc-server/common/jwt" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "github.com/pkg/errors" + "github.com/zeromicro/go-zero/core/stores/sqlx" + + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/logic/user/wxminiauthlogic.go b/app/user/cmd/api/internal/logic/user/wxminiauthlogic.go index 92c6af5..fa667d9 100644 --- a/app/user/cmd/api/internal/logic/user/wxminiauthlogic.go +++ b/app/user/cmd/api/internal/logic/user/wxminiauthlogic.go @@ -4,17 +4,18 @@ import ( "context" "encoding/json" "fmt" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/stores/sqlx" "io" "net/http" "net/url" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" - "qnc-server/app/user/model" - jwtx "qnc-server/common/jwt" - "qnc-server/common/xerr" "time" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/model" + jwtx "tyc-server/common/jwt" + "tyc-server/common/xerr" + + "github.com/pkg/errors" + "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/logx" ) diff --git a/app/user/cmd/api/internal/queue/carMaintenanceQuery.go b/app/user/cmd/api/internal/queue/carMaintenanceQuery.go index 8176005..3b363eb 100644 --- a/app/user/cmd/api/internal/queue/carMaintenanceQuery.go +++ b/app/user/cmd/api/internal/queue/carMaintenanceQuery.go @@ -2,7 +2,7 @@ package queue import ( "context" - "qnc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/svc" "github.com/hibiken/asynq" ) diff --git a/app/user/cmd/api/internal/queue/cleanQueryData.go b/app/user/cmd/api/internal/queue/cleanQueryData.go index e3bad7f..79f550a 100644 --- a/app/user/cmd/api/internal/queue/cleanQueryData.go +++ b/app/user/cmd/api/internal/queue/cleanQueryData.go @@ -3,8 +3,9 @@ package queue import ( "context" "fmt" + "tyc-server/app/user/cmd/api/internal/svc" + "github.com/hibiken/asynq" - "qnc-server/app/user/cmd/api/internal/svc" ) const TASKTIME = "0 2 * * *" diff --git a/app/user/cmd/api/internal/queue/paySuccessNotify.go b/app/user/cmd/api/internal/queue/paySuccessNotify.go index 69e6d51..09db05a 100644 --- a/app/user/cmd/api/internal/queue/paySuccessNotify.go +++ b/app/user/cmd/api/internal/queue/paySuccessNotify.go @@ -5,10 +5,10 @@ import ( "encoding/hex" "encoding/json" "fmt" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/model" - "qnc-server/pkg/lzkit/crypto" - "qnc-server/pkg/lzkit/lzUtils" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/model" + "tyc-server/pkg/lzkit/crypto" + "tyc-server/pkg/lzkit/lzUtils" "github.com/hibiken/asynq" "github.com/zeromicro/go-zero/core/logx" diff --git a/app/user/cmd/api/internal/queue/routes.go b/app/user/cmd/api/internal/queue/routes.go index dd62a9b..d8f5a13 100644 --- a/app/user/cmd/api/internal/queue/routes.go +++ b/app/user/cmd/api/internal/queue/routes.go @@ -3,8 +3,8 @@ package queue import ( "context" "fmt" - "qnc-server/app/user/cmd/api/internal/svc" - "qnc-server/app/user/cmd/api/internal/types" + "tyc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/types" "github.com/hibiken/asynq" ) diff --git a/app/user/cmd/api/internal/service/alipayService.go b/app/user/cmd/api/internal/service/alipayService.go index 84c2624..732ad0a 100644 --- a/app/user/cmd/api/internal/service/alipayService.go +++ b/app/user/cmd/api/internal/service/alipayService.go @@ -3,13 +3,14 @@ package service import ( "context" "fmt" - "github.com/smartwalle/alipay/v3" mathrand "math/rand" "net/http" - "qnc-server/app/user/cmd/api/internal/config" - "qnc-server/pkg/lzkit/lzUtils" "strconv" "time" + "tyc-server/app/user/cmd/api/internal/config" + "tyc-server/pkg/lzkit/lzUtils" + + "github.com/smartwalle/alipay/v3" ) type AliPayService struct { diff --git a/app/user/cmd/api/internal/service/apirequestService.go b/app/user/cmd/api/internal/service/apirequestService.go index 527cfcd..7b87a19 100644 --- a/app/user/cmd/api/internal/service/apirequestService.go +++ b/app/user/cmd/api/internal/service/apirequestService.go @@ -8,14 +8,14 @@ import ( "io" "net/http" "net/url" - "qnc-server/app/user/cmd/api/internal/config" - "qnc-server/app/user/model" - "qnc-server/pkg/lzkit/crypto" - "qnc-server/pkg/lzkit/lzUtils" "strings" "sync" "sync/atomic" "time" + "tyc-server/app/user/cmd/api/internal/config" + "tyc-server/app/user/model" + "tyc-server/pkg/lzkit/crypto" + "tyc-server/pkg/lzkit/lzUtils" "github.com/Masterminds/squirrel" "github.com/bytedance/sonic" diff --git a/app/user/cmd/api/internal/service/applepayService.go b/app/user/cmd/api/internal/service/applepayService.go index cb45030..81d0114 100644 --- a/app/user/cmd/api/internal/service/applepayService.go +++ b/app/user/cmd/api/internal/service/applepayService.go @@ -7,12 +7,13 @@ import ( "encoding/json" "encoding/pem" "fmt" - "github.com/golang-jwt/jwt/v4" "io/ioutil" "net/http" - "qnc-server/app/user/cmd/api/internal/config" "strconv" "time" + "tyc-server/app/user/cmd/api/internal/config" + + "github.com/golang-jwt/jwt/v4" ) // ApplePayService 是 Apple IAP 支付服务的结构体 diff --git a/app/user/cmd/api/internal/service/asynqService.go b/app/user/cmd/api/internal/service/asynqService.go index 328a98b..bf4b8dc 100644 --- a/app/user/cmd/api/internal/service/asynqService.go +++ b/app/user/cmd/api/internal/service/asynqService.go @@ -4,9 +4,9 @@ package service import ( "encoding/json" - "qnc-server/app/user/cmd/api/internal/config" - "qnc-server/app/user/cmd/api/internal/types" "time" + "tyc-server/app/user/cmd/api/internal/config" + "tyc-server/app/user/cmd/api/internal/types" "github.com/hibiken/asynq" "github.com/zeromicro/go-zero/core/logx" diff --git a/app/user/cmd/api/internal/service/tianjuService.go b/app/user/cmd/api/internal/service/tianjuService.go index 9993fcf..ea76996 100644 --- a/app/user/cmd/api/internal/service/tianjuService.go +++ b/app/user/cmd/api/internal/service/tianjuService.go @@ -6,8 +6,8 @@ import ( "io" "net/http" "net/url" - "qnc-server/app/user/cmd/api/internal/config" "strings" + "tyc-server/app/user/cmd/api/internal/config" "github.com/tidwall/gjson" ) diff --git a/app/user/cmd/api/internal/service/verificationService.go b/app/user/cmd/api/internal/service/verificationService.go index 9a78b0f..005da81 100644 --- a/app/user/cmd/api/internal/service/verificationService.go +++ b/app/user/cmd/api/internal/service/verificationService.go @@ -3,13 +3,14 @@ package service import ( "encoding/json" "fmt" - "github.com/tidwall/gjson" "io" "net/http" "net/url" - "qnc-server/app/user/cmd/api/internal/config" - "qnc-server/pkg/lzkit/crypto" "strings" + "tyc-server/app/user/cmd/api/internal/config" + "tyc-server/pkg/lzkit/crypto" + + "github.com/tidwall/gjson" ) type VerificationService struct { diff --git a/app/user/cmd/api/internal/service/wechatpayService.go b/app/user/cmd/api/internal/service/wechatpayService.go index cb2f17a..be6c3df 100644 --- a/app/user/cmd/api/internal/service/wechatpayService.go +++ b/app/user/cmd/api/internal/service/wechatpayService.go @@ -3,6 +3,14 @@ package service import ( "context" "fmt" + "net/http" + "strconv" + "time" + "tyc-server/app/user/cmd/api/internal/config" + "tyc-server/app/user/model" + "tyc-server/common/ctxdata" + "tyc-server/pkg/lzkit/lzUtils" + "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/auth/verifiers" "github.com/wechatpay-apiv3/wechatpay-go/core/downloader" @@ -14,13 +22,6 @@ import ( "github.com/wechatpay-apiv3/wechatpay-go/services/refunddomestic" "github.com/wechatpay-apiv3/wechatpay-go/utils" "github.com/zeromicro/go-zero/core/logx" - "net/http" - "qnc-server/app/user/cmd/api/internal/config" - "qnc-server/app/user/model" - "qnc-server/common/ctxdata" - "qnc-server/pkg/lzkit/lzUtils" - "strconv" - "time" ) const ( diff --git a/app/user/cmd/api/internal/service/westdexService.go b/app/user/cmd/api/internal/service/westdexService.go index 5d0eb74..6349048 100644 --- a/app/user/cmd/api/internal/service/westdexService.go +++ b/app/user/cmd/api/internal/service/westdexService.go @@ -7,10 +7,10 @@ import ( "io" "log" "net/http" - "qnc-server/app/user/cmd/api/internal/config" - "qnc-server/pkg/lzkit/crypto" "strconv" "time" + "tyc-server/app/user/cmd/api/internal/config" + "tyc-server/pkg/lzkit/crypto" "github.com/pkg/errors" ) diff --git a/app/user/cmd/api/internal/service/yushanService.go b/app/user/cmd/api/internal/service/yushanService.go index e776462..669825a 100644 --- a/app/user/cmd/api/internal/service/yushanService.go +++ b/app/user/cmd/api/internal/service/yushanService.go @@ -12,9 +12,9 @@ import ( "fmt" "io" "net/http" - "qnc-server/app/user/cmd/api/internal/config" "strings" "time" + "tyc-server/app/user/cmd/api/internal/config" "github.com/tidwall/gjson" ) diff --git a/app/user/cmd/api/internal/svc/servicecontext.go b/app/user/cmd/api/internal/svc/servicecontext.go index b04de80..89d8425 100644 --- a/app/user/cmd/api/internal/svc/servicecontext.go +++ b/app/user/cmd/api/internal/svc/servicecontext.go @@ -1,10 +1,10 @@ package svc import ( - "qnc-server/app/user/cmd/api/internal/config" - "qnc-server/app/user/cmd/api/internal/middleware" - "qnc-server/app/user/cmd/api/internal/service" - "qnc-server/app/user/model" + "tyc-server/app/user/cmd/api/internal/config" + "tyc-server/app/user/cmd/api/internal/middleware" + "tyc-server/app/user/cmd/api/internal/service" + "tyc-server/app/user/model" "github.com/hibiken/asynq" "github.com/zeromicro/go-zero/core/logx" @@ -25,11 +25,6 @@ type ServiceContext struct { ProductRenderModel model.ProductRenderModel OrderModel model.OrderModel QueryModel model.QueryModel - AgentModel model.AgentModel - AgentAuditModel model.AgentAuditModel - AgentClosureModel model.AgentClosureModel - AgentCommissionModel model.AgentCommissionModel - AgentWalletModel model.AgentWalletModel GlobalNotificationsModel model.GlobalNotificationsModel ExampleModel model.ExampleModel AlipayService *service.AliPayService @@ -89,11 +84,6 @@ func NewServiceContext(c config.Config) *ServiceContext { QueryModel: model.NewQueryModel(db, c.CacheRedis), ExampleModel: model.NewExampleModel(db, c.CacheRedis), GlobalNotificationsModel: model.NewGlobalNotificationsModel(db, c.CacheRedis), - AgentModel: model.NewAgentModel(db, c.CacheRedis), - AgentAuditModel: model.NewAgentAuditModel(db, c.CacheRedis), - AgentCommissionModel: model.NewAgentCommissionModel(db, c.CacheRedis), - AgentWalletModel: model.NewAgentWalletModel(db, c.CacheRedis), - AgentClosureModel: model.NewAgentClosureModel(db, c.CacheRedis), FeatureModel: featureModel, ProductFeatureModel: productFeatureModel, } diff --git a/app/user/cmd/api/internal/types/types.go b/app/user/cmd/api/internal/types/types.go index afa2700..6dbf6e7 100644 --- a/app/user/cmd/api/internal/types/types.go +++ b/app/user/cmd/api/internal/types/types.go @@ -1,34 +1,6 @@ // Code generated by goctl. DO NOT EDIT. package types -type AgentApplyReq struct { - UserID int64 `json:"user_id"` - Region string `json:"region"` - Mobile string `json:"mobile"` - WechatID string `json:"wechat_id"` -} - -type AgentApplyResp struct { - Status string `json:"status"` - Message string `json:"message"` -} - -type AgentAuditStatusReq struct { - UserID int64 `json:"user_id"` -} - -type AgentAuditStatusResp struct { - Status int `json:"status"` // 0=待审核,1=审核通过,2=审核未通过 - AuditReason string `json:"audit_reason"` -} - -type AgentInfoResp struct { - IsAgent bool `json:"is_agent"` - Region string `json:"region"` - Mobile string `json:"mobile"` - WechatID string `json:"wechat_id"` -} - type Feature struct { ID int64 `json:"id"` // 功能ID ApiID string `json:"api_id"` // API标识 diff --git a/app/user/cmd/api/main.go b/app/user/cmd/api/main.go index 6d37348..f06ee3d 100644 --- a/app/user/cmd/api/main.go +++ b/app/user/cmd/api/main.go @@ -5,10 +5,10 @@ import ( "flag" "fmt" "os" - "qnc-server/app/user/cmd/api/internal/config" - "qnc-server/app/user/cmd/api/internal/handler" - "qnc-server/app/user/cmd/api/internal/queue" - "qnc-server/app/user/cmd/api/internal/svc" + "tyc-server/app/user/cmd/api/internal/config" + "tyc-server/app/user/cmd/api/internal/handler" + "tyc-server/app/user/cmd/api/internal/queue" + "tyc-server/app/user/cmd/api/internal/svc" "github.com/zeromicro/go-zero/core/logx" diff --git a/app/user/model/agentAuditModel.go b/app/user/model/agentAuditModel.go deleted file mode 100644 index 80ddf43..0000000 --- a/app/user/model/agentAuditModel.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlx" -) - -var _ AgentAuditModel = (*customAgentAuditModel)(nil) - -type ( - // AgentAuditModel is an interface to be customized, add more methods here, - // and implement the added methods in customAgentAuditModel. - AgentAuditModel interface { - agentAuditModel - } - - customAgentAuditModel struct { - *defaultAgentAuditModel - } -) - -// NewAgentAuditModel returns a model for the database table. -func NewAgentAuditModel(conn sqlx.SqlConn, c cache.CacheConf) AgentAuditModel { - return &customAgentAuditModel{ - defaultAgentAuditModel: newAgentAuditModel(conn, c), - } -} diff --git a/app/user/model/agentAuditModel_gen.go b/app/user/model/agentAuditModel_gen.go deleted file mode 100644 index be139ed..0000000 --- a/app/user/model/agentAuditModel_gen.go +++ /dev/null @@ -1,374 +0,0 @@ -// Code generated by goctl. DO NOT EDIT! - -package model - -import ( - "context" - "database/sql" - "fmt" - "qnc-server/deploy/script/model" - "strings" - - "time" - - "github.com/Masterminds/squirrel" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/stores/builder" - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlc" - "github.com/zeromicro/go-zero/core/stores/sqlx" - "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" -) - -var ( - agentAuditFieldNames = builder.RawFieldNames(&AgentAudit{}) - agentAuditRows = strings.Join(agentAuditFieldNames, ",") - agentAuditRowsExpectAutoSet = strings.Join(stringx.Remove(agentAuditFieldNames, "`id`", "`create_time`", "`update_time`"), ",") - agentAuditRowsWithPlaceHolder = strings.Join(stringx.Remove(agentAuditFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - - cacheQncAgentAuditIdPrefix = "cache:qnc:agentAudit:id:" -) - -type ( - agentAuditModel interface { - Insert(ctx context.Context, session sqlx.Session, data *AgentAudit) (sql.Result, error) - FindOne(ctx context.Context, id int64) (*AgentAudit, error) - Update(ctx context.Context, session sqlx.Session, data *AgentAudit) (sql.Result, error) - UpdateWithVersion(ctx context.Context, session sqlx.Session, data *AgentAudit) error - Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error - SelectBuilder() squirrel.SelectBuilder - DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentAudit) error - FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error) - FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error) - FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*AgentAudit, error) - FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentAudit, error) - FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentAudit, int64, error) - FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentAudit, error) - FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentAudit, error) - Delete(ctx context.Context, session sqlx.Session, id int64) error - } - - defaultAgentAuditModel struct { - sqlc.CachedConn - table string - } - - AgentAudit struct { - Id int64 `db:"id"` - UserId int64 `db:"user_id"` - Region string `db:"region"` - Mobile string `db:"mobile"` - WechatId sql.NullString `db:"wechat_id"` - Status int64 `db:"status"` - AuditReason sql.NullString `db:"audit_reason"` - CreateTime time.Time `db:"create_time"` - AuditTime sql.NullTime `db:"audit_time"` - UpdateTime time.Time `db:"update_time"` // 更新时间 - DeleteTime sql.NullTime `db:"delete_time"` // 删除时间 - DelState int64 `db:"del_state"` // 删除状态 - Version int64 `db:"version"` // 版本号 - } -) - -func newAgentAuditModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultAgentAuditModel { - return &defaultAgentAuditModel{ - CachedConn: sqlc.NewConn(conn, c), - table: "`agent_audit`", - } -} - -func (m *defaultAgentAuditModel) Insert(ctx context.Context, session sqlx.Session, data *AgentAudit) (sql.Result, error) { - data.DelState = globalkey.DelStateNo - qncAgentAuditIdKey := fmt.Sprintf("%s%v", cacheQncAgentAuditIdPrefix, data.Id) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, agentAuditRowsExpectAutoSet) - if session != nil { - return session.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.Status, data.AuditReason, data.AuditTime, data.DeleteTime, data.DelState, data.Version) - } - return conn.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.Status, data.AuditReason, data.AuditTime, data.DeleteTime, data.DelState, data.Version) - }, qncAgentAuditIdKey) -} - -func (m *defaultAgentAuditModel) FindOne(ctx context.Context, id int64) (*AgentAudit, error) { - qncAgentAuditIdKey := fmt.Sprintf("%s%v", cacheQncAgentAuditIdPrefix, id) - var resp AgentAudit - err := m.QueryRowCtx(ctx, &resp, qncAgentAuditIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", agentAuditRows, m.table) - return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) - }) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, model.ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentAuditModel) Update(ctx context.Context, session sqlx.Session, data *AgentAudit) (sql.Result, error) { - qncAgentAuditIdKey := fmt.Sprintf("%s%v", cacheQncAgentAuditIdPrefix, data.Id) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, agentAuditRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.Status, data.AuditReason, data.AuditTime, data.DeleteTime, data.DelState, data.Version, data.Id) - } - return conn.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.Status, data.AuditReason, data.AuditTime, data.DeleteTime, data.DelState, data.Version, data.Id) - }, qncAgentAuditIdKey) -} - -func (m *defaultAgentAuditModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, data *AgentAudit) error { - - oldVersion := data.Version - data.Version += 1 - - var sqlResult sql.Result - var err error - - qncAgentAuditIdKey := fmt.Sprintf("%s%v", cacheQncAgentAuditIdPrefix, data.Id) - sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, agentAuditRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.Status, data.AuditReason, data.AuditTime, data.DeleteTime, data.DelState, data.Version, data.Id, oldVersion) - } - return conn.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.Status, data.AuditReason, data.AuditTime, data.DeleteTime, data.DelState, data.Version, data.Id, oldVersion) - }, qncAgentAuditIdKey) - if err != nil { - return err - } - updateCount, err := sqlResult.RowsAffected() - if err != nil { - return err - } - if updateCount == 0 { - return model.ErrNoRowsUpdate - } - - return nil -} - -func (m *defaultAgentAuditModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentAudit) error { - data.DelState = globalkey.DelStateYes - data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true} - if err := m.UpdateWithVersion(ctx, session, data); err != nil { - return errors.Wrapf(errors.New("delete soft failed "), "AgentAuditModel delete err : %+v", err) - } - return nil -} - -func (m *defaultAgentAuditModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field") - } - - builder = builder.Columns("IFNULL(SUM(" + field + "),0)") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp float64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentAuditModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field") - } - - builder = builder.Columns("COUNT(" + field + ")") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp int64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentAuditModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*AgentAudit, error) { - - builder = builder.Columns(agentAuditRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentAudit - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentAuditModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentAudit, error) { - - builder = builder.Columns(agentAuditRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentAudit - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentAuditModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentAudit, int64, error) { - - total, err := m.FindCount(ctx, builder, "id") - if err != nil { - return nil, 0, err - } - - builder = builder.Columns(agentAuditRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, total, err - } - - var resp []*AgentAudit - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, total, nil - default: - return nil, total, err - } -} - -func (m *defaultAgentAuditModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentAudit, error) { - - builder = builder.Columns(agentAuditRows) - - if preMinId > 0 { - builder = builder.Where(" id < ? ", preMinId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentAudit - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentAuditModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentAudit, error) { - - builder = builder.Columns(agentAuditRows) - - if preMaxId > 0 { - builder = builder.Where(" id > ? ", preMaxId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentAudit - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentAuditModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error { - - return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error { - return fn(ctx, session) - }) - -} - -func (m *defaultAgentAuditModel) SelectBuilder() squirrel.SelectBuilder { - return squirrel.Select().From(m.table) -} -func (m *defaultAgentAuditModel) Delete(ctx context.Context, session sqlx.Session, id int64) error { - qncAgentAuditIdKey := fmt.Sprintf("%s%v", cacheQncAgentAuditIdPrefix, id) - _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) - if session != nil { - return session.ExecCtx(ctx, query, id) - } - return conn.ExecCtx(ctx, query, id) - }, qncAgentAuditIdKey) - return err -} -func (m *defaultAgentAuditModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncAgentAuditIdPrefix, primary) -} -func (m *defaultAgentAuditModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", agentAuditRows, m.table) - return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) -} - -func (m *defaultAgentAuditModel) tableName() string { - return m.table -} diff --git a/app/user/model/agentClosureModel.go b/app/user/model/agentClosureModel.go deleted file mode 100644 index dd92f74..0000000 --- a/app/user/model/agentClosureModel.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlx" -) - -var _ AgentClosureModel = (*customAgentClosureModel)(nil) - -type ( - // AgentClosureModel is an interface to be customized, add more methods here, - // and implement the added methods in customAgentClosureModel. - AgentClosureModel interface { - agentClosureModel - } - - customAgentClosureModel struct { - *defaultAgentClosureModel - } -) - -// NewAgentClosureModel returns a model for the database table. -func NewAgentClosureModel(conn sqlx.SqlConn, c cache.CacheConf) AgentClosureModel { - return &customAgentClosureModel{ - defaultAgentClosureModel: newAgentClosureModel(conn, c), - } -} diff --git a/app/user/model/agentClosureModel_gen.go b/app/user/model/agentClosureModel_gen.go deleted file mode 100644 index e3db764..0000000 --- a/app/user/model/agentClosureModel_gen.go +++ /dev/null @@ -1,409 +0,0 @@ -// Code generated by goctl. DO NOT EDIT! - -package model - -import ( - "context" - "database/sql" - "fmt" - "qnc-server/deploy/script/model" - "strings" - - "time" - - "github.com/Masterminds/squirrel" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/stores/builder" - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlc" - "github.com/zeromicro/go-zero/core/stores/sqlx" - "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" -) - -var ( - agentClosureFieldNames = builder.RawFieldNames(&AgentClosure{}) - agentClosureRows = strings.Join(agentClosureFieldNames, ",") - agentClosureRowsExpectAutoSet = strings.Join(stringx.Remove(agentClosureFieldNames, "`id`", "`create_time`", "`update_time`"), ",") - agentClosureRowsWithPlaceHolder = strings.Join(stringx.Remove(agentClosureFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - - cacheQncAgentClosureIdPrefix = "cache:qnc:agentClosure:id:" - cacheQncAgentClosureAncestorIdDescendantIdPrefix = "cache:qnc:agentClosure:ancestorId:descendantId:" -) - -type ( - agentClosureModel interface { - Insert(ctx context.Context, session sqlx.Session, data *AgentClosure) (sql.Result, error) - FindOne(ctx context.Context, id int64) (*AgentClosure, error) - FindOneByAncestorIdDescendantId(ctx context.Context, ancestorId int64, descendantId int64) (*AgentClosure, error) - Update(ctx context.Context, session sqlx.Session, data *AgentClosure) (sql.Result, error) - UpdateWithVersion(ctx context.Context, session sqlx.Session, data *AgentClosure) error - Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error - SelectBuilder() squirrel.SelectBuilder - DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentClosure) error - FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error) - FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error) - FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*AgentClosure, error) - FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentClosure, error) - FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentClosure, int64, error) - FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentClosure, error) - FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentClosure, error) - Delete(ctx context.Context, session sqlx.Session, id int64) error - } - - defaultAgentClosureModel struct { - sqlc.CachedConn - table string - } - - AgentClosure struct { - Id int64 `db:"id"` - AncestorId int64 `db:"ancestor_id"` - DescendantId int64 `db:"descendant_id"` - Depth int64 `db:"depth"` - CreateTime time.Time `db:"create_time"` - UpdateTime time.Time `db:"update_time"` // 更新时间 - DeleteTime sql.NullTime `db:"delete_time"` // 删除时间 - DelState int64 `db:"del_state"` // 删除状态 - Version int64 `db:"version"` // 版本号 - } -) - -func newAgentClosureModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultAgentClosureModel { - return &defaultAgentClosureModel{ - CachedConn: sqlc.NewConn(conn, c), - table: "`agent_closure`", - } -} - -func (m *defaultAgentClosureModel) Insert(ctx context.Context, session sqlx.Session, data *AgentClosure) (sql.Result, error) { - data.DelState = globalkey.DelStateNo - qncAgentClosureAncestorIdDescendantIdKey := fmt.Sprintf("%s%v:%v", cacheQncAgentClosureAncestorIdDescendantIdPrefix, data.AncestorId, data.DescendantId) - qncAgentClosureIdKey := fmt.Sprintf("%s%v", cacheQncAgentClosureIdPrefix, data.Id) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?)", m.table, agentClosureRowsExpectAutoSet) - if session != nil { - return session.ExecCtx(ctx, query, data.AncestorId, data.DescendantId, data.Depth, data.DeleteTime, data.DelState, data.Version) - } - return conn.ExecCtx(ctx, query, data.AncestorId, data.DescendantId, data.Depth, data.DeleteTime, data.DelState, data.Version) - }, qncAgentClosureAncestorIdDescendantIdKey, qncAgentClosureIdKey) -} - -func (m *defaultAgentClosureModel) FindOne(ctx context.Context, id int64) (*AgentClosure, error) { - qncAgentClosureIdKey := fmt.Sprintf("%s%v", cacheQncAgentClosureIdPrefix, id) - var resp AgentClosure - err := m.QueryRowCtx(ctx, &resp, qncAgentClosureIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", agentClosureRows, m.table) - return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) - }) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, model.ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentClosureModel) FindOneByAncestorIdDescendantId(ctx context.Context, ancestorId int64, descendantId int64) (*AgentClosure, error) { - qncAgentClosureAncestorIdDescendantIdKey := fmt.Sprintf("%s%v:%v", cacheQncAgentClosureAncestorIdDescendantIdPrefix, ancestorId, descendantId) - var resp AgentClosure - err := m.QueryRowIndexCtx(ctx, &resp, qncAgentClosureAncestorIdDescendantIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `ancestor_id` = ? AND `descendant_id` = ? AND del_state = ? limit 1", agentClosureRows, m.table) - if err := conn.QueryRowCtx(ctx, &resp, query, ancestorId, descendantId, globalkey.DelStateNo); err != nil { - return nil, err - } - return resp.Id, nil - }, m.queryPrimary) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, model.ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentClosureModel) Update(ctx context.Context, session sqlx.Session, newData *AgentClosure) (sql.Result, error) { - data, err := m.FindOne(ctx, newData.Id) - if err != nil { - return nil, err - } - qncAgentClosureAncestorIdDescendantIdKey := fmt.Sprintf("%s%v:%v", cacheQncAgentClosureAncestorIdDescendantIdPrefix, data.AncestorId, data.DescendantId) - qncAgentClosureIdKey := fmt.Sprintf("%s%v", cacheQncAgentClosureIdPrefix, data.Id) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, agentClosureRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, newData.AncestorId, newData.DescendantId, newData.Depth, newData.DeleteTime, newData.DelState, newData.Version, newData.Id) - } - return conn.ExecCtx(ctx, query, newData.AncestorId, newData.DescendantId, newData.Depth, newData.DeleteTime, newData.DelState, newData.Version, newData.Id) - }, qncAgentClosureAncestorIdDescendantIdKey, qncAgentClosureIdKey) -} - -func (m *defaultAgentClosureModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *AgentClosure) error { - - oldVersion := newData.Version - newData.Version += 1 - - var sqlResult sql.Result - var err error - - data, err := m.FindOne(ctx, newData.Id) - if err != nil { - return err - } - qncAgentClosureAncestorIdDescendantIdKey := fmt.Sprintf("%s%v:%v", cacheQncAgentClosureAncestorIdDescendantIdPrefix, data.AncestorId, data.DescendantId) - qncAgentClosureIdKey := fmt.Sprintf("%s%v", cacheQncAgentClosureIdPrefix, data.Id) - sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, agentClosureRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, newData.AncestorId, newData.DescendantId, newData.Depth, newData.DeleteTime, newData.DelState, newData.Version, newData.Id, oldVersion) - } - return conn.ExecCtx(ctx, query, newData.AncestorId, newData.DescendantId, newData.Depth, newData.DeleteTime, newData.DelState, newData.Version, newData.Id, oldVersion) - }, qncAgentClosureAncestorIdDescendantIdKey, qncAgentClosureIdKey) - if err != nil { - return err - } - updateCount, err := sqlResult.RowsAffected() - if err != nil { - return err - } - if updateCount == 0 { - return model.ErrNoRowsUpdate - } - - return nil -} - -func (m *defaultAgentClosureModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentClosure) error { - data.DelState = globalkey.DelStateYes - data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true} - if err := m.UpdateWithVersion(ctx, session, data); err != nil { - return errors.Wrapf(errors.New("delete soft failed "), "AgentClosureModel delete err : %+v", err) - } - return nil -} - -func (m *defaultAgentClosureModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field") - } - - builder = builder.Columns("IFNULL(SUM(" + field + "),0)") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp float64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentClosureModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field") - } - - builder = builder.Columns("COUNT(" + field + ")") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp int64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentClosureModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*AgentClosure, error) { - - builder = builder.Columns(agentClosureRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentClosure - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentClosureModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentClosure, error) { - - builder = builder.Columns(agentClosureRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentClosure - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentClosureModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentClosure, int64, error) { - - total, err := m.FindCount(ctx, builder, "id") - if err != nil { - return nil, 0, err - } - - builder = builder.Columns(agentClosureRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, total, err - } - - var resp []*AgentClosure - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, total, nil - default: - return nil, total, err - } -} - -func (m *defaultAgentClosureModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentClosure, error) { - - builder = builder.Columns(agentClosureRows) - - if preMinId > 0 { - builder = builder.Where(" id < ? ", preMinId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentClosure - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentClosureModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentClosure, error) { - - builder = builder.Columns(agentClosureRows) - - if preMaxId > 0 { - builder = builder.Where(" id > ? ", preMaxId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentClosure - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentClosureModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error { - - return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error { - return fn(ctx, session) - }) - -} - -func (m *defaultAgentClosureModel) SelectBuilder() squirrel.SelectBuilder { - return squirrel.Select().From(m.table) -} -func (m *defaultAgentClosureModel) Delete(ctx context.Context, session sqlx.Session, id int64) error { - data, err := m.FindOne(ctx, id) - if err != nil { - return err - } - - qncAgentClosureAncestorIdDescendantIdKey := fmt.Sprintf("%s%v:%v", cacheQncAgentClosureAncestorIdDescendantIdPrefix, data.AncestorId, data.DescendantId) - qncAgentClosureIdKey := fmt.Sprintf("%s%v", cacheQncAgentClosureIdPrefix, id) - _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) - if session != nil { - return session.ExecCtx(ctx, query, id) - } - return conn.ExecCtx(ctx, query, id) - }, qncAgentClosureAncestorIdDescendantIdKey, qncAgentClosureIdKey) - return err -} -func (m *defaultAgentClosureModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncAgentClosureIdPrefix, primary) -} -func (m *defaultAgentClosureModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", agentClosureRows, m.table) - return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) -} - -func (m *defaultAgentClosureModel) tableName() string { - return m.table -} diff --git a/app/user/model/agentCommissionModel.go b/app/user/model/agentCommissionModel.go deleted file mode 100644 index 1b9e614..0000000 --- a/app/user/model/agentCommissionModel.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlx" -) - -var _ AgentCommissionModel = (*customAgentCommissionModel)(nil) - -type ( - // AgentCommissionModel is an interface to be customized, add more methods here, - // and implement the added methods in customAgentCommissionModel. - AgentCommissionModel interface { - agentCommissionModel - } - - customAgentCommissionModel struct { - *defaultAgentCommissionModel - } -) - -// NewAgentCommissionModel returns a model for the database table. -func NewAgentCommissionModel(conn sqlx.SqlConn, c cache.CacheConf) AgentCommissionModel { - return &customAgentCommissionModel{ - defaultAgentCommissionModel: newAgentCommissionModel(conn, c), - } -} diff --git a/app/user/model/agentCommissionModel_gen.go b/app/user/model/agentCommissionModel_gen.go deleted file mode 100644 index daa0744..0000000 --- a/app/user/model/agentCommissionModel_gen.go +++ /dev/null @@ -1,371 +0,0 @@ -// Code generated by goctl. DO NOT EDIT! - -package model - -import ( - "context" - "database/sql" - "fmt" - "qnc-server/deploy/script/model" - "strings" - - "time" - - "github.com/Masterminds/squirrel" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/stores/builder" - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlc" - "github.com/zeromicro/go-zero/core/stores/sqlx" - "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" -) - -var ( - agentCommissionFieldNames = builder.RawFieldNames(&AgentCommission{}) - agentCommissionRows = strings.Join(agentCommissionFieldNames, ",") - agentCommissionRowsExpectAutoSet = strings.Join(stringx.Remove(agentCommissionFieldNames, "`id`", "`create_time`", "`update_time`"), ",") - agentCommissionRowsWithPlaceHolder = strings.Join(stringx.Remove(agentCommissionFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - - cacheQncAgentCommissionIdPrefix = "cache:qnc:agentCommission:id:" -) - -type ( - agentCommissionModel interface { - Insert(ctx context.Context, session sqlx.Session, data *AgentCommission) (sql.Result, error) - FindOne(ctx context.Context, id int64) (*AgentCommission, error) - Update(ctx context.Context, session sqlx.Session, data *AgentCommission) (sql.Result, error) - UpdateWithVersion(ctx context.Context, session sqlx.Session, data *AgentCommission) error - Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error - SelectBuilder() squirrel.SelectBuilder - DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentCommission) error - FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error) - FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error) - FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*AgentCommission, error) - FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentCommission, error) - FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentCommission, int64, error) - FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentCommission, error) - FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentCommission, error) - Delete(ctx context.Context, session sqlx.Session, id int64) error - } - - defaultAgentCommissionModel struct { - sqlc.CachedConn - table string - } - - AgentCommission struct { - Id int64 `db:"id"` - AgentId int64 `db:"agent_id"` - OrderId int64 `db:"order_id"` - CommissionAmount float64 `db:"commission_amount"` - Status int64 `db:"status"` - CreateTime time.Time `db:"create_time"` - UpdateTime time.Time `db:"update_time"` // 更新时间 - DeleteTime sql.NullTime `db:"delete_time"` // 删除时间 - DelState int64 `db:"del_state"` // 删除状态 - Version int64 `db:"version"` // 版本号 - } -) - -func newAgentCommissionModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultAgentCommissionModel { - return &defaultAgentCommissionModel{ - CachedConn: sqlc.NewConn(conn, c), - table: "`agent_commission`", - } -} - -func (m *defaultAgentCommissionModel) Insert(ctx context.Context, session sqlx.Session, data *AgentCommission) (sql.Result, error) { - data.DelState = globalkey.DelStateNo - qncAgentCommissionIdKey := fmt.Sprintf("%s%v", cacheQncAgentCommissionIdPrefix, data.Id) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?, ?)", m.table, agentCommissionRowsExpectAutoSet) - if session != nil { - return session.ExecCtx(ctx, query, data.AgentId, data.OrderId, data.CommissionAmount, data.Status, data.DeleteTime, data.DelState, data.Version) - } - return conn.ExecCtx(ctx, query, data.AgentId, data.OrderId, data.CommissionAmount, data.Status, data.DeleteTime, data.DelState, data.Version) - }, qncAgentCommissionIdKey) -} - -func (m *defaultAgentCommissionModel) FindOne(ctx context.Context, id int64) (*AgentCommission, error) { - qncAgentCommissionIdKey := fmt.Sprintf("%s%v", cacheQncAgentCommissionIdPrefix, id) - var resp AgentCommission - err := m.QueryRowCtx(ctx, &resp, qncAgentCommissionIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", agentCommissionRows, m.table) - return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) - }) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, model.ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentCommissionModel) Update(ctx context.Context, session sqlx.Session, data *AgentCommission) (sql.Result, error) { - qncAgentCommissionIdKey := fmt.Sprintf("%s%v", cacheQncAgentCommissionIdPrefix, data.Id) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, agentCommissionRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, data.AgentId, data.OrderId, data.CommissionAmount, data.Status, data.DeleteTime, data.DelState, data.Version, data.Id) - } - return conn.ExecCtx(ctx, query, data.AgentId, data.OrderId, data.CommissionAmount, data.Status, data.DeleteTime, data.DelState, data.Version, data.Id) - }, qncAgentCommissionIdKey) -} - -func (m *defaultAgentCommissionModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, data *AgentCommission) error { - - oldVersion := data.Version - data.Version += 1 - - var sqlResult sql.Result - var err error - - qncAgentCommissionIdKey := fmt.Sprintf("%s%v", cacheQncAgentCommissionIdPrefix, data.Id) - sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, agentCommissionRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, data.AgentId, data.OrderId, data.CommissionAmount, data.Status, data.DeleteTime, data.DelState, data.Version, data.Id, oldVersion) - } - return conn.ExecCtx(ctx, query, data.AgentId, data.OrderId, data.CommissionAmount, data.Status, data.DeleteTime, data.DelState, data.Version, data.Id, oldVersion) - }, qncAgentCommissionIdKey) - if err != nil { - return err - } - updateCount, err := sqlResult.RowsAffected() - if err != nil { - return err - } - if updateCount == 0 { - return model.ErrNoRowsUpdate - } - - return nil -} - -func (m *defaultAgentCommissionModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentCommission) error { - data.DelState = globalkey.DelStateYes - data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true} - if err := m.UpdateWithVersion(ctx, session, data); err != nil { - return errors.Wrapf(errors.New("delete soft failed "), "AgentCommissionModel delete err : %+v", err) - } - return nil -} - -func (m *defaultAgentCommissionModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field") - } - - builder = builder.Columns("IFNULL(SUM(" + field + "),0)") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp float64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentCommissionModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field") - } - - builder = builder.Columns("COUNT(" + field + ")") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp int64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentCommissionModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*AgentCommission, error) { - - builder = builder.Columns(agentCommissionRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentCommission - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentCommissionModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentCommission, error) { - - builder = builder.Columns(agentCommissionRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentCommission - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentCommissionModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentCommission, int64, error) { - - total, err := m.FindCount(ctx, builder, "id") - if err != nil { - return nil, 0, err - } - - builder = builder.Columns(agentCommissionRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, total, err - } - - var resp []*AgentCommission - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, total, nil - default: - return nil, total, err - } -} - -func (m *defaultAgentCommissionModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentCommission, error) { - - builder = builder.Columns(agentCommissionRows) - - if preMinId > 0 { - builder = builder.Where(" id < ? ", preMinId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentCommission - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentCommissionModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentCommission, error) { - - builder = builder.Columns(agentCommissionRows) - - if preMaxId > 0 { - builder = builder.Where(" id > ? ", preMaxId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentCommission - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentCommissionModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error { - - return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error { - return fn(ctx, session) - }) - -} - -func (m *defaultAgentCommissionModel) SelectBuilder() squirrel.SelectBuilder { - return squirrel.Select().From(m.table) -} -func (m *defaultAgentCommissionModel) Delete(ctx context.Context, session sqlx.Session, id int64) error { - qncAgentCommissionIdKey := fmt.Sprintf("%s%v", cacheQncAgentCommissionIdPrefix, id) - _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) - if session != nil { - return session.ExecCtx(ctx, query, id) - } - return conn.ExecCtx(ctx, query, id) - }, qncAgentCommissionIdKey) - return err -} -func (m *defaultAgentCommissionModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncAgentCommissionIdPrefix, primary) -} -func (m *defaultAgentCommissionModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", agentCommissionRows, m.table) - return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) -} - -func (m *defaultAgentCommissionModel) tableName() string { - return m.table -} diff --git a/app/user/model/agentModel.go b/app/user/model/agentModel.go deleted file mode 100644 index 2aef816..0000000 --- a/app/user/model/agentModel.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlx" -) - -var _ AgentModel = (*customAgentModel)(nil) - -type ( - // AgentModel is an interface to be customized, add more methods here, - // and implement the added methods in customAgentModel. - AgentModel interface { - agentModel - } - - customAgentModel struct { - *defaultAgentModel - } -) - -// NewAgentModel returns a model for the database table. -func NewAgentModel(conn sqlx.SqlConn, c cache.CacheConf) AgentModel { - return &customAgentModel{ - defaultAgentModel: newAgentModel(conn, c), - } -} diff --git a/app/user/model/agentModel_gen.go b/app/user/model/agentModel_gen.go deleted file mode 100644 index d121773..0000000 --- a/app/user/model/agentModel_gen.go +++ /dev/null @@ -1,409 +0,0 @@ -// Code generated by goctl. DO NOT EDIT! - -package model - -import ( - "context" - "database/sql" - "fmt" - "strings" - - "time" - - "github.com/Masterminds/squirrel" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/stores/builder" - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlc" - "github.com/zeromicro/go-zero/core/stores/sqlx" - "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" -) - -var ( - agentFieldNames = builder.RawFieldNames(&Agent{}) - agentRows = strings.Join(agentFieldNames, ",") - agentRowsExpectAutoSet = strings.Join(stringx.Remove(agentFieldNames, "`id`", "`create_time`", "`update_time`"), ",") - agentRowsWithPlaceHolder = strings.Join(stringx.Remove(agentFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - - cacheQncAgentIdPrefix = "cache:qnc:agent:id:" - cacheQncAgentUserIdPrefix = "cache:qnc:agent:userId:" -) - -type ( - agentModel interface { - Insert(ctx context.Context, session sqlx.Session, data *Agent) (sql.Result, error) - FindOne(ctx context.Context, id int64) (*Agent, error) - FindOneByUserId(ctx context.Context, userId int64) (*Agent, error) - Update(ctx context.Context, session sqlx.Session, data *Agent) (sql.Result, error) - UpdateWithVersion(ctx context.Context, session sqlx.Session, data *Agent) error - Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error - SelectBuilder() squirrel.SelectBuilder - DeleteSoft(ctx context.Context, session sqlx.Session, data *Agent) error - FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error) - FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error) - FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*Agent, error) - FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*Agent, error) - FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*Agent, int64, error) - FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*Agent, error) - FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*Agent, error) - Delete(ctx context.Context, session sqlx.Session, id int64) error - } - - defaultAgentModel struct { - sqlc.CachedConn - table string - } - - Agent struct { - Id int64 `db:"id"` - UserId int64 `db:"user_id"` - Region string `db:"region"` - Mobile string `db:"mobile"` - WechatId sql.NullString `db:"wechat_id"` - CreateTime time.Time `db:"create_time"` - UpdateTime time.Time `db:"update_time"` - DeleteTime sql.NullTime `db:"delete_time"` // 删除时间 - DelState int64 `db:"del_state"` // 删除状态 - Version int64 `db:"version"` // 版本号 - } -) - -func newAgentModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultAgentModel { - return &defaultAgentModel{ - CachedConn: sqlc.NewConn(conn, c), - table: "`agent`", - } -} - -func (m *defaultAgentModel) Insert(ctx context.Context, session sqlx.Session, data *Agent) (sql.Result, error) { - data.DelState = globalkey.DelStateNo - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, data.Id) - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, data.UserId) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, agentRowsExpectAutoSet) - if session != nil { - return session.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.DeleteTime, data.DelState, data.Version) - } - return conn.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.DeleteTime, data.DelState, data.Version) - }, qncAgentIdKey, qncAgentUserIdKey) -} - -func (m *defaultAgentModel) FindOne(ctx context.Context, id int64) (*Agent, error) { - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, id) - var resp Agent - err := m.QueryRowCtx(ctx, &resp, qncAgentIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", agentRows, m.table) - return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) - }) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentModel) FindOneByUserId(ctx context.Context, userId int64) (*Agent, error) { - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, userId) - var resp Agent - err := m.QueryRowIndexCtx(ctx, &resp, qncAgentUserIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("select %s from %s where `user_id` = ? and del_state = ? limit 1", agentRows, m.table) - if err := conn.QueryRowCtx(ctx, &resp, query, userId, globalkey.DelStateNo); err != nil { - return nil, err - } - return resp.Id, nil - }, m.queryPrimary) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentModel) Update(ctx context.Context, session sqlx.Session, newData *Agent) (sql.Result, error) { - data, err := m.FindOne(ctx, newData.Id) - if err != nil { - return nil, err - } - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, data.Id) - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, data.UserId) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, agentRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, newData.UserId, newData.Region, newData.Mobile, newData.WechatId, newData.DeleteTime, newData.DelState, newData.Version, newData.Id) - } - return conn.ExecCtx(ctx, query, newData.UserId, newData.Region, newData.Mobile, newData.WechatId, newData.DeleteTime, newData.DelState, newData.Version, newData.Id) - }, qncAgentIdKey, qncAgentUserIdKey) -} - -func (m *defaultAgentModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *Agent) error { - - oldVersion := newData.Version - newData.Version += 1 - - var sqlResult sql.Result - var err error - - data, err := m.FindOne(ctx, newData.Id) - if err != nil { - return err - } - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, data.Id) - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, data.UserId) - sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, agentRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, newData.UserId, newData.Region, newData.Mobile, newData.WechatId, newData.DeleteTime, newData.DelState, newData.Version, newData.Id, oldVersion) - } - return conn.ExecCtx(ctx, query, newData.UserId, newData.Region, newData.Mobile, newData.WechatId, newData.DeleteTime, newData.DelState, newData.Version, newData.Id, oldVersion) - }, qncAgentIdKey, qncAgentUserIdKey) - if err != nil { - return err - } - updateCount, err := sqlResult.RowsAffected() - if err != nil { - return err - } - if updateCount == 0 { - return ErrNoRowsUpdate - } - - return nil -} - -func (m *defaultAgentModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *Agent) error { - data.DelState = globalkey.DelStateYes - data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true} - if err := m.UpdateWithVersion(ctx, session, data); err != nil { - return errors.Wrapf(errors.New("delete soft failed "), "AgentModel delete err : %+v", err) - } - return nil -} - -func (m *defaultAgentModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field") - } - - builder = builder.Columns("IFNULL(SUM(" + field + "),0)") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp float64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field") - } - - builder = builder.Columns("COUNT(" + field + ")") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp int64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*Agent, error) { - - builder = builder.Columns(agentRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return nil, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*Agent, error) { - - builder = builder.Columns(agentRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*Agent, int64, error) { - - total, err := m.FindCount(ctx, builder, "id") - if err != nil { - return nil, 0, err - } - - builder = builder.Columns(agentRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, total, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, total, nil - default: - return nil, total, err - } -} - -func (m *defaultAgentModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*Agent, error) { - - builder = builder.Columns(agentRows) - - if preMinId > 0 { - builder = builder.Where(" id < ? ", preMinId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*Agent, error) { - - builder = builder.Columns(agentRows) - - if preMaxId > 0 { - builder = builder.Where(" id > ? ", preMaxId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error { - - return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error { - return fn(ctx, session) - }) - -} - -func (m *defaultAgentModel) SelectBuilder() squirrel.SelectBuilder { - return squirrel.Select().From(m.table) -} -func (m *defaultAgentModel) Delete(ctx context.Context, session sqlx.Session, id int64) error { - data, err := m.FindOne(ctx, id) - if err != nil { - return err - } - - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, id) - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, data.UserId) - _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("delete from %s where `id` = ?", m.table) - if session != nil { - return session.ExecCtx(ctx, query, id) - } - return conn.ExecCtx(ctx, query, id) - }, qncAgentIdKey, qncAgentUserIdKey) - return err -} -func (m *defaultAgentModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, primary) -} -func (m *defaultAgentModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", agentRows, m.table) - return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) -} - -func (m *defaultAgentModel) tableName() string { - return m.table -} diff --git a/app/user/model/agentWalletModel.go b/app/user/model/agentWalletModel.go deleted file mode 100644 index 1583c4d..0000000 --- a/app/user/model/agentWalletModel.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlx" -) - -var _ AgentWalletModel = (*customAgentWalletModel)(nil) - -type ( - // AgentWalletModel is an interface to be customized, add more methods here, - // and implement the added methods in customAgentWalletModel. - AgentWalletModel interface { - agentWalletModel - } - - customAgentWalletModel struct { - *defaultAgentWalletModel - } -) - -// NewAgentWalletModel returns a model for the database table. -func NewAgentWalletModel(conn sqlx.SqlConn, c cache.CacheConf) AgentWalletModel { - return &customAgentWalletModel{ - defaultAgentWalletModel: newAgentWalletModel(conn, c), - } -} diff --git a/app/user/model/agentWalletModel_gen.go b/app/user/model/agentWalletModel_gen.go deleted file mode 100644 index fdcdf22..0000000 --- a/app/user/model/agentWalletModel_gen.go +++ /dev/null @@ -1,372 +0,0 @@ -// Code generated by goctl. DO NOT EDIT! - -package model - -import ( - "context" - "database/sql" - "fmt" - "qnc-server/deploy/script/model" - "strings" - - "time" - - "github.com/Masterminds/squirrel" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/stores/builder" - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlc" - "github.com/zeromicro/go-zero/core/stores/sqlx" - "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" -) - -var ( - agentWalletFieldNames = builder.RawFieldNames(&AgentWallet{}) - agentWalletRows = strings.Join(agentWalletFieldNames, ",") - agentWalletRowsExpectAutoSet = strings.Join(stringx.Remove(agentWalletFieldNames, "`id`", "`create_time`", "`update_time`"), ",") - agentWalletRowsWithPlaceHolder = strings.Join(stringx.Remove(agentWalletFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - - cacheQncAgentWalletIdPrefix = "cache:qnc:agentWallet:id:" -) - -type ( - agentWalletModel interface { - Insert(ctx context.Context, session sqlx.Session, data *AgentWallet) (sql.Result, error) - FindOne(ctx context.Context, id int64) (*AgentWallet, error) - Update(ctx context.Context, session sqlx.Session, data *AgentWallet) (sql.Result, error) - UpdateWithVersion(ctx context.Context, session sqlx.Session, data *AgentWallet) error - Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error - SelectBuilder() squirrel.SelectBuilder - DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentWallet) error - FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error) - FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error) - FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*AgentWallet, error) - FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentWallet, error) - FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentWallet, int64, error) - FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentWallet, error) - FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentWallet, error) - Delete(ctx context.Context, session sqlx.Session, id int64) error - } - - defaultAgentWalletModel struct { - sqlc.CachedConn - table string - } - - AgentWallet struct { - Id int64 `db:"id"` - AgentId int64 `db:"agent_id"` - Balance float64 `db:"balance"` - FrozenBalance float64 `db:"frozen_balance"` - TotalEarnings float64 `db:"total_earnings"` - WithdrawnAmount float64 `db:"withdrawn_amount"` - CreateTime time.Time `db:"create_time"` - UpdateTime time.Time `db:"update_time"` - DeleteTime sql.NullTime `db:"delete_time"` // 删除时间 - DelState int64 `db:"del_state"` // 删除状态 - Version int64 `db:"version"` // 版本号 - } -) - -func newAgentWalletModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultAgentWalletModel { - return &defaultAgentWalletModel{ - CachedConn: sqlc.NewConn(conn, c), - table: "`agent_wallet`", - } -} - -func (m *defaultAgentWalletModel) Insert(ctx context.Context, session sqlx.Session, data *AgentWallet) (sql.Result, error) { - data.DelState = globalkey.DelStateNo - qncAgentWalletIdKey := fmt.Sprintf("%s%v", cacheQncAgentWalletIdPrefix, data.Id) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", m.table, agentWalletRowsExpectAutoSet) - if session != nil { - return session.ExecCtx(ctx, query, data.AgentId, data.Balance, data.FrozenBalance, data.TotalEarnings, data.WithdrawnAmount, data.DeleteTime, data.DelState, data.Version) - } - return conn.ExecCtx(ctx, query, data.AgentId, data.Balance, data.FrozenBalance, data.TotalEarnings, data.WithdrawnAmount, data.DeleteTime, data.DelState, data.Version) - }, qncAgentWalletIdKey) -} - -func (m *defaultAgentWalletModel) FindOne(ctx context.Context, id int64) (*AgentWallet, error) { - qncAgentWalletIdKey := fmt.Sprintf("%s%v", cacheQncAgentWalletIdPrefix, id) - var resp AgentWallet - err := m.QueryRowCtx(ctx, &resp, qncAgentWalletIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", agentWalletRows, m.table) - return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) - }) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, model.ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentWalletModel) Update(ctx context.Context, session sqlx.Session, data *AgentWallet) (sql.Result, error) { - qncAgentWalletIdKey := fmt.Sprintf("%s%v", cacheQncAgentWalletIdPrefix, data.Id) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, agentWalletRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, data.AgentId, data.Balance, data.FrozenBalance, data.TotalEarnings, data.WithdrawnAmount, data.DeleteTime, data.DelState, data.Version, data.Id) - } - return conn.ExecCtx(ctx, query, data.AgentId, data.Balance, data.FrozenBalance, data.TotalEarnings, data.WithdrawnAmount, data.DeleteTime, data.DelState, data.Version, data.Id) - }, qncAgentWalletIdKey) -} - -func (m *defaultAgentWalletModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, data *AgentWallet) error { - - oldVersion := data.Version - data.Version += 1 - - var sqlResult sql.Result - var err error - - qncAgentWalletIdKey := fmt.Sprintf("%s%v", cacheQncAgentWalletIdPrefix, data.Id) - sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, agentWalletRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, data.AgentId, data.Balance, data.FrozenBalance, data.TotalEarnings, data.WithdrawnAmount, data.DeleteTime, data.DelState, data.Version, data.Id, oldVersion) - } - return conn.ExecCtx(ctx, query, data.AgentId, data.Balance, data.FrozenBalance, data.TotalEarnings, data.WithdrawnAmount, data.DeleteTime, data.DelState, data.Version, data.Id, oldVersion) - }, qncAgentWalletIdKey) - if err != nil { - return err - } - updateCount, err := sqlResult.RowsAffected() - if err != nil { - return err - } - if updateCount == 0 { - return model.ErrNoRowsUpdate - } - - return nil -} - -func (m *defaultAgentWalletModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *AgentWallet) error { - data.DelState = globalkey.DelStateYes - data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true} - if err := m.UpdateWithVersion(ctx, session, data); err != nil { - return errors.Wrapf(errors.New("delete soft failed "), "AgentWalletModel delete err : %+v", err) - } - return nil -} - -func (m *defaultAgentWalletModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field") - } - - builder = builder.Columns("IFNULL(SUM(" + field + "),0)") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp float64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentWalletModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field") - } - - builder = builder.Columns("COUNT(" + field + ")") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp int64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentWalletModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*AgentWallet, error) { - - builder = builder.Columns(agentWalletRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentWallet - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentWalletModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentWallet, error) { - - builder = builder.Columns(agentWalletRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentWallet - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentWalletModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*AgentWallet, int64, error) { - - total, err := m.FindCount(ctx, builder, "id") - if err != nil { - return nil, 0, err - } - - builder = builder.Columns(agentWalletRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, total, err - } - - var resp []*AgentWallet - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, total, nil - default: - return nil, total, err - } -} - -func (m *defaultAgentWalletModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*AgentWallet, error) { - - builder = builder.Columns(agentWalletRows) - - if preMinId > 0 { - builder = builder.Where(" id < ? ", preMinId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentWallet - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentWalletModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*AgentWallet, error) { - - builder = builder.Columns(agentWalletRows) - - if preMaxId > 0 { - builder = builder.Where(" id > ? ", preMaxId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*AgentWallet - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentWalletModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error { - - return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error { - return fn(ctx, session) - }) - -} - -func (m *defaultAgentWalletModel) SelectBuilder() squirrel.SelectBuilder { - return squirrel.Select().From(m.table) -} -func (m *defaultAgentWalletModel) Delete(ctx context.Context, session sqlx.Session, id int64) error { - qncAgentWalletIdKey := fmt.Sprintf("%s%v", cacheQncAgentWalletIdPrefix, id) - _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) - if session != nil { - return session.ExecCtx(ctx, query, id) - } - return conn.ExecCtx(ctx, query, id) - }, qncAgentWalletIdKey) - return err -} -func (m *defaultAgentWalletModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncAgentWalletIdPrefix, primary) -} -func (m *defaultAgentWalletModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", agentWalletRows, m.table) - return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) -} - -func (m *defaultAgentWalletModel) tableName() string { - return m.table -} diff --git a/app/user/model/exampleModel_gen.go b/app/user/model/exampleModel_gen.go index 935642c..1280572 100644 --- a/app/user/model/exampleModel_gen.go +++ b/app/user/model/exampleModel_gen.go @@ -17,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -26,8 +26,8 @@ var ( exampleRowsExpectAutoSet = strings.Join(stringx.Remove(exampleFieldNames, "`id`", "`create_time`", "`update_time`"), ",") exampleRowsWithPlaceHolder = strings.Join(stringx.Remove(exampleFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncExampleIdPrefix = "cache:qnc:example:id:" - cacheQncExampleProductIdPrefix = "cache:qnc:example:productId:" + cacheTycExampleIdPrefix = "cache:tyc:example:id:" + cacheTycExampleProductIdPrefix = "cache:tyc:example:productId:" ) type ( @@ -77,21 +77,21 @@ func newExampleModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultExampleModel func (m *defaultExampleModel) Insert(ctx context.Context, session sqlx.Session, data *Example) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncExampleIdKey := fmt.Sprintf("%s%v", cacheQncExampleIdPrefix, data.Id) - qncExampleProductIdKey := fmt.Sprintf("%s%v", cacheQncExampleProductIdPrefix, data.ProductId) + tycExampleIdKey := fmt.Sprintf("%s%v", cacheTycExampleIdPrefix, data.Id) + tycExampleProductIdKey := fmt.Sprintf("%s%v", cacheTycExampleProductIdPrefix, data.ProductId) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?)", m.table, exampleRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.ProductId, data.QueryParams, data.QueryData, data.DelState, data.Version, data.DeleteTime) } return conn.ExecCtx(ctx, query, data.ProductId, data.QueryParams, data.QueryData, data.DelState, data.Version, data.DeleteTime) - }, qncExampleIdKey, qncExampleProductIdKey) + }, tycExampleIdKey, tycExampleProductIdKey) } func (m *defaultExampleModel) FindOne(ctx context.Context, id int64) (*Example, error) { - qncExampleIdKey := fmt.Sprintf("%s%v", cacheQncExampleIdPrefix, id) + tycExampleIdKey := fmt.Sprintf("%s%v", cacheTycExampleIdPrefix, id) var resp Example - err := m.QueryRowCtx(ctx, &resp, qncExampleIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + err := m.QueryRowCtx(ctx, &resp, tycExampleIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", exampleRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) @@ -106,9 +106,9 @@ func (m *defaultExampleModel) FindOne(ctx context.Context, id int64) (*Example, } func (m *defaultExampleModel) FindOneByProductId(ctx context.Context, productId int64) (*Example, error) { - qncExampleProductIdKey := fmt.Sprintf("%s%v", cacheQncExampleProductIdPrefix, productId) + tycExampleProductIdKey := fmt.Sprintf("%s%v", cacheTycExampleProductIdPrefix, productId) var resp Example - err := m.QueryRowIndexCtx(ctx, &resp, qncExampleProductIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + err := m.QueryRowIndexCtx(ctx, &resp, tycExampleProductIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { query := fmt.Sprintf("select %s from %s where `product_id` = ? and del_state = ? limit 1", exampleRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, productId, globalkey.DelStateNo); err != nil { return nil, err @@ -130,15 +130,15 @@ func (m *defaultExampleModel) Update(ctx context.Context, session sqlx.Session, if err != nil { return nil, err } - qncExampleIdKey := fmt.Sprintf("%s%v", cacheQncExampleIdPrefix, data.Id) - qncExampleProductIdKey := fmt.Sprintf("%s%v", cacheQncExampleProductIdPrefix, data.ProductId) + tycExampleIdKey := fmt.Sprintf("%s%v", cacheTycExampleIdPrefix, data.Id) + tycExampleProductIdKey := fmt.Sprintf("%s%v", cacheTycExampleProductIdPrefix, data.ProductId) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, exampleRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.ProductId, newData.QueryParams, newData.QueryData, newData.DelState, newData.Version, newData.DeleteTime, newData.Id) } return conn.ExecCtx(ctx, query, newData.ProductId, newData.QueryParams, newData.QueryData, newData.DelState, newData.Version, newData.DeleteTime, newData.Id) - }, qncExampleIdKey, qncExampleProductIdKey) + }, tycExampleIdKey, tycExampleProductIdKey) } func (m *defaultExampleModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *Example) error { @@ -153,15 +153,15 @@ func (m *defaultExampleModel) UpdateWithVersion(ctx context.Context, session sql if err != nil { return err } - qncExampleIdKey := fmt.Sprintf("%s%v", cacheQncExampleIdPrefix, data.Id) - qncExampleProductIdKey := fmt.Sprintf("%s%v", cacheQncExampleProductIdPrefix, data.ProductId) + tycExampleIdKey := fmt.Sprintf("%s%v", cacheTycExampleIdPrefix, data.Id) + tycExampleProductIdKey := fmt.Sprintf("%s%v", cacheTycExampleProductIdPrefix, data.ProductId) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, exampleRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.ProductId, newData.QueryParams, newData.QueryData, newData.DelState, newData.Version, newData.DeleteTime, newData.Id, oldVersion) } return conn.ExecCtx(ctx, query, newData.ProductId, newData.QueryParams, newData.QueryData, newData.DelState, newData.Version, newData.DeleteTime, newData.Id, oldVersion) - }, qncExampleIdKey, qncExampleProductIdKey) + }, tycExampleIdKey, tycExampleProductIdKey) if err != nil { return err } @@ -384,19 +384,19 @@ func (m *defaultExampleModel) Delete(ctx context.Context, session sqlx.Session, return err } - qncExampleIdKey := fmt.Sprintf("%s%v", cacheQncExampleIdPrefix, id) - qncExampleProductIdKey := fmt.Sprintf("%s%v", cacheQncExampleProductIdPrefix, data.ProductId) + tycExampleIdKey := fmt.Sprintf("%s%v", cacheTycExampleIdPrefix, id) + tycExampleProductIdKey := fmt.Sprintf("%s%v", cacheTycExampleProductIdPrefix, data.ProductId) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncExampleIdKey, qncExampleProductIdKey) + }, tycExampleIdKey, tycExampleProductIdKey) return err } func (m *defaultExampleModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncExampleIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycExampleIdPrefix, primary) } func (m *defaultExampleModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", exampleRows, m.table) diff --git a/app/user/model/featureModel_gen.go b/app/user/model/featureModel_gen.go index 4879a0e..a6fc22d 100644 --- a/app/user/model/featureModel_gen.go +++ b/app/user/model/featureModel_gen.go @@ -6,7 +6,6 @@ import ( "context" "database/sql" "fmt" - "qnc-server/deploy/script/model" "strings" "time" @@ -18,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -27,8 +26,8 @@ var ( featureRowsExpectAutoSet = strings.Join(stringx.Remove(featureFieldNames, "`id`", "`create_time`", "`update_time`"), ",") featureRowsWithPlaceHolder = strings.Join(stringx.Remove(featureFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncFeatureIdPrefix = "cache:qnc:feature:id:" - cacheQncFeatureApiIdPrefix = "cache:qnc:feature:apiId:" + cacheTycFeatureIdPrefix = "cache:tyc:feature:id:" + cacheTycFeatureApiIdPrefix = "cache:tyc:feature:apiId:" ) type ( @@ -77,39 +76,39 @@ func newFeatureModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultFeatureModel func (m *defaultFeatureModel) Insert(ctx context.Context, session sqlx.Session, data *Feature) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncFeatureApiIdKey := fmt.Sprintf("%s%v", cacheQncFeatureApiIdPrefix, data.ApiId) - qncFeatureIdKey := fmt.Sprintf("%s%v", cacheQncFeatureIdPrefix, data.Id) + tycFeatureApiIdKey := fmt.Sprintf("%s%v", cacheTycFeatureApiIdPrefix, data.ApiId) + tycFeatureIdKey := fmt.Sprintf("%s%v", cacheTycFeatureIdPrefix, data.Id) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?)", m.table, featureRowsExpectAutoSet) + query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?)", m.table, featureRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.ApiId, data.Name) } return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.ApiId, data.Name) - }, qncFeatureApiIdKey, qncFeatureIdKey) + }, tycFeatureApiIdKey, tycFeatureIdKey) } func (m *defaultFeatureModel) FindOne(ctx context.Context, id int64) (*Feature, error) { - qncFeatureIdKey := fmt.Sprintf("%s%v", cacheQncFeatureIdPrefix, id) + tycFeatureIdKey := fmt.Sprintf("%s%v", cacheTycFeatureIdPrefix, id) var resp Feature - err := m.QueryRowCtx(ctx, &resp, qncFeatureIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", featureRows, m.table) + err := m.QueryRowCtx(ctx, &resp, tycFeatureIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", featureRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } } func (m *defaultFeatureModel) FindOneByApiId(ctx context.Context, apiId string) (*Feature, error) { - qncFeatureApiIdKey := fmt.Sprintf("%s%v", cacheQncFeatureApiIdPrefix, apiId) + tycFeatureApiIdKey := fmt.Sprintf("%s%v", cacheTycFeatureApiIdPrefix, apiId) var resp Feature - err := m.QueryRowIndexCtx(ctx, &resp, qncFeatureApiIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `api_id` = ? AND del_state = ? limit 1", featureRows, m.table) + err := m.QueryRowIndexCtx(ctx, &resp, tycFeatureApiIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + query := fmt.Sprintf("select %s from %s where `api_id` = ? and del_state = ? limit 1", featureRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, apiId, globalkey.DelStateNo); err != nil { return nil, err } @@ -119,7 +118,7 @@ func (m *defaultFeatureModel) FindOneByApiId(ctx context.Context, apiId string) case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } @@ -130,15 +129,15 @@ func (m *defaultFeatureModel) Update(ctx context.Context, session sqlx.Session, if err != nil { return nil, err } - qncFeatureApiIdKey := fmt.Sprintf("%s%v", cacheQncFeatureApiIdPrefix, data.ApiId) - qncFeatureIdKey := fmt.Sprintf("%s%v", cacheQncFeatureIdPrefix, data.Id) + tycFeatureApiIdKey := fmt.Sprintf("%s%v", cacheTycFeatureApiIdPrefix, data.ApiId) + tycFeatureIdKey := fmt.Sprintf("%s%v", cacheTycFeatureIdPrefix, data.Id) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, featureRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, featureRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.Id) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.Id) - }, qncFeatureApiIdKey, qncFeatureIdKey) + }, tycFeatureApiIdKey, tycFeatureIdKey) } func (m *defaultFeatureModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *Feature) error { @@ -153,15 +152,15 @@ func (m *defaultFeatureModel) UpdateWithVersion(ctx context.Context, session sql if err != nil { return err } - qncFeatureApiIdKey := fmt.Sprintf("%s%v", cacheQncFeatureApiIdPrefix, data.ApiId) - qncFeatureIdKey := fmt.Sprintf("%s%v", cacheQncFeatureIdPrefix, data.Id) + tycFeatureApiIdKey := fmt.Sprintf("%s%v", cacheTycFeatureApiIdPrefix, data.ApiId) + tycFeatureIdKey := fmt.Sprintf("%s%v", cacheTycFeatureIdPrefix, data.Id) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, featureRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, featureRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.Id, oldVersion) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.Id, oldVersion) - }, qncFeatureApiIdKey, qncFeatureIdKey) + }, tycFeatureApiIdKey, tycFeatureIdKey) if err != nil { return err } @@ -170,7 +169,7 @@ func (m *defaultFeatureModel) UpdateWithVersion(ctx context.Context, session sql return err } if updateCount == 0 { - return model.ErrNoRowsUpdate + return ErrNoRowsUpdate } return nil @@ -384,22 +383,22 @@ func (m *defaultFeatureModel) Delete(ctx context.Context, session sqlx.Session, return err } - qncFeatureApiIdKey := fmt.Sprintf("%s%v", cacheQncFeatureApiIdPrefix, data.ApiId) - qncFeatureIdKey := fmt.Sprintf("%s%v", cacheQncFeatureIdPrefix, id) + tycFeatureApiIdKey := fmt.Sprintf("%s%v", cacheTycFeatureApiIdPrefix, data.ApiId) + tycFeatureIdKey := fmt.Sprintf("%s%v", cacheTycFeatureIdPrefix, id) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) + query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncFeatureApiIdKey, qncFeatureIdKey) + }, tycFeatureApiIdKey, tycFeatureIdKey) return err } func (m *defaultFeatureModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncFeatureIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycFeatureIdPrefix, primary) } func (m *defaultFeatureModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", featureRows, m.table) + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", featureRows, m.table) return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) } diff --git a/app/user/model/globalNotificationsModel_gen.go b/app/user/model/globalNotificationsModel_gen.go index 1045450..ae95573 100644 --- a/app/user/model/globalNotificationsModel_gen.go +++ b/app/user/model/globalNotificationsModel_gen.go @@ -6,7 +6,6 @@ import ( "context" "database/sql" "fmt" - model2 "qnc-server/deploy/script/model" "strings" "time" @@ -18,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -27,7 +26,7 @@ var ( globalNotificationsRowsExpectAutoSet = strings.Join(stringx.Remove(globalNotificationsFieldNames, "`id`", "`create_time`", "`update_time`"), ",") globalNotificationsRowsWithPlaceHolder = strings.Join(stringx.Remove(globalNotificationsFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncGlobalNotificationsIdPrefix = "cache:qnc:globalNotifications:id:" + cacheTycGlobalNotificationsIdPrefix = "cache:tyc:globalNotifications:id:" ) type ( @@ -81,20 +80,20 @@ func newGlobalNotificationsModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultG func (m *defaultGlobalNotificationsModel) Insert(ctx context.Context, session sqlx.Session, data *GlobalNotifications) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheQncGlobalNotificationsIdPrefix, data.Id) + tycGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheTycGlobalNotificationsIdPrefix, data.Id) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, globalNotificationsRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.Title, data.Content, data.NotificationPage, data.StartDate, data.EndDate, data.StartTime, data.EndTime, data.Status, data.DelState, data.Version, data.DeleteTime) } return conn.ExecCtx(ctx, query, data.Title, data.Content, data.NotificationPage, data.StartDate, data.EndDate, data.StartTime, data.EndTime, data.Status, data.DelState, data.Version, data.DeleteTime) - }, qncGlobalNotificationsIdKey) + }, tycGlobalNotificationsIdKey) } func (m *defaultGlobalNotificationsModel) FindOne(ctx context.Context, id int64) (*GlobalNotifications, error) { - qncGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheQncGlobalNotificationsIdPrefix, id) + tycGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheTycGlobalNotificationsIdPrefix, id) var resp GlobalNotifications - err := m.QueryRowCtx(ctx, &resp, qncGlobalNotificationsIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + err := m.QueryRowCtx(ctx, &resp, tycGlobalNotificationsIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", globalNotificationsRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) @@ -102,21 +101,21 @@ func (m *defaultGlobalNotificationsModel) FindOne(ctx context.Context, id int64) case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model2.ErrNotFound + return nil, ErrNotFound default: return nil, err } } func (m *defaultGlobalNotificationsModel) Update(ctx context.Context, session sqlx.Session, data *GlobalNotifications) (sql.Result, error) { - qncGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheQncGlobalNotificationsIdPrefix, data.Id) + tycGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheTycGlobalNotificationsIdPrefix, data.Id) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, globalNotificationsRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, data.Title, data.Content, data.NotificationPage, data.StartDate, data.EndDate, data.StartTime, data.EndTime, data.Status, data.DelState, data.Version, data.DeleteTime, data.Id) } return conn.ExecCtx(ctx, query, data.Title, data.Content, data.NotificationPage, data.StartDate, data.EndDate, data.StartTime, data.EndTime, data.Status, data.DelState, data.Version, data.DeleteTime, data.Id) - }, qncGlobalNotificationsIdKey) + }, tycGlobalNotificationsIdKey) } func (m *defaultGlobalNotificationsModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, data *GlobalNotifications) error { @@ -127,14 +126,14 @@ func (m *defaultGlobalNotificationsModel) UpdateWithVersion(ctx context.Context, var sqlResult sql.Result var err error - qncGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheQncGlobalNotificationsIdPrefix, data.Id) + tycGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheTycGlobalNotificationsIdPrefix, data.Id) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, globalNotificationsRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, data.Title, data.Content, data.NotificationPage, data.StartDate, data.EndDate, data.StartTime, data.EndTime, data.Status, data.DelState, data.Version, data.DeleteTime, data.Id, oldVersion) } return conn.ExecCtx(ctx, query, data.Title, data.Content, data.NotificationPage, data.StartDate, data.EndDate, data.StartTime, data.EndTime, data.Status, data.DelState, data.Version, data.DeleteTime, data.Id, oldVersion) - }, qncGlobalNotificationsIdKey) + }, tycGlobalNotificationsIdKey) if err != nil { return err } @@ -143,7 +142,7 @@ func (m *defaultGlobalNotificationsModel) UpdateWithVersion(ctx context.Context, return err } if updateCount == 0 { - return model2.ErrNoRowsUpdate + return ErrNoRowsUpdate } return nil @@ -352,18 +351,18 @@ func (m *defaultGlobalNotificationsModel) SelectBuilder() squirrel.SelectBuilder return squirrel.Select().From(m.table) } func (m *defaultGlobalNotificationsModel) Delete(ctx context.Context, session sqlx.Session, id int64) error { - qncGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheQncGlobalNotificationsIdPrefix, id) + tycGlobalNotificationsIdKey := fmt.Sprintf("%s%v", cacheTycGlobalNotificationsIdPrefix, id) _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncGlobalNotificationsIdKey) + }, tycGlobalNotificationsIdKey) return err } func (m *defaultGlobalNotificationsModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncGlobalNotificationsIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycGlobalNotificationsIdPrefix, primary) } func (m *defaultGlobalNotificationsModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", globalNotificationsRows, m.table) diff --git a/app/user/model/orderModel_gen.go b/app/user/model/orderModel_gen.go index 6586cd2..00007c3 100644 --- a/app/user/model/orderModel_gen.go +++ b/app/user/model/orderModel_gen.go @@ -6,7 +6,6 @@ import ( "context" "database/sql" "fmt" - "qnc-server/deploy/script/model" "strings" "time" @@ -18,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -27,8 +26,8 @@ var ( orderRowsExpectAutoSet = strings.Join(stringx.Remove(orderFieldNames, "`id`", "`create_time`", "`update_time`"), ",") orderRowsWithPlaceHolder = strings.Join(stringx.Remove(orderFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncOrderIdPrefix = "cache:qnc:order:id:" - cacheQncOrderOrderNoPrefix = "cache:qnc:order:orderNo:" + cacheTycOrderIdPrefix = "cache:tyc:order:id:" + cacheTycOrderOrderNoPrefix = "cache:tyc:order:orderNo:" ) type ( @@ -61,8 +60,8 @@ type ( OrderNo string `db:"order_no"` // 自生成的订单号 UserId int64 `db:"user_id"` // 用户ID ProductId int64 `db:"product_id"` // 产品ID(软关联到产品表) - PaymentPlatform string `db:"payment_platform"` // 支付平台(支付宝、微信、其他) - PaymentScene string `db:"payment_scene"` // 支付场景(App、H5、微信小程序、公众号) + PaymentPlatform string `db:"payment_platform"` // 支付平台(支付宝、微信、苹果内购、其他) + PaymentScene string `db:"payment_scene"` // 支付场景(App、H5、微信小程序、公众号、天远查) PlatformOrderId sql.NullString `db:"platform_order_id"` // 支付平台订单号 Amount float64 `db:"amount"` // 支付金额 Status string `db:"status"` // 支付状态 @@ -86,39 +85,39 @@ func newOrderModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultOrderModel { func (m *defaultOrderModel) Insert(ctx context.Context, session sqlx.Session, data *Order) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncOrderIdKey := fmt.Sprintf("%s%v", cacheQncOrderIdPrefix, data.Id) - qncOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncOrderOrderNoPrefix, data.OrderNo) + tycOrderIdKey := fmt.Sprintf("%s%v", cacheTycOrderIdPrefix, data.Id) + tycOrderOrderNoKey := fmt.Sprintf("%s%v", cacheTycOrderOrderNoPrefix, data.OrderNo) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, orderRowsExpectAutoSet) + query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, orderRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.OrderNo, data.UserId, data.ProductId, data.PaymentPlatform, data.PaymentScene, data.PlatformOrderId, data.Amount, data.Status, data.DelState, data.Version, data.PayTime, data.RefundTime, data.CloseTime, data.DeleteTime) } return conn.ExecCtx(ctx, query, data.OrderNo, data.UserId, data.ProductId, data.PaymentPlatform, data.PaymentScene, data.PlatformOrderId, data.Amount, data.Status, data.DelState, data.Version, data.PayTime, data.RefundTime, data.CloseTime, data.DeleteTime) - }, qncOrderIdKey, qncOrderOrderNoKey) + }, tycOrderIdKey, tycOrderOrderNoKey) } func (m *defaultOrderModel) FindOne(ctx context.Context, id int64) (*Order, error) { - qncOrderIdKey := fmt.Sprintf("%s%v", cacheQncOrderIdPrefix, id) + tycOrderIdKey := fmt.Sprintf("%s%v", cacheTycOrderIdPrefix, id) var resp Order - err := m.QueryRowCtx(ctx, &resp, qncOrderIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", orderRows, m.table) + err := m.QueryRowCtx(ctx, &resp, tycOrderIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", orderRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } } func (m *defaultOrderModel) FindOneByOrderNo(ctx context.Context, orderNo string) (*Order, error) { - qncOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncOrderOrderNoPrefix, orderNo) + tycOrderOrderNoKey := fmt.Sprintf("%s%v", cacheTycOrderOrderNoPrefix, orderNo) var resp Order - err := m.QueryRowIndexCtx(ctx, &resp, qncOrderOrderNoKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `order_no` = ? AND del_state = ? limit 1", orderRows, m.table) + err := m.QueryRowIndexCtx(ctx, &resp, tycOrderOrderNoKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + query := fmt.Sprintf("select %s from %s where `order_no` = ? and del_state = ? limit 1", orderRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, orderNo, globalkey.DelStateNo); err != nil { return nil, err } @@ -128,7 +127,7 @@ func (m *defaultOrderModel) FindOneByOrderNo(ctx context.Context, orderNo string case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } @@ -139,15 +138,15 @@ func (m *defaultOrderModel) Update(ctx context.Context, session sqlx.Session, ne if err != nil { return nil, err } - qncOrderIdKey := fmt.Sprintf("%s%v", cacheQncOrderIdPrefix, data.Id) - qncOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncOrderOrderNoPrefix, data.OrderNo) + tycOrderIdKey := fmt.Sprintf("%s%v", cacheTycOrderIdPrefix, data.Id) + tycOrderOrderNoKey := fmt.Sprintf("%s%v", cacheTycOrderOrderNoPrefix, data.OrderNo) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, orderRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, orderRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.OrderNo, newData.UserId, newData.ProductId, newData.PaymentPlatform, newData.PaymentScene, newData.PlatformOrderId, newData.Amount, newData.Status, newData.DelState, newData.Version, newData.PayTime, newData.RefundTime, newData.CloseTime, newData.DeleteTime, newData.Id) } return conn.ExecCtx(ctx, query, newData.OrderNo, newData.UserId, newData.ProductId, newData.PaymentPlatform, newData.PaymentScene, newData.PlatformOrderId, newData.Amount, newData.Status, newData.DelState, newData.Version, newData.PayTime, newData.RefundTime, newData.CloseTime, newData.DeleteTime, newData.Id) - }, qncOrderIdKey, qncOrderOrderNoKey) + }, tycOrderIdKey, tycOrderOrderNoKey) } func (m *defaultOrderModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *Order) error { @@ -162,15 +161,15 @@ func (m *defaultOrderModel) UpdateWithVersion(ctx context.Context, session sqlx. if err != nil { return err } - qncOrderIdKey := fmt.Sprintf("%s%v", cacheQncOrderIdPrefix, data.Id) - qncOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncOrderOrderNoPrefix, data.OrderNo) + tycOrderIdKey := fmt.Sprintf("%s%v", cacheTycOrderIdPrefix, data.Id) + tycOrderOrderNoKey := fmt.Sprintf("%s%v", cacheTycOrderOrderNoPrefix, data.OrderNo) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, orderRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, orderRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.OrderNo, newData.UserId, newData.ProductId, newData.PaymentPlatform, newData.PaymentScene, newData.PlatformOrderId, newData.Amount, newData.Status, newData.DelState, newData.Version, newData.PayTime, newData.RefundTime, newData.CloseTime, newData.DeleteTime, newData.Id, oldVersion) } return conn.ExecCtx(ctx, query, newData.OrderNo, newData.UserId, newData.ProductId, newData.PaymentPlatform, newData.PaymentScene, newData.PlatformOrderId, newData.Amount, newData.Status, newData.DelState, newData.Version, newData.PayTime, newData.RefundTime, newData.CloseTime, newData.DeleteTime, newData.Id, oldVersion) - }, qncOrderIdKey, qncOrderOrderNoKey) + }, tycOrderIdKey, tycOrderOrderNoKey) if err != nil { return err } @@ -179,7 +178,7 @@ func (m *defaultOrderModel) UpdateWithVersion(ctx context.Context, session sqlx. return err } if updateCount == 0 { - return model.ErrNoRowsUpdate + return ErrNoRowsUpdate } return nil @@ -393,22 +392,22 @@ func (m *defaultOrderModel) Delete(ctx context.Context, session sqlx.Session, id return err } - qncOrderIdKey := fmt.Sprintf("%s%v", cacheQncOrderIdPrefix, id) - qncOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncOrderOrderNoPrefix, data.OrderNo) + tycOrderIdKey := fmt.Sprintf("%s%v", cacheTycOrderIdPrefix, id) + tycOrderOrderNoKey := fmt.Sprintf("%s%v", cacheTycOrderOrderNoPrefix, data.OrderNo) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) + query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncOrderIdKey, qncOrderOrderNoKey) + }, tycOrderIdKey, tycOrderOrderNoKey) return err } func (m *defaultOrderModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncOrderIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycOrderIdPrefix, primary) } func (m *defaultOrderModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", orderRows, m.table) + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", orderRows, m.table) return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) } diff --git a/app/user/model/productFeatureModel_gen.go b/app/user/model/productFeatureModel_gen.go index 51231e4..38547b7 100644 --- a/app/user/model/productFeatureModel_gen.go +++ b/app/user/model/productFeatureModel_gen.go @@ -6,7 +6,6 @@ import ( "context" "database/sql" "fmt" - "qnc-server/deploy/script/model" "strings" "time" @@ -18,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -27,9 +26,8 @@ var ( productFeatureRowsExpectAutoSet = strings.Join(stringx.Remove(productFeatureFieldNames, "`id`", "`create_time`", "`update_time`"), ",") productFeatureRowsWithPlaceHolder = strings.Join(stringx.Remove(productFeatureFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncProductFeatureIdPrefix = "cache:qnc:productFeature:id:" - cacheQncProductFeatureProductIdFeatureIdPrefix = "cache:qnc:productFeature:productId:featureId:" - cacheQncProductFeatureProductIdSortPrefix = "cache:qnc:productFeature:productId:sort:" + cacheTycProductFeatureIdPrefix = "cache:tyc:productFeature:id:" + cacheTycProductFeatureProductIdFeatureIdPrefix = "cache:tyc:productFeature:productId:featureId:" ) type ( @@ -37,7 +35,6 @@ type ( Insert(ctx context.Context, session sqlx.Session, data *ProductFeature) (sql.Result, error) FindOne(ctx context.Context, id int64) (*ProductFeature, error) FindOneByProductIdFeatureId(ctx context.Context, productId int64, featureId int64) (*ProductFeature, error) - FindOneByProductIdSort(ctx context.Context, productId int64, sort int64) (*ProductFeature, error) Update(ctx context.Context, session sqlx.Session, data *ProductFeature) (sql.Result, error) UpdateWithVersion(ctx context.Context, session sqlx.Session, data *ProductFeature) error Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error @@ -59,16 +56,17 @@ type ( } ProductFeature struct { - Id int64 `db:"id"` // 主键ID - ProductId int64 `db:"product_id"` // 产品ID - FeatureId int64 `db:"feature_id"` // 功能ID - CreateTime time.Time `db:"create_time"` // 创建时间 - UpdateTime time.Time `db:"update_time"` // 更新时间 - DeleteTime sql.NullTime `db:"delete_time"` // 删除时间 - DelState int64 `db:"del_state"` // 删除状态 - Version int64 `db:"version"` // 版本号 - Sort int64 `db:"sort"` // 排序字段 - IsImportant int64 `db:"is_important"` // 是否重要,1为重要,0为不重要 + Id int64 `db:"id"` // 主键ID + ProductId int64 `db:"product_id"` // 产品ID + FeatureId int64 `db:"feature_id"` // 功能ID + CreateTime time.Time `db:"create_time"` // 创建时间 + UpdateTime time.Time `db:"update_time"` // 更新时间 + DeleteTime sql.NullTime `db:"delete_time"` // 删除时间 + DelState int64 `db:"del_state"` // 删除状态 + Version int64 `db:"version"` // 版本号 + Sort int64 `db:"sort"` + Enable int64 `db:"enable"` + IsImportant int64 `db:"is_important"` } ) @@ -81,40 +79,39 @@ func newProductFeatureModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultProduc func (m *defaultProductFeatureModel) Insert(ctx context.Context, session sqlx.Session, data *ProductFeature) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncProductFeatureIdKey := fmt.Sprintf("%s%v", cacheQncProductFeatureIdPrefix, data.Id) - qncProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdFeatureIdPrefix, data.ProductId, data.FeatureId) - qncProductFeatureProductIdSortKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdSortPrefix, data.ProductId, data.Sort) + tycProductFeatureIdKey := fmt.Sprintf("%s%v", cacheTycProductFeatureIdPrefix, data.Id) + tycProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheTycProductFeatureProductIdFeatureIdPrefix, data.ProductId, data.FeatureId) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?, ?)", m.table, productFeatureRowsExpectAutoSet) + query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, productFeatureRowsExpectAutoSet) if session != nil { - return session.ExecCtx(ctx, query, data.ProductId, data.FeatureId, data.DeleteTime, data.DelState, data.Version, data.Sort, data.IsImportant) + return session.ExecCtx(ctx, query, data.ProductId, data.FeatureId, data.DeleteTime, data.DelState, data.Version, data.Sort, data.Enable, data.IsImportant) } - return conn.ExecCtx(ctx, query, data.ProductId, data.FeatureId, data.DeleteTime, data.DelState, data.Version, data.Sort, data.IsImportant) - }, qncProductFeatureIdKey, qncProductFeatureProductIdFeatureIdKey, qncProductFeatureProductIdSortKey) + return conn.ExecCtx(ctx, query, data.ProductId, data.FeatureId, data.DeleteTime, data.DelState, data.Version, data.Sort, data.Enable, data.IsImportant) + }, tycProductFeatureIdKey, tycProductFeatureProductIdFeatureIdKey) } func (m *defaultProductFeatureModel) FindOne(ctx context.Context, id int64) (*ProductFeature, error) { - qncProductFeatureIdKey := fmt.Sprintf("%s%v", cacheQncProductFeatureIdPrefix, id) + tycProductFeatureIdKey := fmt.Sprintf("%s%v", cacheTycProductFeatureIdPrefix, id) var resp ProductFeature - err := m.QueryRowCtx(ctx, &resp, qncProductFeatureIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", productFeatureRows, m.table) + err := m.QueryRowCtx(ctx, &resp, tycProductFeatureIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", productFeatureRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } } func (m *defaultProductFeatureModel) FindOneByProductIdFeatureId(ctx context.Context, productId int64, featureId int64) (*ProductFeature, error) { - qncProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdFeatureIdPrefix, productId, featureId) + tycProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheTycProductFeatureProductIdFeatureIdPrefix, productId, featureId) var resp ProductFeature - err := m.QueryRowIndexCtx(ctx, &resp, qncProductFeatureProductIdFeatureIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `product_id` = ? AND `feature_id` = ? AND del_state = ? limit 1", productFeatureRows, m.table) + err := m.QueryRowIndexCtx(ctx, &resp, tycProductFeatureProductIdFeatureIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + query := fmt.Sprintf("select %s from %s where `product_id` = ? and `feature_id` = ? and del_state = ? limit 1", productFeatureRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, productId, featureId, globalkey.DelStateNo); err != nil { return nil, err } @@ -124,27 +121,7 @@ func (m *defaultProductFeatureModel) FindOneByProductIdFeatureId(ctx context.Con case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound - default: - return nil, err - } -} - -func (m *defaultProductFeatureModel) FindOneByProductIdSort(ctx context.Context, productId int64, sort int64) (*ProductFeature, error) { - qncProductFeatureProductIdSortKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdSortPrefix, productId, sort) - var resp ProductFeature - err := m.QueryRowIndexCtx(ctx, &resp, qncProductFeatureProductIdSortKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `product_id` = ? AND `sort` = ? AND del_state = ? limit 1", productFeatureRows, m.table) - if err := conn.QueryRowCtx(ctx, &resp, query, productId, sort, globalkey.DelStateNo); err != nil { - return nil, err - } - return resp.Id, nil - }, m.queryPrimary) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } @@ -155,16 +132,15 @@ func (m *defaultProductFeatureModel) Update(ctx context.Context, session sqlx.Se if err != nil { return nil, err } - qncProductFeatureIdKey := fmt.Sprintf("%s%v", cacheQncProductFeatureIdPrefix, data.Id) - qncProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdFeatureIdPrefix, data.ProductId, data.FeatureId) - qncProductFeatureProductIdSortKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdSortPrefix, data.ProductId, data.Sort) + tycProductFeatureIdKey := fmt.Sprintf("%s%v", cacheTycProductFeatureIdPrefix, data.Id) + tycProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheTycProductFeatureProductIdFeatureIdPrefix, data.ProductId, data.FeatureId) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, productFeatureRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, productFeatureRowsWithPlaceHolder) if session != nil { - return session.ExecCtx(ctx, query, newData.ProductId, newData.FeatureId, newData.DeleteTime, newData.DelState, newData.Version, newData.Sort, newData.IsImportant, newData.Id) + return session.ExecCtx(ctx, query, newData.ProductId, newData.FeatureId, newData.DeleteTime, newData.DelState, newData.Version, newData.Sort, newData.Enable, newData.IsImportant, newData.Id) } - return conn.ExecCtx(ctx, query, newData.ProductId, newData.FeatureId, newData.DeleteTime, newData.DelState, newData.Version, newData.Sort, newData.IsImportant, newData.Id) - }, qncProductFeatureIdKey, qncProductFeatureProductIdFeatureIdKey, qncProductFeatureProductIdSortKey) + return conn.ExecCtx(ctx, query, newData.ProductId, newData.FeatureId, newData.DeleteTime, newData.DelState, newData.Version, newData.Sort, newData.Enable, newData.IsImportant, newData.Id) + }, tycProductFeatureIdKey, tycProductFeatureProductIdFeatureIdKey) } func (m *defaultProductFeatureModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *ProductFeature) error { @@ -179,16 +155,15 @@ func (m *defaultProductFeatureModel) UpdateWithVersion(ctx context.Context, sess if err != nil { return err } - qncProductFeatureIdKey := fmt.Sprintf("%s%v", cacheQncProductFeatureIdPrefix, data.Id) - qncProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdFeatureIdPrefix, data.ProductId, data.FeatureId) - qncProductFeatureProductIdSortKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdSortPrefix, data.ProductId, data.Sort) + tycProductFeatureIdKey := fmt.Sprintf("%s%v", cacheTycProductFeatureIdPrefix, data.Id) + tycProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheTycProductFeatureProductIdFeatureIdPrefix, data.ProductId, data.FeatureId) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, productFeatureRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, productFeatureRowsWithPlaceHolder) if session != nil { - return session.ExecCtx(ctx, query, newData.ProductId, newData.FeatureId, newData.DeleteTime, newData.DelState, newData.Version, newData.Sort, newData.IsImportant, newData.Id, oldVersion) + return session.ExecCtx(ctx, query, newData.ProductId, newData.FeatureId, newData.DeleteTime, newData.DelState, newData.Version, newData.Sort, newData.Enable, newData.IsImportant, newData.Id, oldVersion) } - return conn.ExecCtx(ctx, query, newData.ProductId, newData.FeatureId, newData.DeleteTime, newData.DelState, newData.Version, newData.Sort, newData.IsImportant, newData.Id, oldVersion) - }, qncProductFeatureIdKey, qncProductFeatureProductIdFeatureIdKey, qncProductFeatureProductIdSortKey) + return conn.ExecCtx(ctx, query, newData.ProductId, newData.FeatureId, newData.DeleteTime, newData.DelState, newData.Version, newData.Sort, newData.Enable, newData.IsImportant, newData.Id, oldVersion) + }, tycProductFeatureIdKey, tycProductFeatureProductIdFeatureIdKey) if err != nil { return err } @@ -197,7 +172,7 @@ func (m *defaultProductFeatureModel) UpdateWithVersion(ctx context.Context, sess return err } if updateCount == 0 { - return model.ErrNoRowsUpdate + return ErrNoRowsUpdate } return nil @@ -411,23 +386,22 @@ func (m *defaultProductFeatureModel) Delete(ctx context.Context, session sqlx.Se return err } - qncProductFeatureIdKey := fmt.Sprintf("%s%v", cacheQncProductFeatureIdPrefix, id) - qncProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdFeatureIdPrefix, data.ProductId, data.FeatureId) - qncProductFeatureProductIdSortKey := fmt.Sprintf("%s%v:%v", cacheQncProductFeatureProductIdSortPrefix, data.ProductId, data.Sort) + tycProductFeatureIdKey := fmt.Sprintf("%s%v", cacheTycProductFeatureIdPrefix, id) + tycProductFeatureProductIdFeatureIdKey := fmt.Sprintf("%s%v:%v", cacheTycProductFeatureProductIdFeatureIdPrefix, data.ProductId, data.FeatureId) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) + query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncProductFeatureIdKey, qncProductFeatureProductIdFeatureIdKey, qncProductFeatureProductIdSortKey) + }, tycProductFeatureIdKey, tycProductFeatureProductIdFeatureIdKey) return err } func (m *defaultProductFeatureModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncProductFeatureIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycProductFeatureIdPrefix, primary) } func (m *defaultProductFeatureModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", productFeatureRows, m.table) + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", productFeatureRows, m.table) return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) } diff --git a/app/user/model/productModel_gen.go b/app/user/model/productModel_gen.go index b99af94..ff27656 100644 --- a/app/user/model/productModel_gen.go +++ b/app/user/model/productModel_gen.go @@ -6,7 +6,6 @@ import ( "context" "database/sql" "fmt" - "qnc-server/deploy/script/model" "strings" "time" @@ -18,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -27,8 +26,8 @@ var ( productRowsExpectAutoSet = strings.Join(stringx.Remove(productFieldNames, "`id`", "`create_time`", "`update_time`"), ",") productRowsWithPlaceHolder = strings.Join(stringx.Remove(productFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncProductIdPrefix = "cache:qnc:product:id:" - cacheQncProductProductEnPrefix = "cache:qnc:product:productEn:" + cacheTycProductIdPrefix = "cache:tyc:product:id:" + cacheTycProductProductEnPrefix = "cache:tyc:product:productEn:" ) type ( @@ -81,39 +80,39 @@ func newProductModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultProductModel func (m *defaultProductModel) Insert(ctx context.Context, session sqlx.Session, data *Product) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncProductIdKey := fmt.Sprintf("%s%v", cacheQncProductIdPrefix, data.Id) - qncProductProductEnKey := fmt.Sprintf("%s%v", cacheQncProductProductEnPrefix, data.ProductEn) + tycProductIdKey := fmt.Sprintf("%s%v", cacheTycProductIdPrefix, data.Id) + tycProductProductEnKey := fmt.Sprintf("%s%v", cacheTycProductProductEnPrefix, data.ProductEn) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, productRowsExpectAutoSet) + query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, productRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.ProductName, data.ProductEn, data.Description, data.Notes, data.CostPrice, data.SellPrice) } return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.ProductName, data.ProductEn, data.Description, data.Notes, data.CostPrice, data.SellPrice) - }, qncProductIdKey, qncProductProductEnKey) + }, tycProductIdKey, tycProductProductEnKey) } func (m *defaultProductModel) FindOne(ctx context.Context, id int64) (*Product, error) { - qncProductIdKey := fmt.Sprintf("%s%v", cacheQncProductIdPrefix, id) + tycProductIdKey := fmt.Sprintf("%s%v", cacheTycProductIdPrefix, id) var resp Product - err := m.QueryRowCtx(ctx, &resp, qncProductIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", productRows, m.table) + err := m.QueryRowCtx(ctx, &resp, tycProductIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", productRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } } func (m *defaultProductModel) FindOneByProductEn(ctx context.Context, productEn string) (*Product, error) { - qncProductProductEnKey := fmt.Sprintf("%s%v", cacheQncProductProductEnPrefix, productEn) + tycProductProductEnKey := fmt.Sprintf("%s%v", cacheTycProductProductEnPrefix, productEn) var resp Product - err := m.QueryRowIndexCtx(ctx, &resp, qncProductProductEnKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `product_en` = ? AND del_state = ? limit 1", productRows, m.table) + err := m.QueryRowIndexCtx(ctx, &resp, tycProductProductEnKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + query := fmt.Sprintf("select %s from %s where `product_en` = ? and del_state = ? limit 1", productRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, productEn, globalkey.DelStateNo); err != nil { return nil, err } @@ -123,7 +122,7 @@ func (m *defaultProductModel) FindOneByProductEn(ctx context.Context, productEn case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } @@ -134,15 +133,15 @@ func (m *defaultProductModel) Update(ctx context.Context, session sqlx.Session, if err != nil { return nil, err } - qncProductIdKey := fmt.Sprintf("%s%v", cacheQncProductIdPrefix, data.Id) - qncProductProductEnKey := fmt.Sprintf("%s%v", cacheQncProductProductEnPrefix, data.ProductEn) + tycProductIdKey := fmt.Sprintf("%s%v", cacheTycProductIdPrefix, data.Id) + tycProductProductEnKey := fmt.Sprintf("%s%v", cacheTycProductProductEnPrefix, data.ProductEn) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, productRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, productRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ProductName, newData.ProductEn, newData.Description, newData.Notes, newData.CostPrice, newData.SellPrice, newData.Id) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ProductName, newData.ProductEn, newData.Description, newData.Notes, newData.CostPrice, newData.SellPrice, newData.Id) - }, qncProductIdKey, qncProductProductEnKey) + }, tycProductIdKey, tycProductProductEnKey) } func (m *defaultProductModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *Product) error { @@ -157,15 +156,15 @@ func (m *defaultProductModel) UpdateWithVersion(ctx context.Context, session sql if err != nil { return err } - qncProductIdKey := fmt.Sprintf("%s%v", cacheQncProductIdPrefix, data.Id) - qncProductProductEnKey := fmt.Sprintf("%s%v", cacheQncProductProductEnPrefix, data.ProductEn) + tycProductIdKey := fmt.Sprintf("%s%v", cacheTycProductIdPrefix, data.Id) + tycProductProductEnKey := fmt.Sprintf("%s%v", cacheTycProductProductEnPrefix, data.ProductEn) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, productRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, productRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ProductName, newData.ProductEn, newData.Description, newData.Notes, newData.CostPrice, newData.SellPrice, newData.Id, oldVersion) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ProductName, newData.ProductEn, newData.Description, newData.Notes, newData.CostPrice, newData.SellPrice, newData.Id, oldVersion) - }, qncProductIdKey, qncProductProductEnKey) + }, tycProductIdKey, tycProductProductEnKey) if err != nil { return err } @@ -174,7 +173,7 @@ func (m *defaultProductModel) UpdateWithVersion(ctx context.Context, session sql return err } if updateCount == 0 { - return model.ErrNoRowsUpdate + return ErrNoRowsUpdate } return nil @@ -388,22 +387,22 @@ func (m *defaultProductModel) Delete(ctx context.Context, session sqlx.Session, return err } - qncProductIdKey := fmt.Sprintf("%s%v", cacheQncProductIdPrefix, id) - qncProductProductEnKey := fmt.Sprintf("%s%v", cacheQncProductProductEnPrefix, data.ProductEn) + tycProductIdKey := fmt.Sprintf("%s%v", cacheTycProductIdPrefix, id) + tycProductProductEnKey := fmt.Sprintf("%s%v", cacheTycProductProductEnPrefix, data.ProductEn) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) + query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncProductIdKey, qncProductProductEnKey) + }, tycProductIdKey, tycProductProductEnKey) return err } func (m *defaultProductModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncProductIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycProductIdPrefix, primary) } func (m *defaultProductModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", productRows, m.table) + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", productRows, m.table) return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) } diff --git a/app/user/model/productRenderModel_gen.go b/app/user/model/productRenderModel_gen.go index 3003482..73ec635 100644 --- a/app/user/model/productRenderModel_gen.go +++ b/app/user/model/productRenderModel_gen.go @@ -17,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -26,8 +26,8 @@ var ( productRenderRowsExpectAutoSet = strings.Join(stringx.Remove(productRenderFieldNames, "`id`", "`create_time`", "`update_time`"), ",") productRenderRowsWithPlaceHolder = strings.Join(stringx.Remove(productRenderFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncProductRenderIdPrefix = "cache:qnc:productRender:id:" - cacheQncProductRenderPlatformModuleProductIdPrefix = "cache:qnc:productRender:platform:module:productId:" + cacheTycProductRenderIdPrefix = "cache:tyc:productRender:id:" + cacheTycProductRenderPlatformModuleProductIdPrefix = "cache:tyc:productRender:platform:module:productId:" ) type ( @@ -78,21 +78,21 @@ func newProductRenderModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultProduct func (m *defaultProductRenderModel) Insert(ctx context.Context, session sqlx.Session, data *ProductRender) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncProductRenderIdKey := fmt.Sprintf("%s%v", cacheQncProductRenderIdPrefix, data.Id) - qncProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheQncProductRenderPlatformModuleProductIdPrefix, data.Platform, data.Module, data.ProductId) + tycProductRenderIdKey := fmt.Sprintf("%s%v", cacheTycProductRenderIdPrefix, data.Id) + tycProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheTycProductRenderPlatformModuleProductIdPrefix, data.Platform, data.Module, data.ProductId) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, productRenderRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Platform, data.Module, data.ProductId, data.IsRendered) } return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Platform, data.Module, data.ProductId, data.IsRendered) - }, qncProductRenderIdKey, qncProductRenderPlatformModuleProductIdKey) + }, tycProductRenderIdKey, tycProductRenderPlatformModuleProductIdKey) } func (m *defaultProductRenderModel) FindOne(ctx context.Context, id int64) (*ProductRender, error) { - qncProductRenderIdKey := fmt.Sprintf("%s%v", cacheQncProductRenderIdPrefix, id) + tycProductRenderIdKey := fmt.Sprintf("%s%v", cacheTycProductRenderIdPrefix, id) var resp ProductRender - err := m.QueryRowCtx(ctx, &resp, qncProductRenderIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + err := m.QueryRowCtx(ctx, &resp, tycProductRenderIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", productRenderRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) @@ -107,9 +107,9 @@ func (m *defaultProductRenderModel) FindOne(ctx context.Context, id int64) (*Pro } func (m *defaultProductRenderModel) FindOneByPlatformModuleProductId(ctx context.Context, platform string, module string, productId int64) (*ProductRender, error) { - qncProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheQncProductRenderPlatformModuleProductIdPrefix, platform, module, productId) + tycProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheTycProductRenderPlatformModuleProductIdPrefix, platform, module, productId) var resp ProductRender - err := m.QueryRowIndexCtx(ctx, &resp, qncProductRenderPlatformModuleProductIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + err := m.QueryRowIndexCtx(ctx, &resp, tycProductRenderPlatformModuleProductIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { query := fmt.Sprintf("select %s from %s where `platform` = ? and `module` = ? and `product_id` = ? and del_state = ? limit 1", productRenderRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, platform, module, productId, globalkey.DelStateNo); err != nil { return nil, err @@ -131,15 +131,15 @@ func (m *defaultProductRenderModel) Update(ctx context.Context, session sqlx.Ses if err != nil { return nil, err } - qncProductRenderIdKey := fmt.Sprintf("%s%v", cacheQncProductRenderIdPrefix, data.Id) - qncProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheQncProductRenderPlatformModuleProductIdPrefix, data.Platform, data.Module, data.ProductId) + tycProductRenderIdKey := fmt.Sprintf("%s%v", cacheTycProductRenderIdPrefix, data.Id) + tycProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheTycProductRenderPlatformModuleProductIdPrefix, data.Platform, data.Module, data.ProductId) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, productRenderRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Platform, newData.Module, newData.ProductId, newData.IsRendered, newData.Id) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Platform, newData.Module, newData.ProductId, newData.IsRendered, newData.Id) - }, qncProductRenderIdKey, qncProductRenderPlatformModuleProductIdKey) + }, tycProductRenderIdKey, tycProductRenderPlatformModuleProductIdKey) } func (m *defaultProductRenderModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *ProductRender) error { @@ -154,15 +154,15 @@ func (m *defaultProductRenderModel) UpdateWithVersion(ctx context.Context, sessi if err != nil { return err } - qncProductRenderIdKey := fmt.Sprintf("%s%v", cacheQncProductRenderIdPrefix, data.Id) - qncProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheQncProductRenderPlatformModuleProductIdPrefix, data.Platform, data.Module, data.ProductId) + tycProductRenderIdKey := fmt.Sprintf("%s%v", cacheTycProductRenderIdPrefix, data.Id) + tycProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheTycProductRenderPlatformModuleProductIdPrefix, data.Platform, data.Module, data.ProductId) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, productRenderRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Platform, newData.Module, newData.ProductId, newData.IsRendered, newData.Id, oldVersion) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Platform, newData.Module, newData.ProductId, newData.IsRendered, newData.Id, oldVersion) - }, qncProductRenderIdKey, qncProductRenderPlatformModuleProductIdKey) + }, tycProductRenderIdKey, tycProductRenderPlatformModuleProductIdKey) if err != nil { return err } @@ -385,19 +385,19 @@ func (m *defaultProductRenderModel) Delete(ctx context.Context, session sqlx.Ses return err } - qncProductRenderIdKey := fmt.Sprintf("%s%v", cacheQncProductRenderIdPrefix, id) - qncProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheQncProductRenderPlatformModuleProductIdPrefix, data.Platform, data.Module, data.ProductId) + tycProductRenderIdKey := fmt.Sprintf("%s%v", cacheTycProductRenderIdPrefix, id) + tycProductRenderPlatformModuleProductIdKey := fmt.Sprintf("%s%v:%v:%v", cacheTycProductRenderPlatformModuleProductIdPrefix, data.Platform, data.Module, data.ProductId) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncProductRenderIdKey, qncProductRenderPlatformModuleProductIdKey) + }, tycProductRenderIdKey, tycProductRenderPlatformModuleProductIdKey) return err } func (m *defaultProductRenderModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncProductRenderIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycProductRenderIdPrefix, primary) } func (m *defaultProductRenderModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", productRenderRows, m.table) diff --git a/app/user/model/queryModel_gen.go b/app/user/model/queryModel_gen.go index f8a7ccf..d136076 100644 --- a/app/user/model/queryModel_gen.go +++ b/app/user/model/queryModel_gen.go @@ -6,7 +6,6 @@ import ( "context" "database/sql" "fmt" - "qnc-server/deploy/script/model" "strings" "time" @@ -18,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -27,8 +26,8 @@ var ( queryRowsExpectAutoSet = strings.Join(stringx.Remove(queryFieldNames, "`id`", "`create_time`", "`update_time`"), ",") queryRowsWithPlaceHolder = strings.Join(stringx.Remove(queryFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncQueryIdPrefix = "cache:qnc:query:id:" - cacheQncQueryOrderIdPrefix = "cache:qnc:query:orderId:" + cacheTycQueryIdPrefix = "cache:tyc:query:id:" + cacheTycQueryOrderIdPrefix = "cache:tyc:query:orderId:" ) type ( @@ -81,39 +80,39 @@ func newQueryModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultQueryModel { func (m *defaultQueryModel) Insert(ctx context.Context, session sqlx.Session, data *Query) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncQueryIdKey := fmt.Sprintf("%s%v", cacheQncQueryIdPrefix, data.Id) - qncQueryOrderIdKey := fmt.Sprintf("%s%v", cacheQncQueryOrderIdPrefix, data.OrderId) + tycQueryIdKey := fmt.Sprintf("%s%v", cacheTycQueryIdPrefix, data.Id) + tycQueryOrderIdKey := fmt.Sprintf("%s%v", cacheTycQueryOrderIdPrefix, data.OrderId) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, queryRowsExpectAutoSet) + query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, queryRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.OrderId, data.UserId, data.ProductId, data.QueryParams, data.QueryData, data.QueryState, data.DelState, data.Version, data.DeleteTime) } return conn.ExecCtx(ctx, query, data.OrderId, data.UserId, data.ProductId, data.QueryParams, data.QueryData, data.QueryState, data.DelState, data.Version, data.DeleteTime) - }, qncQueryIdKey, qncQueryOrderIdKey) + }, tycQueryIdKey, tycQueryOrderIdKey) } func (m *defaultQueryModel) FindOne(ctx context.Context, id int64) (*Query, error) { - qncQueryIdKey := fmt.Sprintf("%s%v", cacheQncQueryIdPrefix, id) + tycQueryIdKey := fmt.Sprintf("%s%v", cacheTycQueryIdPrefix, id) var resp Query - err := m.QueryRowCtx(ctx, &resp, qncQueryIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", queryRows, m.table) + err := m.QueryRowCtx(ctx, &resp, tycQueryIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", queryRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) switch err { case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } } func (m *defaultQueryModel) FindOneByOrderId(ctx context.Context, orderId int64) (*Query, error) { - qncQueryOrderIdKey := fmt.Sprintf("%s%v", cacheQncQueryOrderIdPrefix, orderId) + tycQueryOrderIdKey := fmt.Sprintf("%s%v", cacheTycQueryOrderIdPrefix, orderId) var resp Query - err := m.QueryRowIndexCtx(ctx, &resp, qncQueryOrderIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `order_id` = ? AND del_state = ? limit 1", queryRows, m.table) + err := m.QueryRowIndexCtx(ctx, &resp, tycQueryOrderIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + query := fmt.Sprintf("select %s from %s where `order_id` = ? and del_state = ? limit 1", queryRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, orderId, globalkey.DelStateNo); err != nil { return nil, err } @@ -123,7 +122,7 @@ func (m *defaultQueryModel) FindOneByOrderId(ctx context.Context, orderId int64) case nil: return &resp, nil case sqlc.ErrNotFound: - return nil, model.ErrNotFound + return nil, ErrNotFound default: return nil, err } @@ -134,15 +133,15 @@ func (m *defaultQueryModel) Update(ctx context.Context, session sqlx.Session, ne if err != nil { return nil, err } - qncQueryIdKey := fmt.Sprintf("%s%v", cacheQncQueryIdPrefix, data.Id) - qncQueryOrderIdKey := fmt.Sprintf("%s%v", cacheQncQueryOrderIdPrefix, data.OrderId) + tycQueryIdKey := fmt.Sprintf("%s%v", cacheTycQueryIdPrefix, data.Id) + tycQueryOrderIdKey := fmt.Sprintf("%s%v", cacheTycQueryOrderIdPrefix, data.OrderId) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ?", m.table, queryRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, queryRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.OrderId, newData.UserId, newData.ProductId, newData.QueryParams, newData.QueryData, newData.QueryState, newData.DelState, newData.Version, newData.DeleteTime, newData.Id) } return conn.ExecCtx(ctx, query, newData.OrderId, newData.UserId, newData.ProductId, newData.QueryParams, newData.QueryData, newData.QueryState, newData.DelState, newData.Version, newData.DeleteTime, newData.Id) - }, qncQueryIdKey, qncQueryOrderIdKey) + }, tycQueryIdKey, tycQueryOrderIdKey) } func (m *defaultQueryModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *Query) error { @@ -157,15 +156,15 @@ func (m *defaultQueryModel) UpdateWithVersion(ctx context.Context, session sqlx. if err != nil { return err } - qncQueryIdKey := fmt.Sprintf("%s%v", cacheQncQueryIdPrefix, data.Id) - qncQueryOrderIdKey := fmt.Sprintf("%s%v", cacheQncQueryOrderIdPrefix, data.OrderId) + tycQueryIdKey := fmt.Sprintf("%s%v", cacheTycQueryIdPrefix, data.Id) + tycQueryOrderIdKey := fmt.Sprintf("%s%v", cacheTycQueryOrderIdPrefix, data.OrderId) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("UPDATE %s SET %s WHERE `id` = ? AND version = ? ", m.table, queryRowsWithPlaceHolder) + query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, queryRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.OrderId, newData.UserId, newData.ProductId, newData.QueryParams, newData.QueryData, newData.QueryState, newData.DelState, newData.Version, newData.DeleteTime, newData.Id, oldVersion) } return conn.ExecCtx(ctx, query, newData.OrderId, newData.UserId, newData.ProductId, newData.QueryParams, newData.QueryData, newData.QueryState, newData.DelState, newData.Version, newData.DeleteTime, newData.Id, oldVersion) - }, qncQueryIdKey, qncQueryOrderIdKey) + }, tycQueryIdKey, tycQueryOrderIdKey) if err != nil { return err } @@ -174,7 +173,7 @@ func (m *defaultQueryModel) UpdateWithVersion(ctx context.Context, session sqlx. return err } if updateCount == 0 { - return model.ErrNoRowsUpdate + return ErrNoRowsUpdate } return nil @@ -388,22 +387,22 @@ func (m *defaultQueryModel) Delete(ctx context.Context, session sqlx.Session, id return err } - qncQueryIdKey := fmt.Sprintf("%s%v", cacheQncQueryIdPrefix, id) - qncQueryOrderIdKey := fmt.Sprintf("%s%v", cacheQncQueryOrderIdPrefix, data.OrderId) + tycQueryIdKey := fmt.Sprintf("%s%v", cacheTycQueryIdPrefix, id) + tycQueryOrderIdKey := fmt.Sprintf("%s%v", cacheTycQueryOrderIdPrefix, data.OrderId) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("DELETE FROM %s WHERE `id` = ?", m.table) + query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncQueryIdKey, qncQueryOrderIdKey) + }, tycQueryIdKey, tycQueryOrderIdKey) return err } func (m *defaultQueryModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncQueryIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycQueryIdPrefix, primary) } func (m *defaultQueryModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("SELECT %s FROM %s WHERE `id` = ? AND del_state = ? limit 1", queryRows, m.table) + query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", queryRows, m.table) return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) } diff --git a/app/user/model/userAuthModel_gen.go b/app/user/model/userAuthModel_gen.go index 3b2bc18..35f1539 100644 --- a/app/user/model/userAuthModel_gen.go +++ b/app/user/model/userAuthModel_gen.go @@ -17,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -26,9 +26,9 @@ var ( userAuthRowsExpectAutoSet = strings.Join(stringx.Remove(userAuthFieldNames, "`id`", "`create_time`", "`update_time`"), ",") userAuthRowsWithPlaceHolder = strings.Join(stringx.Remove(userAuthFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncUserAuthIdPrefix = "cache:qnc:userAuth:id:" - cacheQncUserAuthAuthTypeAuthKeyPrefix = "cache:qnc:userAuth:authType:authKey:" - cacheQncUserAuthUserIdAuthTypePrefix = "cache:qnc:userAuth:userId:authType:" + cacheTycUserAuthIdPrefix = "cache:tyc:userAuth:id:" + cacheTycUserAuthAuthTypeAuthKeyPrefix = "cache:tyc:userAuth:authType:authKey:" + cacheTycUserAuthUserIdAuthTypePrefix = "cache:tyc:userAuth:userId:authType:" ) type ( @@ -79,22 +79,22 @@ func newUserAuthModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultUserAuthMode func (m *defaultUserAuthModel) Insert(ctx context.Context, session sqlx.Session, data *UserAuth) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthAuthTypeAuthKeyPrefix, data.AuthType, data.AuthKey) - qncUserAuthIdKey := fmt.Sprintf("%s%v", cacheQncUserAuthIdPrefix, data.Id) - qncUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthUserIdAuthTypePrefix, data.UserId, data.AuthType) + tycUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthAuthTypeAuthKeyPrefix, data.AuthType, data.AuthKey) + tycUserAuthIdKey := fmt.Sprintf("%s%v", cacheTycUserAuthIdPrefix, data.Id) + tycUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthUserIdAuthTypePrefix, data.UserId, data.AuthType) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?)", m.table, userAuthRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.UserId, data.AuthKey, data.AuthType) } return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.UserId, data.AuthKey, data.AuthType) - }, qncUserAuthAuthTypeAuthKeyKey, qncUserAuthIdKey, qncUserAuthUserIdAuthTypeKey) + }, tycUserAuthAuthTypeAuthKeyKey, tycUserAuthIdKey, tycUserAuthUserIdAuthTypeKey) } func (m *defaultUserAuthModel) FindOne(ctx context.Context, id int64) (*UserAuth, error) { - qncUserAuthIdKey := fmt.Sprintf("%s%v", cacheQncUserAuthIdPrefix, id) + tycUserAuthIdKey := fmt.Sprintf("%s%v", cacheTycUserAuthIdPrefix, id) var resp UserAuth - err := m.QueryRowCtx(ctx, &resp, qncUserAuthIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + err := m.QueryRowCtx(ctx, &resp, tycUserAuthIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userAuthRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) @@ -109,9 +109,9 @@ func (m *defaultUserAuthModel) FindOne(ctx context.Context, id int64) (*UserAuth } func (m *defaultUserAuthModel) FindOneByAuthTypeAuthKey(ctx context.Context, authType string, authKey string) (*UserAuth, error) { - qncUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthAuthTypeAuthKeyPrefix, authType, authKey) + tycUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthAuthTypeAuthKeyPrefix, authType, authKey) var resp UserAuth - err := m.QueryRowIndexCtx(ctx, &resp, qncUserAuthAuthTypeAuthKeyKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + err := m.QueryRowIndexCtx(ctx, &resp, tycUserAuthAuthTypeAuthKeyKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { query := fmt.Sprintf("select %s from %s where `auth_type` = ? and `auth_key` = ? and del_state = ? limit 1", userAuthRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, authType, authKey, globalkey.DelStateNo); err != nil { return nil, err @@ -129,9 +129,9 @@ func (m *defaultUserAuthModel) FindOneByAuthTypeAuthKey(ctx context.Context, aut } func (m *defaultUserAuthModel) FindOneByUserIdAuthType(ctx context.Context, userId int64, authType string) (*UserAuth, error) { - qncUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthUserIdAuthTypePrefix, userId, authType) + tycUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthUserIdAuthTypePrefix, userId, authType) var resp UserAuth - err := m.QueryRowIndexCtx(ctx, &resp, qncUserAuthUserIdAuthTypeKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + err := m.QueryRowIndexCtx(ctx, &resp, tycUserAuthUserIdAuthTypeKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { query := fmt.Sprintf("select %s from %s where `user_id` = ? and `auth_type` = ? and del_state = ? limit 1", userAuthRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, userId, authType, globalkey.DelStateNo); err != nil { return nil, err @@ -153,16 +153,16 @@ func (m *defaultUserAuthModel) Update(ctx context.Context, session sqlx.Session, if err != nil { return nil, err } - qncUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthAuthTypeAuthKeyPrefix, data.AuthType, data.AuthKey) - qncUserAuthIdKey := fmt.Sprintf("%s%v", cacheQncUserAuthIdPrefix, data.Id) - qncUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthUserIdAuthTypePrefix, data.UserId, data.AuthType) + tycUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthAuthTypeAuthKeyPrefix, data.AuthType, data.AuthKey) + tycUserAuthIdKey := fmt.Sprintf("%s%v", cacheTycUserAuthIdPrefix, data.Id) + tycUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthUserIdAuthTypePrefix, data.UserId, data.AuthType) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, userAuthRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.UserId, newData.AuthKey, newData.AuthType, newData.Id) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.UserId, newData.AuthKey, newData.AuthType, newData.Id) - }, qncUserAuthAuthTypeAuthKeyKey, qncUserAuthIdKey, qncUserAuthUserIdAuthTypeKey) + }, tycUserAuthAuthTypeAuthKeyKey, tycUserAuthIdKey, tycUserAuthUserIdAuthTypeKey) } func (m *defaultUserAuthModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *UserAuth) error { @@ -177,16 +177,16 @@ func (m *defaultUserAuthModel) UpdateWithVersion(ctx context.Context, session sq if err != nil { return err } - qncUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthAuthTypeAuthKeyPrefix, data.AuthType, data.AuthKey) - qncUserAuthIdKey := fmt.Sprintf("%s%v", cacheQncUserAuthIdPrefix, data.Id) - qncUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthUserIdAuthTypePrefix, data.UserId, data.AuthType) + tycUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthAuthTypeAuthKeyPrefix, data.AuthType, data.AuthKey) + tycUserAuthIdKey := fmt.Sprintf("%s%v", cacheTycUserAuthIdPrefix, data.Id) + tycUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthUserIdAuthTypePrefix, data.UserId, data.AuthType) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, userAuthRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.UserId, newData.AuthKey, newData.AuthType, newData.Id, oldVersion) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.UserId, newData.AuthKey, newData.AuthType, newData.Id, oldVersion) - }, qncUserAuthAuthTypeAuthKeyKey, qncUserAuthIdKey, qncUserAuthUserIdAuthTypeKey) + }, tycUserAuthAuthTypeAuthKeyKey, tycUserAuthIdKey, tycUserAuthUserIdAuthTypeKey) if err != nil { return err } @@ -409,20 +409,20 @@ func (m *defaultUserAuthModel) Delete(ctx context.Context, session sqlx.Session, return err } - qncUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthAuthTypeAuthKeyPrefix, data.AuthType, data.AuthKey) - qncUserAuthIdKey := fmt.Sprintf("%s%v", cacheQncUserAuthIdPrefix, id) - qncUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheQncUserAuthUserIdAuthTypePrefix, data.UserId, data.AuthType) + tycUserAuthAuthTypeAuthKeyKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthAuthTypeAuthKeyPrefix, data.AuthType, data.AuthKey) + tycUserAuthIdKey := fmt.Sprintf("%s%v", cacheTycUserAuthIdPrefix, id) + tycUserAuthUserIdAuthTypeKey := fmt.Sprintf("%s%v:%v", cacheTycUserAuthUserIdAuthTypePrefix, data.UserId, data.AuthType) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncUserAuthAuthTypeAuthKeyKey, qncUserAuthIdKey, qncUserAuthUserIdAuthTypeKey) + }, tycUserAuthAuthTypeAuthKeyKey, tycUserAuthIdKey, tycUserAuthUserIdAuthTypeKey) return err } func (m *defaultUserAuthModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncUserAuthIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycUserAuthIdPrefix, primary) } func (m *defaultUserAuthModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userAuthRows, m.table) diff --git a/app/user/model/userModel_gen.go b/app/user/model/userModel_gen.go index 4403dcf..ed69a9f 100644 --- a/app/user/model/userModel_gen.go +++ b/app/user/model/userModel_gen.go @@ -17,7 +17,7 @@ import ( "github.com/zeromicro/go-zero/core/stores/sqlc" "github.com/zeromicro/go-zero/core/stores/sqlx" "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" ) var ( @@ -26,8 +26,8 @@ var ( userRowsExpectAutoSet = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), ",") userRowsWithPlaceHolder = strings.Join(stringx.Remove(userFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - cacheQncUserIdPrefix = "cache:qnc:user:id:" - cacheQncUserMobilePrefix = "cache:qnc:user:mobile:" + cacheTycUserIdPrefix = "cache:tyc:user:id:" + cacheTycUserMobilePrefix = "cache:tyc:user:mobile:" ) type ( @@ -64,7 +64,7 @@ type ( Version int64 `db:"version"` // 版本号 Mobile string `db:"mobile"` Password sql.NullString `db:"password"` - Nickname string `db:"nickname"` + Nickname sql.NullString `db:"nickname"` Info string `db:"info"` Inside int64 `db:"inside"` } @@ -79,21 +79,21 @@ func newUserModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultUserModel { func (m *defaultUserModel) Insert(ctx context.Context, session sqlx.Session, data *User) (sql.Result, error) { data.DelState = globalkey.DelStateNo - qncUserIdKey := fmt.Sprintf("%s%v", cacheQncUserIdPrefix, data.Id) - qncUserMobileKey := fmt.Sprintf("%s%v", cacheQncUserMobilePrefix, data.Mobile) + tycUserIdKey := fmt.Sprintf("%s%v", cacheTycUserIdPrefix, data.Id) + tycUserMobileKey := fmt.Sprintf("%s%v", cacheTycUserMobilePrefix, data.Mobile) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, userRowsExpectAutoSet) if session != nil { return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside) } return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.Mobile, data.Password, data.Nickname, data.Info, data.Inside) - }, qncUserIdKey, qncUserMobileKey) + }, tycUserIdKey, tycUserMobileKey) } func (m *defaultUserModel) FindOne(ctx context.Context, id int64) (*User, error) { - qncUserIdKey := fmt.Sprintf("%s%v", cacheQncUserIdPrefix, id) + tycUserIdKey := fmt.Sprintf("%s%v", cacheTycUserIdPrefix, id) var resp User - err := m.QueryRowCtx(ctx, &resp, qncUserIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { + err := m.QueryRowCtx(ctx, &resp, tycUserIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userRows, m.table) return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) }) @@ -108,9 +108,9 @@ func (m *defaultUserModel) FindOne(ctx context.Context, id int64) (*User, error) } func (m *defaultUserModel) FindOneByMobile(ctx context.Context, mobile string) (*User, error) { - qncUserMobileKey := fmt.Sprintf("%s%v", cacheQncUserMobilePrefix, mobile) + tycUserMobileKey := fmt.Sprintf("%s%v", cacheTycUserMobilePrefix, mobile) var resp User - err := m.QueryRowIndexCtx(ctx, &resp, qncUserMobileKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { + err := m.QueryRowIndexCtx(ctx, &resp, tycUserMobileKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { query := fmt.Sprintf("select %s from %s where `mobile` = ? and del_state = ? limit 1", userRows, m.table) if err := conn.QueryRowCtx(ctx, &resp, query, mobile, globalkey.DelStateNo); err != nil { return nil, err @@ -132,15 +132,15 @@ func (m *defaultUserModel) Update(ctx context.Context, session sqlx.Session, new if err != nil { return nil, err } - qncUserIdKey := fmt.Sprintf("%s%v", cacheQncUserIdPrefix, data.Id) - qncUserMobileKey := fmt.Sprintf("%s%v", cacheQncUserMobilePrefix, data.Mobile) + tycUserIdKey := fmt.Sprintf("%s%v", cacheTycUserIdPrefix, data.Id) + tycUserMobileKey := fmt.Sprintf("%s%v", cacheTycUserMobilePrefix, data.Mobile) return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, userRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id) - }, qncUserIdKey, qncUserMobileKey) + }, tycUserIdKey, tycUserMobileKey) } func (m *defaultUserModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *User) error { @@ -155,15 +155,15 @@ func (m *defaultUserModel) UpdateWithVersion(ctx context.Context, session sqlx.S if err != nil { return err } - qncUserIdKey := fmt.Sprintf("%s%v", cacheQncUserIdPrefix, data.Id) - qncUserMobileKey := fmt.Sprintf("%s%v", cacheQncUserMobilePrefix, data.Mobile) + tycUserIdKey := fmt.Sprintf("%s%v", cacheTycUserIdPrefix, data.Id) + tycUserMobileKey := fmt.Sprintf("%s%v", cacheTycUserMobilePrefix, data.Mobile) sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, userRowsWithPlaceHolder) if session != nil { return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id, oldVersion) } return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.Mobile, newData.Password, newData.Nickname, newData.Info, newData.Inside, newData.Id, oldVersion) - }, qncUserIdKey, qncUserMobileKey) + }, tycUserIdKey, tycUserMobileKey) if err != nil { return err } @@ -386,19 +386,19 @@ func (m *defaultUserModel) Delete(ctx context.Context, session sqlx.Session, id return err } - qncUserIdKey := fmt.Sprintf("%s%v", cacheQncUserIdPrefix, id) - qncUserMobileKey := fmt.Sprintf("%s%v", cacheQncUserMobilePrefix, data.Mobile) + tycUserIdKey := fmt.Sprintf("%s%v", cacheTycUserIdPrefix, id) + tycUserMobileKey := fmt.Sprintf("%s%v", cacheTycUserMobilePrefix, data.Mobile) _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { query := fmt.Sprintf("delete from %s where `id` = ?", m.table) if session != nil { return session.ExecCtx(ctx, query, id) } return conn.ExecCtx(ctx, query, id) - }, qncUserIdKey, qncUserMobileKey) + }, tycUserIdKey, tycUserMobileKey) return err } func (m *defaultUserModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncUserIdPrefix, primary) + return fmt.Sprintf("%s%v", cacheTycUserIdPrefix, primary) } func (m *defaultUserModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userRows, m.table) diff --git a/common/result/httpResult.go b/common/result/httpResult.go index 1b0609a..13200d3 100644 --- a/common/result/httpResult.go +++ b/common/result/httpResult.go @@ -4,7 +4,7 @@ import ( "fmt" "net/http" - "qnc-server/common/xerr" + "tyc-server/common/xerr" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/logx" diff --git a/common/result/jobResult.go b/common/result/jobResult.go index d18476f..720af6d 100644 --- a/common/result/jobResult.go +++ b/common/result/jobResult.go @@ -3,7 +3,7 @@ package result import ( "context" - "qnc-server/common/xerr" + "tyc-server/common/xerr" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/logx" diff --git a/deploy/script/genModel.ps1 b/deploy/script/genModel.ps1 index b4059f6..29a6e8a 100644 --- a/deploy/script/genModel.ps1 +++ b/deploy/script/genModel.ps1 @@ -2,7 +2,7 @@ # .\genModel.ps1 user user # .\genModel.ps1 user user_auth # 再将 .\genModel 下的文件剪切到对应服务的 model 目录里面,记得改 package -# goctl model mysql datasource -url="qnc:5vg67b3UNHu8@tcp(127.0.0.1:20001)/qnc" -table="product" -dir="./model" --home="../template" -cache=true --style=goZero +# goctl model mysql datasource -url="tyc:5vg67b3UNHu8@tcp(127.0.0.1:20001)/tyc" -table="product" -dir="./model" --home="../template" -cache=true --style=goZero param ( [string]$database, [string]$tables @@ -15,12 +15,11 @@ $templateDir = Join-Path -Path (Resolve-Path "$PSScriptRoot/..") -ChildPath "tem $host = "127.0.0.1" $port = "20001" $dbname = "$database" -$username = "qnc" +$username = "tyc" $passwd = "5vg67b3UNHu8" Write-Output "开始创建库:$dbname 的表:$tables" # 执行 goctl 命令生成 model $command = "goctl model mysql datasource -url=`"$username`:$passwd`@tcp($host`:$port)/$dbname`" -table=`"$tables`" -dir=`"$modeldir`" --home=`"$templateDir`" -cache=true --style=goZero" -Invoke-Expression $command -gibyjk. \ No newline at end of file +Invoke-Expression $command \ No newline at end of file diff --git a/deploy/script/gen_models.ps1 b/deploy/script/gen_models.ps1 new file mode 100644 index 0000000..ea71dd1 --- /dev/null +++ b/deploy/script/gen_models.ps1 @@ -0,0 +1,25 @@ +# 设置输出编码为UTF-8 +[Console]::OutputEncoding = [System.Text.Encoding]::UTF8 +# 数据库连接信息 - 修改了URL格式 +$DB_URL = "tyc:5vg67b3UNHu8@(127.0.0.1:20001)/tyc" +$OUTPUT_DIR = "./model" +$TEMPLATE_DIR = "../template" + +# 表名列表 +$tables = @( + "example", + "feature", + "global_notifications", + "order", + "product", + "product_feature", + "product_render", + "query", + "user", + "user_auth" +) + +# 为每个表生成模型 +foreach ($table in $tables) { + goctl model mysql datasource -url="tyc:5vg67b3UNHu8@tcp(127.0.0.1:20001)/tyc" -table="$table" -dir="./model" --home="../template" -cache=true --style=goZero +} diff --git a/deploy/script/model/agentModel.go b/deploy/script/model/agentModel.go deleted file mode 100644 index 2aef816..0000000 --- a/deploy/script/model/agentModel.go +++ /dev/null @@ -1,27 +0,0 @@ -package model - -import ( - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlx" -) - -var _ AgentModel = (*customAgentModel)(nil) - -type ( - // AgentModel is an interface to be customized, add more methods here, - // and implement the added methods in customAgentModel. - AgentModel interface { - agentModel - } - - customAgentModel struct { - *defaultAgentModel - } -) - -// NewAgentModel returns a model for the database table. -func NewAgentModel(conn sqlx.SqlConn, c cache.CacheConf) AgentModel { - return &customAgentModel{ - defaultAgentModel: newAgentModel(conn, c), - } -} diff --git a/deploy/script/model/agentModel_gen.go b/deploy/script/model/agentModel_gen.go deleted file mode 100644 index d121773..0000000 --- a/deploy/script/model/agentModel_gen.go +++ /dev/null @@ -1,409 +0,0 @@ -// Code generated by goctl. DO NOT EDIT! - -package model - -import ( - "context" - "database/sql" - "fmt" - "strings" - - "time" - - "github.com/Masterminds/squirrel" - "github.com/pkg/errors" - "github.com/zeromicro/go-zero/core/stores/builder" - "github.com/zeromicro/go-zero/core/stores/cache" - "github.com/zeromicro/go-zero/core/stores/sqlc" - "github.com/zeromicro/go-zero/core/stores/sqlx" - "github.com/zeromicro/go-zero/core/stringx" - "qnc-server/common/globalkey" -) - -var ( - agentFieldNames = builder.RawFieldNames(&Agent{}) - agentRows = strings.Join(agentFieldNames, ",") - agentRowsExpectAutoSet = strings.Join(stringx.Remove(agentFieldNames, "`id`", "`create_time`", "`update_time`"), ",") - agentRowsWithPlaceHolder = strings.Join(stringx.Remove(agentFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?" - - cacheQncAgentIdPrefix = "cache:qnc:agent:id:" - cacheQncAgentUserIdPrefix = "cache:qnc:agent:userId:" -) - -type ( - agentModel interface { - Insert(ctx context.Context, session sqlx.Session, data *Agent) (sql.Result, error) - FindOne(ctx context.Context, id int64) (*Agent, error) - FindOneByUserId(ctx context.Context, userId int64) (*Agent, error) - Update(ctx context.Context, session sqlx.Session, data *Agent) (sql.Result, error) - UpdateWithVersion(ctx context.Context, session sqlx.Session, data *Agent) error - Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error - SelectBuilder() squirrel.SelectBuilder - DeleteSoft(ctx context.Context, session sqlx.Session, data *Agent) error - FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error) - FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error) - FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*Agent, error) - FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*Agent, error) - FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*Agent, int64, error) - FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*Agent, error) - FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*Agent, error) - Delete(ctx context.Context, session sqlx.Session, id int64) error - } - - defaultAgentModel struct { - sqlc.CachedConn - table string - } - - Agent struct { - Id int64 `db:"id"` - UserId int64 `db:"user_id"` - Region string `db:"region"` - Mobile string `db:"mobile"` - WechatId sql.NullString `db:"wechat_id"` - CreateTime time.Time `db:"create_time"` - UpdateTime time.Time `db:"update_time"` - DeleteTime sql.NullTime `db:"delete_time"` // 删除时间 - DelState int64 `db:"del_state"` // 删除状态 - Version int64 `db:"version"` // 版本号 - } -) - -func newAgentModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultAgentModel { - return &defaultAgentModel{ - CachedConn: sqlc.NewConn(conn, c), - table: "`agent`", - } -} - -func (m *defaultAgentModel) Insert(ctx context.Context, session sqlx.Session, data *Agent) (sql.Result, error) { - data.DelState = globalkey.DelStateNo - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, data.Id) - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, data.UserId) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?)", m.table, agentRowsExpectAutoSet) - if session != nil { - return session.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.DeleteTime, data.DelState, data.Version) - } - return conn.ExecCtx(ctx, query, data.UserId, data.Region, data.Mobile, data.WechatId, data.DeleteTime, data.DelState, data.Version) - }, qncAgentIdKey, qncAgentUserIdKey) -} - -func (m *defaultAgentModel) FindOne(ctx context.Context, id int64) (*Agent, error) { - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, id) - var resp Agent - err := m.QueryRowCtx(ctx, &resp, qncAgentIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error { - query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", agentRows, m.table) - return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo) - }) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentModel) FindOneByUserId(ctx context.Context, userId int64) (*Agent, error) { - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, userId) - var resp Agent - err := m.QueryRowIndexCtx(ctx, &resp, qncAgentUserIdKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) { - query := fmt.Sprintf("select %s from %s where `user_id` = ? and del_state = ? limit 1", agentRows, m.table) - if err := conn.QueryRowCtx(ctx, &resp, query, userId, globalkey.DelStateNo); err != nil { - return nil, err - } - return resp.Id, nil - }, m.queryPrimary) - switch err { - case nil: - return &resp, nil - case sqlc.ErrNotFound: - return nil, ErrNotFound - default: - return nil, err - } -} - -func (m *defaultAgentModel) Update(ctx context.Context, session sqlx.Session, newData *Agent) (sql.Result, error) { - data, err := m.FindOne(ctx, newData.Id) - if err != nil { - return nil, err - } - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, data.Id) - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, data.UserId) - return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, agentRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, newData.UserId, newData.Region, newData.Mobile, newData.WechatId, newData.DeleteTime, newData.DelState, newData.Version, newData.Id) - } - return conn.ExecCtx(ctx, query, newData.UserId, newData.Region, newData.Mobile, newData.WechatId, newData.DeleteTime, newData.DelState, newData.Version, newData.Id) - }, qncAgentIdKey, qncAgentUserIdKey) -} - -func (m *defaultAgentModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *Agent) error { - - oldVersion := newData.Version - newData.Version += 1 - - var sqlResult sql.Result - var err error - - data, err := m.FindOne(ctx, newData.Id) - if err != nil { - return err - } - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, data.Id) - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, data.UserId) - sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, agentRowsWithPlaceHolder) - if session != nil { - return session.ExecCtx(ctx, query, newData.UserId, newData.Region, newData.Mobile, newData.WechatId, newData.DeleteTime, newData.DelState, newData.Version, newData.Id, oldVersion) - } - return conn.ExecCtx(ctx, query, newData.UserId, newData.Region, newData.Mobile, newData.WechatId, newData.DeleteTime, newData.DelState, newData.Version, newData.Id, oldVersion) - }, qncAgentIdKey, qncAgentUserIdKey) - if err != nil { - return err - } - updateCount, err := sqlResult.RowsAffected() - if err != nil { - return err - } - if updateCount == 0 { - return ErrNoRowsUpdate - } - - return nil -} - -func (m *defaultAgentModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *Agent) error { - data.DelState = globalkey.DelStateYes - data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true} - if err := m.UpdateWithVersion(ctx, session, data); err != nil { - return errors.Wrapf(errors.New("delete soft failed "), "AgentModel delete err : %+v", err) - } - return nil -} - -func (m *defaultAgentModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field") - } - - builder = builder.Columns("IFNULL(SUM(" + field + "),0)") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp float64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) { - - if len(field) == 0 { - return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field") - } - - builder = builder.Columns("COUNT(" + field + ")") - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return 0, err - } - - var resp int64 - err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return 0, err - } -} - -func (m *defaultAgentModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*Agent, error) { - - builder = builder.Columns(agentRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql() - if err != nil { - return nil, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*Agent, error) { - - builder = builder.Columns(agentRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*Agent, int64, error) { - - total, err := m.FindCount(ctx, builder, "id") - if err != nil { - return nil, 0, err - } - - builder = builder.Columns(agentRows) - - if orderBy == "" { - builder = builder.OrderBy("id DESC") - } else { - builder = builder.OrderBy(orderBy) - } - - if page < 1 { - page = 1 - } - offset := (page - 1) * pageSize - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, total, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, total, nil - default: - return nil, total, err - } -} - -func (m *defaultAgentModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*Agent, error) { - - builder = builder.Columns(agentRows) - - if preMinId > 0 { - builder = builder.Where(" id < ? ", preMinId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*Agent, error) { - - builder = builder.Columns(agentRows) - - if preMaxId > 0 { - builder = builder.Where(" id > ? ", preMaxId) - } - - query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql() - if err != nil { - return nil, err - } - - var resp []*Agent - err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...) - switch err { - case nil: - return resp, nil - default: - return nil, err - } -} - -func (m *defaultAgentModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error { - - return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error { - return fn(ctx, session) - }) - -} - -func (m *defaultAgentModel) SelectBuilder() squirrel.SelectBuilder { - return squirrel.Select().From(m.table) -} -func (m *defaultAgentModel) Delete(ctx context.Context, session sqlx.Session, id int64) error { - data, err := m.FindOne(ctx, id) - if err != nil { - return err - } - - qncAgentIdKey := fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, id) - qncAgentUserIdKey := fmt.Sprintf("%s%v", cacheQncAgentUserIdPrefix, data.UserId) - _, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { - query := fmt.Sprintf("delete from %s where `id` = ?", m.table) - if session != nil { - return session.ExecCtx(ctx, query, id) - } - return conn.ExecCtx(ctx, query, id) - }, qncAgentIdKey, qncAgentUserIdKey) - return err -} -func (m *defaultAgentModel) formatPrimary(primary interface{}) string { - return fmt.Sprintf("%s%v", cacheQncAgentIdPrefix, primary) -} -func (m *defaultAgentModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error { - query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", agentRows, m.table) - return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo) -} - -func (m *defaultAgentModel) tableName() string { - return m.table -} diff --git a/deploy/script/model/vars.go b/deploy/script/model/vars.go index 9267571..81462b5 100644 --- a/deploy/script/model/vars.go +++ b/deploy/script/model/vars.go @@ -1,9 +1,9 @@ package model import ( - "errors" - "github.com/zeromicro/go-zero/core/stores/sqlx" + "errors" + "github.com/zeromicro/go-zero/core/stores/sqlx" ) var ErrNotFound = sqlx.ErrNotFound -var ErrNoRowsUpdate = errors.New("update db no rows change") +var ErrNoRowsUpdate = errors.New("update db no rows change") \ No newline at end of file diff --git a/deploy/template/api/handler.tpl b/deploy/template/api/handler.tpl index dcd3729..3c02295 100644 --- a/deploy/template/api/handler.tpl +++ b/deploy/template/api/handler.tpl @@ -3,8 +3,8 @@ package {{.PkgName}} import ( "net/http" - "qnc-server/common/result" - "qnc-server/pkg/lzkit/validator" + "tyc-server/common/result" + "tyc-server/pkg/lzkit/validator" "github.com/zeromicro/go-zero/rest/httpx" {{.ImportPackages}} ) diff --git a/deploy/template/api/main.tpl b/deploy/template/api/main.tpl index 71be5cb..a4ab692 100644 --- a/deploy/template/api/main.tpl +++ b/deploy/template/api/main.tpl @@ -5,7 +5,6 @@ import ( "fmt" {{.importPackages}} - "qnc-server/common/middleware" ) var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file") diff --git a/deploy/template/model/import-no-cache.tpl b/deploy/template/model/import-no-cache.tpl index 2b5e853..581f500 100644 --- a/deploy/template/model/import-no-cache.tpl +++ b/deploy/template/model/import-no-cache.tpl @@ -6,7 +6,7 @@ import ( {{if .time}}"time"{{end}} - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" "github.com/Masterminds/squirrel" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/stores/builder" diff --git a/deploy/template/model/import.tpl b/deploy/template/model/import.tpl index 3cd8038..177473e 100644 --- a/deploy/template/model/import.tpl +++ b/deploy/template/model/import.tpl @@ -6,7 +6,7 @@ import ( {{if .time}}"time"{{end}} - "qnc-server/common/globalkey" + "tyc-server/common/globalkey" "github.com/Masterminds/squirrel" "github.com/pkg/errors" "github.com/zeromicro/go-zero/core/stores/builder" diff --git a/deploy/template/rpc/main.tpl b/deploy/template/rpc/main.tpl index d7bea24..f815b6b 100644 --- a/deploy/template/rpc/main.tpl +++ b/deploy/template/rpc/main.tpl @@ -5,7 +5,7 @@ import ( "fmt" {{.imports}} - "qnc-server/common/interceptor/rpcserver" + "tyc-server/common/interceptor/rpcserver" "github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/core/service" diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 2bf12ac..4c5b11a 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -1,84 +1,83 @@ services: + mysql: + image: mysql:8.0.34 + container_name: tyc_mysql + environment: + # 时区上海 - Time zone Shanghai (Change if needed) + TZ: Asia/Shanghai + # root 密码 - root password + MYSQL_ROOT_PASSWORD: yfg87gyuYiy1 + MYSQL_DATABASE: tyc + MYSQL_USER: tyc + MYSQL_PASSWORD: 5vg67b3UNHu8 + ports: + - "20001:3306" + volumes: + # 数据挂载 - Data mounting + - ./data/mysql/data:/var/lib/mysql + # 日志 + command: + # 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配) + # Modify the Mysql 8.0 default password strategy to the original strategy (MySQL8.0 to change its default strategy will cause the password to be unable to match) + --default-authentication-plugin=mysql_native_password + --character-set-server=utf8mb4 + --collation-server=utf8mb4_general_ci + --explicit_defaults_for_timestamp=true + --lower_case_table_names=1 + privileged: true + restart: always + networks: + - tyc_net - mysql: - image: mysql:8.0.34 - container_name: qnc_mysql - environment: - # 时区上海 - Time zone Shanghai (Change if needed) - TZ: Asia/Shanghai - # root 密码 - root password - MYSQL_ROOT_PASSWORD: yfg87gyuYiy1 - MYSQL_DATABASE: qnc - MYSQL_USER: qnc - MYSQL_PASSWORD: 5vg67b3UNHu8 - ports: - - "20001:3306" - volumes: - # 数据挂载 - Data mounting - - ./data/mysql/data:/var/lib/mysql - # 日志 - command: - # 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配) - # Modify the Mysql 8.0 default password strategy to the original strategy (MySQL8.0 to change its default strategy will cause the password to be unable to match) - --default-authentication-plugin=mysql_native_password - --character-set-server=utf8mb4 - --collation-server=utf8mb4_general_ci - --explicit_defaults_for_timestamp=true - --lower_case_table_names=1 - privileged: true - restart: always - networks: - - qnc_net + redis: + image: redis:7.4.0 + container_name: tyc_redis + ports: + - "20002:6379" + environment: + # 时区上海 - Time zone Shanghai (Change if needed) + TZ: Asia/Shanghai + volumes: + # 数据文件 - data files + - ./data/redis/data:/data:rw + command: "redis-server --requirepass 3m3WsgyCKWqz --appendonly yes" + privileged: true + restart: always + networks: + - tyc_net - redis: - image: redis:7.4.0 - container_name: qnc_redis - ports: - - "20002:6379" - environment: - # 时区上海 - Time zone Shanghai (Change if needed) - TZ: Asia/Shanghai - volumes: - # 数据文件 - data files - - ./data/redis/data:/data:rw - command: "redis-server --requirepass 3m3WsgyCKWqz --appendonly yes" - privileged: true - restart: always - networks: - - qnc_net + asynqmon: + image: hibiken/asynqmon:latest + container_name: tyc_asynqmon + ports: + - "20003:8080" + environment: + - TZ=Asia/Shanghai + command: + - "--redis-addr=tyc_redis:6379" + - "--redis-password=3m3WsgyCKWqz" + restart: always + networks: + - tyc_net + depends_on: + - redis - asynqmon: - image: hibiken/asynqmon:latest - container_name: qnc_asynqmon - ports: - - "20003:8080" - environment: - - TZ=Asia/Shanghai - command: - - '--redis-addr=qnc_redis:6379' - - '--redis-password=3m3WsgyCKWqz' - restart: always - networks: - - qnc_net - depends_on: - - redis - - phpmyadmin: - image: phpmyadmin/phpmyadmin - container_name: qnc_phpmyadmin - restart: unless-stopped - environment: - PMA_HOST: qnc_mysql - PMA_PORT: 3306 - PMA_USER: qnc - PMA_PASSWORD: 5vg67b3UNHu8 - ports: - - "20004:80" - depends_on: - - mysql - networks: - - qnc_net + phpmyadmin: + image: phpmyadmin/phpmyadmin + container_name: tyc_phpmyadmin + restart: unless-stopped + environment: + PMA_HOST: tyc_mysql + PMA_PORT: 3306 + PMA_USER: tyc + PMA_PASSWORD: 5vg67b3UNHu8 + ports: + - "20004:80" + depends_on: + - mysql + networks: + - tyc_net networks: - qnc_net: - driver: bridge + tyc_net: + driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml index 7be0d80..b50a810 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,90 +1,89 @@ -version: '3' +version: "3" services: + mysql: + image: mysql:8.0.34 + container_name: tyc_mysql + environment: + # 时区上海 - Time zone Shanghai (Change if needed) + TZ: Asia/Shanghai + # root 密码 - root password + MYSQL_ROOT_PASSWORD: yfg87gyuYiy1 + MYSQL_DATABASE: tyc + MYSQL_USER: tyc + MYSQL_PASSWORD: 5vg67b3UNHu8 + ports: + - "20001:3306" + volumes: + # 数据挂载 - Data mounting + - ./data/mysql/data:/var/lib/mysql + # 日志 + command: + # 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配) + # Modify the Mysql 8.0 default password strategy to the original strategy (MySQL8.0 to change its default strategy will cause the password to be unable to match) + --default-authentication-plugin=mysql_native_password + --character-set-server=utf8mb4 + --collation-server=utf8mb4_general_ci + --explicit_defaults_for_timestamp=true + --lower_case_table_names=1 + privileged: true + restart: always + networks: + - tyc_net + - 1panel-network - mysql: - image: mysql:8.0.34 - container_name: qnc_mysql - environment: - # 时区上海 - Time zone Shanghai (Change if needed) - TZ: Asia/Shanghai - # root 密码 - root password - MYSQL_ROOT_PASSWORD: yfg87gyuYiy1 - MYSQL_DATABASE: qnc - MYSQL_USER: qnc - MYSQL_PASSWORD: 5vg67b3UNHu8 - ports: - - "20001:3306" - volumes: - # 数据挂载 - Data mounting - - ./data/mysql/data:/var/lib/mysql - # 日志 - command: - # 将mysql8.0默认密码策略 修改为 原先 策略 (mysql8.0对其默认策略做了更改 会导致密码无法匹配) - # Modify the Mysql 8.0 default password strategy to the original strategy (MySQL8.0 to change its default strategy will cause the password to be unable to match) - --default-authentication-plugin=mysql_native_password - --character-set-server=utf8mb4 - --collation-server=utf8mb4_general_ci - --explicit_defaults_for_timestamp=true - --lower_case_table_names=1 - privileged: true - restart: always - networks: - - qnc_net - - 1panel-network + redis: + image: redis:7.4.0 + container_name: tyc_redis + ports: + - "20002:6379" + environment: + # 时区上海 - Time zone Shanghai (Change if needed) + TZ: Asia/Shanghai + volumes: + # 数据文件 - data files + - ./data/redis/data:/data:rw + command: "redis-server --requirepass 3m3WsgyCKWqz --appendonly yes" + privileged: true + restart: always + networks: + - tyc_net - redis: - image: redis:7.4.0 - container_name: qnc_redis - ports: - - "20002:6379" - environment: - # 时区上海 - Time zone Shanghai (Change if needed) - TZ: Asia/Shanghai - volumes: - # 数据文件 - data files - - ./data/redis/data:/data:rw - command: "redis-server --requirepass 3m3WsgyCKWqz --appendonly yes" - privileged: true - restart: always - networks: - - qnc_net + asynqmon: + image: hibiken/asynqmon:latest + container_name: tyc_asynqmon + ports: + - "20003:8080" + environment: + - TZ=Asia/Shanghai + command: + - "--redis-addr=tyc_redis:6379" + - "--redis-password=3m3WsgyCKWqz" + restart: always + networks: + - tyc_net + depends_on: + - redis - asynqmon: - image: hibiken/asynqmon:latest - container_name: qnc_asynqmon - ports: - - "20003:8080" - environment: - - TZ=Asia/Shanghai - command: - - '--redis-addr=qnc_redis:6379' - - '--redis-password=3m3WsgyCKWqz' - restart: always - networks: - - qnc_net - depends_on: - - redis - - main: - container_name: qnc_main - build: - context: . - dockerfile: ./app/user/cmd/api/Dockerfile - ports: - - "20004:8888" - environment: - - TZ=Asia/Shanghai - - ENV=production - depends_on: - - mysql - - redis - networks: - - qnc_net - restart: always + main: + container_name: tyc_main + build: + context: . + dockerfile: ./app/user/cmd/api/Dockerfile + ports: + - "20004:8888" + environment: + - TZ=Asia/Shanghai + - ENV=production + depends_on: + - mysql + - redis + networks: + - tyc_net + restart: always networks: - qnc_net: - driver: bridge - 1panel-network: - external: true + tyc_net: + driver: bridge + 1panel-network: + external: true diff --git a/gen_api.ps1 b/gen_api.ps1 new file mode 100644 index 0000000..32eca87 --- /dev/null +++ b/gen_api.ps1 @@ -0,0 +1,2 @@ +# API生成脚本 +goctl api go --api ./app/user/cmd/api/desc/main.api --dir ./app/user/cmd/api --home ./deploy/template \ No newline at end of file diff --git a/go.mod b/go.mod index 0ca625c..70fe7ae 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module qnc-server +module tyc-server go 1.22.4