add 代码生成导出excel
This commit is contained in:
parent
b68f9fbbca
commit
61b8f655d4
@ -100,7 +100,7 @@ type ToolsGenTableColumnsEditReq struct {
|
||||
TreeCode string `p:"tree_code"`
|
||||
TreeParentCode string `p:"tree_parent_code"`
|
||||
TreeName string `p:"tree_name"`
|
||||
UserName string
|
||||
ExcelPort string `p:"excelPort"`
|
||||
}
|
||||
|
||||
type ToolsGenTableColumnsEditRes struct {
|
||||
|
22
go.mod
22
go.mod
@ -17,6 +17,7 @@ require (
|
||||
github.com/tencentyun/cos-go-sdk-v5 v0.7.34
|
||||
github.com/tiger1103/gfast-cache v1.0.0
|
||||
github.com/tiger1103/gfast-token v1.0.3
|
||||
github.com/xuri/excelize/v2 v2.7.1
|
||||
)
|
||||
|
||||
require (
|
||||
@ -50,11 +51,14 @@ require (
|
||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
|
||||
github.com/mozillazg/go-httpheader v0.2.1 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
|
||||
github.com/pkg/errors v0.8.1 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
github.com/richardlehane/mscfb v1.0.4 // indirect
|
||||
github.com/richardlehane/msoleps v1.0.3 // indirect
|
||||
github.com/rivo/uniseg v0.4.3 // indirect
|
||||
github.com/satori/go.uuid v1.2.0 // indirect
|
||||
github.com/sirupsen/logrus v1.4.0 // indirect
|
||||
@ -64,20 +68,22 @@ require (
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.11 // indirect
|
||||
github.com/tklauser/numcpus v0.6.0 // indirect
|
||||
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca // indirect
|
||||
github.com/xuri/nfp v0.0.0-20230802015359-2d5eeba905e9 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
go.opentelemetry.io/otel v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.11.2 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.11.2 // indirect
|
||||
go.uber.org/atomic v1.5.1 // indirect
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
|
||||
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75 // indirect
|
||||
golang.org/x/crypto v0.12.0 // indirect
|
||||
golang.org/x/image v0.5.0 // indirect
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de // indirect
|
||||
golang.org/x/net v0.7.0 // indirect
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
||||
golang.org/x/sys v0.5.0 // indirect
|
||||
golang.org/x/term v0.5.0 // indirect
|
||||
golang.org/x/text v0.7.0 // indirect
|
||||
golang.org/x/tools v0.1.12 // indirect
|
||||
golang.org/x/net v0.14.0 // indirect
|
||||
golang.org/x/sync v0.1.0 // indirect
|
||||
golang.org/x/sys v0.11.0 // indirect
|
||||
golang.org/x/term v0.11.0 // indirect
|
||||
golang.org/x/text v0.12.0 // indirect
|
||||
golang.org/x/tools v0.6.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
53
go.sum
53
go.sum
@ -140,6 +140,8 @@ github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OH
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/mojocn/base64Captcha v1.3.5 h1:Qeilr7Ta6eDtG4S+tQuZ5+hO+QHbiGAJdi4PfoagaA0=
|
||||
github.com/mojocn/base64Captcha v1.3.5/go.mod h1:/tTTXn4WTpX9CfrmipqRytCpJ27Uw3G6I7NcP2WwcmY=
|
||||
github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ=
|
||||
@ -178,6 +180,11 @@ github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdk
|
||||
github.com/qiniu/go-sdk/v7 v7.13.0 h1:0bWRh/oAC2cArUILZLuWN+s9hPep1JYch5sA2Mfxq7A=
|
||||
github.com/qiniu/go-sdk/v7 v7.13.0/go.mod h1:btsaOc8CA3hdVloULfFdDgDc+g4f3TDZEFsDY0BLE+w=
|
||||
github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs=
|
||||
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
|
||||
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
|
||||
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
|
||||
github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
|
||||
github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
|
||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
@ -227,8 +234,17 @@ github.com/tklauser/go-sysconf v0.3.11 h1:89WgdJhk5SNwJfu+GKyYveZ4IaJ7xAkecBo+Kd
|
||||
github.com/tklauser/go-sysconf v0.3.11/go.mod h1:GqXfhXY3kiPa0nAXPDIQIWzJbMCB7AmcWpGR8lSZfqI=
|
||||
github.com/tklauser/numcpus v0.6.0 h1:kebhY2Qt+3U6RNK7UqpYNA+tJ23IBEGKkB7JQBfDYms=
|
||||
github.com/tklauser/numcpus v0.6.0/go.mod h1:FEZLMke0lhOUG6w2JadTzp0a+Nl8PF/GFkQ5UVIcaL4=
|
||||
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
|
||||
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca h1:uvPMDVyP7PXMMioYdyPH+0O+Ta/UO1WFfNYMO3Wz0eg=
|
||||
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
|
||||
github.com/xuri/excelize/v2 v2.7.1 h1:gm8q0UCAyaTt3MEF5wWMjVdmthm2EHAWesGSKS9tdVI=
|
||||
github.com/xuri/excelize/v2 v2.7.1/go.mod h1:qc0+2j4TvAUrBw36ATtcTeC1VCM0fFdAXZOmcF4nTpY=
|
||||
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
|
||||
github.com/xuri/nfp v0.0.0-20230802015359-2d5eeba905e9 h1:jmhvNv5by7bXDzzjzBXaIWmEI4lMYfv5iJtI5Pw5/aM=
|
||||
github.com/xuri/nfp v0.0.0-20230802015359-2d5eeba905e9/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
|
||||
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg=
|
||||
@ -250,14 +266,20 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75 h1:TbGuee8sSq15Iguxu4deQ7+Bqq/d2rsQejGcEtADAMQ=
|
||||
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
|
||||
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
||||
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
|
||||
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@ -268,15 +290,19 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@ -301,23 +327,31 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
|
||||
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
|
||||
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2/go.mod h1:EFNZuWvGYxIRUEX+K8UmCFwYmZjqcrnq15ZuVldZkZ0=
|
||||
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
@ -326,8 +360,9 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
|
||||
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
@ -34,21 +34,21 @@ type sSysDictData struct {
|
||||
}
|
||||
|
||||
// GetDictWithDataByType 通过字典键类型获取选项
|
||||
func (s *sSysDictData) GetDictWithDataByType(ctx context.Context, req *system.GetDictReq) (dict *system.GetDictRes,
|
||||
func (s *sSysDictData) GetDictWithDataByType(ctx context.Context, dictType, defaultValue string) (dict *system.GetDictRes,
|
||||
err error) {
|
||||
cache := service.Cache()
|
||||
cacheKey := consts.CacheSysDict + "_" + req.DictType
|
||||
cacheKey := consts.CacheSysDict + "_" + dictType
|
||||
//从缓存获取
|
||||
iDict := cache.GetOrSetFuncLock(ctx, cacheKey, func(ctx context.Context) (value interface{}, err error) {
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
//从数据库获取
|
||||
dict = &system.GetDictRes{}
|
||||
//获取类型数据
|
||||
err = dao.SysDictType.Ctx(ctx).Where(dao.SysDictType.Columns().DictType, req.DictType).
|
||||
err = dao.SysDictType.Ctx(ctx).Where(dao.SysDictType.Columns().DictType, dictType).
|
||||
Where(dao.SysDictType.Columns().Status, 1).Fields(model.DictTypeRes{}).Scan(&dict.Info)
|
||||
liberr.ErrIsNil(ctx, err, "获取字典类型失败")
|
||||
err = dao.SysDictData.Ctx(ctx).Fields(model.DictDataRes{}).
|
||||
Where(dao.SysDictData.Columns().DictType, req.DictType).
|
||||
Where(dao.SysDictData.Columns().DictType, dictType).
|
||||
Order(dao.SysDictData.Columns().DictSort + " asc," +
|
||||
dao.SysDictData.Columns().DictCode + " asc").
|
||||
Scan(&dict.Values)
|
||||
@ -65,8 +65,8 @@ func (s *sSysDictData) GetDictWithDataByType(ctx context.Context, req *system.Ge
|
||||
}
|
||||
//设置给定的默认值
|
||||
for _, v := range dict.Values {
|
||||
if req.DefaultValue != "" {
|
||||
if gstr.Equal(req.DefaultValue, v.DictValue) {
|
||||
if defaultValue != "" {
|
||||
if gstr.Equal(defaultValue, v.DictValue) {
|
||||
v.IsDefault = 1
|
||||
} else {
|
||||
v.IsDefault = 0
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
type ISysDictData interface {
|
||||
GetDictWithDataByType(ctx context.Context, req *system.GetDictReq) (dict *system.GetDictRes, err error)
|
||||
GetDictWithDataByType(ctx context.Context, dictType, defaultValue string) (dict *system.GetDictRes, err error)
|
||||
List(ctx context.Context, req *system.DictDataSearchReq) (res *system.DictDataSearchRes, err error)
|
||||
Add(ctx context.Context, req *system.DictDataAddReq, userId uint64) (err error)
|
||||
Get(ctx context.Context, dictCode uint) (res *system.DictDataGetRes, err error)
|
||||
|
@ -9,6 +9,7 @@ package router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/tiger1103/gfast/v3/internal/app/mqueue/controller"
|
||||
)
|
||||
@ -18,8 +19,11 @@ var R = new(Router)
|
||||
type Router struct{}
|
||||
|
||||
func (router *Router) BindController(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
group.Group("/mqueue/demo", func(group *ghttp.RouterGroup) {
|
||||
group.POST("/produce", controller.Demo.Produce)
|
||||
group.ALL("/subscribe", controller.Demo.Subscribe)
|
||||
})
|
||||
isEnable := g.Cfg().MustGet(ctx, "mqueue.enable").Bool()
|
||||
if isEnable{
|
||||
group.Group("/mqueue/demo", func(group *ghttp.RouterGroup) {
|
||||
group.POST("/produce", controller.Demo.Produce)
|
||||
group.ALL("/subscribe", controller.Demo.Subscribe)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ type dictDataController struct {
|
||||
|
||||
// GetDictData 获取字典数据
|
||||
func (c *dictDataController) GetDictData(ctx context.Context, req *system.GetDictReq) (res *system.GetDictRes, err error) {
|
||||
res, err = commonService.SysDictData().GetDictWithDataByType(ctx, req)
|
||||
res, err = commonService.SysDictData().GetDictWithDataByType(ctx, req.DictType,req.DefaultValue)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -364,6 +364,9 @@ func (s *sToolsGenTable) SaveEdit(ctx context.Context, req *system.ToolsGenTable
|
||||
if req.ShowDetail != "" {
|
||||
table.ShowDetail = gconv.Bool(req.ShowDetail)
|
||||
}
|
||||
if req.ExcelPort != "" {
|
||||
table.ExcelPort = gconv.Bool(req.ExcelPort)
|
||||
}
|
||||
if req.TplCategory != "" {
|
||||
table.TplCategory = req.TplCategory
|
||||
}
|
||||
|
@ -8,5 +8,5 @@
|
||||
package consts
|
||||
|
||||
const (
|
||||
Version = "3.2.5"
|
||||
Version = "3.2.6"
|
||||
)
|
||||
|
118
library/libUtils/excel_helper.go
Normal file
118
library/libUtils/excel_helper.go
Normal file
@ -0,0 +1,118 @@
|
||||
package libUtils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/xuri/excelize/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
ExcelHelperRowLimit = 65536
|
||||
ExcelHelperColLimit = 256
|
||||
)
|
||||
|
||||
type ExcelHelper struct{}
|
||||
|
||||
type ExcelHelperFile struct {
|
||||
*excelize.File
|
||||
err error
|
||||
}
|
||||
|
||||
func (helperFile *ExcelHelperFile) MapToExcel(sheet string, cells map[string]interface{}) *ExcelHelperFile {
|
||||
if helperFile.err != nil {
|
||||
return helperFile
|
||||
}
|
||||
for axis, item := range cells {
|
||||
err := helperFile.File.SetCellValue(sheet, axis, item)
|
||||
if err != nil {
|
||||
helperFile.err = err
|
||||
return helperFile
|
||||
}
|
||||
}
|
||||
return helperFile
|
||||
}
|
||||
|
||||
func (helperFile *ExcelHelperFile) SetCellBorder(sheet, hcell, vcell string) *ExcelHelperFile {
|
||||
style, err := helperFile.File.NewStyle(&excelize.Style{
|
||||
Border: []excelize.Border{
|
||||
{Type: "left", Color: "#000000", Style: 1},
|
||||
{Type: "top", Color: "#000000", Style: 1},
|
||||
{Type: "bottom", Color: "#000000", Style: 1},
|
||||
{Type: "right", Color: "#000000", Style: 1},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
helperFile.err = err
|
||||
return helperFile
|
||||
}
|
||||
_ = helperFile.File.SetCellStyle(sheet, hcell, vcell, style)
|
||||
return helperFile
|
||||
}
|
||||
|
||||
func (helperFile *ExcelHelperFile) ArrToExcel(sheet string, axis string, rows [][]interface{}) *ExcelHelperFile {
|
||||
if helperFile.err != nil {
|
||||
return helperFile
|
||||
}
|
||||
|
||||
rowNum := len(rows)
|
||||
if rowNum == 0 {
|
||||
helperFile.err = errors.New("没有需要导出的数据")
|
||||
return helperFile
|
||||
}
|
||||
if rowNum > ExcelHelperRowLimit {
|
||||
helperFile.err = errors.New(fmt.Sprintf("导出数据行数超过%d", ExcelHelperRowLimit))
|
||||
return helperFile
|
||||
}
|
||||
colNum := len(rows[0])
|
||||
if colNum > ExcelHelperColLimit {
|
||||
helperFile.err = errors.New(fmt.Sprintf("导出数据列数超过%d", ExcelHelperColLimit))
|
||||
return helperFile
|
||||
}
|
||||
|
||||
axisCol, axisRow, err := excelize.SplitCellName(axis)
|
||||
if err != nil {
|
||||
helperFile.err = err
|
||||
return helperFile
|
||||
}
|
||||
|
||||
for index, item := range rows {
|
||||
cell, _ := excelize.JoinCellName(axisCol, index+axisRow)
|
||||
err = helperFile.File.SetSheetRow(sheet, cell, &item)
|
||||
if err != nil {
|
||||
helperFile.err = err
|
||||
return helperFile
|
||||
}
|
||||
}
|
||||
return helperFile
|
||||
}
|
||||
|
||||
func (helperFile *ExcelHelperFile) SaveByPath(path string) (savePath string, err error) {
|
||||
if helperFile.err != nil {
|
||||
return "", helperFile.err
|
||||
}
|
||||
path = path + ".xlsx"
|
||||
err = helperFile.File.SaveAs(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
func (excel *ExcelHelper) OpenFile(tplPath string) (file *ExcelHelperFile, err error) {
|
||||
temp, err := excelize.OpenFile(tplPath)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
file = &ExcelHelperFile{
|
||||
File: temp,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (excel *ExcelHelper) CreateFile() (file *ExcelHelperFile) {
|
||||
f := excelize.NewFile()
|
||||
file = &ExcelHelperFile{
|
||||
File: f,
|
||||
}
|
||||
return
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -30,6 +30,19 @@ type {{.table.ClassName}}SearchRes struct {
|
||||
*model.{{.table.ClassName}}SearchRes
|
||||
}
|
||||
|
||||
{{if .table.ExcelPort }}
|
||||
// {{.table.ClassName}}ExportReq 导出请求
|
||||
type {{.table.ClassName}}ExportReq struct {
|
||||
g.Meta `path:"/export" tags:"{{$.table.FunctionName}}" method:"get" summary:"{{$.table.FunctionName}}导出"`
|
||||
commonApi.Author
|
||||
model.{{.table.ClassName}}SearchReq
|
||||
}
|
||||
// {{.table.ClassName}}ExportRes 导出响应
|
||||
type {{.table.ClassName}}ExportRes struct {
|
||||
commonApi.EmptyRes
|
||||
}
|
||||
|
||||
{{end}}
|
||||
|
||||
{{if gt (len .table.LinkedTables) 0}}
|
||||
//相关连表查询数据
|
||||
|
@ -16,7 +16,26 @@
|
||||
{{end}}
|
||||
package controller
|
||||
////
|
||||
|
||||
{{$hasGmap:=false}}
|
||||
{{$hasGstr:=false}}
|
||||
{{$hasGconv:=false}}
|
||||
{{$hasSystemApi:=false}}
|
||||
{{$hasCommonService:=false}}
|
||||
{{range $index, $column := .table.DetailColumns}}
|
||||
{{if ne $column.DictType ""}}
|
||||
{{$hasGmap = true}}
|
||||
{{$hasGconv = true}}
|
||||
{{$hasSystemApi = true}}
|
||||
{{$hasCommonService = true}}
|
||||
{{if eq $column.HtmlType "checkbox" "" "selects" "treeSelects"}}
|
||||
{{$hasGstr = true}}
|
||||
{{end}}
|
||||
{{else if ne $column.LinkTableName ""}}
|
||||
{{if eq $column.HtmlType "checkbox" "" "selects" "treeSelects"}}
|
||||
{{$hasGstr = true}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
import (
|
||||
"context"
|
||||
"{{.goModName}}/api/v1/{{.table.ModuleName}}"
|
||||
@ -29,9 +48,31 @@ import (
|
||||
{{if ne $.table.ModuleName "system"}}
|
||||
systemService "github.com/tiger1103/gfast/v3/internal/app/system/service"
|
||||
{{else}}
|
||||
"github.com/tiger1103/gfast/v3/internal/app/system/service"
|
||||
"{{.goModName}}/internal/app/system/service"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if .table.ExcelPort }}
|
||||
{{if $hasGmap}}
|
||||
"github.com/gogf/gf/v2/container/gmap"
|
||||
{{end}}
|
||||
"github.com/gogf/gf/v2/encoding/gurl"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
{{if $hasGstr}}
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
{{end}}
|
||||
{{if $hasGconv}}
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
{{end}}
|
||||
{{if and (ne $.table.ModuleName "system") $hasSystemApi}}
|
||||
systemApi "{{$.goModName}}/api/v1/system"
|
||||
{{end}}
|
||||
{{if $hasCommonService}}
|
||||
commonService "github.com/tiger1103/gfast/v3/internal/app/common/service"
|
||||
{{end}}
|
||||
"{{$.goModName}}/{{$.table.PackageName}}/model"
|
||||
"{{$.goModName}}/library/libUtils"
|
||||
"github.com/xuri/excelize/v2"
|
||||
{{end}}
|
||||
)
|
||||
////
|
||||
type {{$structName}}Controller struct {
|
||||
@ -51,9 +92,187 @@ func (c *{{$structName}}Controller) List(ctx context.Context, req *{{.table.Modu
|
||||
return
|
||||
}
|
||||
|
||||
{{if .table.ExcelPort }}
|
||||
////
|
||||
// Export 导出excel
|
||||
func (c *{{$structName}}Controller) Export(ctx context.Context, req *{{.table.ModuleName}}.{{.table.ClassName}}ExportReq) (res *{{.table.ModuleName}}.{{.table.ClassName}}ExportRes, err error) {
|
||||
var (
|
||||
r=ghttp.RequestFromCtx(ctx)
|
||||
listData []*model.{{.table.ClassName}}InfoRes
|
||||
//表头
|
||||
{{$tableHeader := ""}}
|
||||
{{range $index, $column := .table.DetailColumns}}
|
||||
{{if and (ne $column.HtmlType "richtext") (ne $column.HtmlType "imagefile") (ne $column.HtmlType "images") (ne $column.HtmlType "file") (ne $column.HtmlType "files")}}
|
||||
{{$tableHeader = concat $tableHeader `"` $column.ColumnComment `"` "," }}
|
||||
{{end}}
|
||||
{{end}}
|
||||
tableHead = []interface{}{ {{$tableHeader}} }
|
||||
excelData [][]interface{}
|
||||
//字典选项处理
|
||||
{{$dictArr:=newArray}}
|
||||
{{range $index, $column := .table.Columns}}
|
||||
{{if and (ne $column.DictType "") (ne (inArray $dictArr $column.DictType) true)}}
|
||||
{{$dictArr = append $dictArr $column.DictType}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{$apiModelName := "system"}}
|
||||
{{if ne $.table.ModuleName "system"}}
|
||||
{{$apiModelName = "systemApi"}}
|
||||
{{end}}
|
||||
{{range $index, $column := $dictArr}}
|
||||
{{$column|CaseCamelLower}} *{{$apiModelName}}.GetDictRes
|
||||
{{$column|CaseCamelLower}}Map = gmap.New()
|
||||
{{end}}
|
||||
)
|
||||
req.PageNum = 1
|
||||
req.PageSize = 500
|
||||
//获取字典数据
|
||||
{{range $index, $column := $dictArr}}
|
||||
{{$column|CaseCamelLower}},err = commonService.SysDictData().GetDictWithDataByType(ctx,"{{$column}}","")
|
||||
if err!=nil{
|
||||
return
|
||||
}
|
||||
{{end}}
|
||||
{{range $index, $column := $dictArr}}
|
||||
for _,v:=range {{$column|CaseCamelLower}}.Values{
|
||||
{{$column|CaseCamelLower}}Map.Set(v.DictValue,v.DictLabel)
|
||||
}
|
||||
{{end}}
|
||||
excelData = append(excelData,tableHead)
|
||||
for {
|
||||
listData,err = service.{{.table.ClassName}}().GetExportData(ctx,&req.{{.table.ClassName}}SearchReq)
|
||||
if err!=nil{
|
||||
return
|
||||
}
|
||||
if listData==nil{
|
||||
break
|
||||
}
|
||||
for _,v:=range listData{
|
||||
var (
|
||||
{{range $index, $column := .table.DetailColumns}}
|
||||
{{if and (ne $column.HtmlType "richtext") (ne $column.HtmlType "imagefile") (ne $column.HtmlType "images") (ne $column.HtmlType "file") (ne $column.HtmlType "files")}}
|
||||
{{if or (ne $column.DictType "") (ne $column.LinkTableName "")}}
|
||||
{{if eq $column.HtmlType "checkbox" "" "selects" "treeSelects"}}
|
||||
//多选-{{$column.ColumnComment}}
|
||||
{{$column.HtmlField}} []string
|
||||
{{if ne $column.DictType ""}}
|
||||
{{$column.HtmlField}}Arr = gstr.Split(v.{{$column.GoField}},",")
|
||||
{{end}}
|
||||
{{else}}
|
||||
//单选-{{$column.ColumnComment}}
|
||||
{{if ne $column.DictType ""}}
|
||||
{{$column.HtmlField}} interface{}
|
||||
{{else}}
|
||||
{{$column.HtmlField}} string
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{else if eq $column.ColumnName "created_by" "updated_by"}}
|
||||
//{{$column.ColumnComment}}
|
||||
{{$column.HtmlField}} string
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
)
|
||||
{{range $index, $column := .table.DetailColumns}}
|
||||
{{if and (ne $column.HtmlType "richtext") (ne $column.HtmlType "imagefile") (ne $column.HtmlType "images") (ne $column.HtmlType "file") (ne $column.HtmlType "files")}}
|
||||
{{if ne $column.DictType ""}}
|
||||
{{if eq $column.HtmlType "checkbox" "" "selects" "treeSelects"}}
|
||||
//字典-多选-{{$column.ColumnComment}}
|
||||
for _,ctv:=range {{$column.HtmlField}}Arr {
|
||||
if {{$column.DictType|CaseCamelLower}}Map.Contains(ctv){
|
||||
{{$column.HtmlField}} = append({{$column.HtmlField}},gconv.String({{$column.DictType|CaseCamelLower}}Map.Get(ctv)))
|
||||
}
|
||||
}
|
||||
{{else}}
|
||||
//字典-单选-{{$column.ColumnComment}}
|
||||
{{$column.HtmlField}} = {{$column.DictType|CaseCamelLower}}Map.Get(gconv.String(v.{{$column.GoField}}))
|
||||
{{end}}
|
||||
{{else if ne $column.LinkTableName ""}}
|
||||
{{if eq $column.HtmlType "checkbox" "" "selects" "treeSelects"}}
|
||||
//关联表-多选-{{$column.ColumnComment}}
|
||||
for _,ctv :=range v.Linked{{$column.GoField}}{
|
||||
{{$column.HtmlField}} = append({{$column.HtmlField}},ctv.{{$column.LinkLabelName|CaseCamel}})
|
||||
}
|
||||
{{else}}
|
||||
//关联表-单选-{{$column.ColumnComment}}
|
||||
if v.Linked{{$column.GoField}}!=nil{
|
||||
{{$column.HtmlField}} = v.Linked{{$column.GoField}}.{{$column.LinkLabelName|CaseCamel}}
|
||||
}
|
||||
{{end}}
|
||||
{{else if eq $column.ColumnName "created_by"}}
|
||||
//{{$column.ColumnComment}}
|
||||
if v.CreatedUser!=nil{
|
||||
{{$column.HtmlField}} = v.CreatedUser.UserNickname
|
||||
}
|
||||
{{else if eq $column.ColumnName "updated_by"}}
|
||||
//{{$column.ColumnComment}}
|
||||
if v.UpdatedUser!=nil{
|
||||
{{$column.HtmlField}} = v.UpdatedUser.UserNickname
|
||||
}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
dt := []interface{}{
|
||||
{{range $index, $column := .table.DetailColumns}}
|
||||
{{if and (ne $column.HtmlType "richtext") (ne $column.HtmlType "imagefile") (ne $column.HtmlType "images") (ne $column.HtmlType "file") (ne $column.HtmlType "files")}}
|
||||
{{if ne $column.DictType ""}}
|
||||
{{if eq $column.HtmlType "checkbox" "" "selects" "treeSelects"}}
|
||||
//字典-多选-{{$column.ColumnComment}}
|
||||
gstr.Join({{$column.HtmlField}},","),
|
||||
{{else}}
|
||||
//字典-单选-{{$column.ColumnComment}}
|
||||
{{$column.HtmlField}},
|
||||
{{end}}
|
||||
{{else if ne $column.LinkTableName ""}}
|
||||
{{if eq $column.HtmlType "checkbox" "" "selects" "treeSelects"}}
|
||||
//关联表-多选-{{$column.ColumnComment}}
|
||||
gstr.Join({{$column.HtmlField}},","),
|
||||
{{else}}
|
||||
//关联表-单选-{{$column.ColumnComment}}
|
||||
{{$column.HtmlField}},
|
||||
{{end}}
|
||||
{{else if eq $column.ColumnName "created_by"}}
|
||||
//{{$column.ColumnComment}}
|
||||
{{$column.HtmlField}} ,
|
||||
{{else if eq $column.ColumnName "updated_by"}}
|
||||
//{{$column.ColumnComment}}
|
||||
{{$column.HtmlField}},
|
||||
{{else if eq $column.HtmlType "date" "datetime"}}
|
||||
v.{{$column.GoField}}.Format("Y-m-d H:i:s"),
|
||||
{{else}}
|
||||
v.{{$column.GoField}},
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
excelData = append(excelData,dt)
|
||||
}
|
||||
req.PageNum++
|
||||
}
|
||||
//创建excel处理对象
|
||||
excel := new(libUtils.ExcelHelper).CreateFile()
|
||||
excel.ArrToExcel("Sheet1", "A1", excelData)
|
||||
col, _ := excelize.ColumnNumberToName(len(tableHead))
|
||||
row := len(excelData)
|
||||
cr, _ := excelize.JoinCellName(col, row)
|
||||
excel.SetCellBorder("Sheet1", "A1", cr)
|
||||
_, err = excel.WriteTo(r.Response.Writer)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
r.Response.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
r.Response.Header().Set("Accept-Ranges", "bytes")
|
||||
r.Response.Header().Set("Access-Control-Expose-Headers", "*")
|
||||
r.Response.Header().Set("Content-Disposition", "attachment; filename="+gurl.Encode("{{.table.TableComment}}")+".xlsx")
|
||||
r.Response.Buffer()
|
||||
r.Exit()
|
||||
return
|
||||
}
|
||||
{{end}}
|
||||
|
||||
|
||||
{{if gt (len .table.LinkedTables) 0}}
|
||||
// LinkedDataSearch 相关连表查询数据
|
||||
// Linked{{$.table.ClassName}}DataSearch 相关连表查询数据
|
||||
func(c *{{$structName}}Controller) Linked{{$.table.ClassName}}DataSearch(ctx context.Context, req *{{.table.ModuleName}}.Linked{{$.table.ClassName}}DataSearchReq) (res *{{.table.ModuleName}}.Linked{{$.table.ClassName}}DataSearchRes, err error) {
|
||||
{{$serviceVal := "service"}}
|
||||
{{if ne $.table.ModuleName "system"}}
|
||||
|
@ -16,6 +16,7 @@ package logic
|
||||
{{$libUtils:=false}}
|
||||
{{$usedSystemModule:=false}}
|
||||
{{$gstr:=false}}
|
||||
{{$hasLinkTable:=false}}
|
||||
{{range $index, $column := .table.Columns}}
|
||||
{{if eq $column.HtmlType "images" "file" "files"}}
|
||||
{{$libUtils = true}}
|
||||
@ -27,6 +28,7 @@ package logic
|
||||
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
||||
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
||||
{{$gstr = true}}
|
||||
{{$hasLinkTable = true}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
@ -235,6 +237,82 @@ func (s *s{{.table.ClassName}})List(ctx context.Context, req *model.{{.table.Cla
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
{{if .table.ExcelPort }}
|
||||
////
|
||||
func (s *s{{.table.ClassName}})GetExportData(ctx context.Context, req *model.{{.table.ClassName}}SearchReq) (listRes []*model.{{.table.ClassName}}InfoRes, err error){
|
||||
err = g.Try(ctx, func(ctx context.Context) {
|
||||
m := dao.{{.table.ClassName}}.Ctx(ctx).WithAll()
|
||||
{{range $index, $column := .table.QueryColumns}}
|
||||
{{if eq $column.QueryType "LIKE"}}
|
||||
if req.{{$column.GoField}} != "" {
|
||||
m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" like ?", "%"+req.{{$column.GoField}}+"%")
|
||||
}
|
||||
{{else if eq $column.QueryType "EQ"}}
|
||||
{{if eq $column.GoType "string"}}
|
||||
if req.{{$column.GoField}} != "" {
|
||||
m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" = ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}{{if ne $column.FieldConversion ""}}){{end}})
|
||||
}
|
||||
{{else if eq $column.GoType "Time"}}
|
||||
{{if eq $column.ColumnName "created_at"}}
|
||||
if len(req.DateRange) != 0 {
|
||||
m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" >=? AND "+dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" <=?", req.DateRange[0], req.DateRange[1])
|
||||
}
|
||||
{{else}}
|
||||
if req.{{$column.GoField}} != "" {
|
||||
m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" = ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}{{if ne $column.FieldConversion ""}}){{end}})
|
||||
}
|
||||
{{end}}
|
||||
{{else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") (eq $column.GoType "bool")}}
|
||||
if req.{{$column.GoField}} != "" {
|
||||
m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" = ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}{{if ne $column.FieldConversion ""}}){{end}})
|
||||
}
|
||||
{{end}}
|
||||
{{else if eq $column.QueryType "BETWEEN" }}
|
||||
if req.{{$column.GoField}} != nil && len(req.{{$column.GoField}}) > 0 {
|
||||
if req.{{$column.GoField}}[0] != "" {
|
||||
m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" >= ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}[0]{{if ne $column.FieldConversion ""}}){{end}})
|
||||
}
|
||||
if len(req.{{$column.GoField}}) > 1 && req.{{$column.GoField}}[1] != "" {
|
||||
m = m.Where(dao.{{$.table.ClassName}}.Columns().{{$column.GoField}}+" < ?", {{if ne $column.FieldConversion ""}}{{$column.FieldConversion}}({{end}}req.{{$column.GoField}}[1]{{if ne $column.FieldConversion ""}}){{end}})
|
||||
}
|
||||
}
|
||||
{{end}}
|
||||
{{end}}
|
||||
if req.PageNum == 0 {
|
||||
req.PageNum = 1
|
||||
}
|
||||
if req.PageSize == 0 {
|
||||
req.PageSize = consts.PageSize
|
||||
}
|
||||
order:= "{{.table.SortColumn}} {{.table.SortType}}"
|
||||
if req.OrderBy!=""{
|
||||
order = req.OrderBy
|
||||
}
|
||||
err = m.Page(req.PageNum, req.PageSize).Order(order).Scan(&listRes)
|
||||
liberr.ErrIsNil(ctx, err, "获取数据失败")
|
||||
{{if $hasLinkTable}}
|
||||
for _,v:=range listRes{
|
||||
{{range $index, $column := .table.Columns}}
|
||||
{{if eq $column.HtmlType "selects" "checkbox" "treeSelects"}}
|
||||
{{range $ti, $linkedTable := $.table.LinkedTables}}
|
||||
{{if eq $column.LinkTableClass $linkedTable.ClassName}}
|
||||
err = g.Model("{{$linkedTable.TableName}}").
|
||||
Fields(model.Linked{{$.table.ClassName}}{{$linkedTable.ClassName}}{}).
|
||||
Where("{{$column.LinkLabelId}}", gstr.Split(v.{{$column.GoField}}, ",")).
|
||||
Scan(&v.Linked{{$column.GoField}})
|
||||
liberr.ErrIsNil(ctx, err)
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
}
|
||||
{{end}}
|
||||
})
|
||||
return
|
||||
}
|
||||
{{end}}
|
||||
|
||||
////
|
||||
{{if gt (len .table.LinkedTables) 0}}
|
||||
// LinkedDataSearch 相关连表查询数据
|
||||
|
@ -30,6 +30,9 @@ import (
|
||||
////
|
||||
type I{{.table.ClassName}} interface {
|
||||
List(ctx context.Context, req *model.{{.table.ClassName}}SearchReq) (res *model.{{.table.ClassName}}SearchRes, err error)
|
||||
{{if .table.ExcelPort }}
|
||||
GetExportData(ctx context.Context, req *model.{{.table.ClassName}}SearchReq) (listRes []*model.{{.table.ClassName}}InfoRes, err error)
|
||||
{{end}}
|
||||
GetBy{{.table.PkColumn.GoField}}(ctx context.Context, {{.table.PkColumn.GoField}} {{$.table.PkColumn.GoType}}) (res *model.{{.table.ClassName}}InfoRes,err error)
|
||||
Add(ctx context.Context, req *model.{{.table.ClassName}}AddReq) (err error)
|
||||
Edit(ctx context.Context, req *model.{{.table.ClassName}}EditReq) (err error)
|
||||
|
@ -20,6 +20,7 @@ DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.
|
||||
DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/add';
|
||||
DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/edit';
|
||||
DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/delete';
|
||||
DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/export';
|
||||
{{range $index,$column:= .table.Columns}}
|
||||
{{if and $column.IsStatus $column.IsList}}
|
||||
DELETE FROM `sys_auth_rule` WHERE `name` = '{{$plugin}}{{.apiVersion}}/{{$.table.ModuleName}}/{{$.table.BusinessName | CaseCamelLower}}/change{{$column.GoField}}';
|
||||
@ -56,6 +57,11 @@ VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.Busi
|
||||
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
|
||||
VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/delete','{{.table.FunctionName}}删除','','','{{.table.FunctionName}}删除',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
|
||||
|
||||
{{if .table.ExcelPort}}
|
||||
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
|
||||
VALUES(@parentId,'{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{.table.BusinessName | CaseCamelLower}}/export','{{.table.FunctionName}}导出','','','{{.table.FunctionName}}导出',2,0,1,0,'','','',0,'sys_admin',0,@now,@now);
|
||||
{{end}}
|
||||
|
||||
{{range $index,$column:= .table.Columns}}
|
||||
{{if and $column.IsStatus $column.IsList}}
|
||||
INSERT INTO `sys_auth_rule` (`pid`,`name`,`title`,`icon`,`condition`,`remark`,`menu_type`,`weigh`,`is_cached`,`is_hide`,`path`,`link_url`,`component`,`is_iframe`,`module_type`,`model_id`,`created_at`,`updated_at`)
|
||||
|
@ -6,11 +6,11 @@
|
||||
{{$treeName := .table.TreeName}}
|
||||
<div class="{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-edit">
|
||||
<!-- 添加或修改{{.table.FunctionName}}对话框 -->
|
||||
<el-dialog v-model="isShowDialog" width="769px" :close-on-click-modal="false" :destroy-on-close="true">
|
||||
<el-dialog v-model="isShowDialog" width="800px" :close-on-click-modal="false" :destroy-on-close="true">
|
||||
<template #header>
|
||||
<div v-drag="['.{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-edit .el-dialog', '.{{.table.ModuleName}}-{{.table.BusinessName|CaseCamelLower}}-edit .el-dialog__header']">{{"{{"}}(!formData.{{.table.PkColumn.HtmlField}} || formData.{{.table.PkColumn.HtmlField}}==0?'添加':'修改')+'{{.table.FunctionName}}'{{"}}"}}</div>
|
||||
</template>
|
||||
<el-form ref="formRef" :model="formData" :rules="rules" label-width="90px">
|
||||
<el-form ref="formRef" :model="formData" :rules="rules">
|
||||
{{if .table.IsPkInsertable}}
|
||||
<el-form-item label="{{.table.PkColumn.ColumnComment}}" prop="{{.table.PkColumn.HtmlField}}">
|
||||
<el-input v-model="formData.{{.table.PkColumn.HtmlField}}" placeholder="请输入{{.table.PkColumn.ColumnComment}}" v-bind:disabled="this.currentOp === 'edit'" />
|
||||
@ -198,7 +198,7 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button type="primary" @click="onSubmit">确 定</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确 定</el-button>
|
||||
<el-button @click="onCancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -224,6 +224,15 @@
|
||||
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/delete'"
|
||||
><el-icon><ele-Delete /></el-icon>删除</el-button>
|
||||
</el-col>
|
||||
{{if .table.ExcelPort }}
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
@click="handleExport()"
|
||||
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/export'"
|
||||
><el-icon><ele-Download /></el-icon>导出Excel</el-button>
|
||||
</el-col>
|
||||
{{end}}
|
||||
</el-row>
|
||||
</div>
|
||||
<el-table v-loading="loading" :data="tableData.data" @selection-change="handleSelectionChange">
|
||||
@ -443,6 +452,9 @@ import {
|
||||
} from "/@/views/{{$plugin}}{{.table.ModuleName}}/{{$businessName}}/list/component/model"
|
||||
import {{$plugin}}{{if ne $plugin ""}}{{.apiVersion|replace "/" "_"|CaseCamel}}{{else}}{{.apiVersion|replace "/" "_"|CaseCamelLower}}{{end}}{{.table.ModuleName|CaseCamel}}{{.table.ClassName}}Edit from "/@/views/{{$plugin}}{{.table.ModuleName}}/{{$businessName}}/list/component/edit.vue"
|
||||
import {{$plugin}}{{if ne $plugin ""}}{{.apiVersion|replace "/" "_"|CaseCamel}}{{else}}{{.apiVersion|replace "/" "_"|CaseCamelLower}}{{end}}{{.table.ModuleName|CaseCamel}}{{.table.ClassName}}Detail from "/@/views/{{$plugin}}{{.table.ModuleName}}/{{$businessName}}/list/component/detail.vue"
|
||||
{{if .table.ExcelPort }}
|
||||
import {downLoadXml} from "/@/utils/zipdownload";
|
||||
{{end}}
|
||||
export default defineComponent({
|
||||
name: "{{$plugin}}{{if ne $plugin ""}}{{.apiVersion|replace "/" "_"|CaseCamel}}{{else}}{{.apiVersion|replace "/" "_"|CaseCamelLower}}{{end}}{{.table.ModuleName|CaseCamel}}{{.table.ClassName}}List",
|
||||
components:{
|
||||
@ -645,6 +657,12 @@ export default defineComponent({
|
||||
const handleView = (row:{{$.table.ClassName}}TableColumns)=>{
|
||||
detailRef.value.openDialog(toRaw(row));
|
||||
}
|
||||
{{if .table.ExcelPort }}
|
||||
//导出excel
|
||||
const handleExport = ()=>{
|
||||
downLoadXml('/{{$plugin}}{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/export',state.tableData.param,'get')
|
||||
}
|
||||
{{end}}
|
||||
return {
|
||||
proxy,
|
||||
editRef,
|
||||
@ -679,6 +697,9 @@ export default defineComponent({
|
||||
{{if eq .table.ShowDetail "true"}}
|
||||
handleView,
|
||||
{{end}}
|
||||
{{if .table.ExcelPort }}
|
||||
handleExport,
|
||||
{{end}}
|
||||
...toRefs(state),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user