Skip to content

Commit

Permalink
refact(model): seperate model with differentschema
Browse files Browse the repository at this point in the history
  • Loading branch information
Matrix-X committed Oct 9, 2024
1 parent ac3d672 commit 153a0be
Show file tree
Hide file tree
Showing 25 changed files with 236 additions and 137 deletions.
2 changes: 1 addition & 1 deletion api/admin/department.api
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type (
type (
CreateDepartmentRequest {
DepName string `json:"depName"`
LeaderId int64 `json:"leaderId"`
LeaderUuid string `json:"leaderUuid"`
PId int64 `json:"pId"`
Desc string `json:"desc,optional"`
PhoneNumber string `json:"phoneNumber,optional"`
Expand Down
16 changes: 8 additions & 8 deletions api/admin/user.api
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ service PowerX {

@doc "查询员工"
@handler GetUser
get /users/:id (GetUserRequest) returns (GetUserReply)
get /users/:uuid (GetUserRequest) returns (GetUserReply)

@doc "List员工"
@handler ListUsers
Expand All @@ -33,11 +33,11 @@ service PowerX {

@doc "编辑员工信息"
@handler UpdateUser
patch /users/:id (UpdateUserRequest) returns (UpdateUserReply)
patch /users/:uuid (UpdateUserRequest) returns (UpdateUserReply)

@doc "删除员工"
@handler DeleteUser
delete /users/:id (DeleteUserRequest) returns (DeleteUserReply)
delete /users/:uuid (DeleteUserRequest) returns (DeleteUserReply)

@doc "重设密码"
@handler ResetPassword
Expand All @@ -46,7 +46,7 @@ service PowerX {

type (
GetUserRequest {
Id int64 `path:"id"`
Uuid string `path:"uuid"`
}

GetUserReply {
Expand Down Expand Up @@ -136,7 +136,7 @@ type (

type (
UpdateUserRequest {
Id int64 `path:"id"`
Uuid string `path:"uuid"`
Name string `json:"name,optional"`
NickName string `json:"nickName,optional"`
Desc string `json:"desc,optional"`
Expand All @@ -159,17 +159,17 @@ type (

type (
DeleteUserRequest {
Id int64 `path:"id"`
Uuid string `path:"uuid"`
}

DeleteUserReply {
Id int64 `json:"id"`
Uuid string `json:"uuid"`
}
)

type (
ResetPasswordRequest {
UserId int64 `json:"userId"`
UserUuid string `json:"userUuid"`
}

ResetPasswordReply {
Expand Down
40 changes: 40 additions & 0 deletions api/openapi/provider/brainx/demo.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
syntax = "v1"

info(
title: "Provider Demo Open API of BrainX"
desc: "This is a api of Open API in Artisan Cloud"
author: "Matrix-X"
email: "[email protected]"
version: "v1"
)

@server(
group: openapi/provider/brainx
prefix: /openapi/v1/provider/brainx
middleware: OpenAPIJWTAuth
)

service PowerX {
@doc "hello world api for provider demo"
@handler HelloWorld
get /hello-world returns (HelloWorldResponse)

@doc "timeout api for provider demo"
@handler EchoLongTime
post /echo-long-time (EchoLongTimeRequest) returns (EchoLongTimeResponse)
}



type (
HelloWorldResponse {
Message string `json:"message"`
}

EchoLongTimeRequest {
Timeout int `json:"timeout"`
}
EchoLongTimeResponse {
Message string `json:"message"`
}
)
9 changes: 9 additions & 0 deletions cmd/ctl/database/seed/mediaresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package seed
import (
"PowerX/internal/config"
"PowerX/internal/model/media"
"PowerX/internal/model/powermodel"
"PowerX/internal/uc/powerx"
"PowerX/pkg/httpx"
"PowerX/pkg/securityx"
"PowerX/pkg/slicex"
"fmt"
"github.com/pkg/errors"
Expand Down Expand Up @@ -37,6 +39,7 @@ func DefaultMediaResource(db *gorm.DB, conf *config.Config) (data []*media.Media
path := path2.Join(powerx.DefaultStoragePath, "shop")
coverImage := ProductCoverImage(ucMediaResource.LocalStorageUrl, path)
detailImages := ProductDetailImages(ucMediaResource.LocalStorageUrl, path)
//fmt2.Dump(coverImage, detailImages)

data = slicex.Concatenate(data, coverImage, detailImages)
return data
Expand All @@ -46,6 +49,9 @@ func ProductCoverImage(url string, name string) []*media.MediaResource {
imageUrl, _ := httpx.AppendURIs(url, fmt.Sprintf("%s/0.png", name))
return []*media.MediaResource{
{
PowerUUIDModel: powermodel.PowerUUIDModel{
UUID: securityx.GenerateUUID(),
},
Url: imageUrl,
IsLocalStored: true,
},
Expand All @@ -58,6 +64,9 @@ func ProductDetailImages(url string, path string) []*media.MediaResource {
imageUrl, _ := httpx.AppendURIs(url, path, fmt.Sprintf("%d.png", i+1))

urls = append(urls, &media.MediaResource{
PowerUUIDModel: powermodel.PowerUUIDModel{
UUID: securityx.GenerateUUID(),
},
Url: imageUrl,
IsLocalStored: true,
})
Expand Down
Loading

0 comments on commit 153a0be

Please sign in to comment.