Angular Init
程序员文章站
2022-06-03 23:13:23
...
初始化angular项目
下载angular-cli
建立项目
注意这里文件名或者文件的名字无法使用下划线,只能使用横线 。
载入服务
浏览器打开http://localhost:4200看到消息Our app works则证明成功。
Angular Samples
https://ng-matero.github.io/ng-matero/auth/login
https://www.cnblogs.com/nzbin/p/11150811.html
https://github.com/ng-matero/ng-matero
### 6.1 Get User By ID
* Request
`https://<hosting>/v1/electric/getuser/<id>`
| Parameter | Description |
| ---- | ---- |
| id | User ID |
* Verb:
`GET`
* BODY:
`N/A`
* Responce
`Success case:`
```json
{
"status": "succeeded",
"data": {
"id": 1,
"name": "test1234",
"icon": "\\1.ico",
"birthday": "1999-01-01",
"role": "admin",
"password": "123456789",
"createddate": "2021-11-11 06:50:49",
"updateddate": "2021-11-11 06:54:56"
}
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.2 Get All Users
* Request
`https://<hosting>/v1/electric/getallusers`
* Verb:
`GET`
* BODY:
`N/A`
* Responce
`Success case:`
```json
{
"status": "succeeded",
"data": {
"users": [
{
"id": 1,
"name": "test1234",
"icon": "\\1.ico",
"birthday": "1999-01-01",
"role": "admin",
"password": "123456789",
"createddate": "2021-11-11 06:50:49",
"updateddate": "2021-11-11 06:54:56"
},
{
"id": 2,
"name": "test1234",
"icon": "\\1.ico",
"birthday": "1999-01-01",
"role": "admin",
"password": "123456789",
"createddate": "2021-11-11 06:48:17",
"updateddate": "2021-11-11 06:55:21"
}
]
}
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.3 Delete User By ID
* Request
`https://<hosting>/v1/electric/deleteuser/<id>`
| Parameter | Description |
| ---- | ---- |
| id | User ID |
* Verb:
`POST`
* BODY:
`N/A`
* Responce
`Success case:`
```json
{
"status": "succeeded",
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.4 Add User
* Request:
`https://<hosting>/v1/electric/adduser`
* Verb:
`DELETE`
* BODY:
```json
{
"id":"1",
"name":"test1234",
"icon":"1.ico",
"birthday":"1999-01-01",
"role":"admin",
"password":"123456789"
}
```
* Responce
`Success case:`
```json
{
"status": "succeeded",
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.5 Update User Information
* Request:
`https://<hosting>/v1/electric/updateuser`
* Verb:
`PATCH`
* BODY:
```json
{
"id":"1",
"name":"test1234",
"icon":"\\1.ico",
"birthday":"1999-01-01",
"role":"admin"
}
```
* Responce
`Success case:`
```json
{
"status": "succeeded",
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.6 Update User Password
* Request:
`https://<hosting>/v1/electric/updateuserpassword`
* Verb:
`PATCH`
* BODY:
```json
{
"id":"1",
"password":"1234567890123"
}
```
* Responce
`Success case:`
```json
{
"status": "succeeded",
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
下载angular-cli
npm install -g angular-cli
建立项目
ng new first-angular
注意这里文件名或者文件的名字无法使用下划线,只能使用横线 。
载入服务
cd first-angular ng serve
浏览器打开http://localhost:4200看到消息Our app works则证明成功。
Angular Samples
https://ng-matero.github.io/ng-matero/auth/login
https://www.cnblogs.com/nzbin/p/11150811.html
https://github.com/ng-matero/ng-matero
### 6.1 Get User By ID
* Request
`https://<hosting>/v1/electric/getuser/<id>`
| Parameter | Description |
| ---- | ---- |
| id | User ID |
* Verb:
`GET`
* BODY:
`N/A`
* Responce
`Success case:`
```json
{
"status": "succeeded",
"data": {
"id": 1,
"name": "test1234",
"icon": "\\1.ico",
"birthday": "1999-01-01",
"role": "admin",
"password": "123456789",
"createddate": "2021-11-11 06:50:49",
"updateddate": "2021-11-11 06:54:56"
}
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.2 Get All Users
* Request
`https://<hosting>/v1/electric/getallusers`
* Verb:
`GET`
* BODY:
`N/A`
* Responce
`Success case:`
```json
{
"status": "succeeded",
"data": {
"users": [
{
"id": 1,
"name": "test1234",
"icon": "\\1.ico",
"birthday": "1999-01-01",
"role": "admin",
"password": "123456789",
"createddate": "2021-11-11 06:50:49",
"updateddate": "2021-11-11 06:54:56"
},
{
"id": 2,
"name": "test1234",
"icon": "\\1.ico",
"birthday": "1999-01-01",
"role": "admin",
"password": "123456789",
"createddate": "2021-11-11 06:48:17",
"updateddate": "2021-11-11 06:55:21"
}
]
}
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.3 Delete User By ID
* Request
`https://<hosting>/v1/electric/deleteuser/<id>`
| Parameter | Description |
| ---- | ---- |
| id | User ID |
* Verb:
`POST`
* BODY:
`N/A`
* Responce
`Success case:`
```json
{
"status": "succeeded",
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.4 Add User
* Request:
`https://<hosting>/v1/electric/adduser`
* Verb:
`DELETE`
* BODY:
```json
{
"id":"1",
"name":"test1234",
"icon":"1.ico",
"birthday":"1999-01-01",
"role":"admin",
"password":"123456789"
}
```
* Responce
`Success case:`
```json
{
"status": "succeeded",
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.5 Update User Information
* Request:
`https://<hosting>/v1/electric/updateuser`
* Verb:
`PATCH`
* BODY:
```json
{
"id":"1",
"name":"test1234",
"icon":"\\1.ico",
"birthday":"1999-01-01",
"role":"admin"
}
```
* Responce
`Success case:`
```json
{
"status": "succeeded",
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
### 6.6 Update User Password
* Request:
`https://<hosting>/v1/electric/updateuserpassword`
* Verb:
`PATCH`
* BODY:
```json
{
"id":"1",
"password":"1234567890123"
}
```
* Responce
`Success case:`
```json
{
"status": "succeeded",
}
```
`Failure cases:`
```json
{
"status": "failed",
"error": "XXXX",
}
```
上一篇: Adobe 的开源之路