Browse Source

消除冗余代码 细节提示修复

main
pixel 5 years ago
parent
commit
e440b27216
  1. 2
      server/api/v1/exa_customer.go
  2. 4
      server/service/exa_customer.go
  3. 4
      server/service/exa_file_upload_download.go
  4. 11
      server/service/sys_api.go
  5. 4
      server/service/sys_authority.go
  6. 4
      server/service/sys_menu.go
  7. 4
      server/service/sys_user.go

2
server/api/v1/exa_customer.go

@ -105,7 +105,7 @@ func GetExaCustomerList(c *gin.Context) {
_ = c.ShouldBindJSON(&pageInfo)
err, customerList, total := service.GetCustomerInfoList(waitUse.AuthorityId, pageInfo)
if err != nil {
response.FailWithMessage(fmt.Sprintf("创建失败:%v", err), c)
response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c)
} else {
response.OkWithData(resp.PageResult{
List: customerList,

4
server/service/exa_customer.go

@ -52,9 +52,6 @@ func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB
if err != nil {
return
} else {
var a model.SysAuthority
a.AuthorityId = sysUserAuthorityID
err, auth := GetAuthorityInfo(a)
@ -70,5 +67,4 @@ func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err
err = db.Limit(limit).Offset(offset).Preload("SysUser").Where("sys_user_authority_id in (?)", dataId).Find(&CustomerList).Error
}
return err, CustomerList, total
}
}

4
server/service/exa_file_upload_download.go

@ -45,11 +45,7 @@ func GetFileRecordInfoList(info request.PageInfo) (err error, list interface{},
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB
if err != nil {
return
} else {
var fileLists []model.ExaFileUploadAndDownload
err = db.Limit(limit).Offset(offset).Order("updated_at desc").Find(&fileLists).Error
return err, fileLists, total
}
}

11
server/service/sys_api.go

@ -30,7 +30,7 @@ func CreateApi(a model.SysApi) (err error) {
// @return error
func DeleteApi(a model.SysApi) (err error) {
err = global.GVA_DB.Delete(a).Error
ClearCasbin(1, a.Path,a.Method)
ClearCasbin(1, a.Path, a.Method)
return err
}
@ -45,10 +45,6 @@ func GetAPIInfoList(a model.SysApi, info request.PageInfo, Order string, Desc bo
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB
if err != nil {
return
} else {
var apiList []model.SysApi
if a.Path != "" {
@ -82,7 +78,6 @@ func GetAPIInfoList(a model.SysApi, info request.PageInfo, Order string, Desc bo
}
}
return err, apiList, total
}
}
// @title GetAllApis
@ -114,7 +109,7 @@ func UpdateApi(a model.SysApi) (err error) {
err = global.GVA_DB.Where("id = ?", a.ID).First(&oldA).Error
if oldA.Path != a.Path || oldA.Method != a.Method{
if oldA.Path != a.Path || oldA.Method != a.Method {
flag := global.GVA_DB.Where("path = ? AND method = ?", a.Path, a.Method).Find(&model.SysApi{}).RecordNotFound()
if !flag {
return errors.New("存在相同api路径")
@ -123,7 +118,7 @@ func UpdateApi(a model.SysApi) (err error) {
if err != nil {
return err
} else {
err = UpdateCasbinApi(oldA.Path, a.Path,oldA.Method,a.Method)
err = UpdateCasbinApi(oldA.Path, a.Path, oldA.Method, a.Method)
if err != nil {
return err
} else {

4
server/service/sys_authority.go

@ -60,9 +60,6 @@ func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, t
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB
if err != nil {
return
} else {
var authority []model.SysAuthority
err = db.Limit(limit).Offset(offset).Preload("DataAuthorityId").Where("parent_id = 0").Find(&authority).Error
if len(authority) > 0 {
@ -71,7 +68,6 @@ func GetAuthorityInfoList(info request.PageInfo) (err error, list interface{}, t
}
}
return err, authority, total
}
}
// @title GetAuthorityInfo

4
server/service/sys_menu.go

@ -46,16 +46,12 @@ func GetInfoList(info request.PageInfo) (err error, list interface{}, total int)
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB
if err != nil {
return
} else {
var menuList []model.SysBaseMenu
err = db.Limit(limit).Offset(offset).Where("parent_id = 0").Order("sort", true).Find(&menuList).Error
for i := 0; i < len(menuList); i++ {
err = getBaseChildrenList(&menuList[i])
}
return err, menuList, total
}
}
// @title getBaseChildrenList

4
server/service/sys_user.go

@ -71,13 +71,9 @@ func GetUserInfoList(info request.PageInfo) (err error, list interface{}, total
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB
if err != nil {
return
} else {
var userList []model.SysUser
err = db.Limit(limit).Offset(offset).Preload("Authority").Find(&userList).Error
return err, userList, total
}
}
// @title SetUserAuthority

Loading…
Cancel
Save