Explorar o código

修改sys_role首页组件字段名称

huangyh %!s(int64=6) %!d(string=hai) anos
pai
achega
6610eb7621

+ 13 - 0
controllers/gen/SystemController_gen.go

@@ -675,6 +675,19 @@ func (c *SystemController) UpdateRole(ctx *gin.Context) {
 	partial.System_UpdateRole(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
 }
 
+// GetUserRoles
+// @Title GetUserRoles
+// @Description 根据用户ID获取用户角色
+// @Param	user_id    string  false  "用户ID"
+// @Success 200 {object} sysReturn
+// @Failure 403 :id is empty
+// @router /get_user_roles  [post,get,put]
+func (c *SystemController) GetUserRoles(ctx *gin.Context) {
+	//
+	db := c.apiengine.BusinessOrmEngine[ctx.GetString("domain")]
+	partial.System_GetUserRoles(&entitys.CtrlContext{c.apiengine, ctx, db, c.apiengine.PlatformOrmEngine})
+}
+
 // FindRoleMenu
 // @Title FindRoleMenu
 // @Description 查找角色权限

+ 20 - 1
controllers/partial/SystemController.go

@@ -467,6 +467,25 @@ func System_UpdateRole(c *entitys.CtrlContext) {
 	}
 }
 
+// _GetUserRoles
+// @Title _GetUserRoles
+// @Description 根据用户id获取用户角色
+// @Param	user_id    string  false  "用户ID"
+// @Success 200 {object} Account
+// @Failure 403 :id is empty
+func System_GetUserRoles(c *entitys.CtrlContext) {
+	user_id := c.Ctx.Query("user_id")
+
+	var roles []sysmodel.SysRole
+	err := c.Db.SQL("select sys_role.* from sys_user_role, sys_role where sys_user_role.role_id = sys_role.id and sys_role.del_flag = 0 and sys_user_role.user_id = ? order by sys_role.priority asc", user_id).Find(&roles)
+
+	if err == nil {
+		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", roles})
+	} else {
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
+	}
+}
+
 // _FindRolePage
 // @Title _FindRolePage
 // @Description 角色分页
@@ -2245,7 +2264,7 @@ func System_UpdateOptionset(c *entitys.CtrlContext) {
 	if err == nil {
 		c.Ctx.JSON(200, sysmodel.SysReturn{200, "", nil})
 	} else {
-		c.Ctx.JSON(500, sysmodel.SysReturn{500, "", nil})
+		c.Ctx.JSON(500, sysmodel.SysReturn{500, err.Error(), nil})
 	}
 }
 

+ 20 - 15
models/SysRole_gen.go

@@ -1,33 +1,38 @@
-
 package models
+
 import (
-	//__import_packages__
+//__import_packages__
 )
 
 type SysRole struct {
 	//主键
-	Id   string    `xorm:"'id' varchar(36) pk notnull "json:"id"`
+	Id string `xorm:"'id' varchar(36) pk notnull "json:"id"`
 	//名称
-	Name   string    `xorm:"'name' varchar(36) notnull "json:"name"`
+	Name string `xorm:"'name' varchar(36) notnull "json:"name"`
 	//编码
-	Code   string    `xorm:"'code' varchar(36) notnull "json:"code"`
+	Code string `xorm:"'code' varchar(36) notnull "json:"code"`
+	//角色进入后台首页组件
+	IndexComponent string `xorm:"'index_component' varchar(500) notnull "json:"index_component"`
+	//角色app首页url
+	AppIndex string `xorm:"'app_index' varchar(500) notnull "json:"app_index"`
+	//优先级
+	Priority int32 `xorm:"'priority' notnull "json:"priority"`
 	//备注
-	Remark   string    `xorm:"'remark' varchar(100) notnull "json:"remark"`
+	Remark string `xorm:"'remark' varchar(100) notnull "json:"remark"`
 	//状态 0:禁用   1:正常
-	Status   int32    `xorm:"'status' notnull "json:"status"`
+	Status int32 `xorm:"'status' notnull "json:"status"`
 	//域
-	Domain   string    `xorm:"'domain' varchar(50) notnull "json:"domain"`
+	Domain string `xorm:"'domain' varchar(50) notnull "json:"domain"`
 	//创建人
-	CreateBy   string    `xorm:"'create_by' varchar(36) notnull "json:"create_by"`
+	CreateBy string `xorm:"'create_by' varchar(36) notnull "json:"create_by"`
 	//创建时间
-	CreateTime   LocalTime    `xorm:"'create_time' notnull "json:"create_time"`
+	CreateTime LocalTime `xorm:"'create_time' notnull "json:"create_time"`
 	//最后更新人
-	LastUpdateBy   string    `xorm:"'last_update_by' varchar(36) notnull "json:"last_update_by"`
+	LastUpdateBy string `xorm:"'last_update_by' varchar(36) notnull "json:"last_update_by"`
 	//最后更新时间
-	LastUpdateTime   int64    `xorm:"'last_update_time' notnull "json:"last_update_time"`
+	LastUpdateTime int64 `xorm:"'last_update_time' notnull "json:"last_update_time"`
 	//是否删除 1:删除   0:正常
-	DelFlag   int32    `xorm:"'del_flag' notnull "json:"del_flag"`
-
+	DelFlag int32 `xorm:"'del_flag' notnull "json:"del_flag"`
 }
 
 func (t *SysRole) TableName() string {
@@ -35,6 +40,6 @@ func (t *SysRole) TableName() string {
 }
 
 func init() {
-    AddTableName("sys_role")
+	AddTableName("sys_role")
 	RegisterModel(new(SysRole))
 }

+ 5 - 5
sqlconfig/light-apiengine/sys_role_gen.xml

@@ -2,13 +2,13 @@
 <sqlMap>
     <sql id="insert_sys_role">
         insert into sys_role
-		(`id`,`name`,`code`,`index_url`,`app_index`,`priority`,`remark`,`status`,`domain`,`create_by`,`create_time`,`last_update_by`,`last_update_time`,`del_flag`)
+		(`id`,`name`,`code`,`index_component`,`app_index`,`priority`,`remark`,`status`,`domain`,`create_by`,`create_time`,`last_update_by`,`last_update_time`,`del_flag`)
 		values
-		(?id,?name,?code,?index_url,?app_index,?priority,?remark,?status,?domain,?create_by,?create_time,?last_update_by,?last_update_time,?del_flag)
+		(?id,?name,?code,?index_component,?app_index,?priority,?remark,?status,?domain,?create_by,?create_time,?last_update_by,?last_update_time,?del_flag)
     </sql>
     <sql id="update_sys_role">
         update sys_role set
-		`name` = ?name,`code` = ?code,`index_url` = ?index_url,`app_index` = ?app_index,`priority` = ?priority,`remark` = ?remark,`status` = ?status,`domain` = ?domain,`create_by` = ?create_by,`create_time` = ?create_time,`last_update_by` = ?last_update_by,`last_update_time` = ?last_update_time,`del_flag` = ?del_flag
+		`name` = ?name,`code` = ?code,`index_component` = ?index_component,`app_index` = ?app_index,`priority` = ?priority,`remark` = ?remark,`status` = ?status,`domain` = ?domain,`create_by` = ?create_by,`create_time` = ?create_time,`last_update_by` = ?last_update_by,`last_update_time` = ?last_update_time,`del_flag` = ?del_flag
 		where id = ?id
     </sql>
     <sql id="deleteone_sys_role">
@@ -17,13 +17,13 @@
     </sql>
     <sql id="selectone_sys_role">
         select 
-			`id`,`name`,`code`,`index_url`,`app_index`,`priority`,`remark`,`status`,`domain`,`create_by`,`create_time`,`last_update_by`,`last_update_time`,`del_flag`
+			`id`,`name`,`code`,`index_component`,`app_index`,`priority`,`remark`,`status`,`domain`,`create_by`,`create_time`,`last_update_by`,`last_update_time`,`del_flag`
         from sys_role
 		where id = ?id
     </sql>
     <sql id="selectall_sys_role">
         select 
-			`id`,`name`,`code`,`index_url`,`app_index`,`priority`,`remark`,`status`,`domain`,`create_by`,`create_time`,`last_update_by`,`last_update_time`,`del_flag`
+			`id`,`name`,`code`,`index_component`,`app_index`,`priority`,`remark`,`status`,`domain`,`create_by`,`create_time`,`last_update_by`,`last_update_time`,`del_flag`
         from sys_role
     </sql>
 </sqlMap>