diff --git a/server/api/v1/exa_customer.go b/server/api/v1/exa_customer.go index 8659b779..72e3f13f 100644 --- a/server/api/v1/exa_customer.go +++ b/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, diff --git a/server/service/exa_customer.go b/server/service/exa_customer.go index 2f8baec7..97ad4bc2 100644 --- a/server/service/exa_customer.go +++ b/server/service/exa_customer.go @@ -52,23 +52,19 @@ func GetCustomerInfoList(sysUserAuthorityID string, info request.PageInfo) (err limit := info.PageSize offset := info.PageSize * (info.Page - 1) db := global.GVA_DB + var a model.SysAuthority + a.AuthorityId = sysUserAuthorityID + err, auth := GetAuthorityInfo(a) + var dataId []string + for _, v := range auth.DataAuthorityId { + dataId = append(dataId, v.AuthorityId) + } + var CustomerList []model.ExaCustomer + err = db.Where("sys_user_authority_id in (?)", dataId).Find(&CustomerList).Count(&total).Error if err != nil { - return - } else { - var a model.SysAuthority - a.AuthorityId = sysUserAuthorityID - err, auth := GetAuthorityInfo(a) - var dataId []string - for _, v := range auth.DataAuthorityId { - dataId = append(dataId, v.AuthorityId) - } - var CustomerList []model.ExaCustomer - err = db.Where("sys_user_authority_id in (?)", dataId).Find(&CustomerList).Count(&total).Error - if err != nil { - return err, CustomerList, total - } else { - err = db.Limit(limit).Offset(offset).Preload("SysUser").Where("sys_user_authority_id in (?)", dataId).Find(&CustomerList).Error - } return err, CustomerList, total + } else { + err = db.Limit(limit).Offset(offset).Preload("SysUser").Where("sys_user_authority_id in (?)", dataId).Find(&CustomerList).Error } + return err, CustomerList, total } diff --git a/server/service/exa_file_upload_download.go b/server/service/exa_file_upload_download.go index e56953b4..69512d86 100644 --- a/server/service/exa_file_upload_download.go +++ b/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 - } + var fileLists []model.ExaFileUploadAndDownload + err = db.Limit(limit).Offset(offset).Order("updated_at desc").Find(&fileLists).Error + return err, fileLists, total } diff --git a/server/service/sys_api.go b/server/service/sys_api.go index 6d0a8726..1c1d5a37 100644 --- a/server/service/sys_api.go +++ b/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,44 +45,39 @@ 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 + var apiList []model.SysApi - if err != nil { - return - } else { - var apiList []model.SysApi - - if a.Path != "" { - db = db.Where("path LIKE ?", "%"+a.Path+"%") - } + if a.Path != "" { + db = db.Where("path LIKE ?", "%"+a.Path+"%") + } - if a.Description != "" { - db = db.Where("description LIKE ?", "%"+a.Description+"%") - } + if a.Description != "" { + db = db.Where("description LIKE ?", "%"+a.Description+"%") + } - if a.Method != "" { - db = db.Where("method = ?", a.Method) - } + if a.Method != "" { + db = db.Where("method = ?", a.Method) + } - err = db.Find(&apiList).Count(&total).Error + err = db.Find(&apiList).Count(&total).Error - if err != nil { - return err, apiList, total - } else { - db = db.Limit(limit).Offset(offset) - if Order != "" { - var OrderStr string - if Desc { - OrderStr = Order + " desc" - } else { - OrderStr = Order - } - err = db.Order(OrderStr, true).Find(&apiList).Error + if err != nil { + return err, apiList, total + } else { + db = db.Limit(limit).Offset(offset) + if Order != "" { + var OrderStr string + if Desc { + OrderStr = Order + " desc" } else { - err = db.Order("api_group", true).Find(&apiList).Error + OrderStr = Order } + err = db.Order(OrderStr, true).Find(&apiList).Error + } else { + err = db.Order("api_group", true).Find(&apiList).Error } - return err, apiList, total } + 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 { diff --git a/server/service/sys_authority.go b/server/service/sys_authority.go index 49e8f3d3..90ab2525 100644 --- a/server/service/sys_authority.go +++ b/server/service/sys_authority.go @@ -60,18 +60,14 @@ 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 { - for k, _ := range authority { - err = findChildrenAuthority(&authority[k]) - } + var authority []model.SysAuthority + err = db.Limit(limit).Offset(offset).Preload("DataAuthorityId").Where("parent_id = 0").Find(&authority).Error + if len(authority) > 0 { + for k, _ := range authority { + err = findChildrenAuthority(&authority[k]) } - return err, authority, total } + return err, authority, total } // @title GetAuthorityInfo diff --git a/server/service/sys_menu.go b/server/service/sys_menu.go index 0e1b8e5c..d4a0c739 100644 --- a/server/service/sys_menu.go +++ b/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 + 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 diff --git a/server/service/sys_user.go b/server/service/sys_user.go index f526aad2..a8e63cf9 100644 --- a/server/service/sys_user.go +++ b/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 - } + var userList []model.SysUser + err = db.Limit(limit).Offset(offset).Preload("Authority").Find(&userList).Error + return err, userList, total } // @title SetUserAuthority