diff --git a/code/base-project/base-go-v3/biz/handler/money_category/money_category_service.go b/code/base-project/base-go-v3/biz/handler/money_category/money_category_service.go index ddda0f61..724ebf96 100644 --- a/code/base-project/base-go-v3/biz/handler/money_category/money_category_service.go +++ b/code/base-project/base-go-v3/biz/handler/money_category/money_category_service.go @@ -52,3 +52,26 @@ func QueryUserMoneyCategory(ctx context.Context, c *app.RequestContext) { response.Success(c).Data(resp).Send() } + +// DeleteUserMoneyCategory . +// @router /money/category/delete [GET] +func DeleteUserMoneyCategory(ctx context.Context, c *app.RequestContext) { + var err error + var req money_category.DeleteUserMoneyCategoryReq + err = c.BindAndValidate(&req) + if err != nil { + c.String(consts.StatusBadRequest, err.Error()) + return + } + + err = db.Queries.DeleteUserMoneyCategoryById(ctx, req.Id) + + if err != nil { + errorx.AddError(c, err) + return + } + + resp := new(money_category.DeleteUserMoneyCategoryResp) + + response.Success(c).Data(resp).Send() +} diff --git a/code/base-project/base-go-v3/biz/model/money_category/money_category.pb.go b/code/base-project/base-go-v3/biz/model/money_category/money_category.pb.go index 0a73a237..f2675748 100644 --- a/code/base-project/base-go-v3/biz/model/money_category/money_category.pb.go +++ b/code/base-project/base-go-v3/biz/model/money_category/money_category.pb.go @@ -185,6 +185,91 @@ func (x *QueryUserMoneyCategoryResp) GetCategories() []*UserMoneyCategory { return nil } +type DeleteUserMoneyCategoryReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=Id,proto3" form:"id" json:"id" vd:"$!=''"` +} + +func (x *DeleteUserMoneyCategoryReq) Reset() { + *x = DeleteUserMoneyCategoryReq{} + if protoimpl.UnsafeEnabled { + mi := &file_money_category_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteUserMoneyCategoryReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUserMoneyCategoryReq) ProtoMessage() {} + +func (x *DeleteUserMoneyCategoryReq) ProtoReflect() protoreflect.Message { + mi := &file_money_category_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteUserMoneyCategoryReq.ProtoReflect.Descriptor instead. +func (*DeleteUserMoneyCategoryReq) Descriptor() ([]byte, []int) { + return file_money_category_proto_rawDescGZIP(), []int{3} +} + +func (x *DeleteUserMoneyCategoryReq) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type DeleteUserMoneyCategoryResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DeleteUserMoneyCategoryResp) Reset() { + *x = DeleteUserMoneyCategoryResp{} + if protoimpl.UnsafeEnabled { + mi := &file_money_category_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteUserMoneyCategoryResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUserMoneyCategoryResp) ProtoMessage() {} + +func (x *DeleteUserMoneyCategoryResp) ProtoReflect() protoreflect.Message { + mi := &file_money_category_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteUserMoneyCategoryResp.ProtoReflect.Descriptor instead. +func (*DeleteUserMoneyCategoryResp) Descriptor() ([]byte, []int) { + return file_money_category_proto_rawDescGZIP(), []int{4} +} + var File_money_category_proto protoreflect.FileDescriptor var file_money_category_proto_rawDesc = []byte{ @@ -207,20 +292,35 @@ var file_money_category_proto_rawDesc = []byte{ 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x0a, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x69, - 0x65, 0x73, 0x32, 0x9d, 0x01, 0x0a, 0x14, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, - 0x67, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x84, 0x01, 0x0a, 0x16, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, - 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x29, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x63, - 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, - 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, - 0x71, 0x1a, 0x2a, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, - 0x72, 0x79, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x65, - 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x13, 0xca, - 0xc1, 0x18, 0x0f, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, - 0x72, 0x79, 0x42, 0x2b, 0x5a, 0x29, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, - 0x61, 0x73, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, - 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x22, 0x3d, 0x0a, 0x1a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, + 0x12, 0x1f, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x0f, 0xca, 0xbb, + 0x18, 0x02, 0x69, 0x64, 0xda, 0xbb, 0x18, 0x05, 0x24, 0x21, 0x3d, 0x27, 0x27, 0x52, 0x02, 0x49, + 0x64, 0x22, 0x1d, 0x0a, 0x1b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4d, + 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, + 0x32, 0xae, 0x02, 0x0a, 0x14, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, + 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x84, 0x01, 0x0a, 0x16, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, + 0x67, 0x6f, 0x72, 0x79, 0x12, 0x29, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x63, 0x61, 0x74, + 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x4d, + 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, + 0x2a, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, + 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x13, 0xca, 0xc1, 0x18, + 0x0f, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, + 0x12, 0x8e, 0x01, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4d, + 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x2a, 0x2e, 0x6d, + 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, + 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x2b, 0x2e, 0x6d, 0x6f, 0x6e, 0x65, 0x79, + 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, + 0x79, 0x52, 0x65, 0x73, 0x70, 0x22, 0x1a, 0xca, 0xc1, 0x18, 0x16, 0x2f, 0x6d, 0x6f, 0x6e, 0x65, + 0x79, 0x2f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x2f, 0x64, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x42, 0x2b, 0x5a, 0x29, 0x63, 0x6e, 0x2f, 0x6f, 0x6e, 0x65, 0x61, 0x6f, 0x2f, 0x62, 0x61, + 0x73, 0x65, 0x2d, 0x67, 0x6f, 0x2f, 0x62, 0x69, 0x7a, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, + 0x6d, 0x6f, 0x6e, 0x65, 0x79, 0x5f, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -235,18 +335,22 @@ func file_money_category_proto_rawDescGZIP() []byte { return file_money_category_proto_rawDescData } -var file_money_category_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_money_category_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_money_category_proto_goTypes = []interface{}{ - (*QueryUserMoneyCategoryReq)(nil), // 0: money_category.QueryUserMoneyCategoryReq - (*UserMoneyCategory)(nil), // 1: money_category.UserMoneyCategory - (*QueryUserMoneyCategoryResp)(nil), // 2: money_category.QueryUserMoneyCategoryResp + (*QueryUserMoneyCategoryReq)(nil), // 0: money_category.QueryUserMoneyCategoryReq + (*UserMoneyCategory)(nil), // 1: money_category.UserMoneyCategory + (*QueryUserMoneyCategoryResp)(nil), // 2: money_category.QueryUserMoneyCategoryResp + (*DeleteUserMoneyCategoryReq)(nil), // 3: money_category.DeleteUserMoneyCategoryReq + (*DeleteUserMoneyCategoryResp)(nil), // 4: money_category.DeleteUserMoneyCategoryResp } var file_money_category_proto_depIdxs = []int32{ 1, // 0: money_category.QueryUserMoneyCategoryResp.categories:type_name -> money_category.UserMoneyCategory 0, // 1: money_category.MoneyCategoryService.QueryUserMoneyCategory:input_type -> money_category.QueryUserMoneyCategoryReq - 2, // 2: money_category.MoneyCategoryService.QueryUserMoneyCategory:output_type -> money_category.QueryUserMoneyCategoryResp - 2, // [2:3] is the sub-list for method output_type - 1, // [1:2] is the sub-list for method input_type + 3, // 2: money_category.MoneyCategoryService.DeleteUserMoneyCategory:input_type -> money_category.DeleteUserMoneyCategoryReq + 2, // 3: money_category.MoneyCategoryService.QueryUserMoneyCategory:output_type -> money_category.QueryUserMoneyCategoryResp + 4, // 4: money_category.MoneyCategoryService.DeleteUserMoneyCategory:output_type -> money_category.DeleteUserMoneyCategoryResp + 3, // [3:5] is the sub-list for method output_type + 1, // [1:3] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -294,6 +398,30 @@ func file_money_category_proto_init() { return nil } } + file_money_category_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteUserMoneyCategoryReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_money_category_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteUserMoneyCategoryResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -301,7 +429,7 @@ func file_money_category_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_money_category_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/code/base-project/base-go-v3/biz/router/money_category/middleware.go b/code/base-project/base-go-v3/biz/router/money_category/middleware.go index f4a92cf0..a2b83050 100644 --- a/code/base-project/base-go-v3/biz/router/money_category/middleware.go +++ b/code/base-project/base-go-v3/biz/router/money_category/middleware.go @@ -25,3 +25,8 @@ func _queryusermoneycategoryMw() []app.HandlerFunc { // your code... return nil } + +func _deleteusermoneycategoryMw() []app.HandlerFunc { + // your code... + return nil +} diff --git a/code/base-project/base-go-v3/biz/router/money_category/money_category.go b/code/base-project/base-go-v3/biz/router/money_category/money_category.go index 60accc04..88852833 100644 --- a/code/base-project/base-go-v3/biz/router/money_category/money_category.go +++ b/code/base-project/base-go-v3/biz/router/money_category/money_category.go @@ -20,5 +20,7 @@ func Register(r *server.Hertz) { { _money := root.Group("/money", _moneyMw()...) _money.GET("/category", append(_queryusermoneycategoryMw(), money_category.QueryUserMoneyCategory)...) + _category := _money.Group("/category", _categoryMw()...) + _category.GET("/delete", append(_deleteusermoneycategoryMw(), money_category.DeleteUserMoneyCategory)...) } } diff --git a/code/base-project/base-go-v3/conf/dev/conf.yaml b/code/base-project/base-go-v3/conf/dev/conf.yaml index b193b217..38516cfd 100644 --- a/code/base-project/base-go-v3/conf/dev/conf.yaml +++ b/code/base-project/base-go-v3/conf/dev/conf.yaml @@ -4,8 +4,8 @@ server: jwt: secret: 3Bde3BGEbYqtqyEUzW3ry8jKFcaPH17fRmTmqE7MDr05Lwj95uruRKrrkb44TJ4s - access_expiry: 720h - refresh_expiry: 720h + access_expiry: -1 + refresh_expiry: -1 snowflake: datacenter_id: 1 diff --git a/code/base-project/base-go-v3/db/queries/money_user_category.sql b/code/base-project/base-go-v3/db/queries/money_user_category.sql index 582da908..7cd22e13 100644 --- a/code/base-project/base-go-v3/db/queries/money_user_category.sql +++ b/code/base-project/base-go-v3/db/queries/money_user_category.sql @@ -6,3 +6,7 @@ VALUES ($1, $2, $3, $4, $5, $6); SELECT * FROM money_user_category WHERE user_id = $1; + +-- name: DeleteUserMoneyCategoryById :exec +DELETE FROM money_user_category +WHERE id = $1; diff --git a/code/base-project/base-go-v3/db/sqlc/money_user_category.sql.go b/code/base-project/base-go-v3/db/sqlc/money_user_category.sql.go index 06d9a362..884a9a56 100644 --- a/code/base-project/base-go-v3/db/sqlc/money_user_category.sql.go +++ b/code/base-project/base-go-v3/db/sqlc/money_user_category.sql.go @@ -20,6 +20,16 @@ type BatchInsertMoneyUserCategoriesParams struct { SortNumber pgtype.Int4 } +const deleteUserMoneyCategoryById = `-- name: DeleteUserMoneyCategoryById :exec +DELETE FROM money_user_category +WHERE id = $1 +` + +func (q *Queries) DeleteUserMoneyCategoryById(ctx context.Context, id int64) error { + _, err := q.db.Exec(ctx, deleteUserMoneyCategoryById, id) + return err +} + const findUserMoneyCategoriesByUserID = `-- name: FindUserMoneyCategoriesByUserID :many SELECT id, user_id, name, icon, type, sort_number, create_time FROM money_user_category diff --git a/code/base-project/base-go-v3/idl/money_category.proto b/code/base-project/base-go-v3/idl/money_category.proto index 39211941..388e2838 100644 --- a/code/base-project/base-go-v3/idl/money_category.proto +++ b/code/base-project/base-go-v3/idl/money_category.proto @@ -20,8 +20,20 @@ message UserMoneyCategory { message QueryUserMoneyCategoryResp { repeated UserMoneyCategory categories = 1; } + +message DeleteUserMoneyCategoryReq{ + int64 Id = 1[(api.body)="id",(api.vd)="$!=''"]; +} + +message DeleteUserMoneyCategoryResp { +} + service MoneyCategoryService { rpc QueryUserMoneyCategory(QueryUserMoneyCategoryReq) returns (QueryUserMoneyCategoryResp){ option (api.get) = '/money/category'; }; -} \ No newline at end of file + rpc DeleteUserMoneyCategory(DeleteUserMoneyCategoryReq) returns (DeleteUserMoneyCategoryResp){ + option (api.get) = '/money/category/delete'; + }; +} +