Created
November 23, 2022 07:34
-
-
Save wubin1989/497e0aa448b8e55c4aab5a0a961e7cad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (receiver *GoStatsImpl) LargestRemainder(ctx context.Context, payload vo.PercentageReqVo) (data []vo.PercentageRespVo, err error) { | |
if len(payload.Data) == 0 { | |
return | |
} | |
input := make([]numberutils.Percentage, 0) | |
for _, item := range payload.Data { | |
input = append(input, numberutils.Percentage{ | |
Value: item.Value, | |
Data: item.Key, | |
}) | |
} | |
numberutils.LargestRemainder(input, int32(payload.Places)) | |
for _, item := range input { | |
data = append(data, vo.PercentageRespVo{ | |
Value: item.Value, | |
Key: item.Data.(string), | |
Percent: item.Percent, | |
PercentFormatted: item.PercentFormatted, | |
}) | |
} | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment