{"id":21178714,"url":"https://github.com/poabob/go-pano","last_synced_at":"2025-03-14T18:43:34.979Z","repository":{"id":102352454,"uuid":"563690975","full_name":"POABOB/go-pano","owner":"POABOB","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-06T00:58:04.000Z","size":31198,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T11:45:15.110Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/POABOB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-09T05:56:42.000Z","updated_at":"2022-11-09T05:58:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"0836343d-4a53-4f0b-ab06-6db6d18a327b","html_url":"https://github.com/POABOB/go-pano","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/POABOB%2Fgo-pano","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/POABOB%2Fgo-pano/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/POABOB%2Fgo-pano/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/POABOB%2Fgo-pano/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/POABOB","download_url":"https://codeload.github.com/POABOB/go-pano/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243629222,"owners_count":20322017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T17:23:33.029Z","updated_at":"2025-03-14T18:43:34.972Z","avatar_url":"https://github.com/POABOB.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gin-Framework\n\n## Dev Configuration\n\n### Run Docker Service\n\n```\ndocker-compose up\n```\n\n## SQL init\n\nIf you are the first time starting this project, just use below sql commands to login.\n\n```sql\nINSERT INTO `Users` (`user_id`, `name`, `account`, `password`, `roles_string`, `status`) VALUES\n(1, 'ADMIN', '__pano_admin__', '$2a$10$94v4wlp6ZRanI6Xv1k4hyePZJlTJf.o08fSUqPby/mABlGGgRiRAa', '[\\\"admin\\\"]', 1);\nINSERT INTO `Clinic` (`clinic_id`, `name`, `start_at`, `end_at`, `quota_per_month`, `token`) VALUES\n(1, '測試診所', '2022-10-10', '2099-12-31', 200, 'rHsxKe6qPxxoZJh2oPJPk2mVzNFB5XmfOnkLpCwvbhnOnbU9i3');\n```\n\n\n## Prod Configuration\n\n### 1. Copy config.yml to config-prod.yml \u0026 change the dsn, mode of mysql\n\n```yml\nserver:\n  version: v0.1\n  addr: :80\n  mode: prod\n  static_dir: ./static\n  public_dir: ./public\n  # view_dir: ./view\n  # upload_dir: ./storage\n  max_multipart_memory: 50\n\npython:\n  dev_host: 127.0.0.1\n  test_host: 127.0.0.1\n  prod_host: pano-python\n\ndatabase-in-docker:\n  dialect: mysql\n  datasource: \u003cuser\u003e:\u003cpassword\u003e@tcp(mysql:3306)/pano?charset=utf8mb4\u0026timeout=10s\u0026parseTime=True\n  dir: migrations\n  table: migrations\n  max_idle_conns: 2\n  max_open_conns: 16\n\ndatabase:\n  dialect: mysql\n  datasource: \u003cuser\u003e:\u003cpassword\u003e@tcp(mysql:3306)/pano?charset=utf8mb4\u0026timeout=10s\u0026parseTime=True\n  dir: migrations\n  table: migrations\n  max_idle_conns: 2\n  max_open_conns: 16\n```\n\n\n### 2. Copy docker-compose.yml to Copy docker-compose-prod.yml, change the config of mysql, and chang the target of pano-go service.\n\n```yml\nversion: \"3\"\nservices:\n  pano-python:\n    image: poabob/pano-python:prod-1.0.0\n    build: ./dist/python\n    container_name: pano-python\n    volumes:\n      - ./dist/static:/app/go/static\n    ports:\n      - 5001:5001\n  pano-go:\n    image: poabob/pano-go:prod-1.0.0\n    build: \n      context: .\n      dockerfile: Dockerfile\n      target: prod\n    container_name: pano-go\n    volumes:\n      - ./dist/log:/app/go/log\n      - ./dist/static:/app/go/static\n      - ./dist/public:/app/go/public\n    depends_on:\n      - mysql\n    ports:\n      - 80:80\n  mysql:\n    image: mariadb:10.9\n    container_name: mysql\n    restart: always\n    environment:\n      MYSQL_DATABASE: \"\u003cDB\u003e\"\n      MYSQL_USER: \"\u003cuser\u003e\"\n      MYSQL_PASSWORD: \"\u003cpassword\u003e\"\n      MYSQL_RANDOM_ROOT_PASSWORD: true\n    ports:\n      - \"3306:3306\"\n    volumes:\n      - ./dist/mysql:/var/lib/mysql\n```\n\n### 3. Start the service\n\n```\ndocker-compose -f docker-compose-prod.yml up\n```\n\n\n## Generate swag document\n\nAll comments were written in router/router.go, so you need to find the path.\n\n```\n# In Docker\ndocker exec pano-go swag init -g ./router/router_v1.go -o ./docs\n\n# In real mechine\nswag init -g ./router/router_v1.go -o ./docs\n```\n\n## Generate wire service\n\n1. Edit `router/wire.go` and write the initialization of dependency injections.\n\n* Example\n```go\n//go:build wireinject\n// +build wireinject\n\npackage router_v1\n\nimport (\n\t\"github.com/google/wire\"\n\n\tclinic_repository \"go-pano/domain/repository/clinic\"\n\n\tclinic_service \"go-pano/domain/service/clinic\"\n\t\"go-pano/utils\"\n)\n\nfunc initClinicService() clinic_service.IClinicService {\n\twire.Build(\n\t\tclinic_service.NewClinicService,\n\t\tclinic_repository.NewClinicRepository,\n\t\tutils.NewDBInstance,\n\t)\n\treturn nil\n}\n```\n\n2. When you added the relationship of each class, run command `wire \u003crelative_path\u003e.`.\n\n```bash\n# In Docker\ndocker exec pano-go wire ./router/.\n\n# In real mechine\nwire ./router/.\n```\n\n3. Add the functions of dependency injections where you want.\n\n```go\npackage router_v1\n\nimport (\n\t\"github.com/gin-gonic/gin\"\n\t\"go-pano/domain/delivery/http\"\n)\n\nfunc NewRouter(app *gin.Engine) {\n\n\tapi := app.Group(\"/api\")\n\t{\n\t\t// After\n\t\thttp.NewClinicHandler(api, initClinicService())\n\n        // Before\n        // cr := clinic_repository.NewClinicRepository(db)\n\t\t// cs := clinic_service.NewClinicService(cr)\n\t\t// http.NewClinicHandler(api, cs)\n\n\t}\n\n}\n\n```\n\n## Use Protocol Buffers\n\nGenerate all pb files.\n\n```\n# In Docker\ndocker exec pano-go protoc ./protos/*/*.proto  --go_out=plugins=grpc:. --go_opt=paths=source_relative\n\n# In real mechine\nprotoc ./protos/*/*.proto  --go_out=plugins=grpc:. --go_opt=paths=source_relative\n```\n\n## Furture Table\n\n```sql\nCREATE TABLE IF NOT EXISTS `Record` (\n  `record_id` int PRIMARY KEY AUTO_INCREMENT COMMENT '紀錄ID',\n  `clinic_id` int DEFAULT 0 COMMENT '診所ID',\n  `predict_id` int DEFAULT 0 COMMENT '預測ID',\n  `score` int NOT NULL DEFAULT 80 COMMENT '準確度',\n  `comment` varchar(1024) NOT NULL DEFAULT \"\" COMMENT '準確度評論'\n)ENGINE = InnoDB DEFAULT CHARSET=utf8mb4;\n```\n\n## TODO\n\n- Write down the real process\n- Finish Predict Unit Tests\n- User RBAC control\n- Clinic Token Request\n- Record API\n  - services used per month every clinic\n  - services score list","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoabob%2Fgo-pano","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoabob%2Fgo-pano","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoabob%2Fgo-pano/lists"}