mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: fix organization pagination count error (#3215)
* fix(organization): ensure count includes shared organizations Adjust the `GetOrganizationCount` function to account for shared organizations by adding an additional parameter and modifying the count query accordingly. This change ensures that the organization count correctly reflects shared organizations within the system. * ```fix(organization): optimize GetOrganizationCount query Refactor the GetOrganizationCount function to use a more efficient search method by leveraging the 'is_shared' field directly in the query condition. This change improves the performance for counting organizations by avoiding unnecessary iteration over potentially large result sets. ``` --------- Co-authored-by: CuiJing <cuijing@tul.com.cn>
This commit is contained in:
parent
a330fbc11f
commit
0de4e7da38
@ -65,7 +65,7 @@ func (c *ApiController) GetOrganizations() {
|
||||
c.ResponseOk(organizations)
|
||||
} else {
|
||||
limit := util.ParseInt(limit)
|
||||
count, err := object.GetOrganizationCount(owner, field, value)
|
||||
count, err := object.GetOrganizationCount(owner, organizationName, field, value)
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
@ -138,7 +138,7 @@ func (c *ApiController) AddOrganization() {
|
||||
return
|
||||
}
|
||||
|
||||
count, err := object.GetOrganizationCount("", "", "")
|
||||
count, err := object.GetOrganizationCount("", "", "", "")
|
||||
if err != nil {
|
||||
c.ResponseError(err.Error())
|
||||
return
|
||||
|
@ -79,9 +79,9 @@ type Organization struct {
|
||||
AccountItems []*AccountItem `xorm:"varchar(5000)" json:"accountItems"`
|
||||
}
|
||||
|
||||
func GetOrganizationCount(owner, field, value string) (int64, error) {
|
||||
func GetOrganizationCount(owner, name, field, value string) (int64, error) {
|
||||
session := GetSession(owner, -1, -1, field, value, "", "")
|
||||
return session.Count(&Organization{})
|
||||
return session.Count(&Organization{Name: name})
|
||||
}
|
||||
|
||||
func GetOrganizations(owner string, name ...string) ([]*Organization, error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user