commit
continuous-integration/drone/push Build is passing Details

master
黄海 4 years ago
parent d814dab594
commit d9ee6ebad7

@ -5,13 +5,25 @@
</component>
<component name="ChangeListManager">
<list default="true" id="19c8c37d-a056-451c-a29d-fb612b9a3e2f" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/Business/CaptchaRelate/CaptchaController/CaptchaController.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Business/ImRelate/ImRelateController/ImRelateController.go" beforeDir="false" afterPath="$PROJECT_DIR$/Business/ImRelate/ImRelateController/ImRelateController.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Router/CommonToolsRouter.go" beforeDir="false" afterPath="$PROJECT_DIR$/Router/CommonToolsRouter.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Go File" />
</list>
</option>
</component>
<component name="GOROOT" url="file://C:/Program Files/Go" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
@ -26,6 +38,7 @@
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="DefaultGoTemplateProperty" value="Go File" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
@ -34,7 +47,7 @@
<property name="go.modules.go.list.on.any.changes.was.set" value="true" />
<property name="go.sdk.automatically.set" value="true" />
<property name="go.tried.to.enable.integration.vgo.integrator" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/Utils" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/Business/CaptchaRelate/CaptchaController" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
@ -42,18 +55,11 @@
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="E:\Work\dsMin\dsSzxy\Business\CaptchaRelate\CaptchaController" />
<recent name="E:\Work\dsMin\dsSzxy\Utils" />
</key>
</component>
<component name="RunManager" selected="Go Build.go build dsSzxy">
<configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
<module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" />
<kind value="FILE" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<method v="2" />
</configuration>
<configuration name="go build dsSzxy" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" />
@ -72,15 +78,6 @@
<filePath value="$PROJECT_DIR$/main.go" />
<method v="2" />
</configuration>
<configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
<module name="dsSzxy" />
<working_directory value="$PROJECT_DIR$" />
<kind value="DIRECTORY" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Build.go build dsSzxy" />

@ -0,0 +1,92 @@
package CaptchaController
import (
"fmt"
"github.com/gin-gonic/gin"
"github.com/mojocn/base64Captcha"
"image/color"
"net/http"
)
//模块的路由配置
func Routers(r *gin.RouterGroup) {
rr := r.Group("/captchaRelate")
rr.GET("/GetOne", GetOne)
rr.GET("/Verify", Verify)
}
// 设置自带的store
var store = base64Captcha.DefaultMemStore
//存储验证码的结构
type CaptchaResult struct {
Id string `json:"id"`
Base64Blob string `json:"base_64_blob"`
}
// 生成图形化验证码
func GetOne(c *gin.Context) {
id, b64s, err := CaptMake()
if err != nil {
c.JSON(http.StatusOK, gin.H{"success": false, "info": "发生错误!"})
}
captchaResult := CaptchaResult{
Id: id,
Base64Blob: b64s,
}
c.JSON(http.StatusOK, gin.H{"success": true, "captcha": captchaResult})
return
}
//验证captcha是否正确
func Verify(c *gin.Context) {
id := c.PostForm("id")
capt := c.PostForm("capt")
if id == "" || capt == "" {
c.JSON(http.StatusOK, gin.H{"success": false, "msg": "参数错误!"})
}
if CaptVerify(id, capt) == true {
c.JSON(http.StatusOK, gin.H{"success": true})
} else {
c.JSON(http.StatusOK, gin.H{"success": false})
}
return
}
//生成验证码
func CaptMake() (id, b64s string, err error) {
var driver base64Captcha.Driver
var driverString base64Captcha.DriverString
// 配置验证码信息
captchaConfig := base64Captcha.DriverString{
Height: 60,
Width: 200,
NoiseCount: 0,
ShowLineOptions: 2 | 4,
Length: 4,
Source: "1234567890qwertyuioplkjhgfdsazxcvbnm",
BgColor: &color.RGBA{
R: 3,
G: 102,
B: 214,
A: 125,
},
Fonts: []string{"wqy-microhei.ttc"},
}
driverString = captchaConfig
driver = driverString.ConvertFonts()
captcha := base64Captcha.NewCaptcha(driver, store)
lid, lb64s, lerr := captcha.Generate()
return lid, lb64s, lerr
}
//验证captcha是否正确
func CaptVerify(id string, capt string) bool {
fmt.Println("id:" + id)
fmt.Println("capt:" + capt)
return store.Verify(id, capt, false)
}

@ -21,10 +21,7 @@ import (
//模块的路由配置
func Routers(r *gin.RouterGroup) {
rr := r.Group("/imRelate")
rr.POST("/fileUpload", fileUpload)
return
}
func fileUpload(c *gin.Context) {

@ -1,6 +1,7 @@
package Router
import (
"dsSzxy/Business/CaptchaRelate/CaptchaController"
"dsSzxy/Business/ImRelate/ImRelateController"
"dsSzxy/Business/MinIORelate/MinIORelateController"
"github.com/gin-gonic/gin"
@ -14,4 +15,6 @@ func GinRouter(r *gin.Engine) {
MinIORelateController.Routers(rr)
//IM
ImRelateController.Routers(rr)
//Captcha
CaptchaController.Routers(rr)
}

@ -16,6 +16,7 @@ require (
github.com/go-redis/redis v6.15.9+incompatible // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/minio/minio-go/v6 v6.0.57 // indirect
github.com/mojocn/base64Captcha v1.3.5 // indirect
github.com/pkg/sftp v1.13.1 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
@ -23,6 +24,7 @@ require (
github.com/xormplus/builder v0.0.0-20200331055651-240ff40009be // indirect
github.com/xormplus/xorm v0.0.0-20210512135344-8123d584d5f5 // indirect
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/text v0.3.6 // indirect
gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 // indirect

@ -36,6 +36,8 @@ github.com/go-redis/redis v6.15.9+incompatible h1:K0pv1D7EQUjfyoMql+r/jZqCLizCGK
github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
@ -71,6 +73,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 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
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/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
@ -107,8 +111,11 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnk
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/image v0.0.0-20190501045829-6d32002ffd75/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
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=

Loading…
Cancel
Save