Compare commits
10 Commits
29f248f1b4
...
f6a38a1246
Author | SHA1 | Date | |
---|---|---|---|
f6a38a1246 | |||
1d46f6a9a2 | |||
e340813938 | |||
78dbb3a175 | |||
43916f00f0 | |||
c53d5fdf2a | |||
b18c3d58ab | |||
32fcdd7ad1 | |||
b9ca357448 | |||
9059458433 |
@ -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)
|
||||
}
|
||||
|
@ -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"`
|
||||
}
|
||||
)
|
||||
|
@ -12,4 +12,3 @@ import "user.api"
|
||||
import "query.api"
|
||||
import "pay.api"
|
||||
import "product.api"
|
||||
import "agent.api"
|
||||
|
@ -36,10 +36,12 @@ service main {
|
||||
@handler wxMiniAuth
|
||||
post /user/wxMiniAuth (WXMiniAuthReq) returns (WXMiniAuthResp)
|
||||
|
||||
|
||||
@doc "wechat h5 auth"
|
||||
@handler wxH5Auth
|
||||
post /user/wxh5Auth (WXH5AuthReq) returns (WXH5AuthResp)
|
||||
|
||||
@handler DecryptMobile
|
||||
post /user/decryptMobile
|
||||
}
|
||||
|
||||
//need login
|
||||
|
@ -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 密码,如果未设置则留空
|
||||
@ -32,9 +32,9 @@ TianjuConfig:
|
||||
ApiKey: "479bcac2a77b56e976d044ff2bd996f4"
|
||||
BaseURL: "https://apis.tianapi.com"
|
||||
Alipay:
|
||||
AppID: "2021004165608254"
|
||||
PrivateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCvo8TmTNnVguKwMYrX0z01PfUlSS+AqwwCH1+/P39q6No+09yO1bjhy4LowtDfwKX8F+IZLl5Cx06f1M8KzPvjQliBAfMJ1FuTEOOXPmtE1YLAYIUMLbltR6Crnp16T28eF41Uo0PUo2ple/oSjWhYgsTJjyBMXY04f6HM2uZlHOhG2aOUz2CDNbvkEhNddazuPMgo8Xl7vwENGDFTPa85HmSSoDppFowLdYfAw2Jl1ilKNg4sOPc6d507nXdgpMlUguwZxol6OQ2hBS6v9OjII5cJ1tyR/klJRapnIPmFaPvhDozYwjU6Z3jMvcbrByl0qNpLrbEFS4pn9hfRo4YrAgMBAAECggEAZAi0Ri6TCqXnEk7FMzMec0p8auYJ5hCFYFgaIkS5/1vroUjtH3TePcu5HXSHnkiMwM2hepIMIaB+SU3dNduVwtOwsJk5oOmP1m0SErv8QFISjBrs7AjGyVS4T8ahDl5bfRoQ5pmuMld4a6B2x0Y+ndqs1ddsn9HQctNOhexOuFsSjX1N3PZxFzfRTmGzxf7kwZGlXMN7G1r3Rp4koylYHVpqjXIK34Anc8SVljxFVkFOk62QvBdYcCucepymHNl0pYwPDCCylPH8OpIXOErmPldTflmoLRc+ywu9rw4I8UvkoPgTe+16he+jdi/N7cwbMTfixq+/Aeadjv2AgMuwkQKBgQDgLS3dRFAc6FMSJIA0FKgv5D/R3NZgWilbOAF11PtnE4AX4i0yZryGtLq+3NWCWYQF8iI60lIy3rEf9zWncwfadhWTEDUBjjrqqU46N2ddTzHsDw09I56TT2vrEwCdmJ2vh1hxPfgE3fSDnKbP4Wkl77JCTH7v0rA1jb65Plt8TwKBgQDIkrXqe/pVHDdxswoPL6em32TnKiaJ/R/UDDio20mgGG7FWEJAY5yYtu0y9Ug7W8PjJE7/cJ2/dwDSvHZm8R0iq8d6XkzN03Z+uvzGnMdUraXJZHSPZ5L/2ofysXjt/OtpA1Sox5++1+obiq6CZ6IYORLSxSf+it1JUbKXsNcVZQKBgQCTPzm7984DXtqJtS38h4D9jBgbWcn6Gd7GSuAyrIXBa76ccXSsgWzdskJjcZxQdUnRufyf1Fwni7yeOXullFoZNazwHxoh/nFWh4SZmqCrWoR5AF36xbW4HtfM3XtvCLqye90s7L5HPB8Kf8/WBcJSJ8JX5/UMw7/4PTWEaaAf4wKBgQCEXu7YVgIccYbV7wdQhm7q3rxFI7hTkU6UL4ylRDQPCJDyhREUValf0DozS1XkdueM3MWWJ8i0N+G/MsohnjdQTnZT+DBQFqM5eEai/Y1AAWpMw5N5oS2O1barIR1iU2053QzeZwCyfuTuUFRjk+mSevhFSgDfKN5qKRTor7kDUQKBgB3fC6jO8XCwimPvpsiGnuddNAq/w8iqSjSwuSvbI0Q7Lq6rvAIw2AmkC5t4kW4JcZLUgDvAs4GFoPDYhoL73vc1e2c35VTNck6IxZSQzzQ9pfXFiLtTe6eqggN4EOPGHKLd92CMAgoeySsp3NydpGSx2N/NUqp8BkoFLQ/k2W9o"
|
||||
AlipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2CqoCp95w/JV3RT/gzF4/8QmVT1HQNaeW7yUp+mA7x9AbjvlTW/+eRn6oGAL/XhZLjvHD0XjKLVKX0MJVS1aUQHEHEbOJN4Eu8II45OavD4iZISa7Kp9V6AM+i4qTyaeV2wNDnGxHQBaLVUGCfMR+56EK2YpORdE1H9uy72SSQseVb3bmpsV9EW/IJNmcVL/ut3uA1JWAoRmzlQ7ekxg7p8AYXzYPEHQr1tl7W+M4zv9wO9GKZCxIqMA8U3RP5npPfRaCfIRGzXzCqFEEUvWuidOB7frsvN4jiPD07qpL2Bi9LM1X/ee2kC/oM8Uhd7ERZhG8MbZfijZKxgrsDKBcwIDAQAB"
|
||||
AppID: "2021004161631930"
|
||||
PrivateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCOh6r6Ce7ZgMf5mWqVsU8sYNdU0HRlZbgYUQ2wF65PzWU3vL52+LG89ATbtHeKUy6esuuaAyYhuDrqU9f6mUl5QJGsWCF6JqqyberVIMJfdsdOTbgooSSUBxIsMYfoRZPdsZ9dHomDxfi2oGWJdAnaruTxKw7W8EPJwqc9/vopzdxLsT8t/eMzr4jvHIBVHtkMbmgNJ8b05tqJ1FViK3Yt78YBkt3PLdyjLzqRuKlVpmNceBEhzNbg4menGBzpJHTWO4uGk0KzUgY7wCSfyjrA9IPyWnDqlhws+9LwFKgkNpqxmwGgMihLysDRFOD5D1VLfry/yYT22UrwAzXFQYUvAgMBAAECggEAfKGfXXMwG5sjwltnuyvHepvXzz9UeJHgz8qYeIHMl9WYC4wM1IWVDhAm62M8IIWqP3Ve1VapklTBl8PnGSfO+qr+dsC9zU1geBPrg6BYtxdrIkqNnWGDVbl1J5XMLMwih3nZS5j3UHXdjPxmrTH9p+7FHSm0mTiRXizLB0gdwk0E+H+btJKLpCvqqIoEucowzbjY/ch86ASojpQGZiWapbi+03Xke6/wlGCbNzgGmQQo/C6XAbxl2ZKJxS/yp0JxGfO6gPJYx3xkuf+Pwr0U3imN8yDB/xo0LVamoxQggWua+mQXt72J4zD2imIU7TB4JFJV3kUd+45KLOccOsOuCQKBgQDLfsBxU/LiNn+zW6yus+dCu7JzQSN2K57XF+PSXhQTSjIu4K4y8v4WZHdSwkAGQSU3MLq66QD7ELYHGDBakFFj3sX7z2CHshFlu2I/DYP+0LPVRlIblsSDFn6rYBLOPXc3VkuEFcA0PpO3vW6yF7h2d9OpGaiYmpTvXa/6oPLQfQKBgQCzTgxTTrzZjLXCv85fzX3aYu9ceP4N0jaOwveEMvKNClSomUIDfHLn4sUTmAvHBdJz4Xqy/7+v/YpI0ifC0KouX0t6h3+YA6n4hCvpBMlUVACtHUfx+mzjj+KLxEvmm6ZJCmV5DC3yYvaDTANafM3PzyQRs/jw5WPWywezFfooGwKBgQC4Fq9TFkWYHQNDJ0C9PqSL+y7BEwFYireED+maSl9Q4AMr4zfTgX0YlsRXSsEOp2paVivmoJixh3mUS26azwnCFir21LCXsSAJ7w0+yyRIpVa6LoZizO5zRCtNL3lzt6kcl2VzVRXubVnGk4kLdWf7TAVfaYXan6TyMcfcLDPdJQKBgCwtV6YS6T6kh4fjICLEi3SKGbVr7hRTrbOA3+EHeHE9kVw03mnjeKAfZDUOqiAwFAkPDd8aWg0vZ6nHdZpvNO7V9c/LoKlAhdlAH117G2uWgtAkPbyl2bw7kDKle5nm0ZJ/aD7pvExTC6+Pw+fAhijkPVvLPtODgRTD0zLRgF/vAoGBAMdxes5p7u+Eoa41c3Y39dGvY30QiiGPB4oWLTdmyh4VQfC7DU7ihUCRsk5w4i/BuTNNlJauWM2MMX7YeRBt6ncq59vBAU2OeLd6oRsOkE2ZkH7tNDnGxZuOZkiSFnYUQLMBPnVe4JkS7ZvRWSyuIi9SE8TDpTLbH1kfEmIMq4dR"
|
||||
AlipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjoeq+gnu2YDH+ZlqlbFPLGDXVNB0ZWW4GFENsBeuT81lN7y+dvixvPQE27R3ilMunrLrmgMmIbg66lPX+plJeUCRrFgheiaqsm3q1SDCX3bHTk24KKEklAcSLDGH6EWT3bGfXR6Jg8X4tqBliXQJ2q7k8SsO1vBDycKnPf76Kc3cS7E/Lf3jM6+I7xyAVR7ZDG5oDSfG9ObaidRVYit2Le/GAZLdzy3coy86kbipVaZjXHgRIczW4OJnpxgc6SR01juLhpNCs1IGO8Akn8o6wPSD8lpw6pYcLPvS8BSoJDaasZsBoDIoS8rA0RTg+Q9VS368v8mE9tlK8AM1xUGFLwIDAQAB"
|
||||
IsProduction: true
|
||||
NotifyUrl: "https://6m4685017o.goho.co/api/v1/pay/alipay/callback"
|
||||
ReturnURL: "http://localhost:5678/inquire"
|
||||
|
@ -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" # 单节点模式
|
||||
|
||||
@ -34,9 +34,9 @@ TianjuConfig:
|
||||
ApiKey: "479bcac2a77b56e976d044ff2bd996f4"
|
||||
BaseURL: "https://apis.tianapi.com"
|
||||
Alipay:
|
||||
AppID: "2021004165608254"
|
||||
PrivateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCvo8TmTNnVguKwMYrX0z01PfUlSS+AqwwCH1+/P39q6No+09yO1bjhy4LowtDfwKX8F+IZLl5Cx06f1M8KzPvjQliBAfMJ1FuTEOOXPmtE1YLAYIUMLbltR6Crnp16T28eF41Uo0PUo2ple/oSjWhYgsTJjyBMXY04f6HM2uZlHOhG2aOUz2CDNbvkEhNddazuPMgo8Xl7vwENGDFTPa85HmSSoDppFowLdYfAw2Jl1ilKNg4sOPc6d507nXdgpMlUguwZxol6OQ2hBS6v9OjII5cJ1tyR/klJRapnIPmFaPvhDozYwjU6Z3jMvcbrByl0qNpLrbEFS4pn9hfRo4YrAgMBAAECggEAZAi0Ri6TCqXnEk7FMzMec0p8auYJ5hCFYFgaIkS5/1vroUjtH3TePcu5HXSHnkiMwM2hepIMIaB+SU3dNduVwtOwsJk5oOmP1m0SErv8QFISjBrs7AjGyVS4T8ahDl5bfRoQ5pmuMld4a6B2x0Y+ndqs1ddsn9HQctNOhexOuFsSjX1N3PZxFzfRTmGzxf7kwZGlXMN7G1r3Rp4koylYHVpqjXIK34Anc8SVljxFVkFOk62QvBdYcCucepymHNl0pYwPDCCylPH8OpIXOErmPldTflmoLRc+ywu9rw4I8UvkoPgTe+16he+jdi/N7cwbMTfixq+/Aeadjv2AgMuwkQKBgQDgLS3dRFAc6FMSJIA0FKgv5D/R3NZgWilbOAF11PtnE4AX4i0yZryGtLq+3NWCWYQF8iI60lIy3rEf9zWncwfadhWTEDUBjjrqqU46N2ddTzHsDw09I56TT2vrEwCdmJ2vh1hxPfgE3fSDnKbP4Wkl77JCTH7v0rA1jb65Plt8TwKBgQDIkrXqe/pVHDdxswoPL6em32TnKiaJ/R/UDDio20mgGG7FWEJAY5yYtu0y9Ug7W8PjJE7/cJ2/dwDSvHZm8R0iq8d6XkzN03Z+uvzGnMdUraXJZHSPZ5L/2ofysXjt/OtpA1Sox5++1+obiq6CZ6IYORLSxSf+it1JUbKXsNcVZQKBgQCTPzm7984DXtqJtS38h4D9jBgbWcn6Gd7GSuAyrIXBa76ccXSsgWzdskJjcZxQdUnRufyf1Fwni7yeOXullFoZNazwHxoh/nFWh4SZmqCrWoR5AF36xbW4HtfM3XtvCLqye90s7L5HPB8Kf8/WBcJSJ8JX5/UMw7/4PTWEaaAf4wKBgQCEXu7YVgIccYbV7wdQhm7q3rxFI7hTkU6UL4ylRDQPCJDyhREUValf0DozS1XkdueM3MWWJ8i0N+G/MsohnjdQTnZT+DBQFqM5eEai/Y1AAWpMw5N5oS2O1barIR1iU2053QzeZwCyfuTuUFRjk+mSevhFSgDfKN5qKRTor7kDUQKBgB3fC6jO8XCwimPvpsiGnuddNAq/w8iqSjSwuSvbI0Q7Lq6rvAIw2AmkC5t4kW4JcZLUgDvAs4GFoPDYhoL73vc1e2c35VTNck6IxZSQzzQ9pfXFiLtTe6eqggN4EOPGHKLd92CMAgoeySsp3NydpGSx2N/NUqp8BkoFLQ/k2W9o"
|
||||
AlipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2CqoCp95w/JV3RT/gzF4/8QmVT1HQNaeW7yUp+mA7x9AbjvlTW/+eRn6oGAL/XhZLjvHD0XjKLVKX0MJVS1aUQHEHEbOJN4Eu8II45OavD4iZISa7Kp9V6AM+i4qTyaeV2wNDnGxHQBaLVUGCfMR+56EK2YpORdE1H9uy72SSQseVb3bmpsV9EW/IJNmcVL/ut3uA1JWAoRmzlQ7ekxg7p8AYXzYPEHQr1tl7W+M4zv9wO9GKZCxIqMA8U3RP5npPfRaCfIRGzXzCqFEEUvWuidOB7frsvN4jiPD07qpL2Bi9LM1X/ee2kC/oM8Uhd7ERZhG8MbZfijZKxgrsDKBcwIDAQAB"
|
||||
AppID: "2021004161631930"
|
||||
PrivateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCOh6r6Ce7ZgMf5mWqVsU8sYNdU0HRlZbgYUQ2wF65PzWU3vL52+LG89ATbtHeKUy6esuuaAyYhuDrqU9f6mUl5QJGsWCF6JqqyberVIMJfdsdOTbgooSSUBxIsMYfoRZPdsZ9dHomDxfi2oGWJdAnaruTxKw7W8EPJwqc9/vopzdxLsT8t/eMzr4jvHIBVHtkMbmgNJ8b05tqJ1FViK3Yt78YBkt3PLdyjLzqRuKlVpmNceBEhzNbg4menGBzpJHTWO4uGk0KzUgY7wCSfyjrA9IPyWnDqlhws+9LwFKgkNpqxmwGgMihLysDRFOD5D1VLfry/yYT22UrwAzXFQYUvAgMBAAECggEAfKGfXXMwG5sjwltnuyvHepvXzz9UeJHgz8qYeIHMl9WYC4wM1IWVDhAm62M8IIWqP3Ve1VapklTBl8PnGSfO+qr+dsC9zU1geBPrg6BYtxdrIkqNnWGDVbl1J5XMLMwih3nZS5j3UHXdjPxmrTH9p+7FHSm0mTiRXizLB0gdwk0E+H+btJKLpCvqqIoEucowzbjY/ch86ASojpQGZiWapbi+03Xke6/wlGCbNzgGmQQo/C6XAbxl2ZKJxS/yp0JxGfO6gPJYx3xkuf+Pwr0U3imN8yDB/xo0LVamoxQggWua+mQXt72J4zD2imIU7TB4JFJV3kUd+45KLOccOsOuCQKBgQDLfsBxU/LiNn+zW6yus+dCu7JzQSN2K57XF+PSXhQTSjIu4K4y8v4WZHdSwkAGQSU3MLq66QD7ELYHGDBakFFj3sX7z2CHshFlu2I/DYP+0LPVRlIblsSDFn6rYBLOPXc3VkuEFcA0PpO3vW6yF7h2d9OpGaiYmpTvXa/6oPLQfQKBgQCzTgxTTrzZjLXCv85fzX3aYu9ceP4N0jaOwveEMvKNClSomUIDfHLn4sUTmAvHBdJz4Xqy/7+v/YpI0ifC0KouX0t6h3+YA6n4hCvpBMlUVACtHUfx+mzjj+KLxEvmm6ZJCmV5DC3yYvaDTANafM3PzyQRs/jw5WPWywezFfooGwKBgQC4Fq9TFkWYHQNDJ0C9PqSL+y7BEwFYireED+maSl9Q4AMr4zfTgX0YlsRXSsEOp2paVivmoJixh3mUS26azwnCFir21LCXsSAJ7w0+yyRIpVa6LoZizO5zRCtNL3lzt6kcl2VzVRXubVnGk4kLdWf7TAVfaYXan6TyMcfcLDPdJQKBgCwtV6YS6T6kh4fjICLEi3SKGbVr7hRTrbOA3+EHeHE9kVw03mnjeKAfZDUOqiAwFAkPDd8aWg0vZ6nHdZpvNO7V9c/LoKlAhdlAH117G2uWgtAkPbyl2bw7kDKle5nm0ZJ/aD7pvExTC6+Pw+fAhijkPVvLPtODgRTD0zLRgF/vAoGBAMdxes5p7u+Eoa41c3Y39dGvY30QiiGPB4oWLTdmyh4VQfC7DU7ihUCRsk5w4i/BuTNNlJauWM2MMX7YeRBt6ncq59vBAU2OeLd6oRsOkE2ZkH7tNDnGxZuOZkiSFnYUQLMBPnVe4JkS7ZvRWSyuIi9SE8TDpTLbH1kfEmIMq4dR"
|
||||
AlipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAomw6g4rBmCr/QoX3NI3DVLyDpkaUytZ2uFhdfQaegIDAuUfZfgpTCASlAtO82t8ISAbSOSyp9CUpwdGV4EYOiCBbLxMYB6taaHPiIjJ1zNT1EakJzWgU53hz1AVeABB9kdAvMqSvjH6KLoVupmqm4Li8ZwDW9M2ANAmyDfKgiF0Lt4aUUnaZktoCrTWTkpmtfRZCHNACj851IllvN2wyC4OL7dJq5UzOFxmn07Dy/2z4UAhaaSAyRVawpOui5AIYJTXZERLYL3KMyRnMuZoFq3xltzVTzRPM06nRa9RfeVNVwWVtGBIe/r8tcg5wyhI57KUszGNOmUIm/se6G2lnAQIDAQAB"
|
||||
IsProduction: true
|
||||
NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/alipay/callback"
|
||||
ReturnURL: "https://www.tianyuancha.cn/report"
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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{
|
||||
{
|
||||
@ -209,6 +187,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/user/decryptMobile",
|
||||
Handler: user.DecryptMobileHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// mobile code login
|
||||
Method: http.MethodPost,
|
||||
|
@ -0,0 +1,16 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"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 {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := user.NewDecryptMobileLogic(r.Context(), svcCtx)
|
||||
err := l.DecryptMobile()
|
||||
result.HttpResult(r, w, nil, err)
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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"
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
@ -135,7 +135,6 @@ var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceR
|
||||
"toc_PhoneTwoElements": (*QueryServiceLogic).ProcessTocPhoneTwoElementsLogic,
|
||||
"toc_IDCardTwoElements": (*QueryServiceLogic).ProcessTocIDCardTwoElementsLogic,
|
||||
"toc_NaturalLifeStatus": (*QueryServiceLogic).ProcessTocNaturalLifeStatusLogic,
|
||||
"toc_PersonVehicleVerification": (*QueryServiceLogic).ProcessTocPersonVehicleVerificationLogic,
|
||||
"toc_DualMarriage": (*QueryServiceLogic).ProcessTocDualMarriageLogic,
|
||||
"toc_PhoneNumberRisk": (*QueryServiceLogic).ProcessTocPhoneNumberRiskLogic,
|
||||
"toc_NetworkDuration": (*QueryServiceLogic).ProcessTocNetworkDurationLogic,
|
||||
@ -146,12 +145,13 @@ var productProcessors = map[string]func(*QueryServiceLogic, *types.QueryServiceR
|
||||
"toc_BankCardBlacklist": (*QueryServiceLogic).ProcessTocBankCardBlacklistLogic,
|
||||
|
||||
// 查车部分
|
||||
"toc_vehicleInsuranceSummary": (*QueryServiceLogic).ProcessTocVehicleInsuranceSummaryLogic, // 车辆出险信息
|
||||
"toc_vehicleMaintenanceRecord": (*QueryServiceLogic).ProcessTocVehicleMaintenanceRecordLogic, // 车辆维修记录
|
||||
"toc_VehiclesUnderName": (*QueryServiceLogic).ProcessTocVehiclesUnderNameLogic, // 名下车辆
|
||||
"toc_vehicleValuation": (*QueryServiceLogic).ProcessTocVehicleValuationLogic, // 车辆估值
|
||||
"toc_chassisNumberCheck": (*QueryServiceLogic).ProcessTocChassisNumberCheckLogic, // 车辆识别代码
|
||||
"toc_vehicleTransferCount": (*QueryServiceLogic).ProcessTocVehicleTransferCountLogic, // 车辆过户次数
|
||||
"toc_vehicleInsuranceSummary": (*QueryServiceLogic).ProcessTocVehicleInsuranceSummaryLogic, // 车辆出险信息
|
||||
"toc_vehicleMaintenanceRecord": (*QueryServiceLogic).ProcessTocVehicleMaintenanceRecordLogic, // 车辆维修记录
|
||||
"toc_VehiclesUnderName": (*QueryServiceLogic).ProcessTocVehiclesUnderNameLogic, // 名下车辆
|
||||
"toc_vehicleValuation": (*QueryServiceLogic).ProcessTocVehicleValuationLogic, // 车辆估值
|
||||
"toc_chassisNumberCheck": (*QueryServiceLogic).ProcessTocChassisNumberCheckLogic, // 车辆识别代码
|
||||
"toc_vehicleTransferCount": (*QueryServiceLogic).ProcessTocVehicleTransferCountLogic, // 车辆过户次数
|
||||
"toc_PersonVehicleVerification": (*QueryServiceLogic).ProcessTocPersonVehicleVerificationLogic, // 人车核验
|
||||
|
||||
"toc_ExitRestriction": (*QueryServiceLogic).ProcessTocExitRestrictionLogic, // 限制出境
|
||||
"toc_MonthlyMobileConsumptionLevel": (*QueryServiceLogic).ProcessTocMonthlyMobileConsumptionLevelLogic, // 月消费水平
|
||||
@ -1690,7 +1690,7 @@ func (l *QueryServiceLogic) ProcessTocBankCardThreeElementsVerificationLogic(req
|
||||
return &types.QueryServiceResp{Id: cacheNo}, nil
|
||||
}
|
||||
|
||||
// ProcessTocMobileRiskAssessmentLogic 手机号码风险评估
|
||||
// ProcessTocMobileRiskAssessmentLogic 高风险特殊手机号
|
||||
func (l *QueryServiceLogic) ProcessTocMobileRiskAssessmentLogic(req *types.QueryServiceReq) (*types.QueryServiceResp, error) {
|
||||
userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if getUidErr != nil {
|
||||
|
@ -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"
|
||||
)
|
||||
|
29
app/user/cmd/api/internal/logic/user/decryptmobilelogic.go
Normal file
29
app/user/cmd/api/internal/logic/user/decryptmobilelogic.go
Normal file
@ -0,0 +1,29 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"tyc-server/app/user/cmd/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DecryptMobileLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDecryptMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DecryptMobileLogic {
|
||||
return &DecryptMobileLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DecryptMobileLogic) DecryptMobile() error {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return nil
|
||||
}
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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 * * *"
|
||||
|
@ -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"
|
||||
@ -112,7 +112,7 @@ func (l *PaySuccessNotifyUserHandler) ProcessTask(ctx context.Context, t *asynq.
|
||||
func (l *PaySuccessNotifyUserHandler) handleError(ctx context.Context, err error, order *model.Order, query *model.Query) error {
|
||||
logx.Errorf("处理任务失败,原因: %v", err)
|
||||
|
||||
if order.Status == "paid" && query.QueryState == model.QueryStatePending {
|
||||
if order.Status == "paid" && query.QueryState == model.QueryStateProcessing {
|
||||
// 更新查询状态为失败
|
||||
query.QueryState = model.QueryStateFailed
|
||||
updateQueryErr := l.svcCtx.QueryModel.UpdateWithVersion(ctx, nil, query)
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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 {
|
||||
|
@ -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"
|
||||
@ -235,6 +235,7 @@ var requestProcessors = map[string]func(*ApiRequestService, context.Context, []b
|
||||
"HRD004": (*ApiRequestService).ProcessHRD004Request,
|
||||
"mobilelocal": (*ApiRequestService).ProcessMobilelocalRequest, // 手机归属地
|
||||
"sfz": (*ApiRequestService).ProcessSfzRequest, // 身份证归属地
|
||||
"IDV044": (*ApiRequestService).ProcessIDV044Request,
|
||||
}
|
||||
|
||||
// PreprocessRequestApi 调用指定的请求处理函数
|
||||
@ -894,30 +895,14 @@ func (a *ApiRequestService) ProcessCAR059Request(ctx context.Context, params []b
|
||||
logx.Infof("车辆维保记录查询任务,订单号: %s, 未查询到结果,需要重试", orderID.String())
|
||||
|
||||
// 检查重试次数
|
||||
maxRetries := 10
|
||||
maxRetries := 56
|
||||
if retryCount >= maxRetries {
|
||||
return nil, fmt.Errorf("车辆维保记录查询任务已达最大重试次数 %d,停止重试,订单号: %s",
|
||||
maxRetries, orderID.String())
|
||||
}
|
||||
|
||||
// 计算基础延迟时间
|
||||
var delay time.Duration
|
||||
if retryCount == 0 {
|
||||
delay = 10 * time.Millisecond // 第一次设置极小延迟而非0
|
||||
} else {
|
||||
// 指数退避策略
|
||||
baseDelay := 3 * time.Second
|
||||
maxDelay := 1 * time.Hour
|
||||
|
||||
delay = baseDelay
|
||||
for i := 1; i < int(retryCount); i++ {
|
||||
delay = delay * 2
|
||||
if delay > maxDelay {
|
||||
delay = maxDelay
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// 固定延迟时间为30秒
|
||||
fixedDelay := 30 * time.Second
|
||||
|
||||
// 检查ctx是否已经有超时
|
||||
deadline, hasDeadline := ctx.Deadline()
|
||||
@ -929,32 +914,20 @@ func (a *ApiRequestService) ProcessCAR059Request(ctx context.Context, params []b
|
||||
return nil, fmt.Errorf("上下文已超时,停止重试,订单号: %s", orderID.String())
|
||||
}
|
||||
|
||||
// 保留一些安全边界,确保有足够时间执行后续操作
|
||||
safetyBuffer := 500 * time.Millisecond
|
||||
|
||||
// 如果剩余时间不足以完成当前延迟加安全边界
|
||||
if timeRemaining < delay+safetyBuffer {
|
||||
// 使用剩余时间的50%作为延迟,确保有足够时间完成后续操作
|
||||
adjustedDelay := time.Duration(float64(timeRemaining) * 0.5)
|
||||
|
||||
// 确保最小延迟不小于10毫秒
|
||||
if adjustedDelay < 10*time.Millisecond {
|
||||
adjustedDelay = 10 * time.Millisecond
|
||||
}
|
||||
|
||||
logx.Infof("调整延迟时间以适应上下文超时,原始延迟: %v, 新延迟: %v, 剩余时间: %v",
|
||||
delay, adjustedDelay, timeRemaining)
|
||||
|
||||
delay = adjustedDelay
|
||||
// 如果剩余时间不足以等待完整的15秒
|
||||
if timeRemaining < fixedDelay+500*time.Millisecond {
|
||||
logx.Infof("上下文剩余时间不足,提前返回,订单号: %s, 剩余时间: %v",
|
||||
orderID.String(), timeRemaining)
|
||||
return nil, fmt.Errorf("上下文剩余时间不足,无法完成下一次重试")
|
||||
}
|
||||
}
|
||||
|
||||
// 等待指定延迟时间
|
||||
logx.Infof("安排延迟重试,订单号: %s, 延迟: %v, 重试次数: %d",
|
||||
orderID.String(), delay, retryCount+1)
|
||||
// 等待固定的延迟时间
|
||||
logx.Infof("安排固定延迟重试,订单号: %s, 延迟: 30秒, 重试次数: %d",
|
||||
orderID.String(), retryCount+1)
|
||||
|
||||
select {
|
||||
case <-time.After(delay):
|
||||
case <-time.After(fixedDelay):
|
||||
// 延迟时间到,继续处理
|
||||
case <-ctx.Done():
|
||||
// 上下文被取消,返回错误
|
||||
@ -974,8 +947,8 @@ func (a *ApiRequestService) ProcessCAR059Request(ctx context.Context, params []b
|
||||
}
|
||||
return nil, fmt.Errorf("车辆维保记录结果查询失败: %+v", err)
|
||||
}
|
||||
logx.Infof("车辆维保记录查询任务完成,订单号: %s, 结果数据长度: %d",
|
||||
orderID.String(), len(resp))
|
||||
logx.Infof("车辆维保记录查询任务完成,订单号: %s",
|
||||
orderID.String())
|
||||
return &APIInternalResult{
|
||||
Data: resp,
|
||||
}, nil
|
||||
@ -1443,7 +1416,7 @@ func (a *ApiRequestService) ProcessCOM187Request(ctx context.Context, params []b
|
||||
"keyword": name.String(),
|
||||
}
|
||||
resp, err := a.yushanService.request("COM187", request)
|
||||
if err != nil {
|
||||
if err != nil && err != ErrEmptyResult {
|
||||
return nil, fmt.Errorf("出境限制查询失败: %+v", err)
|
||||
}
|
||||
return &APIInternalResult{
|
||||
@ -1622,7 +1595,7 @@ func (a *ApiRequestService) ProcessFIN018Request(ctx context.Context, params []b
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 手机号码风险评估
|
||||
// 高风险特殊手机号
|
||||
func (a *ApiRequestService) ProcessMOB032Request(ctx context.Context, params []byte) (*APIInternalResult, error) {
|
||||
mobile := gjson.GetBytes(params, "mobile")
|
||||
if !mobile.Exists() {
|
||||
@ -1634,7 +1607,7 @@ func (a *ApiRequestService) ProcessMOB032Request(ctx context.Context, params []b
|
||||
}
|
||||
resp, err := a.yushanService.request("MOB032", request)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("手机号码风险评估失败: %+v", err)
|
||||
return nil, fmt.Errorf("高风险特殊手机号失败: %+v", err)
|
||||
}
|
||||
return &APIInternalResult{
|
||||
Data: resp,
|
||||
@ -1724,3 +1697,21 @@ func (a *ApiRequestService) ProcessSfzRequest(ctx context.Context, params []byte
|
||||
Data: resp,
|
||||
}, nil
|
||||
}
|
||||
func (a *ApiRequestService) ProcessIDV044Request(ctx context.Context, params []byte) (*APIInternalResult, error) {
|
||||
idCard := gjson.GetBytes(params, "id_card")
|
||||
name := gjson.GetBytes(params, "name")
|
||||
if !idCard.Exists() || !name.Exists() {
|
||||
return nil, errors.New("api请求, IDV044, 获取相关参数失败")
|
||||
}
|
||||
request := map[string]interface{}{
|
||||
"cardNo": idCard.String(),
|
||||
"name": name.String(),
|
||||
}
|
||||
resp, err := a.yushanService.request("IDV044", request)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("婚姻状态查询失败: %v", err)
|
||||
}
|
||||
return &APIInternalResult{
|
||||
Data: resp,
|
||||
}, nil
|
||||
}
|
||||
|
@ -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 支付服务的结构体
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
)
|
||||
|
@ -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 {
|
||||
|
@ -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 (
|
||||
|
@ -4,14 +4,15 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
"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"
|
||||
)
|
||||
|
||||
type WestResp struct {
|
||||
@ -99,7 +100,6 @@ func (w *WestDexService) CallAPI(code string, reqData map[string]interface{}) (r
|
||||
return nil, DecryptErr
|
||||
}
|
||||
return decryptedData, errors.New(westDexResp.Message)
|
||||
log.Println(string(decryptedData))
|
||||
}
|
||||
if westDexResp.Data == "" {
|
||||
return nil, errors.New(westDexResp.Message)
|
||||
|
@ -8,12 +8,13 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"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"
|
||||
)
|
||||
@ -28,6 +29,11 @@ func NewYushanService(c config.Config) *YushanService {
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
// ErrEmptyResult 表示查询结果为空
|
||||
ErrEmptyResult = errors.New("查询结果为空")
|
||||
)
|
||||
|
||||
func (y *YushanService) request(prodID string, params map[string]interface{}) ([]byte, error) {
|
||||
// 获取当前时间戳
|
||||
unixMilliseconds := time.Now().UnixNano() / int64(time.Millisecond)
|
||||
@ -98,7 +104,7 @@ func (y *YushanService) request(prodID string, params map[string]interface{}) ([
|
||||
|
||||
if retCode == "100000" {
|
||||
// retcode 为 100000,表示查询为空
|
||||
return respData, fmt.Errorf("羽山请求查空: %s", string(respData))
|
||||
return json.RawMessage("{}"), ErrEmptyResult
|
||||
} else if retCode == "000000" || retCode == "000001" || retCode == "000002" || retCode == "000003" {
|
||||
// retcode 为 000000,表示有数据,返回 retdata
|
||||
retData := gjson.GetBytes(respData, "retdata")
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ type TocCarVin struct {
|
||||
}
|
||||
type TocCarVinDrivingPermit struct {
|
||||
VinCode string `json:"vin_code" validate:"required"`
|
||||
CarDrivingPermit string `json:"car_drivingPermit" validate:"required"`
|
||||
CarDrivingPermit string `json:"car_driving_permit" validate:"required"`
|
||||
}
|
||||
type TocCarVinLicense struct {
|
||||
VinCode string `json:"vin_code" validate:"required"`
|
||||
@ -173,7 +173,7 @@ type TocBankCardThreeElementsVerification struct {
|
||||
BankCard string `json:"bank_card" validate:"required"`
|
||||
}
|
||||
|
||||
// 手机号码风险评估
|
||||
// 高风险特殊手机号
|
||||
type TocMobileRiskAssessment struct {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
}
|
||||
|
@ -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标识
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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),
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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),
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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),
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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),
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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),
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user