开启测试模式时,显示按钮支持生成测试数据快速体验

This commit is contained in:
gotoeasy 2023-10-24 21:00:24 +08:00
parent fbbd54a2b0
commit 59f2039b96
3 changed files with 9 additions and 3 deletions

View File

@ -41,6 +41,7 @@ func Run() {
gweb.RegisterController(method.POST, contextPath+"/v1/store/names", controller.StorageNamesController) // 查询日志仓名称列表
gweb.RegisterController(method.POST, contextPath+"/v1/store/list", controller.StorageListController) // 查询日志仓信息列表
gweb.RegisterController(method.POST, contextPath+"/v1/store/delete", controller.StorageDeleteController) // 删除日志仓
gweb.RegisterController(method.POST, contextPath+"/v1/store/mode", controller.TestModeController) // 查询是否测试模式
gweb.RegisterController(method.POST, contextPath+"/v1/user/enableLogin", controller.IsEnableLoginController) // 查询是否开启用户密码登录功能
gweb.RegisterController(method.POST, contextPath+"/v1/user/login", controller.LoginController) // Login
gweb.RegisterController(method.POST, contextPath+"/v1/version/info", controller.VersionController) // 查询版本信息

View File

@ -12,7 +12,7 @@ import (
func JsonLogAddTestDataController(req *gweb.HttpRequest) *gweb.HttpResult {
if !conf.IsTestMode() {
return gweb.Ok() // 非测试模式时忽略
return gweb.Error500("当前不是测试模式,不支持生成测试数据") // 非测试模式时忽略
}
cnt := 0
@ -36,7 +36,7 @@ func JsonLogAddTestDataController(req *gweb.HttpRequest) *gweb.HttpResult {
}
md2 := &logdata.LogDataModel{
Text: "几个随机字符串供查询试验:" + cmn.RandomString(1) + "," + cmn.RandomString(2) + "," + cmn.RandomString(3) + "," + cmn.RandomString(4) + "," + cmn.RandomString(5),
Text: "几个随机字符串供查询试验:" + cmn.RandomString(1) + "" + cmn.Right(cmn.ULID(), 2) + "" + cmn.RandomString(3) + "" + cmn.Right(cmn.ULID(), 4) + "" + cmn.Right(cmn.ULID(), 5),
Date: cmn.Now(),
System: "demo",
ServerName: "default",

View File

@ -13,6 +13,11 @@ import (
"github.com/gotoeasy/glang/cmn"
)
// 查询是否测试模式
func TestModeController(req *gweb.HttpRequest) *gweb.HttpResult {
return gweb.Result(conf.IsTestMode())
}
// 查询版本信息
func VersionController(req *gweb.HttpRequest) *gweb.HttpResult {
rs := cmn.OfMap("version", ver.VERSION, "latest", getLatestVersion()) // version当前版本号latest最新版本号
@ -75,7 +80,7 @@ func StorageDeleteController(req *gweb.HttpRequest) *gweb.HttpResult {
// 尝试查询最新版本号(注:这里不能保证服务一定可用),查不到返回空串
func getLatestVersion() string {
// {"version":"v0.12.0"}
bts, err := cmn.HttpGetJson("https://glc.gotoeasy.top/glogcenter/current/version.json?v=" + ver.VERSION) // 取最新版本号
bts, err := cmn.HttpGetJson("https://glc.gotoeasy.top/glogcenter/current/version.json?v="+ver.VERSION, "Auth:glc") // 取最新版本号
if err != nil {
return ""
}