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

master
黄海 4 years ago
parent d9ee6ebad7
commit cf6ae44f7b

@ -4,13 +4,11 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="19c8c37d-a056-451c-a29d-fb612b9a3e2f" name="Default Changelist" comment=""> <list default="true" id="19c8c37d-a056-451c-a29d-fb612b9a3e2f" name="Default Changelist" comment="commit">
<change afterPath="$PROJECT_DIR$/Business/CaptchaRelate/CaptchaController/CaptchaController.go" afterDir="false" /> <change afterPath="$PROJECT_DIR$/static/getcapt.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/Business/CaptchaRelate/CaptchaController/CaptchaController.go" beforeDir="false" afterPath="$PROJECT_DIR$/Business/CaptchaRelate/CaptchaController/CaptchaController.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Router/CommonToolsRouter.go" beforeDir="false" afterPath="$PROJECT_DIR$/Router/CommonToolsRouter.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/main.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> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -21,6 +19,7 @@
<option name="RECENT_TEMPLATES"> <option name="RECENT_TEMPLATES">
<list> <list>
<option value="Go File" /> <option value="Go File" />
<option value="HTML File" />
</list> </list>
</option> </option>
</component> </component>
@ -39,6 +38,7 @@
<component name="PropertiesComponent"> <component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" /> <property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="DefaultGoTemplateProperty" value="Go File" /> <property name="DefaultGoTemplateProperty" value="Go File" />
<property name="DefaultHtmlFileTemplate" value="HTML File" />
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
@ -101,6 +101,10 @@
</option> </option>
<option name="oldMeFiltersMigrated" value="true" /> <option name="oldMeFiltersMigrated" value="true" />
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="commit" />
<option name="LAST_COMMIT_MESSAGE" value="commit" />
</component>
<component name="VgoProject"> <component name="VgoProject">
<integration-enabled>true</integration-enabled> <integration-enabled>true</integration-enabled>
</component> </component>

@ -8,17 +8,17 @@ import (
"net/http" "net/http"
) )
//模块的路由配置 // Routers 模块的路由配置
func Routers(r *gin.RouterGroup) { func Routers(r *gin.RouterGroup) {
rr := r.Group("/captchaRelate") rr := r.Group("/captchaRelate")
rr.GET("/GetOne", GetOne) rr.GET("/GetOne", GetOne)
rr.GET("/Verify", Verify) rr.POST("/Verify", Verify)
} }
// 设置自带的store // 设置自带的store
var store = base64Captcha.DefaultMemStore var store = base64Captcha.DefaultMemStore
//存储验证码的结构 // CaptchaResult 存储验证码的结构
type CaptchaResult struct { type CaptchaResult struct {
Id string `json:"id"` Id string `json:"id"`
Base64Blob string `json:"base_64_blob"` Base64Blob string `json:"base_64_blob"`

@ -25,6 +25,8 @@ func main() {
gin.SetMode(gin.DebugMode) gin.SetMode(gin.DebugMode)
// 开启gin服务器 // 开启gin服务器
r := gin.Default() r := gin.Default()
//设置静态资源
r.Static("/dsSzxy/static", "./static")
// 使用跨域中间件 // 使用跨域中间件
r.Use(Utils.Cors()) r.Use(Utils.Cors())
//主路由 //主路由

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<img id="capt" src=""/><br/>
<input id="captvalue" placeholder="请输入验证码"/><br/>
<input type="button" name="save" value="提交" onclick="submit()"/>
<script>
var curCaptId = "";
//得到图形验证码和id
$.ajax({
type: "GET",
url: "/dsSzxy/captchaRelate/GetOne",
data: {},
dataType: "JSON",
success: function (result) {
curCaptId = result.captcha.id;
document.getElementById("capt").src = result.captcha.base_64_blob;
}
});
//提交验证码和id
function submit() {
var capt = document.getElementById("captvalue").value;
var postdata = {
"id": curCaptId,
"capt": capt
};
$.ajax({
type: "POST",
url: "/dsSzxy/captchaRelate/Verify",
data: postdata,
dataType: "JSON",
success: function (result) {
if (result.code == 0) {
alert("验证成功");
} else {
alert("验证错误:" + result.msg);
}
}
});
}
</script>
</body>
</html>
Loading…
Cancel
Save