|
@@ -19,6 +19,7 @@ func NewAppPermitRepo(engine *xorm.Engine) *AppPermitRepo {
|
|
|
|
|
|
|
|
func (d *AppPermitRepo) GetList(m map[string]interface{})([]viewmodels.AppPermitInfo, error) {
|
|
func (d *AppPermitRepo) GetList(m map[string]interface{})([]viewmodels.AppPermitInfo, error) {
|
|
|
sqlSelect := ` SELECT A.app_id,
|
|
sqlSelect := ` SELECT A.app_id,
|
|
|
|
|
+ B.app_title,
|
|
|
A.role_id,
|
|
A.role_id,
|
|
|
A.permit_id,
|
|
A.permit_id,
|
|
|
A.permit_title,
|
|
A.permit_title,
|
|
@@ -34,6 +35,9 @@ func (d *AppPermitRepo) GetList(m map[string]interface{})([]viewmodels.AppPermit
|
|
|
if appKey, ok := m["appKey"]; ok {
|
|
if appKey, ok := m["appKey"]; ok {
|
|
|
sqlWhere += " AND B.app_key = '" + fmt.Sprintf("%s", appKey) + "'"
|
|
sqlWhere += " AND B.app_key = '" + fmt.Sprintf("%s", appKey) + "'"
|
|
|
}
|
|
}
|
|
|
|
|
+ if appId, ok := m["appId"]; ok {
|
|
|
|
|
+ sqlWhere += " AND A.app_id = " + fmt.Sprintf("%d", appId)
|
|
|
|
|
+ }
|
|
|
if roleId, ok := m["roleId"]; ok {
|
|
if roleId, ok := m["roleId"]; ok {
|
|
|
sqlWhere += " AND A.role_id = " + fmt.Sprintf("%d", roleId)
|
|
sqlWhere += " AND A.role_id = " + fmt.Sprintf("%d", roleId)
|
|
|
}
|
|
}
|
|
@@ -51,6 +55,35 @@ func (d *AppPermitRepo) GetList(m map[string]interface{})([]viewmodels.AppPermit
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func (d *AppPermitRepo) GetListById(appId, roleId int64)([]viewmodels.AppPermitInfo, error) {
|
|
|
|
|
+ sqlSelect := ` SELECT A.app_id,
|
|
|
|
|
+ B.app_title,
|
|
|
|
|
+ A.role_id,
|
|
|
|
|
+ A.permit_id,
|
|
|
|
|
+ A.permit_title,
|
|
|
|
|
+ A.permit_code,
|
|
|
|
|
+ A.permit_desc,
|
|
|
|
|
+ A.permit_type,
|
|
|
|
|
+ A.root_id,
|
|
|
|
|
+ A.parent_id,
|
|
|
|
|
+ A.sort_no `
|
|
|
|
|
+ sqlFrom := ` FROM app_permit AS A
|
|
|
|
|
+ JOIN app AS B ON (A.app_id = B.app_id) `
|
|
|
|
|
+ sqlWhere := ` WHERE A.deleted_flag = 0 `
|
|
|
|
|
+ sqlWhere += fmt.Sprintf(" AND A.app_id = %d ", appId)
|
|
|
|
|
+ sqlWhere += fmt.Sprintf(" AND A.role_id = %d ", roleId)
|
|
|
|
|
+
|
|
|
|
|
+ sqlOrderBy := " ORDER BY A.app_id, A.role_id, A.parent_id, A.sort_no "
|
|
|
|
|
+
|
|
|
|
|
+ datalist := make([]viewmodels.AppPermitInfo, 0)
|
|
|
|
|
+ err := d.engine.SQL(sqlSelect + sqlFrom + sqlWhere + sqlOrderBy).Find(&datalist)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ return nil, err
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return datalist, nil
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func (d *AppPermitRepo) GetListByKey(appKey string, roleId int64)([]viewmodels.AppPermitInfo, error) {
|
|
func (d *AppPermitRepo) GetListByKey(appKey string, roleId int64)([]viewmodels.AppPermitInfo, error) {
|
|
|
sqlSelect := ` SELECT A.app_id,
|
|
sqlSelect := ` SELECT A.app_id,
|
|
|
A.role_id,
|
|
A.role_id,
|