Skip to content

这是一个用ARP4G开发的简单的通讯录,用于给应用开发者演示ARP4G的功能

License

Notifications You must be signed in to change notification settings

framework-erp/ARP4G-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ARP4G-example

这是一个用ARP4G开发的简单的通讯录,用于给应用开发者演示ARP4G的功能。

安装

  1. 首先需要 Go 已安装(1.18及以上版本),和MongoDB,然后可以用以下命令安装ARP4G-example。
git clone https://github.com/framework-arp/ARP4G-example.git
  1. 运行ARP4G-example
cd ARP4G-example/cmd
go run main.go

这会启动一个HTTP服务在8080端口,看见以下提示说明启动成功:

[GIN-debug] Listening and serving HTTP on :8080
  1. 功能验证

在浏览器输入:

http://127.0.0.1:8080/addressbook/addcontact?name=neo&phone=12346

你将看到返回的JSON:

{
	"data": {
		"Id": 1586935438273155072,
		"Name": "neo",
		"PhoneNumber": "12346",
		"GroupId": 0
	},
	"success": true
}

你新添加了一个联系人。

想要运行更多的功能接口请查阅代码gin 路由

建议从参考代码的角度,AddressBookService中的service定义是一个更好的入口:

//通讯录的服务
type AddressBookService interface {
	//添加联系人
	AddContact(ctx context.Context, contactName string, phoneNumber string) (*aggregate.Contact, error)
	//删除联系人
	RemoveContact(ctx context.Context, contactId int64) error
	//把联系人放入组
	PutContactInGroup(ctx context.Context, contactId int64, groupId int64) (*aggregate.Contact, error)
	//添加组
	AddGroup(ctx context.Context, groupName string) (*aggregate.Group, error)
	//删除组,该组的联系人不会被删除
	RemoveGroup(ctx context.Context, groupId int64) error
	//获得所有的组
	GetGroups(ctx context.Context) ([]*aggregate.Group, error)
	//获得一个组的所有联系人
	GetContactsForGroup(ctx context.Context, groupId int64) ([]*aggregate.Contact, error)
	//获得不在任何组的所有联系人,这些联系人通常会在客户端被包装成一个“朋友”组
	GetContactsNotInGroup(ctx context.Context) ([]*aggregate.Contact, error)
	//模糊查询名字中包含特定文字的所有联系人
	QueryContacts(ctx context.Context, contains string) ([]*aggregate.Contact, error)
	FindContactById(ctx context.Context, contactId int64) (*aggregate.Contact, error)
}

Releases

No releases published

Packages

No packages published

Languages