Maily used Golang,MySQL(mariadb),docker. web Framework used beego mainly for it's orm and cookie functions.
I'v deployed the service on myself vps.Hereis the address which reverse proxied by nginx. [Test data](#test data) see below.
For time reason, only achieve basic functions and lot's optimizes like code and deploy automatic things had not done.Monitor only have nginx access log not deployed,Here just talk about what I think should do according to my work now.
About monitors it's very import .Should have nginx and framework‘s access log, error log and analasis by kibana. And the alert system,maily used Promithues and Grapfana, monitor services collection api accessible, system's CPU usage,memory usage,io latency and others indicators.
| account/phone_no | password | confirm pin |
|---|---|---|
| 123 | 123 | 123 |
| 234 | 111 | 123 |
Docker
-
go to
scripts/mysql_servicesmake DEPLOYdeploy mysql service.- after service deployed( port 3306 started), run
make CREATE_DATABASE. make CREATE_TABLEmake SOURCE_DATAto source test data.
-
go to root directory.
make INSTALLcreate service image.make RUN_SERVICE, service port 9099.
-
user table
id phone_no name password salt balance transter_pin create_date primary_key user unique id user name password password salt balance amount transter confirm pin -
transcation table
| id | no | from_user | to_user | amount | request_date | confirm_date | status |
|---|---|---|---|---|---|---|---|
| random 64 characters strings | user_no | user_no | amout | datetime |
status1: created; 2: confirmed
| value | meaning |
|---|---|
| 1 | got |
| 2 | sent |
| value | meaning | description |
|---|---|---|
| 0 | success | |
| 1001 | user not exists | value start with 1 relates to user logins |
| 1002 | error password | |
| 1003 | account not exists | query by other user check receiver whether exists |
| 1004 | need login | |
| 2001 | cannot find receiver account | values starts with 2 relates to transter transcation errors |
| 2002 | balance not enough |
-
/user/loginparams:
-
phone: user login no。mostly phone no or other unique IDs.
-
password
return:
{ "status": 0, // 0 success. other error code. "body": { "user_info": { "transcation_no": "", "name": "userNname", "balance": "12.30" } } } -
-
/user/get_account_introcheck account whether exists. If exists, return the user base info with publish format.
-
/transaction/listget transaction history
params:
page: optional, default 1. from 1.psize: optional, default 10.transcation_type: [reference type defines](transcation type defines) optional, default 0.time_range_start:future implementestime_range_end:future implementesuser_info: future implementes
return:
{ "status": 0, // 0 is success. other is error code. "body": { "total": 88, // total transcation count "page": 3, // current page "psize": 10, // current page size "transcation_list": [ { "transcation_no": "ajixiyasx", "user_name": "user_name1", // transaction user "transcation_type": 1, // ref transaction type defines below "amount": 20.30 // transter amount }, { "transcation_no": "joijoijioa", "user_name": "user_name2", // transaction user "transcation_type": 1, // ref transaction type defines below "amount": 20.30 // transter amount }, ] } } -
/transcation/detailget specify transcation
-
/transaction/create_orderparams:
-
to_user -
amount
return
{ "status": 0, // success. error defines: ref error code "transcation_no": "jijijoaijixea" // encoded transcation id. } -
-
/transcation/confimparams:
tranfer_passworduser setted transfer pin. future can be sms or email.transcation_no
return
{ "status": 0, // success. error defines: ref error code "transcation_no": "jijijoaijixea" // encoded transcation id. } -
/transcation/cancelparamstranscation_no:
return
{ "status": 0, //success. error defines: ref error code "transcation_no": "jijijoaijixea" // "encoded transcation id." }



