From 1a63a89faf6663ee831452a6e5cdd2283117fe34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sat, 13 Jan 2024 17:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=80=E6=9D=A1=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- abstract/base.go | 2 ++ base.go | 10 ++++++++++ go.mod | 26 +++++++++++++------------- go.sum | 24 ++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/abstract/base.go b/abstract/base.go index 9fea75e..52733a5 100644 --- a/abstract/base.go +++ b/abstract/base.go @@ -22,6 +22,8 @@ type Base interface { Create(dbInstance *gorm.DB, data interface{}, optionList ...database.SetOption) error // Update 更新数据 Update(dbInstance *gorm.DB, updateData interface{}, optionFuncList ...database.SetOption) (int64, error) + // UpdateOne 更新一条数据 + UpdateOne(dbInstance *gorm.DB, updateData interface{}, optionFuncList ...database.SetOption) (int64, error) // List 查询数据列表 List(dbInstance *gorm.DB, result interface{}, optionFuncList ...database.SetOption) error // Delete 删除数据 diff --git a/base.go b/base.go index 5f8383d..35b9fa5 100644 --- a/base.go +++ b/base.go @@ -48,6 +48,16 @@ func (b *BaseDao) Update(dbInstance *gorm.DB, updateData interface{}, optionFunc return r.RowsAffected, r.Error } +// UpdateOne 更新一条数据 +// +// Author : go_developer@163.com<白茶清欢> +// +// Date : 17:05 2024/1/13 +func (b *BaseDao) UpdateOne(dbInstance *gorm.DB, updateData interface{}, optionFuncList ...SetOption) (int64, error) { + optionFuncList = append(optionFuncList, WithLimit(1, 0)) + return b.Update(dbInstance, updateData, optionFuncList...) +} + // List 查询数据列表 // // Author : go_developer@163.com<白茶清欢> diff --git a/go.mod b/go.mod index 4d826fa..eccea85 100644 --- a/go.mod +++ b/go.mod @@ -5,11 +5,11 @@ go 1.21 toolchain go1.21.3 require ( - git.zhangdeman.cn/zhangdeman/consts v0.0.0-20230815040024-2b12dd51d19b + git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240104123641-b3f23974e5d6 git.zhangdeman.cn/zhangdeman/logger v0.0.0-20231008133508-da9b21010445 git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20231014130641-ca8081f83abe - git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20231201104703-2a8ebdc5697a - git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230904123542-faafa8ee2a79 + git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240110090803-399e964daa0c + git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20231227102049-448b472c5336 github.com/gin-gonic/gin v1.9.1 github.com/pkg/errors v0.9.1 github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 @@ -20,9 +20,9 @@ require ( ) require ( - git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20230826152035-90f7ba59144a // indirect - git.zhangdeman.cn/zhangdeman/gin v0.0.0-20230910072935-d176a23c53d1 // indirect - git.zhangdeman.cn/zhangdeman/util v0.0.0-20231014142840-445c6407db92 // indirect + git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20231229032122-804bc9822704 // indirect + git.zhangdeman.cn/zhangdeman/gin v0.0.0-20240102081642-c4edba172b59 // indirect + git.zhangdeman.cn/zhangdeman/util v0.0.0-20231227095334-7eb5cdbf9253 // indirect github.com/BurntSushi/toml v1.3.2 // indirect github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 // indirect github.com/bytedance/sonic v1.10.2 // indirect @@ -44,22 +44,22 @@ require ( github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible // indirect github.com/lestrrat-go/strftime v1.0.6 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-sqlite3 v1.14.18 // indirect + github.com/mattn/go-sqlite3 v1.14.19 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mozillazg/go-pinyin v0.20.0 // indirect - github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/arch v0.6.0 // indirect - golang.org/x/crypto v0.16.0 // indirect - golang.org/x/net v0.19.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/arch v0.7.0 // indirect + golang.org/x/crypto v0.18.0 // indirect + golang.org/x/net v0.20.0 // indirect + golang.org/x/sys v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ece3779..e1afa7f 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,14 @@ git.zhangdeman.cn/zhangdeman/consts v0.0.0-20230815040024-2b12dd51d19b h1:C7KftnLh7dOqzNRs5dn/9yqMDvuqMn5RCglvV6bY758= git.zhangdeman.cn/zhangdeman/consts v0.0.0-20230815040024-2b12dd51d19b/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k= +git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240104123641-b3f23974e5d6 h1:ytpXTP3oxp480BAZQoOzqlBP4XP73NcpMplZ1/fA1lQ= +git.zhangdeman.cn/zhangdeman/consts v0.0.0-20240104123641-b3f23974e5d6/go.mod h1:IXXaZkb7vGzGnGM5RRWrASAuwrVSNxuoe0DmeXx5g6k= git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20230826152035-90f7ba59144a h1:B37yGkb/ETYInbS3j5JR6lgXPsvGjKcY26fsIlSpKxA= git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20230826152035-90f7ba59144a/go.mod h1:l9S40lsDnTd/VAZjh1kmfYvz0B9z+7oT86pMQ/KurWo= +git.zhangdeman.cn/zhangdeman/easymap v0.0.0-20231229032122-804bc9822704/go.mod h1:SrtvrQRdzt+8KfYzvosH++gWxo2ShPTzR1m3VQ6uX7U= git.zhangdeman.cn/zhangdeman/gin v0.0.0-20230910072935-d176a23c53d1 h1:PSHEmrCJYabC30IkAWHMV22vmdwLtEJW5H/OqVwAaTA= git.zhangdeman.cn/zhangdeman/gin v0.0.0-20230910072935-d176a23c53d1/go.mod h1:wk5vDJWbWWq5C2zuPIHFDu/92SzPNverELcRPdWglGM= +git.zhangdeman.cn/zhangdeman/gin v0.0.0-20240102081642-c4edba172b59 h1:5PczpGlBxlo9AbbQrhnZSxC+Kp2E0fdywM0x6BCI2c8= +git.zhangdeman.cn/zhangdeman/gin v0.0.0-20240102081642-c4edba172b59/go.mod h1:8S+YPh3DRMkG9UI2LRyTQB1/p910cukfjGKignlNses= git.zhangdeman.cn/zhangdeman/logger v0.0.0-20231008133508-da9b21010445 h1:yBpL6QqC5e4LS5LZgwnjeanUmbJleeCwvZ344EpR5Vg= git.zhangdeman.cn/zhangdeman/logger v0.0.0-20231008133508-da9b21010445/go.mod h1:qLJrvO4n5i0PjOCCcAQUMKDvsqf8QJRmMUDRk8yAw7g= git.zhangdeman.cn/zhangdeman/op_type v0.0.0-20231014130641-ca8081f83abe h1:J5EYHX4A4pV7Jlxjg3ZCyV6t5L8NPb1czHhawGQisUY= @@ -12,10 +17,15 @@ git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20230909065133-098dcddf1fca h1:Coa git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20230909065133-098dcddf1fca/go.mod h1:AWyjclAKRM7HiUNzm2wKhYw+s4Jz7fg8YngN+PYdKNo= git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20231201104703-2a8ebdc5697a h1:gWBA5Wu5744oAk5B4heZBrF/Q36xA8cpUVcVQ6/1gl8= git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20231201104703-2a8ebdc5697a/go.mod h1:w7kG4zyTJ1uPFaTWhze+OQuaUBINT2XnDxpyiM6ctc0= +git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240110090803-399e964daa0c h1:k7VCn9GfRGTilvdF/TcTFVMDBfKLe3VeGAtMTiDSnS0= +git.zhangdeman.cn/zhangdeman/serialize v0.0.0-20240110090803-399e964daa0c/go.mod h1:w7kG4zyTJ1uPFaTWhze+OQuaUBINT2XnDxpyiM6ctc0= git.zhangdeman.cn/zhangdeman/util v0.0.0-20231014142840-445c6407db92 h1:p1GVRYJc3NNoZeLs4CukitAbM3O/ALNq3l31cnbBQDM= git.zhangdeman.cn/zhangdeman/util v0.0.0-20231014142840-445c6407db92/go.mod h1:6OBeuwKy2J1TjdAwStEyC6aYC3kStmJiCg1eFC7g0fk= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20231227095334-7eb5cdbf9253 h1:GO3oZa5a2sqwAzGcLDJtQzmshSWRmoP7IDS8bwFqvC4= +git.zhangdeman.cn/zhangdeman/util v0.0.0-20231227095334-7eb5cdbf9253/go.mod h1:VpPjBlwz8U+OxZuxzHQBv1aEEZ3pStH6bZvT21ADEbI= git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230904123542-faafa8ee2a79 h1:zYeoxIpceV8/NUuMElYhr1pl+0xAhhKFLZD6XbbKs6M= git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20230904123542-faafa8ee2a79/go.mod h1:kvjAbtGTo14gKCS0X4rxnb2sPkskHOUy2NXcx34t6Mw= +git.zhangdeman.cn/zhangdeman/wrapper v0.0.0-20231227102049-448b472c5336/go.mod h1:txJM11rEDsszLb3ACJIlPYv1EoNu+QbkXqjx0kCpMZo= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ= @@ -83,6 +93,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI= +github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -94,6 +106,8 @@ github.com/mozillazg/go-pinyin v0.20.0 h1:BtR3DsxpApHfKReaPO1fCqF4pThRwH9uwvXzm+ github.com/mozillazg/go-pinyin v0.20.0/go.mod h1:iR4EnMMRXkfpFVV5FMi4FNB6wGq9NV6uDWbUuPhP4Yc= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= +github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -128,20 +142,28 @@ go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.6.0 h1:S0JTfE48HbRj80+4tbvZDYsJ3tGv6BUU3XxyZ7CirAc= golang.org/x/arch v0.6.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= +golang.org/x/arch v0.7.0 h1:pskyeJh/3AmoQ8CPE95vxHLqp1G1GfGNXTmcl9NEKTc= +golang.org/x/arch v0.7.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -150,6 +172,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=