mirror of
				https://github.com/jerryWangor/iris_web.git
				synced 2025-10-31 18:52:39 +08:00 
			
		
		
		
	demo
This commit is contained in:
		| @@ -102,6 +102,7 @@ func (c *UserController) Edit(ctx iris.Context) { | ||||
| 	} | ||||
|  | ||||
| 	// 查询记录 | ||||
| 	var userInfo = vo.UserInfoVo{} | ||||
| 	id := ctx.Params().GetIntDefault("id", 0) | ||||
| 	if id > 0 { | ||||
| 		info := &model.User{Id: id} | ||||
| @@ -114,7 +115,6 @@ func (c *UserController) Edit(ctx iris.Context) { | ||||
| 			return | ||||
| 		} | ||||
|  | ||||
| 		var userInfo = vo.UserInfoVo{} | ||||
| 		userInfo.User = *info | ||||
| 		// 头像 | ||||
| 		userInfo.Avatar = utils.GetImageUrl(info.Avatar) | ||||
| @@ -127,10 +127,9 @@ func (c *UserController) Edit(ctx iris.Context) { | ||||
| 			roleIds = append(roleIds, v.RoleId) | ||||
| 		} | ||||
| 		userInfo.RoleIds = roleIds | ||||
|  | ||||
| 		// 数据绑定 | ||||
| 		ctx.ViewData("info", userInfo) | ||||
| 	} | ||||
| 	// 数据绑定 | ||||
| 	ctx.ViewData("info", userInfo) | ||||
| 	// 绑定参数 | ||||
| 	ctx.ViewData("genderList", constant.GENDER_LIST) | ||||
| 	ctx.ViewData("levelList", levelList) | ||||
|   | ||||
| @@ -10,7 +10,7 @@ func Query(s string) template.HTML { | ||||
| 	return unescapeHTML(str) | ||||
| } | ||||
|  | ||||
| func Select(s string, list string, level int) template.HTML { | ||||
| func Select(s string, list interface{}, level int) template.HTML { | ||||
| 	str := "<select name=\"city\" lay-verify=\"\">\n  <option value=\"\">请选择一个城市</option>\n  <option value=\"010\">北京</option>\n  <option value=\"021\">上海</option>\n  <option value=\"0571\">杭州</option>\n</select>" | ||||
| 	return unescapeHTML(str) | ||||
| } | ||||
| @@ -83,7 +83,7 @@ func Safe(s string) template.HTML { | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func Date(s string, b string) template.HTML { | ||||
| func Date(s string, b int64) template.HTML { | ||||
| 	//{{date "birthday|1|出生日期|date" .info.Birthday}} | ||||
| 	return "" | ||||
| } | ||||
| @@ -113,7 +113,7 @@ func Kindeditor(s string) template.HTML { | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func Checkbox(s string, data map[string]interface{}, r []int) template.HTML { | ||||
| func Checkbox(s string, data map[int]string, r interface{}) template.HTML { | ||||
| 	//{{checkbox "roleIds|name|id" .roleList .info.RoleIds}} | ||||
| 	return "" | ||||
| } | ||||
| @@ -122,7 +122,7 @@ func Radio(s string) template.HTML { | ||||
| 	return "" | ||||
| } | ||||
|  | ||||
| func City(c int, a int, b int) template.HTML { | ||||
| func City(s string, a int, b int) template.HTML { | ||||
| 	//{{city .info.DistrictCode 3 1}} | ||||
| 	return "" | ||||
| } | ||||
|   | ||||
| @@ -29,14 +29,48 @@ import ( | ||||
| 	"easygoadmin/app/widget" | ||||
| 	"github.com/kataras/iris/v12" | ||||
| 	"github.com/kataras/iris/v12/sessions" | ||||
| 	"github.com/kataras/iris/v12/sessions/sessiondb/redis" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| // 注册路由 | ||||
| func RegisterRouter(app *iris.Application) { | ||||
|  | ||||
| 	// 2\. 初始化数据库。 | ||||
| 	// 这些是默认值, | ||||
| 	// 你可以基于你运行中的 redis 服务器的设置去替换它们: | ||||
| 	db := redis.New(redis.Config{ | ||||
| 		Network:   "tcp", | ||||
| 		Addr:      "127.0.0.1:6379", | ||||
| 		Timeout:   time.Duration(30) * time.Second, | ||||
| 		MaxActive: 10, | ||||
| 		Password:  "", | ||||
| 		Database:  "", | ||||
| 		Prefix:    "", | ||||
| 		Delim:     "-", | ||||
| 		Driver:    redis.Redigo(), // 可使用 redis.Radix() 代替。 | ||||
| 	}) | ||||
|  | ||||
| 	// 可选择配置如下驱动程序: | ||||
| 	// driver := redis.Redigo() | ||||
| 	// driver.MaxIdle = ... | ||||
| 	// driver.IdleTimeout = ... | ||||
| 	// driver.Wait = ... | ||||
| 	// redis.Config {Driver: driver} | ||||
|  | ||||
| 	// 当执行 control+C/cmd+C  时关闭连接 | ||||
| 	iris.RegisterOnInterrupt(func() { | ||||
| 		db.Close() | ||||
| 	}) | ||||
|  | ||||
| 	// 注册SESSION中间件 | ||||
| 	session := sessions.New(sessions.Config{ | ||||
| 		Cookie: sessions.DefaultCookieName, | ||||
| 	}) | ||||
|  | ||||
| 	// 3\. 注册它们。 | ||||
| 	session.UseDatabase(db) | ||||
|  | ||||
| 	// SESSION中间件 | ||||
| 	app.Use(session.Handler()) | ||||
| 	// 登录验证中间件 | ||||
|   | ||||
							
								
								
									
										7
									
								
								test_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								test_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| package main | ||||
|  | ||||
| import "testing" | ||||
|  | ||||
| func Testa(t testing.T) { | ||||
|  | ||||
| } | ||||
| @@ -7,12 +7,12 @@ | ||||
|                 <input type="text" name="realname" placeholder="请输入用户姓名" autocomplete="off" class="layui-input"> | ||||
|             </div> | ||||
|         </div> | ||||
| <!--        <div class="layui-inline">--> | ||||
| <!--            <label class="layui-form-label">性别:</label>--> | ||||
| <!--            <div class="layui-input-inline">--> | ||||
| <!--                {{select "gender|0|性别|name|id" "1=男,2=女,3=保密" 0}}--> | ||||
| <!--            </div>--> | ||||
| <!--        </div>--> | ||||
|         <div class="layui-inline"> | ||||
|             <label class="layui-form-label">性别:</label> | ||||
|             <div class="layui-input-inline"> | ||||
|                 {{select "gender|0|性别|name|id" "1=男,2=女,3=保密" 0}} | ||||
|             </div> | ||||
|         </div> | ||||
|         <div class="layui-inline"> | ||||
|             <div class="layui-input-inline" style="width: auto;"> | ||||
| 				{{query "查询"}} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 jerry
					jerry