|
@@ -6,6 +6,7 @@ import (
|
|
|
"fmt"
|
|
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
|
+ "go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
)
|
|
|
|
|
|
func incrementer(ctx *ApiSession, typeName string) (serial string, err error) {
|
|
@@ -34,3 +35,16 @@ func incrementer(ctx *ApiSession, typeName string) (serial string, err error) {
|
|
|
return fmt.Sprintf("%s-%05d", cate.LetterName, index), nil
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+func SearchBillTypeById(ctx *ApiSession, collectName string, id primitive.ObjectID) (string, error) {
|
|
|
+ found, curbill := repo.RepoSeachDocMap(ctx.CreateRepoCtx(), &repo.DocSearchOptions{
|
|
|
+ CollectName: collectName,
|
|
|
+ Project: []string{"type"},
|
|
|
+ Query: repo.Map{"_id": id},
|
|
|
+ Sort: bson.M{"_id": -1},
|
|
|
+ })
|
|
|
+ if !found {
|
|
|
+ return "", fmt.Errorf("未找到该分类")
|
|
|
+ }
|
|
|
+ return curbill["type"].(string), nil
|
|
|
+}
|