├── .chglog ├── CHANGELOG.tpl.md └── config.yml ├── .dockerignore ├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile-api ├── Dockerfile-rpc ├── LICENSE ├── Makefile ├── README.En.md ├── README.md ├── api ├── core.go ├── desc │ ├── all.api │ ├── base.api │ ├── core │ │ ├── api.api │ │ ├── authority.api │ │ ├── captcha.api │ │ ├── configuration.api │ │ ├── department.api │ │ ├── dictionary.api │ │ ├── dictionary_detail.api │ │ ├── menu.api │ │ ├── oauth_provider.api │ │ ├── position.api │ │ ├── role.api │ │ ├── token.api │ │ └── user.api │ ├── job │ │ ├── task.api │ │ └── task_log.api │ └── mcms │ │ ├── email.api │ │ ├── email_log.api │ │ ├── email_provider.api │ │ ├── sms.api │ │ ├── sms_log.api │ │ └── sms_provider.api ├── etc │ └── core.yaml └── internal │ ├── config │ └── config.go │ ├── handler │ ├── api │ │ ├── create_api_handler.go │ │ ├── delete_api_handler.go │ │ ├── get_api_by_id_handler.go │ │ ├── get_api_list_handler.go │ │ └── update_api_handler.go │ ├── authority │ │ ├── create_or_update_api_authority_handler.go │ │ ├── create_or_update_menu_authority_handler.go │ │ ├── get_api_authority_handler.go │ │ └── get_menu_authority_handler.go │ ├── base │ │ ├── init_database_handler.go │ │ ├── init_job_database_handler.go │ │ └── init_mcms_database_handler.go │ ├── captcha │ │ ├── get_captcha_handler.go │ │ ├── get_email_captcha_handler.go │ │ └── get_sms_captcha_handler.go │ ├── configuration │ │ ├── create_configuration_handler.go │ │ ├── delete_configuration_handler.go │ │ ├── get_configuration_by_id_handler.go │ │ ├── get_configuration_list_handler.go │ │ └── update_configuration_handler.go │ ├── department │ │ ├── create_department_handler.go │ │ ├── delete_department_handler.go │ │ ├── get_department_by_id_handler.go │ │ ├── get_department_list_handler.go │ │ └── update_department_handler.go │ ├── dictionary │ │ ├── create_dictionary_handler.go │ │ ├── delete_dictionary_handler.go │ │ ├── get_dictionary_by_id_handler.go │ │ ├── get_dictionary_list_handler.go │ │ └── update_dictionary_handler.go │ ├── dictionarydetail │ │ ├── create_dictionary_detail_handler.go │ │ ├── delete_dictionary_detail_handler.go │ │ ├── get_dictionary_detail_by_dictionary_name_handler.go │ │ ├── get_dictionary_detail_by_id_handler.go │ │ ├── get_dictionary_detail_list_handler.go │ │ └── update_dictionary_detail_handler.go │ ├── emaillog │ │ ├── create_email_log_handler.go │ │ ├── delete_email_log_handler.go │ │ ├── get_email_log_by_id_handler.go │ │ ├── get_email_log_list_handler.go │ │ └── update_email_log_handler.go │ ├── emailprovider │ │ ├── create_email_provider_handler.go │ │ ├── delete_email_provider_handler.go │ │ ├── get_email_provider_by_id_handler.go │ │ ├── get_email_provider_list_handler.go │ │ └── update_email_provider_handler.go │ ├── menu │ │ ├── create_menu_handler.go │ │ ├── delete_menu_handler.go │ │ ├── get_menu_list_by_role_handler.go │ │ ├── get_menu_list_handler.go │ │ └── update_menu_handler.go │ ├── messagesender │ │ ├── send_email_handler.go │ │ └── send_sms_handler.go │ ├── oauthprovider │ │ ├── create_oauth_provider_handler.go │ │ ├── delete_oauth_provider_handler.go │ │ ├── get_oauth_provider_by_id_handler.go │ │ ├── get_oauth_provider_list_handler.go │ │ ├── oauth_callback_handler.go │ │ ├── oauth_login_handler.go │ │ └── update_oauth_provider_handler.go │ ├── position │ │ ├── create_position_handler.go │ │ ├── delete_position_handler.go │ │ ├── get_position_by_id_handler.go │ │ ├── get_position_list_handler.go │ │ └── update_position_handler.go │ ├── publicapi │ │ └── get_public_system_configuration_list_handler.go │ ├── publicuser │ │ ├── login_by_email_handler.go │ │ ├── login_by_sms_handler.go │ │ ├── login_handler.go │ │ ├── register_by_email_handler.go │ │ ├── register_by_sms_handler.go │ │ ├── register_handler.go │ │ ├── reset_password_by_email_handler.go │ │ └── reset_password_by_sms_handler.go │ ├── role │ │ ├── create_role_handler.go │ │ ├── delete_role_handler.go │ │ ├── get_role_by_id_handler.go │ │ ├── get_role_list_handler.go │ │ └── update_role_handler.go │ ├── routes.go │ ├── smslog │ │ ├── create_sms_log_handler.go │ │ ├── delete_sms_log_handler.go │ │ ├── get_sms_log_by_id_handler.go │ │ ├── get_sms_log_list_handler.go │ │ └── update_sms_log_handler.go │ ├── smsprovider │ │ ├── create_sms_provider_handler.go │ │ ├── delete_sms_provider_handler.go │ │ ├── get_sms_provider_by_id_handler.go │ │ ├── get_sms_provider_list_handler.go │ │ └── update_sms_provider_handler.go │ ├── task │ │ ├── create_task_handler.go │ │ ├── delete_task_handler.go │ │ ├── get_task_by_id_handler.go │ │ ├── get_task_list_handler.go │ │ └── update_task_handler.go │ ├── tasklog │ │ ├── create_task_log_handler.go │ │ ├── delete_task_log_handler.go │ │ ├── get_task_log_by_id_handler.go │ │ ├── get_task_log_list_handler.go │ │ └── update_task_log_handler.go │ ├── token │ │ ├── create_token_handler.go │ │ ├── delete_token_handler.go │ │ ├── get_token_by_id_handler.go │ │ ├── get_token_list_handler.go │ │ ├── logout_handler.go │ │ └── update_token_handler.go │ └── user │ │ ├── access_token_handler.go │ │ ├── change_password_handler.go │ │ ├── create_user_handler.go │ │ ├── delete_user_handler.go │ │ ├── get_user_by_id_handler.go │ │ ├── get_user_info_handler.go │ │ ├── get_user_list_handler.go │ │ ├── get_user_perm_code_handler.go │ │ ├── get_user_profile_handler.go │ │ ├── logout_handler.go │ │ ├── refresh_token_handler.go │ │ ├── update_user_handler.go │ │ └── update_user_profile_handler.go │ ├── i18n │ ├── locale │ │ ├── en.json │ │ └── zh.json │ └── var.go │ ├── logic │ ├── api │ │ ├── create_api_logic.go │ │ ├── delete_api_logic.go │ │ ├── get_api_by_id_logic.go │ │ ├── get_api_list_logic.go │ │ └── update_api_logic.go │ ├── authority │ │ ├── create_or_update_api_authority_logic.go │ │ ├── create_or_update_menu_authority_logic.go │ │ ├── get_api_authority_logic.go │ │ └── get_menu_authority_logic.go │ ├── base │ │ ├── init_database_logic.go │ │ ├── init_job_database_logic.go │ │ └── init_mcms_database_logic.go │ ├── captcha │ │ ├── get_captcha_logic.go │ │ ├── get_email_captcha_logic.go │ │ └── get_sms_captcha_logic.go │ ├── configuration │ │ ├── create_configuration_logic.go │ │ ├── delete_configuration_logic.go │ │ ├── get_configuration_by_id_logic.go │ │ ├── get_configuration_list_logic.go │ │ └── update_configuration_logic.go │ ├── department │ │ ├── create_department_logic.go │ │ ├── delete_department_logic.go │ │ ├── get_department_by_id_logic.go │ │ ├── get_department_list_logic.go │ │ └── update_department_logic.go │ ├── dictionary │ │ ├── create_dictionary_logic.go │ │ ├── delete_dictionary_logic.go │ │ ├── get_dictionary_by_id_logic.go │ │ ├── get_dictionary_list_logic.go │ │ └── update_dictionary_logic.go │ ├── dictionarydetail │ │ ├── create_dictionary_detail_logic.go │ │ ├── delete_dictionary_detail_logic.go │ │ ├── get_dictionary_detail_by_dictionary_name_logic.go │ │ ├── get_dictionary_detail_by_id_logic.go │ │ ├── get_dictionary_detail_list_logic.go │ │ └── update_dictionary_detail_logic.go │ ├── emaillog │ │ ├── create_email_log_logic.go │ │ ├── delete_email_log_logic.go │ │ ├── get_email_log_by_id_logic.go │ │ ├── get_email_log_list_logic.go │ │ └── update_email_log_logic.go │ ├── emailprovider │ │ ├── create_email_provider_logic.go │ │ ├── delete_email_provider_logic.go │ │ ├── get_email_provider_by_id_logic.go │ │ ├── get_email_provider_list_logic.go │ │ └── update_email_provider_logic.go │ ├── menu │ │ ├── create_menu_logic.go │ │ ├── delete_menu_logic.go │ │ ├── get_menu_list_by_role_logic.go │ │ ├── get_menu_list_logic.go │ │ └── update_menu_logic.go │ ├── messagesender │ │ ├── send_email_logic.go │ │ └── send_sms_logic.go │ ├── oauthprovider │ │ ├── create_oauth_provider_logic.go │ │ ├── delete_oauth_provider_logic.go │ │ ├── get_oauth_provider_by_id_logic.go │ │ ├── get_oauth_provider_list_logic.go │ │ ├── oauth_callback_logic.go │ │ ├── oauth_login_logic.go │ │ └── update_oauth_provider_logic.go │ ├── position │ │ ├── create_position_logic.go │ │ ├── delete_position_logic.go │ │ ├── get_position_by_id_logic.go │ │ ├── get_position_list_logic.go │ │ └── update_position_logic.go │ ├── publicapi │ │ └── get_public_system_configuration_list_logic.go │ ├── publicuser │ │ ├── login_by_email_logic.go │ │ ├── login_by_sms_logic.go │ │ ├── login_logic.go │ │ ├── register_by_email_logic.go │ │ ├── register_by_sms_logic.go │ │ ├── register_logic.go │ │ ├── reset_password_by_email_logic.go │ │ └── reset_password_by_sms_logic.go │ ├── role │ │ ├── create_role_logic.go │ │ ├── delete_role_logic.go │ │ ├── get_role_by_id_logic.go │ │ ├── get_role_list_logic.go │ │ └── update_role_logic.go │ ├── smslog │ │ ├── create_sms_log_logic.go │ │ ├── delete_sms_log_logic.go │ │ ├── get_sms_log_by_id_logic.go │ │ ├── get_sms_log_list_logic.go │ │ └── update_sms_log_logic.go │ ├── smsprovider │ │ ├── create_sms_provider_logic.go │ │ ├── delete_sms_provider_logic.go │ │ ├── get_sms_provider_by_id_logic.go │ │ ├── get_sms_provider_list_logic.go │ │ └── update_sms_provider_logic.go │ ├── task │ │ ├── create_task_logic.go │ │ ├── delete_task_logic.go │ │ ├── get_task_by_id_logic.go │ │ ├── get_task_list_logic.go │ │ └── update_task_logic.go │ ├── tasklog │ │ ├── create_task_log_logic.go │ │ ├── delete_task_log_logic.go │ │ ├── get_task_log_by_id_logic.go │ │ ├── get_task_log_list_logic.go │ │ └── update_task_log_logic.go │ ├── token │ │ ├── create_token_logic.go │ │ ├── delete_token_logic.go │ │ ├── get_token_by_id_logic.go │ │ ├── get_token_list_logic.go │ │ ├── logout_logic.go │ │ └── update_token_logic.go │ └── user │ │ ├── access_token_logic.go │ │ ├── change_password_logic.go │ │ ├── create_user_logic.go │ │ ├── delete_user_logic.go │ │ ├── get_user_by_id_logic.go │ │ ├── get_user_info_logic.go │ │ ├── get_user_list_logic.go │ │ ├── get_user_perm_code_logic.go │ │ ├── get_user_profile_logic.go │ │ ├── logout_logic.go │ │ ├── refresh_token_logic.go │ │ ├── update_user_logic.go │ │ └── update_user_profile_logic.go │ ├── middleware │ └── authority_middleware.go │ ├── svc │ └── service_context.go │ └── types │ └── types.go ├── core.json ├── deploy ├── docker-compose │ ├── all_in_one │ │ ├── mysql │ │ │ ├── docker-compose-cn.yaml │ │ │ └── docker-compose.yaml │ │ ├── postgresql │ │ │ ├── api │ │ │ │ └── etc │ │ │ │ │ └── core.yaml │ │ │ ├── backend │ │ │ │ └── default.conf │ │ │ ├── docker-compose-cn.yaml │ │ │ ├── docker-compose.yaml │ │ │ └── rpc │ │ │ │ └── etc │ │ │ │ └── core.yaml │ │ ├── readme.md │ │ └── readme_en.md │ ├── core-only │ │ ├── api │ │ │ └── etc │ │ │ │ └── core.yaml │ │ ├── docker-compose-cn.yaml │ │ └── docker-compose.yaml │ ├── jaeger │ │ └── docker-compose.yaml │ ├── mongodb │ │ └── docker-compose.yaml │ ├── mysql_redis │ │ └── docker-compose.yaml │ ├── postgresql_redis │ │ └── docker-compose.yaml │ └── rocketmq │ │ └── docker-compose.yaml └── k8s │ ├── auth.yaml │ ├── backend-ui.yaml │ ├── core-api.yaml │ ├── core-rpc.yaml │ ├── ingress-patch.yaml │ ├── ingress.yaml │ ├── log-collecting │ └── filebeat │ │ └── filebeat-deploy.yaml │ ├── prometheus │ ├── prometheus-service-monitor.yaml │ ├── rbac.yaml │ └── setup.sh │ ├── pv.yaml │ ├── setup-ingress.sh │ └── setup.sh ├── go.mod ├── go.sum └── rpc ├── .gitignore ├── core.go ├── core.proto ├── coreclient └── core.go ├── desc ├── api.proto ├── authority.proto ├── base.proto ├── configuration.proto ├── department.proto ├── dictionary.proto ├── dictionarydetail.proto ├── menu.proto ├── oauthprovider.proto ├── position.proto ├── role.proto ├── token.proto └── user.proto ├── ent ├── api.go ├── api │ ├── api.go │ └── where.go ├── api_create.go ├── api_delete.go ├── api_query.go ├── api_update.go ├── client.go ├── configuration.go ├── configuration │ ├── configuration.go │ └── where.go ├── configuration_create.go ├── configuration_delete.go ├── configuration_query.go ├── configuration_update.go ├── department.go ├── department │ ├── department.go │ └── where.go ├── department_create.go ├── department_delete.go ├── department_query.go ├── department_update.go ├── dictionary.go ├── dictionary │ ├── dictionary.go │ └── where.go ├── dictionary_create.go ├── dictionary_delete.go ├── dictionary_query.go ├── dictionary_update.go ├── dictionarydetail.go ├── dictionarydetail │ ├── dictionarydetail.go │ └── where.go ├── dictionarydetail_create.go ├── dictionarydetail_delete.go ├── dictionarydetail_query.go ├── dictionarydetail_update.go ├── ent.go ├── enttest │ └── enttest.go ├── generate.go ├── hook │ └── hook.go ├── intercept │ └── intercept.go ├── menu.go ├── menu │ ├── menu.go │ └── where.go ├── menu_create.go ├── menu_delete.go ├── menu_query.go ├── menu_update.go ├── migrate │ ├── migrate.go │ └── schema.go ├── mutation.go ├── oauthprovider.go ├── oauthprovider │ ├── oauthprovider.go │ └── where.go ├── oauthprovider_create.go ├── oauthprovider_delete.go ├── oauthprovider_query.go ├── oauthprovider_update.go ├── pagination.go ├── position.go ├── position │ ├── position.go │ └── where.go ├── position_create.go ├── position_delete.go ├── position_query.go ├── position_update.go ├── predicate │ └── predicate.go ├── role.go ├── role │ ├── role.go │ └── where.go ├── role_create.go ├── role_delete.go ├── role_query.go ├── role_update.go ├── runtime.go ├── runtime │ └── runtime.go ├── schema │ ├── api.go │ ├── configuration.go │ ├── department.go │ ├── dictionary.go │ ├── dictionary_detail.go │ ├── menu.go │ ├── mixins │ │ └── soft_delete.go │ ├── oauth_provider.go │ ├── position.go │ ├── role.go │ ├── token.go │ └── user.go ├── set_not_nil.go ├── template │ ├── pagination.tmpl │ └── set_not_nil.tmpl ├── token.go ├── token │ ├── token.go │ └── where.go ├── token_create.go ├── token_delete.go ├── token_query.go ├── token_update.go ├── tx.go ├── user.go ├── user │ ├── user.go │ └── where.go ├── user_create.go ├── user_delete.go ├── user_query.go └── user_update.go ├── etc └── core.yaml ├── internal ├── config │ └── config.go ├── logic │ ├── api │ │ ├── create_api_logic.go │ │ ├── delete_api_logic.go │ │ ├── get_api_by_id_logic.go │ │ ├── get_api_list_logic.go │ │ └── update_api_logic.go │ ├── authority │ │ ├── create_or_update_menu_authority_logic.go │ │ └── get_menu_authority_logic.go │ ├── base │ │ ├── init_database_api_data.go │ │ ├── init_database_logic.go │ │ └── init_database_menu_data.go │ ├── configuration │ │ ├── create_configuration_logic.go │ │ ├── delete_configuration_logic.go │ │ ├── get_configuration_by_id_logic.go │ │ ├── get_configuration_list_logic.go │ │ └── update_configuration_logic.go │ ├── department │ │ ├── create_department_logic.go │ │ ├── delete_department_logic.go │ │ ├── get_department_by_id_logic.go │ │ ├── get_department_list_logic.go │ │ └── update_department_logic.go │ ├── dictionary │ │ ├── create_dictionary_logic.go │ │ ├── delete_dictionary_logic.go │ │ ├── get_dictionary_by_id_logic.go │ │ ├── get_dictionary_list_logic.go │ │ └── update_dictionary_logic.go │ ├── dictionarydetail │ │ ├── create_dictionary_detail_logic.go │ │ ├── delete_dictionary_detail_logic.go │ │ ├── get_dictionary_detail_by_dictionary_name_logic.go │ │ ├── get_dictionary_detail_by_id_logic.go │ │ ├── get_dictionary_detail_list_logic.go │ │ └── update_dictionary_detail_logic.go │ ├── menu │ │ ├── create_menu_logic.go │ │ ├── delete_menu_logic.go │ │ ├── get_menu_list_by_role_logic.go │ │ ├── get_menu_list_logic.go │ │ └── update_menu_logic.go │ ├── oauthprovider │ │ ├── create_oauth_provider_logic.go │ │ ├── delete_oauth_provider_logic.go │ │ ├── feishu_sdk.go │ │ ├── get_oauth_provider_by_id_logic.go │ │ ├── get_oauth_provider_list_logic.go │ │ ├── oauth_callback_logic.go │ │ ├── oauth_login_logic.go │ │ └── update_oauth_provider_logic.go │ ├── position │ │ ├── create_position_logic.go │ │ ├── delete_position_logic.go │ │ ├── get_position_by_id_logic.go │ │ ├── get_position_list_logic.go │ │ └── update_position_logic.go │ ├── role │ │ ├── create_role_logic.go │ │ ├── delete_role_logic.go │ │ ├── get_role_by_id_logic.go │ │ ├── get_role_list_logic.go │ │ └── update_role_logic.go │ ├── token │ │ ├── block_user_all_token_logic.go │ │ ├── create_token_logic.go │ │ ├── delete_token_logic.go │ │ ├── get_token_by_id_logic.go │ │ ├── get_token_list_logic.go │ │ └── update_token_logic.go │ └── user │ │ ├── create_user_logic.go │ │ ├── delete_user_logic.go │ │ ├── get_user_by_id_logic.go │ │ ├── get_user_by_username_logic.go │ │ ├── get_user_list_logic.go │ │ └── update_user_logic.go ├── server │ └── core_server.go ├── svc │ └── service_context.go └── utils │ ├── dberrorhandler │ └── error_handler.go │ ├── dbfunc │ └── department.go │ └── entx │ └── ent_tx.go └── types └── core ├── core.pb.go └── core_grpc.pb.go /.chglog/CHANGELOG.tpl.md: -------------------------------------------------------------------------------- 1 | {{ range .Versions }} 2 | 3 | ## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }}) 4 | 5 | {{ range .CommitGroups -}} 6 | ### {{ .Title }} 7 | 8 | {{ range .Commits -}} 9 | * {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} 10 | {{ end }} 11 | {{ end -}} 12 | 13 | {{- if .MergeCommits -}} 14 | ### Pull Requests 15 | 16 | {{ range .MergeCommits -}} 17 | * {{ .Header }} 18 | {{ end }} 19 | {{ end -}} 20 | 21 | {{- if .NoteGroups -}} 22 | {{ range .NoteGroups -}} 23 | ### {{ .Title }} 24 | 25 | {{ range .Notes }} 26 | {{ .Body }} 27 | {{ end }} 28 | {{ end -}} 29 | {{ end -}} 30 | {{ end -}} -------------------------------------------------------------------------------- /.chglog/config.yml: -------------------------------------------------------------------------------- 1 | style: github 2 | template: CHANGELOG.tpl.md 3 | info: 4 | title: CHANGELOG 5 | repository_url: https://github.com/suyuan32/simple-admin-core 6 | options: 7 | commits: 8 | # filters: 9 | # Type: 10 | # - feat 11 | # - fix 12 | # - perf 13 | # - refactor 14 | commit_groups: 15 | # title_maps: 16 | # feat: Features 17 | # fix: Bug Fixes 18 | # perf: Performance Improvements 19 | # refactor: Code Refactoring 20 | header: 21 | pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" 22 | pattern_maps: 23 | - Type 24 | - Scope 25 | - Subject 26 | notes: 27 | keywords: 28 | - BREAKING CHANGE -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .github/ 2 | docs/ 3 | .git/ -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [ ] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: [ 'https://afdian.net/a/geeksu?tab=home', 'https://patreon.com/RyanSU' ] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build and Release Folders 2 | bin-debug/ 3 | bin-release/ 4 | [Oo]bj/ 5 | [Bb]in/ 6 | node_modules/ 7 | 8 | 9 | # Other files and folders 10 | .settings/ 11 | .idea/ 12 | .vscode/ 13 | 14 | # Executables 15 | *.swf 16 | *.air 17 | *.ipa 18 | *.apk 19 | 20 | # Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` 21 | # should NOT be excluded as they contain compiler settings and other important 22 | # information for Eclipse / Flash Builder. 23 | cusCMD 24 | 25 | # config file avoid exposing private data 26 | *_dev.yaml 27 | 28 | core_api 29 | core_rpc 30 | 31 | # VsCode debug files 32 | __debug* -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | You are very welcome to join!Raise an issue Or submit a Pull Request。 2 | 3 | Pull Request: 4 | 5 | Fork code! 6 | Create your own branch: git checkout -b feat/xxxx 7 | Submit your changes: git commit -am 'feat(function): add xxxxx' 8 | Push your branch: git push origin feat/xxxx 9 | submit pull request 10 | -------------------------------------------------------------------------------- /Dockerfile-api: -------------------------------------------------------------------------------- 1 | FROM alpine:3.21 2 | 3 | # Define the project name | 定义项目名称 4 | ARG PROJECT=core 5 | # Define the config file name | 定义配置文件名 6 | ARG CONFIG_FILE=core.yaml 7 | # Define the author | 定义作者 8 | ARG AUTHOR="yuansu.china.work@gmail.com" 9 | 10 | LABEL org.opencontainers.image.authors=${AUTHOR} 11 | 12 | WORKDIR /app 13 | ENV PROJECT=${PROJECT} 14 | ENV CONFIG_FILE=${CONFIG_FILE} 15 | 16 | ENV TZ=Asia/Shanghai 17 | RUN apk update --no-cache && apk add --no-cache tzdata 18 | 19 | COPY ./${PROJECT}_api ./ 20 | COPY ./api/etc/${CONFIG_FILE} ./etc/ 21 | COPY ./api/internal/i18n/locale/ ./etc/locale/ 22 | 23 | EXPOSE 9100 24 | 25 | ENTRYPOINT ["./core_api", "-f", "etc/core.yaml"] -------------------------------------------------------------------------------- /Dockerfile-rpc: -------------------------------------------------------------------------------- 1 | FROM alpine:3.21 2 | 3 | # Define the project name | 定义项目名称 4 | ARG PROJECT=core 5 | # Define the config file name | 定义配置文件名 6 | ARG CONFIG_FILE=core.yaml 7 | # Define the author | 定义作者 8 | ARG AUTHOR="yuansu.china.work@gmail.com" 9 | 10 | LABEL org.opencontainers.image.authors=${AUTHOR} 11 | 12 | WORKDIR /app 13 | ENV PROJECT=${PROJECT} 14 | ENV CONFIG_FILE=${CONFIG_FILE} 15 | 16 | ENV TZ=Asia/Shanghai 17 | RUN apk update --no-cache && apk add --no-cache tzdata 18 | 19 | COPY ./${PROJECT}_rpc ./ 20 | COPY ./rpc/etc/${CONFIG_FILE} ./etc/ 21 | 22 | EXPOSE 9101 23 | 24 | ENTRYPOINT ["./core_rpc", "-f", "etc/core.yaml"] -------------------------------------------------------------------------------- /api/desc/all.api: -------------------------------------------------------------------------------- 1 | import "base.api" 2 | import "./core/role.api" 3 | import "./core/user.api" 4 | import "./core/menu.api" 5 | import "./core/captcha.api" 6 | import "./core/api.api" 7 | import "./core/authority.api" 8 | import "./core/dictionary.api" 9 | import "./core/oauth_provider.api" 10 | import "./core/token.api" 11 | import "./core/department.api" 12 | import "./core/position.api" 13 | import "./core/dictionary_detail.api" 14 | import "./job/task.api" 15 | import "./job/task_log.api" 16 | import "./mcms/email_log.api" 17 | import "./mcms/sms_log.api" 18 | import "./mcms/sms_provider.api" 19 | import "./mcms/email_provider.api" 20 | import "./mcms/sms.api" 21 | import "./mcms/email.api" 22 | import "./core/configuration.api" -------------------------------------------------------------------------------- /api/desc/mcms/email.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | import "../base.api" 4 | 5 | type ( 6 | SendEmailReq { 7 | // Target email address | 目标邮箱地址 8 | Target string `json:"target"` 9 | 10 | // The email subject | 邮件标题 11 | Subject string `json:"subject"` 12 | 13 | // The email content | 邮件内容 14 | Content string `json:"content"` 15 | 16 | // The email provider | 邮件服务提供商 17 | Provider *string `json:"provider,optional"` 18 | } 19 | ) 20 | 21 | @server( 22 | jwt: Auth 23 | group: messagesender 24 | middleware: Authority 25 | ) 26 | 27 | service Core { 28 | // Send email message | 发送电子邮件 29 | @handler sendEmail 30 | post /email/send (SendEmailReq) returns (BaseMsgResp) 31 | } -------------------------------------------------------------------------------- /api/desc/mcms/sms.api: -------------------------------------------------------------------------------- 1 | syntax = "v1" 2 | 3 | import "../base.api" 4 | 5 | type ( 6 | SendSmsReq { 7 | // Phone number | 电话号码 8 | PhoneNumber string `json:"phoneNumber"` 9 | 10 | // The parameters | 参数 11 | Params string `json:"params"` 12 | 13 | // The template ID | 模板 ID 14 | TemplateId *string `json:"templateId,optional"` 15 | 16 | // The app ID | App ID 17 | AppId *string `json:"appId,optional"` 18 | 19 | // The signuture name | 签名名称 20 | SignName *string `json:"signName,optional"` 21 | 22 | // The email provider | 邮件服务提供商 23 | Provider *string `json:"provider,optional"` 24 | } 25 | ) 26 | 27 | @server( 28 | jwt: Auth 29 | group: messagesender 30 | middleware: Authority 31 | ) 32 | 33 | service Core { 34 | // Send sms message | 发送短信 35 | @handler sendSms 36 | post /sms/send (SendSmsReq) returns (BaseMsgResp) 37 | } -------------------------------------------------------------------------------- /api/internal/handler/api/create_api_handler.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/api" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /api/create api CreateApi 14 | // 15 | // Create API information | 创建API 16 | // 17 | // Create API information | 创建API 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: ApiInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateApiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.ApiInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := api.NewCreateApiLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateApi(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/api/delete_api_handler.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/api" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /api/delete api DeleteApi 14 | // 15 | // Delete API information | 删除API信息 16 | // 17 | // Delete API information | 删除API信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteApiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := api.NewDeleteApiLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteApi(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/api/get_api_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/api" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /api api GetApiById 14 | // 15 | // Get API by ID | 通过ID获取API 16 | // 17 | // Get API by ID | 通过ID获取API 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: ApiInfoResp 27 | 28 | func GetApiByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := api.NewGetApiByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetApiById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/api/get_api_list_handler.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/api" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /api/list api GetApiList 14 | // 15 | // Get API list | 获取API列表 16 | // 17 | // Get API list | 获取API列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: ApiListReq 24 | // 25 | // Responses: 26 | // 200: ApiListResp 27 | 28 | func GetApiListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.ApiListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := api.NewGetApiListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetApiList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/api/update_api_handler.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/api" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /api/update api UpdateApi 14 | // 15 | // Update API information | 创建API 16 | // 17 | // Update API information | 创建API 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: ApiInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateApiHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.ApiInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := api.NewUpdateApiLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateApi(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/authority/get_api_authority_handler.go: -------------------------------------------------------------------------------- 1 | package authority 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/authority" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /authority/api/role authority GetApiAuthority 14 | // 15 | // Get role's API authorization list | 获取角色api权限列表 16 | // 17 | // Get role's API authorization list | 获取角色api权限列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: ApiAuthorityListResp 27 | 28 | func GetApiAuthorityHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := authority.NewGetApiAuthorityLogic(r.Context(), svcCtx) 37 | resp, err := l.GetApiAuthority(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/authority/get_menu_authority_handler.go: -------------------------------------------------------------------------------- 1 | package authority 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/authority" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /authority/menu/role authority GetMenuAuthority 14 | // 15 | // Get role's menu authorization list | 获取角色菜单权限列表 16 | // 17 | // Get role's menu authorization list | 获取角色菜单权限列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: MenuAuthorityInfoResp 27 | 28 | func GetMenuAuthorityHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := authority.NewGetMenuAuthorityLogic(r.Context(), svcCtx) 37 | resp, err := l.GetMenuAuthority(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/base/init_database_handler.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/base" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /core/init/database base InitDatabase 13 | // 14 | // Initialize database | 初始化数据库 15 | // 16 | // Initialize database | 初始化数据库 17 | // 18 | // Responses: 19 | // 200: BaseMsgResp 20 | 21 | func InitDatabaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := base.NewInitDatabaseLogic(r.Context(), svcCtx) 24 | resp, err := l.InitDatabase() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/base/init_job_database_handler.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/base" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /core/init/job_database base InitJobDatabase 13 | // 14 | // Initialize job database | 初始化定时任务数据库 15 | // 16 | // Initialize job database | 初始化定时任务数据库 17 | // 18 | // Responses: 19 | // 200: BaseMsgResp 20 | 21 | func InitJobDatabaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := base.NewInitJobDatabaseLogic(r.Context(), svcCtx) 24 | resp, err := l.InitJobDatabase() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/base/init_mcms_database_handler.go: -------------------------------------------------------------------------------- 1 | package base 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/base" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /core/init/mcms_database base InitMcmsDatabase 13 | // 14 | // Initialize Message Center database | 初始化消息中心数据库 15 | // 16 | // Initialize Message Center database | 初始化消息中心数据库 17 | // 18 | // Responses: 19 | // 200: BaseMsgResp 20 | 21 | func InitMcmsDatabaseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := base.NewInitMcmsDatabaseLogic(r.Context(), svcCtx) 24 | resp, err := l.InitMcmsDatabase() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/captcha/get_captcha_handler.go: -------------------------------------------------------------------------------- 1 | package captcha 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/captcha" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /captcha captcha GetCaptcha 13 | // 14 | // Get captcha | 获取验证码 15 | // 16 | // Get captcha | 获取验证码 17 | // 18 | // Responses: 19 | // 200: CaptchaResp 20 | 21 | func GetCaptchaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := captcha.NewGetCaptchaLogic(r.Context(), svcCtx) 24 | resp, err := l.GetCaptcha() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/captcha/get_email_captcha_handler.go: -------------------------------------------------------------------------------- 1 | package captcha 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/captcha" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /captcha/email captcha GetEmailCaptcha 14 | // 15 | // Get Email Captcha | 获取邮箱验证码 16 | // 17 | // Get Email Captcha | 获取邮箱验证码 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: EmailCaptchaReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func GetEmailCaptchaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.EmailCaptchaReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := captcha.NewGetEmailCaptchaLogic(r.Context(), svcCtx) 37 | resp, err := l.GetEmailCaptcha(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/captcha/get_sms_captcha_handler.go: -------------------------------------------------------------------------------- 1 | package captcha 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/captcha" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /captcha/sms captcha GetSmsCaptcha 14 | // 15 | // Get SMS Captcha | 获取短信验证码 16 | // 17 | // Get SMS Captcha | 获取短信验证码 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: SmsCaptchaReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func GetSmsCaptchaHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.SmsCaptchaReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := captcha.NewGetSmsCaptchaLogic(r.Context(), svcCtx) 37 | resp, err := l.GetSmsCaptcha(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/department/create_department_handler.go: -------------------------------------------------------------------------------- 1 | package department 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/department" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /department/create department CreateDepartment 14 | // 15 | // Create department information | 创建部门 16 | // 17 | // Create department information | 创建部门 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: DepartmentInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateDepartmentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.DepartmentInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := department.NewCreateDepartmentLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateDepartment(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/department/delete_department_handler.go: -------------------------------------------------------------------------------- 1 | package department 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/department" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /department/delete department DeleteDepartment 14 | // 15 | // Delete department information | 删除部门信息 16 | // 17 | // Delete department information | 删除部门信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteDepartmentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := department.NewDeleteDepartmentLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteDepartment(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/department/get_department_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package department 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/department" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /department department GetDepartmentById 14 | // 15 | // Get Department by ID | 通过ID获取部门 16 | // 17 | // Get Department by ID | 通过ID获取部门 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: DepartmentInfoResp 27 | 28 | func GetDepartmentByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := department.NewGetDepartmentByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetDepartmentById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/department/get_department_list_handler.go: -------------------------------------------------------------------------------- 1 | package department 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/department" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /department/list department GetDepartmentList 14 | // 15 | // Get department list | 获取部门列表 16 | // 17 | // Get department list | 获取部门列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: DepartmentListReq 24 | // 25 | // Responses: 26 | // 200: DepartmentListResp 27 | 28 | func GetDepartmentListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.DepartmentListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := department.NewGetDepartmentListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetDepartmentList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/department/update_department_handler.go: -------------------------------------------------------------------------------- 1 | package department 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/department" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /department/update department UpdateDepartment 14 | // 15 | // Update department information | 更新部门 16 | // 17 | // Update department information | 更新部门 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: DepartmentInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateDepartmentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.DepartmentInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := department.NewUpdateDepartmentLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateDepartment(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/dictionary/create_dictionary_handler.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/dictionary" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /dictionary/create dictionary CreateDictionary 14 | // 15 | // Create dictionary information | 创建字典 16 | // 17 | // Create dictionary information | 创建字典 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: DictionaryInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateDictionaryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.DictionaryInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := dictionary.NewCreateDictionaryLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateDictionary(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/dictionary/delete_dictionary_handler.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/dictionary" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /dictionary/delete dictionary DeleteDictionary 14 | // 15 | // Delete dictionary information | 删除字典信息 16 | // 17 | // Delete dictionary information | 删除字典信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteDictionaryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := dictionary.NewDeleteDictionaryLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteDictionary(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/dictionary/get_dictionary_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/dictionary" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /dictionary dictionary GetDictionaryById 14 | // 15 | // Get Dictionary by ID | 通过ID获取字典 16 | // 17 | // Get Dictionary by ID | 通过ID获取字典 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: DictionaryInfoResp 27 | 28 | func GetDictionaryByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := dictionary.NewGetDictionaryByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetDictionaryById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/dictionary/get_dictionary_list_handler.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/dictionary" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /dictionary/list dictionary GetDictionaryList 14 | // 15 | // Get dictionary list | 获取字典列表 16 | // 17 | // Get dictionary list | 获取字典列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: DictionaryListReq 24 | // 25 | // Responses: 26 | // 200: DictionaryListResp 27 | 28 | func GetDictionaryListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.DictionaryListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := dictionary.NewGetDictionaryListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetDictionaryList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/dictionary/update_dictionary_handler.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/dictionary" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /dictionary/update dictionary UpdateDictionary 14 | // 15 | // Update dictionary information | 更新字典 16 | // 17 | // Update dictionary information | 更新字典 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: DictionaryInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateDictionaryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.DictionaryInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := dictionary.NewUpdateDictionaryLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateDictionary(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/emaillog/create_email_log_handler.go: -------------------------------------------------------------------------------- 1 | package emaillog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/emaillog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /email_log/create emaillog CreateEmailLog 14 | // 15 | // Create email log information | 创建电子邮件日志 16 | // 17 | // Create email log information | 创建电子邮件日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: EmailLogInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateEmailLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.EmailLogInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := emaillog.NewCreateEmailLogLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateEmailLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/emaillog/delete_email_log_handler.go: -------------------------------------------------------------------------------- 1 | package emaillog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/emaillog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /email_log/delete emaillog DeleteEmailLog 14 | // 15 | // Delete email log information | 删除电子邮件日志信息 16 | // 17 | // Delete email log information | 删除电子邮件日志信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteEmailLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := emaillog.NewDeleteEmailLogLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteEmailLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/emaillog/get_email_log_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package emaillog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/emaillog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /email_log emaillog GetEmailLogById 14 | // 15 | // Get email log by ID | 通过ID获取电子邮件日志 16 | // 17 | // Get email log by ID | 通过ID获取电子邮件日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDReq 24 | // 25 | // Responses: 26 | // 200: EmailLogInfoResp 27 | 28 | func GetEmailLogByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := emaillog.NewGetEmailLogByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetEmailLogById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/emaillog/get_email_log_list_handler.go: -------------------------------------------------------------------------------- 1 | package emaillog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/emaillog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /email_log/list emaillog GetEmailLogList 14 | // 15 | // Get email log list | 获取电子邮件日志列表 16 | // 17 | // Get email log list | 获取电子邮件日志列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: EmailLogListReq 24 | // 25 | // Responses: 26 | // 200: EmailLogListResp 27 | 28 | func GetEmailLogListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.EmailLogListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := emaillog.NewGetEmailLogListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetEmailLogList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/emaillog/update_email_log_handler.go: -------------------------------------------------------------------------------- 1 | package emaillog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/emaillog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /email_log/update emaillog UpdateEmailLog 14 | // 15 | // Update email log information | 更新电子邮件日志 16 | // 17 | // Update email log information | 更新电子邮件日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: EmailLogInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateEmailLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.EmailLogInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := emaillog.NewUpdateEmailLogLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateEmailLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/menu/create_menu_handler.go: -------------------------------------------------------------------------------- 1 | package menu 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/menu" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /menu/create menu CreateMenu 14 | // 15 | // Create menu information | 创建菜单 16 | // 17 | // Create menu information | 创建菜单 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: MenuPlainInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateMenuHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.MenuPlainInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := menu.NewCreateMenuLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateMenu(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/menu/delete_menu_handler.go: -------------------------------------------------------------------------------- 1 | package menu 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/menu" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /menu/delete menu DeleteMenu 14 | // 15 | // Delete menu information | 删除菜单信息 16 | // 17 | // Delete menu information | 删除菜单信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteMenuHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := menu.NewDeleteMenuLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteMenu(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/menu/get_menu_list_by_role_handler.go: -------------------------------------------------------------------------------- 1 | package menu 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/menu" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /menu/role/list menu GetMenuListByRole 13 | // 14 | // Get menu list by role | 获取菜单列表 15 | // 16 | // Get menu list by role | 获取菜单列表 17 | // 18 | // Responses: 19 | // 200: MenuListResp 20 | 21 | func GetMenuListByRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := menu.NewGetMenuListByRoleLogic(r.Context(), svcCtx) 24 | resp, err := l.GetMenuListByRole() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/menu/get_menu_list_handler.go: -------------------------------------------------------------------------------- 1 | package menu 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/menu" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /menu/list menu GetMenuList 13 | // 14 | // Get menu list | 获取菜单列表 15 | // 16 | // Get menu list | 获取菜单列表 17 | // 18 | // Responses: 19 | // 200: MenuPlainInfoListResp 20 | 21 | func GetMenuListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := menu.NewGetMenuListLogic(r.Context(), svcCtx) 24 | resp, err := l.GetMenuList() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/menu/update_menu_handler.go: -------------------------------------------------------------------------------- 1 | package menu 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/menu" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /menu/update menu UpdateMenu 14 | // 15 | // Update menu information | 更新菜单 16 | // 17 | // Update menu information | 更新菜单 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: MenuPlainInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateMenuHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.MenuPlainInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := menu.NewUpdateMenuLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateMenu(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/messagesender/send_email_handler.go: -------------------------------------------------------------------------------- 1 | package messagesender 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/messagesender" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /email/send messagesender SendEmail 14 | // 15 | // Send email message | 发送电子邮件 16 | // 17 | // Send email message | 发送电子邮件 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: SendEmailReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func SendEmailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.SendEmailReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := messagesender.NewSendEmailLogic(r.Context(), svcCtx) 37 | resp, err := l.SendEmail(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/messagesender/send_sms_handler.go: -------------------------------------------------------------------------------- 1 | package messagesender 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/messagesender" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms/send messagesender SendSms 14 | // 15 | // Send sms message | 发送短信 16 | // 17 | // Send sms message | 发送短信 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: SendSmsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func SendSmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.SendSmsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := messagesender.NewSendSmsLogic(r.Context(), svcCtx) 37 | resp, err := l.SendSms(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/oauthprovider/oauth_callback_handler.go: -------------------------------------------------------------------------------- 1 | package oauthprovider 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/oauthprovider" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /oauth/login/callback oauthprovider OauthCallback 13 | // 14 | // Oauth log in callback route | Oauth 登录返回调接口 15 | // 16 | // Oauth log in callback route | Oauth 登录返回调接口 17 | // 18 | // Responses: 19 | // 200: CallbackResp 20 | 21 | func OauthCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := oauthprovider.NewOauthCallbackLogic(r, svcCtx) 24 | resp, err := l.OauthCallback() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/oauthprovider/oauth_login_handler.go: -------------------------------------------------------------------------------- 1 | package oauthprovider 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/oauthprovider" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /oauth/login oauthprovider OauthLogin 14 | // 15 | // Oauth log in | Oauth 登录 16 | // 17 | // Oauth log in | Oauth 登录 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: OauthLoginReq 24 | // 25 | // Responses: 26 | // 200: RedirectResp 27 | 28 | func OauthLoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.OauthLoginReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := oauthprovider.NewOauthLoginLogic(r.Context(), svcCtx) 37 | resp, err := l.OauthLogin(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/position/create_position_handler.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/position" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /position/create position CreatePosition 14 | // 15 | // Create position information | 创建职位 16 | // 17 | // Create position information | 创建职位 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: PositionInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreatePositionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.PositionInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := position.NewCreatePositionLogic(r.Context(), svcCtx) 37 | resp, err := l.CreatePosition(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/position/delete_position_handler.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/position" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /position/delete position DeletePosition 14 | // 15 | // Delete position information | 删除职位信息 16 | // 17 | // Delete position information | 删除职位信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeletePositionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := position.NewDeletePositionLogic(r.Context(), svcCtx) 37 | resp, err := l.DeletePosition(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/position/get_position_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/position" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /position position GetPositionById 14 | // 15 | // Get position by ID | 通过ID获取职位 16 | // 17 | // Get position by ID | 通过ID获取职位 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: PositionInfoResp 27 | 28 | func GetPositionByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := position.NewGetPositionByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetPositionById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/position/get_position_list_handler.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/position" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /position/list position GetPositionList 14 | // 15 | // Get position list | 获取职位列表 16 | // 17 | // Get position list | 获取职位列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: PositionListReq 24 | // 25 | // Responses: 26 | // 200: PositionListResp 27 | 28 | func GetPositionListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.PositionListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := position.NewGetPositionListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetPositionList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/position/update_position_handler.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/position" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /position/update position UpdatePosition 14 | // 15 | // Update position information | 更新职位 16 | // 17 | // Update position information | 更新职位 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: PositionInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdatePositionHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.PositionInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := position.NewUpdatePositionLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdatePosition(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/publicapi/get_public_system_configuration_list_handler.go: -------------------------------------------------------------------------------- 1 | package publicapi 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/publicapi" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /configuration/system/list publicapi GetPublicSystemConfigurationList 13 | // 14 | // Get public system configuration list | 获取公开系统参数列表 15 | // 16 | // Get public system configuration list | 获取公开系统参数列表 17 | // 18 | // Responses: 19 | // 200: ConfigurationListResp 20 | 21 | func GetPublicSystemConfigurationListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := publicapi.NewGetPublicSystemConfigurationListLogic(r.Context(), svcCtx) 24 | resp, err := l.GetPublicSystemConfigurationList() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/publicuser/login_by_email_handler.go: -------------------------------------------------------------------------------- 1 | package publicuser 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/publicuser" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/login_by_email publicuser LoginByEmail 14 | // 15 | // Log in by email | 邮箱登录 16 | // 17 | // Log in by email | 邮箱登录 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: LoginByEmailReq 24 | // 25 | // Responses: 26 | // 200: LoginResp 27 | 28 | func LoginByEmailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.LoginByEmailReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := publicuser.NewLoginByEmailLogic(r.Context(), svcCtx) 37 | resp, err := l.LoginByEmail(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/publicuser/login_by_sms_handler.go: -------------------------------------------------------------------------------- 1 | package publicuser 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/publicuser" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/login_by_sms publicuser LoginBySms 14 | // 15 | // Log in by SMS | 短信登录 16 | // 17 | // Log in by SMS | 短信登录 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: LoginBySmsReq 24 | // 25 | // Responses: 26 | // 200: LoginResp 27 | 28 | func LoginBySmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.LoginBySmsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := publicuser.NewLoginBySmsLogic(r.Context(), svcCtx) 37 | resp, err := l.LoginBySms(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/publicuser/login_handler.go: -------------------------------------------------------------------------------- 1 | package publicuser 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/publicuser" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/login publicuser Login 14 | // 15 | // Log in | 登录 16 | // 17 | // Log in | 登录 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: LoginReq 24 | // 25 | // Responses: 26 | // 200: LoginResp 27 | 28 | func LoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.LoginReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := publicuser.NewLoginLogic(r.Context(), svcCtx) 37 | resp, err := l.Login(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/publicuser/register_by_email_handler.go: -------------------------------------------------------------------------------- 1 | package publicuser 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/publicuser" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/register_by_email publicuser RegisterByEmail 14 | // 15 | // Register by Email | 邮箱注册 16 | // 17 | // Register by Email | 邮箱注册 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: RegisterByEmailReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func RegisterByEmailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.RegisterByEmailReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := publicuser.NewRegisterByEmailLogic(r.Context(), svcCtx) 37 | resp, err := l.RegisterByEmail(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/publicuser/register_by_sms_handler.go: -------------------------------------------------------------------------------- 1 | package publicuser 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/publicuser" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/register_by_sms publicuser RegisterBySms 14 | // 15 | // Register by SMS | 短信注册 16 | // 17 | // Register by SMS | 短信注册 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: RegisterBySmsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func RegisterBySmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.RegisterBySmsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := publicuser.NewRegisterBySmsLogic(r.Context(), svcCtx) 37 | resp, err := l.RegisterBySms(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/publicuser/register_handler.go: -------------------------------------------------------------------------------- 1 | package publicuser 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/publicuser" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/register publicuser Register 14 | // 15 | // Register | 注册 16 | // 17 | // Register | 注册 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: RegisterReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func RegisterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.RegisterReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := publicuser.NewRegisterLogic(r.Context(), svcCtx) 37 | resp, err := l.Register(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/role/create_role_handler.go: -------------------------------------------------------------------------------- 1 | package role 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/role" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /role/create role CreateRole 14 | // 15 | // Create role information | 创建角色 16 | // 17 | // Create role information | 创建角色 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: RoleInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.RoleInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := role.NewCreateRoleLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateRole(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/role/delete_role_handler.go: -------------------------------------------------------------------------------- 1 | package role 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/role" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /role/delete role DeleteRole 14 | // 15 | // Delete role information | 删除角色信息 16 | // 17 | // Delete role information | 删除角色信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := role.NewDeleteRoleLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteRole(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/role/get_role_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package role 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/role" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /role role GetRoleById 14 | // 15 | // Get Role by ID | 通过ID获取角色 16 | // 17 | // Get Role by ID | 通过ID获取角色 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: RoleInfoResp 27 | 28 | func GetRoleByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := role.NewGetRoleByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetRoleById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/role/get_role_list_handler.go: -------------------------------------------------------------------------------- 1 | package role 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/role" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /role/list role GetRoleList 14 | // 15 | // Get role list | 获取角色列表 16 | // 17 | // Get role list | 获取角色列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: RoleListReq 24 | // 25 | // Responses: 26 | // 200: RoleListResp 27 | 28 | func GetRoleListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.RoleListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := role.NewGetRoleListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetRoleList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/role/update_role_handler.go: -------------------------------------------------------------------------------- 1 | package role 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/role" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /role/update role UpdateRole 14 | // 15 | // Update role information | 更新角色 16 | // 17 | // Update role information | 更新角色 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: RoleInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.RoleInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := role.NewUpdateRoleLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateRole(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smslog/create_sms_log_handler.go: -------------------------------------------------------------------------------- 1 | package smslog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smslog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_log/create smslog CreateSmsLog 14 | // 15 | // Create sms log information | 创建短信日志 16 | // 17 | // Create sms log information | 创建短信日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: SmsLogInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateSmsLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.SmsLogInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smslog.NewCreateSmsLogLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateSmsLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smslog/delete_sms_log_handler.go: -------------------------------------------------------------------------------- 1 | package smslog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smslog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_log/delete smslog DeleteSmsLog 14 | // 15 | // Delete sms log information | 删除短信日志信息 16 | // 17 | // Delete sms log information | 删除短信日志信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteSmsLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smslog.NewDeleteSmsLogLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteSmsLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smslog/get_sms_log_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package smslog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smslog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_log smslog GetSmsLogById 14 | // 15 | // Get sms log by ID | 通过ID获取短信日志 16 | // 17 | // Get sms log by ID | 通过ID获取短信日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDReq 24 | // 25 | // Responses: 26 | // 200: SmsLogInfoResp 27 | 28 | func GetSmsLogByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smslog.NewGetSmsLogByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetSmsLogById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smslog/get_sms_log_list_handler.go: -------------------------------------------------------------------------------- 1 | package smslog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smslog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_log/list smslog GetSmsLogList 14 | // 15 | // Get sms log list | 获取短信日志列表 16 | // 17 | // Get sms log list | 获取短信日志列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: SmsLogListReq 24 | // 25 | // Responses: 26 | // 200: SmsLogListResp 27 | 28 | func GetSmsLogListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.SmsLogListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smslog.NewGetSmsLogListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetSmsLogList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smslog/update_sms_log_handler.go: -------------------------------------------------------------------------------- 1 | package smslog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smslog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_log/update smslog UpdateSmsLog 14 | // 15 | // Update sms log information | 更新短信日志 16 | // 17 | // Update sms log information | 更新短信日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: SmsLogInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateSmsLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.SmsLogInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smslog.NewUpdateSmsLogLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateSmsLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smsprovider/create_sms_provider_handler.go: -------------------------------------------------------------------------------- 1 | package smsprovider 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smsprovider" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_provider/create smsprovider CreateSmsProvider 14 | // 15 | // Create sms provider information | 创建短信配置 16 | // 17 | // Create sms provider information | 创建短信配置 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: SmsProviderInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateSmsProviderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.SmsProviderInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smsprovider.NewCreateSmsProviderLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateSmsProvider(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smsprovider/delete_sms_provider_handler.go: -------------------------------------------------------------------------------- 1 | package smsprovider 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smsprovider" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_provider/delete smsprovider DeleteSmsProvider 14 | // 15 | // Delete sms provider information | 删除短信配置信息 16 | // 17 | // Delete sms provider information | 删除短信配置信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteSmsProviderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smsprovider.NewDeleteSmsProviderLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteSmsProvider(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smsprovider/get_sms_provider_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package smsprovider 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smsprovider" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_provider smsprovider GetSmsProviderById 14 | // 15 | // Get sms provider by ID | 通过ID获取短信配置 16 | // 17 | // Get sms provider by ID | 通过ID获取短信配置 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: SmsProviderInfoResp 27 | 28 | func GetSmsProviderByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smsprovider.NewGetSmsProviderByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetSmsProviderById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/smsprovider/get_sms_provider_list_handler.go: -------------------------------------------------------------------------------- 1 | package smsprovider 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/smsprovider" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /sms_provider/list smsprovider GetSmsProviderList 14 | // 15 | // Get sms provider list | 获取短信配置列表 16 | // 17 | // Get sms provider list | 获取短信配置列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: SmsProviderListReq 24 | // 25 | // Responses: 26 | // 200: SmsProviderListResp 27 | 28 | func GetSmsProviderListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.SmsProviderListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := smsprovider.NewGetSmsProviderListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetSmsProviderList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/task/create_task_handler.go: -------------------------------------------------------------------------------- 1 | package task 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/task" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task/create task CreateTask 14 | // 15 | // Create task information | 创建Task 16 | // 17 | // Create task information | 创建Task 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TaskInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TaskInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := task.NewCreateTaskLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateTask(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/task/delete_task_handler.go: -------------------------------------------------------------------------------- 1 | package task 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/task" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task/delete task DeleteTask 14 | // 15 | // Delete task information | 删除Task信息 16 | // 17 | // Delete task information | 删除Task信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := task.NewDeleteTaskLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteTask(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/task/get_task_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package task 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/task" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task task GetTaskById 14 | // 15 | // Get task by ID | 通过ID获取Task 16 | // 17 | // Get task by ID | 通过ID获取Task 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: TaskInfoResp 27 | 28 | func GetTaskByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := task.NewGetTaskByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetTaskById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/task/get_task_list_handler.go: -------------------------------------------------------------------------------- 1 | package task 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/task" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task/list task GetTaskList 14 | // 15 | // Get task list | 获取Task列表 16 | // 17 | // Get task list | 获取Task列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TaskListReq 24 | // 25 | // Responses: 26 | // 200: TaskListResp 27 | 28 | func GetTaskListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TaskListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := task.NewGetTaskListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetTaskList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/task/update_task_handler.go: -------------------------------------------------------------------------------- 1 | package task 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/task" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task/update task UpdateTask 14 | // 15 | // Update task information | 更新Task 16 | // 17 | // Update task information | 更新Task 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TaskInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TaskInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := task.NewUpdateTaskLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateTask(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/tasklog/create_task_log_handler.go: -------------------------------------------------------------------------------- 1 | package tasklog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task_log/create tasklog CreateTaskLog 14 | // 15 | // Create task log information | 创建任务日志 16 | // 17 | // Create task log information | 创建任务日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TaskLogInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateTaskLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TaskLogInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := tasklog.NewCreateTaskLogLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateTaskLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/tasklog/delete_task_log_handler.go: -------------------------------------------------------------------------------- 1 | package tasklog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task_log/delete tasklog DeleteTaskLog 14 | // 15 | // Delete task log information | 删除任务日志信息 16 | // 17 | // Delete task log information | 删除任务日志信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteTaskLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := tasklog.NewDeleteTaskLogLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteTaskLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/tasklog/get_task_log_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package tasklog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task_log tasklog GetTaskLogById 14 | // 15 | // Get task log by ID | 通过ID获取任务日志 16 | // 17 | // Get task log by ID | 通过ID获取任务日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: IDReq 24 | // 25 | // Responses: 26 | // 200: TaskLogInfoResp 27 | 28 | func GetTaskLogByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.IDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := tasklog.NewGetTaskLogByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetTaskLogById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/tasklog/get_task_log_list_handler.go: -------------------------------------------------------------------------------- 1 | package tasklog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task_log/list tasklog GetTaskLogList 14 | // 15 | // Get task log list | 获取任务日志列表 16 | // 17 | // Get task log list | 获取任务日志列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TaskLogListReq 24 | // 25 | // Responses: 26 | // 200: TaskLogListResp 27 | 28 | func GetTaskLogListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TaskLogListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := tasklog.NewGetTaskLogListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetTaskLogList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/tasklog/update_task_log_handler.go: -------------------------------------------------------------------------------- 1 | package tasklog 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/tasklog" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /task_log/update tasklog UpdateTaskLog 14 | // 15 | // Update task log information | 更新任务日志 16 | // 17 | // Update task log information | 更新任务日志 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TaskLogInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateTaskLogHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TaskLogInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := tasklog.NewUpdateTaskLogLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateTaskLog(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/token/create_token_handler.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/token" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /token/create token CreateToken 14 | // 15 | // Create token information | 创建Token 16 | // 17 | // Create token information | 创建Token 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TokenInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TokenInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := token.NewCreateTokenLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateToken(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/token/delete_token_handler.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/token" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /token/delete token DeleteToken 14 | // 15 | // Delete token information | 删除Token信息 16 | // 17 | // Delete token information | 删除Token信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := token.NewDeleteTokenLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteToken(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/token/get_token_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/token" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /token token GetTokenById 14 | // 15 | // Get Token by ID | 通过ID获取Token 16 | // 17 | // Get Token by ID | 通过ID获取Token 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDReq 24 | // 25 | // Responses: 26 | // 200: TokenInfoResp 27 | 28 | func GetTokenByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := token.NewGetTokenByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetTokenById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/token/get_token_list_handler.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/token" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /token/list token GetTokenList 14 | // 15 | // Get token list | 获取Token列表 16 | // 17 | // Get token list | 获取Token列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TokenListReq 24 | // 25 | // Responses: 26 | // 200: TokenListResp 27 | 28 | func GetTokenListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TokenListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := token.NewGetTokenListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetTokenList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/token/logout_handler.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/token" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /token/logout token Logout 14 | // 15 | // Force logging out by user UUID | 根据UUID强制用户退出 16 | // 17 | // Force logging out by user UUID | 根据UUID强制用户退出 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := token.NewLogoutLogic(r.Context(), svcCtx) 37 | resp, err := l.Logout(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/token/update_token_handler.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/token" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /token/update token UpdateToken 14 | // 15 | // Update token information | 更新 Token 16 | // 17 | // Update token information | 更新 Token 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: TokenInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.TokenInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := token.NewUpdateTokenLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateToken(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/user/access_token_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /user/access_token user AccessToken 13 | // 14 | // Access token | 获取短期 token 15 | // 16 | // Access token | 获取短期 token 17 | // 18 | // Responses: 19 | // 200: RefreshTokenResp 20 | 21 | func AccessTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := user.NewAccessTokenLogic(r.Context(), svcCtx) 24 | resp, err := l.AccessToken() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/user/change_password_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/change_password user ChangePassword 14 | // 15 | // Change Password | 修改密码 16 | // 17 | // Change Password | 修改密码 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: ChangePasswordReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func ChangePasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.ChangePasswordReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := user.NewChangePasswordLogic(r.Context(), svcCtx) 37 | resp, err := l.ChangePassword(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/user/create_user_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/create user CreateUser 14 | // 15 | // Create user information | 创建用户 16 | // 17 | // Create user information | 创建用户 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UserInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func CreateUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UserInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := user.NewCreateUserLogic(r.Context(), svcCtx) 37 | resp, err := l.CreateUser(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/user/delete_user_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/delete user DeleteUser 14 | // 15 | // Delete user information | 删除用户信息 16 | // 17 | // Delete user information | 删除用户信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDsReq 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func DeleteUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDsReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := user.NewDeleteUserLogic(r.Context(), svcCtx) 37 | resp, err := l.DeleteUser(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/user/get_user_by_id_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user user GetUserById 14 | // 15 | // Get User by ID | 通过ID获取用户 16 | // 17 | // Get User by ID | 通过ID获取用户 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UUIDReq 24 | // 25 | // Responses: 26 | // 200: UserInfoResp 27 | 28 | func GetUserByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UUIDReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := user.NewGetUserByIdLogic(r.Context(), svcCtx) 37 | resp, err := l.GetUserById(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/user/get_user_info_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /user/info user GetUserInfo 13 | // 14 | // Get user basic information | 获取用户基本信息 15 | // 16 | // Get user basic information | 获取用户基本信息 17 | // 18 | // Responses: 19 | // 200: UserBaseIDInfoResp 20 | 21 | func GetUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := user.NewGetUserInfoLogic(r.Context(), svcCtx) 24 | resp, err := l.GetUserInfo() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/user/get_user_list_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/list user GetUserList 14 | // 15 | // Get user list | 获取用户列表 16 | // 17 | // Get user list | 获取用户列表 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UserListReq 24 | // 25 | // Responses: 26 | // 200: UserListResp 27 | 28 | func GetUserListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UserListReq 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := user.NewGetUserListLogic(r.Context(), svcCtx) 37 | resp, err := l.GetUserList(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/user/get_user_perm_code_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /user/perm user GetUserPermCode 13 | // 14 | // Get user's permission code | 获取用户权限码 15 | // 16 | // Get user's permission code | 获取用户权限码 17 | // 18 | // Responses: 19 | // 200: PermCodeResp 20 | 21 | func GetUserPermCodeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := user.NewGetUserPermCodeLogic(r.Context(), svcCtx) 24 | resp, err := l.GetUserPermCode() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/user/get_user_profile_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /user/profile user GetUserProfile 13 | // 14 | // Get user's profile | 获取用户个人信息 15 | // 16 | // Get user's profile | 获取用户个人信息 17 | // 18 | // Responses: 19 | // 200: ProfileResp 20 | 21 | func GetUserProfileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := user.NewGetUserProfileLogic(r.Context(), svcCtx) 24 | resp, err := l.GetUserProfile() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/user/logout_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /user/logout user Logout 13 | // 14 | // Log out | 退出登陆 15 | // 16 | // Log out | 退出登陆 17 | // 18 | // Responses: 19 | // 200: BaseMsgResp 20 | 21 | func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := user.NewLogoutLogic(r.Context(), svcCtx) 24 | resp, err := l.Logout() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/user/refresh_token_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | ) 11 | 12 | // swagger:route get /user/refresh_token user RefreshToken 13 | // 14 | // Refresh token | 获取刷新 token 15 | // 16 | // Refresh token | 获取刷新 token 17 | // 18 | // Responses: 19 | // 200: RefreshTokenResp 20 | 21 | func RefreshTokenHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 22 | return func(w http.ResponseWriter, r *http.Request) { 23 | l := user.NewRefreshTokenLogic(r.Context(), svcCtx) 24 | resp, err := l.RefreshToken() 25 | if err != nil { 26 | err = svcCtx.Trans.TransError(r.Context(), err) 27 | httpx.ErrorCtx(r.Context(), w, err) 28 | } else { 29 | httpx.OkJsonCtx(r.Context(), w, resp) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /api/internal/handler/user/update_user_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/update user UpdateUser 14 | // 15 | // Update user information | 更新用户 16 | // 17 | // Update user information | 更新用户 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: UserInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.UserInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := user.NewUpdateUserLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateUser(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/handler/user/update_user_profile_handler.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/zeromicro/go-zero/rest/httpx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/logic/user" 9 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/api/internal/types" 11 | ) 12 | 13 | // swagger:route post /user/profile user UpdateUserProfile 14 | // 15 | // Update user's profile | 更新用户个人信息 16 | // 17 | // Update user's profile | 更新用户个人信息 18 | // 19 | // Parameters: 20 | // + name: body 21 | // require: true 22 | // in: body 23 | // type: ProfileInfo 24 | // 25 | // Responses: 26 | // 200: BaseMsgResp 27 | 28 | func UpdateUserProfileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { 29 | return func(w http.ResponseWriter, r *http.Request) { 30 | var req types.ProfileInfo 31 | if err := httpx.Parse(r, &req, true); err != nil { 32 | httpx.ErrorCtx(r.Context(), w, err) 33 | return 34 | } 35 | 36 | l := user.NewUpdateUserProfileLogic(r.Context(), svcCtx) 37 | resp, err := l.UpdateUserProfile(&req) 38 | if err != nil { 39 | err = svcCtx.Trans.TransError(r.Context(), err) 40 | httpx.ErrorCtx(r.Context(), w, err) 41 | } else { 42 | httpx.OkJsonCtx(r.Context(), w, resp) 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /api/internal/i18n/var.go: -------------------------------------------------------------------------------- 1 | package i18n 2 | 3 | import ( 4 | "embed" 5 | ) 6 | 7 | //go:embed locale/*.json 8 | var LocaleFS embed.FS 9 | -------------------------------------------------------------------------------- /api/internal/logic/api/create_api_logic.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreateApiLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreateApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateApiLogic { 20 | return &CreateApiLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreateApiLogic) CreateApi(req *types.ApiInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.CreateApi(l.ctx, 29 | &core.ApiInfo{ 30 | Path: req.Path, 31 | Description: req.Description, 32 | ApiGroup: req.Group, 33 | Method: req.Method, 34 | IsRequired: req.IsRequired, 35 | ServiceName: req.ServiceName, 36 | }) 37 | if err != nil { 38 | return nil, err 39 | } 40 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 41 | } 42 | -------------------------------------------------------------------------------- /api/internal/logic/api/delete_api_logic.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteApiLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteApiLogic { 20 | return &DeleteApiLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteApiLogic) DeleteApi(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeleteApi(l.ctx, &core.IDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/api/update_api_logic.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type UpdateApiLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewUpdateApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateApiLogic { 20 | return &UpdateApiLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *UpdateApiLogic) UpdateApi(req *types.ApiInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.UpdateApi(l.ctx, 29 | &core.ApiInfo{ 30 | Id: req.Id, 31 | Path: req.Path, 32 | Description: req.Description, 33 | ApiGroup: req.Group, 34 | Method: req.Method, 35 | IsRequired: req.IsRequired, 36 | ServiceName: req.ServiceName, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 42 | } 43 | -------------------------------------------------------------------------------- /api/internal/logic/authority/create_or_update_menu_authority_logic.go: -------------------------------------------------------------------------------- 1 | package authority 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreateOrUpdateMenuAuthorityLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreateOrUpdateMenuAuthorityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateOrUpdateMenuAuthorityLogic { 20 | return &CreateOrUpdateMenuAuthorityLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreateOrUpdateMenuAuthorityLogic) CreateOrUpdateMenuAuthority(req *types.MenuAuthorityInfoReq) (resp *types.BaseMsgResp, err error) { 28 | authority, err := l.svcCtx.CoreRpc.CreateOrUpdateMenuAuthority(l.ctx, &core.RoleMenuAuthorityReq{ 29 | RoleId: req.RoleId, 30 | MenuIds: req.MenuIds, 31 | }) 32 | if err != nil { 33 | return nil, err 34 | } 35 | 36 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, authority.Msg)}, nil 37 | } 38 | -------------------------------------------------------------------------------- /api/internal/logic/authority/get_menu_authority_logic.go: -------------------------------------------------------------------------------- 1 | package authority 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/api/internal/types" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetMenuAuthorityLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetMenuAuthorityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenuAuthorityLogic { 22 | return &GetMenuAuthorityLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetMenuAuthorityLogic) GetMenuAuthority(req *types.IDReq) (resp *types.MenuAuthorityInfoResp, err error) { 30 | data, err := l.svcCtx.CoreRpc.GetMenuAuthority(l.ctx, &core.IDReq{ 31 | Id: req.Id, 32 | }) 33 | if err != nil { 34 | return nil, err 35 | } 36 | 37 | resp = &types.MenuAuthorityInfoResp{ 38 | BaseDataInfo: types.BaseDataInfo{ 39 | Msg: l.svcCtx.Trans.Trans(l.ctx, i18n.Success), 40 | }, 41 | Data: types.MenuAuthorityInfoReq{ 42 | RoleId: req.Id, 43 | MenuIds: data.MenuIds, 44 | }, 45 | } 46 | 47 | return resp, nil 48 | } 49 | -------------------------------------------------------------------------------- /api/internal/logic/configuration/create_configuration_logic.go: -------------------------------------------------------------------------------- 1 | package configuration 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreateConfigurationLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreateConfigurationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateConfigurationLogic { 20 | return &CreateConfigurationLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreateConfigurationLogic) CreateConfiguration(req *types.ConfigurationInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.CreateConfiguration(l.ctx, 29 | &core.ConfigurationInfo{ 30 | Sort: req.Sort, 31 | State: req.State, 32 | Name: req.Name, 33 | Key: req.Key, 34 | Value: req.Value, 35 | Category: req.Category, 36 | Remark: req.Remark, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 42 | } 43 | -------------------------------------------------------------------------------- /api/internal/logic/configuration/delete_configuration_logic.go: -------------------------------------------------------------------------------- 1 | package configuration 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteConfigurationLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteConfigurationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteConfigurationLogic { 20 | return &DeleteConfigurationLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteConfigurationLogic) DeleteConfiguration(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.DeleteConfiguration(l.ctx, &core.IDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/configuration/update_configuration_logic.go: -------------------------------------------------------------------------------- 1 | package configuration 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type UpdateConfigurationLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewUpdateConfigurationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateConfigurationLogic { 20 | return &UpdateConfigurationLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *UpdateConfigurationLogic) UpdateConfiguration(req *types.ConfigurationInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.UpdateConfiguration(l.ctx, 29 | &core.ConfigurationInfo{ 30 | Id: req.Id, 31 | Sort: req.Sort, 32 | State: req.State, 33 | Name: req.Name, 34 | Key: req.Key, 35 | Value: req.Value, 36 | Category: req.Category, 37 | Remark: req.Remark, 38 | }) 39 | if err != nil { 40 | return nil, err 41 | } 42 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/internal/logic/department/create_department_logic.go: -------------------------------------------------------------------------------- 1 | package department 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreateDepartmentLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreateDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDepartmentLogic { 20 | return &CreateDepartmentLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreateDepartmentLogic) CreateDepartment(req *types.DepartmentInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.CreateDepartment(l.ctx, 29 | &core.DepartmentInfo{ 30 | Status: req.Status, 31 | Sort: req.Sort, 32 | Name: req.Name, 33 | Ancestors: req.Ancestors, 34 | Leader: req.Leader, 35 | Phone: req.Phone, 36 | Email: req.Email, 37 | Remark: req.Remark, 38 | ParentId: req.ParentId, 39 | }) 40 | if err != nil { 41 | return nil, err 42 | } 43 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 44 | } 45 | -------------------------------------------------------------------------------- /api/internal/logic/department/delete_department_logic.go: -------------------------------------------------------------------------------- 1 | package department 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteDepartmentLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteDepartmentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDepartmentLogic { 20 | return &DeleteDepartmentLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteDepartmentLogic) DeleteDepartment(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeleteDepartment(l.ctx, &core.IDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/dictionary/create_dictionary_logic.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/zeromicro/go-zero/core/logx" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/api/internal/types" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | ) 12 | 13 | type CreateDictionaryLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreateDictionaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDictionaryLogic { 20 | return &CreateDictionaryLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreateDictionaryLogic) CreateDictionary(req *types.DictionaryInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.CreateDictionary(l.ctx, 29 | &core.DictionaryInfo{ 30 | Title: req.Title, 31 | Name: req.Name, 32 | Status: req.Status, 33 | Desc: req.Desc, 34 | }) 35 | if err != nil { 36 | return nil, err 37 | } 38 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 39 | } 40 | -------------------------------------------------------------------------------- /api/internal/logic/dictionary/delete_dictionary_logic.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteDictionaryLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteDictionaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictionaryLogic { 20 | return &DeleteDictionaryLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteDictionaryLogic) DeleteDictionary(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeleteDictionary(l.ctx, &core.IDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/dictionary/update_dictionary_logic.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type UpdateDictionaryLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewUpdateDictionaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateDictionaryLogic { 20 | return &UpdateDictionaryLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *UpdateDictionaryLogic) UpdateDictionary(req *types.DictionaryInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.UpdateDictionary(l.ctx, 29 | &core.DictionaryInfo{ 30 | Id: req.Id, 31 | Title: req.Title, 32 | Name: req.Name, 33 | Status: req.Status, 34 | Desc: req.Desc, 35 | }) 36 | if err != nil { 37 | return nil, err 38 | } 39 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 40 | } 41 | -------------------------------------------------------------------------------- /api/internal/logic/emaillog/delete_email_log_logic.go: -------------------------------------------------------------------------------- 1 | package emaillog 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | "github.com/zeromicro/go-zero/core/errorx" 8 | 9 | "github.com/suyuan32/simple-admin-message-center/types/mcms" 10 | 11 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 12 | "github.com/suyuan32/simple-admin-core/api/internal/types" 13 | 14 | "github.com/zeromicro/go-zero/core/logx" 15 | ) 16 | 17 | type DeleteEmailLogLogic struct { 18 | logx.Logger 19 | ctx context.Context 20 | svcCtx *svc.ServiceContext 21 | } 22 | 23 | func NewDeleteEmailLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteEmailLogLogic { 24 | return &DeleteEmailLogLogic{ 25 | Logger: logx.WithContext(ctx), 26 | ctx: ctx, 27 | svcCtx: svcCtx, 28 | } 29 | } 30 | 31 | func (l *DeleteEmailLogLogic) DeleteEmailLog(req *types.UUIDsReq) (resp *types.BaseMsgResp, err error) { 32 | if !l.svcCtx.Config.McmsRpc.Enabled { 33 | return nil, errorx.NewCodeUnavailableError(i18n.ServiceUnavailable) 34 | } 35 | data, err := l.svcCtx.McmsRpc.DeleteEmailLog(l.ctx, &mcms.UUIDsReq{ 36 | Ids: req.Ids, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/internal/logic/emailprovider/delete_email_provider_logic.go: -------------------------------------------------------------------------------- 1 | package emailprovider 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | "github.com/zeromicro/go-zero/core/errorx" 8 | 9 | "github.com/suyuan32/simple-admin-message-center/types/mcms" 10 | 11 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 12 | "github.com/suyuan32/simple-admin-core/api/internal/types" 13 | 14 | "github.com/zeromicro/go-zero/core/logx" 15 | ) 16 | 17 | type DeleteEmailProviderLogic struct { 18 | logx.Logger 19 | ctx context.Context 20 | svcCtx *svc.ServiceContext 21 | } 22 | 23 | func NewDeleteEmailProviderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteEmailProviderLogic { 24 | return &DeleteEmailProviderLogic{ 25 | Logger: logx.WithContext(ctx), 26 | ctx: ctx, 27 | svcCtx: svcCtx, 28 | } 29 | } 30 | 31 | func (l *DeleteEmailProviderLogic) DeleteEmailProvider(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 32 | if !l.svcCtx.Config.McmsRpc.Enabled { 33 | return nil, errorx.NewCodeUnavailableError(i18n.ServiceUnavailable) 34 | } 35 | data, err := l.svcCtx.McmsRpc.DeleteEmailProvider(l.ctx, &mcms.IDsReq{ 36 | Ids: req.Ids, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/internal/logic/menu/delete_menu_logic.go: -------------------------------------------------------------------------------- 1 | package menu 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteMenuLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteMenuLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteMenuLogic { 20 | return &DeleteMenuLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteMenuLogic) DeleteMenu(req *types.IDReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeleteMenu(l.ctx, &core.IDReq{Id: req.Id}) 29 | if err != nil { 30 | return nil, err 31 | } 32 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 33 | } 34 | -------------------------------------------------------------------------------- /api/internal/logic/oauthprovider/delete_oauth_provider_logic.go: -------------------------------------------------------------------------------- 1 | package oauthprovider 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteOauthProviderLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteOauthProviderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOauthProviderLogic { 20 | return &DeleteOauthProviderLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteOauthProviderLogic) DeleteOauthProvider(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeleteOauthProvider(l.ctx, &core.IDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/oauthprovider/oauth_login_logic.go: -------------------------------------------------------------------------------- 1 | package oauthprovider 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/api/internal/types" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type OauthLoginLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewOauthLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OauthLoginLogic { 22 | return &OauthLoginLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *OauthLoginLogic) OauthLogin(req *types.OauthLoginReq) (resp *types.RedirectResp, err error) { 30 | result, err := l.svcCtx.CoreRpc.OauthLogin(l.ctx, &core.OauthLoginReq{ 31 | State: req.State, 32 | Provider: req.Provider, 33 | }) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | return &types.RedirectResp{ 39 | BaseDataInfo: types.BaseDataInfo{Msg: l.svcCtx.Trans.Trans(l.ctx, i18n.Success)}, 40 | Data: types.RedirectInfo{URL: result.Url}, 41 | }, nil 42 | } 43 | -------------------------------------------------------------------------------- /api/internal/logic/position/create_position_logic.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreatePositionLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreatePositionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreatePositionLogic { 20 | return &CreatePositionLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreatePositionLogic) CreatePosition(req *types.PositionInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.CreatePosition(l.ctx, 29 | &core.PositionInfo{ 30 | Status: req.Status, 31 | Sort: req.Sort, 32 | Name: req.Name, 33 | Code: req.Code, 34 | Remark: req.Remark, 35 | }) 36 | if err != nil { 37 | return nil, err 38 | } 39 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 40 | } 41 | -------------------------------------------------------------------------------- /api/internal/logic/position/delete_position_logic.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeletePositionLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeletePositionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeletePositionLogic { 20 | return &DeletePositionLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeletePositionLogic) DeletePosition(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeletePosition(l.ctx, &core.IDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/position/update_position_logic.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type UpdatePositionLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewUpdatePositionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdatePositionLogic { 20 | return &UpdatePositionLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *UpdatePositionLogic) UpdatePosition(req *types.PositionInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.UpdatePosition(l.ctx, 29 | &core.PositionInfo{ 30 | Id: req.Id, 31 | Status: req.Status, 32 | Sort: req.Sort, 33 | Name: req.Name, 34 | Code: req.Code, 35 | Remark: req.Remark, 36 | }) 37 | if err != nil { 38 | return nil, err 39 | } 40 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 41 | } 42 | -------------------------------------------------------------------------------- /api/internal/logic/role/create_role_logic.go: -------------------------------------------------------------------------------- 1 | package role 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreateRoleLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreateRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateRoleLogic { 20 | return &CreateRoleLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreateRoleLogic) CreateRole(req *types.RoleInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.CreateRole(l.ctx, 29 | &core.RoleInfo{ 30 | Status: req.Status, 31 | Name: req.Name, 32 | Code: req.Code, 33 | DefaultRouter: req.DefaultRouter, 34 | Remark: req.Remark, 35 | Sort: req.Sort, 36 | }) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 42 | } 43 | -------------------------------------------------------------------------------- /api/internal/logic/role/delete_role_logic.go: -------------------------------------------------------------------------------- 1 | package role 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteRoleLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteRoleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteRoleLogic { 20 | return &DeleteRoleLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteRoleLogic) DeleteRole(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeleteRole(l.ctx, &core.IDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/smslog/delete_sms_log_logic.go: -------------------------------------------------------------------------------- 1 | package smslog 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | "github.com/zeromicro/go-zero/core/errorx" 8 | 9 | "github.com/suyuan32/simple-admin-message-center/types/mcms" 10 | 11 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 12 | "github.com/suyuan32/simple-admin-core/api/internal/types" 13 | 14 | "github.com/zeromicro/go-zero/core/logx" 15 | ) 16 | 17 | type DeleteSmsLogLogic struct { 18 | logx.Logger 19 | ctx context.Context 20 | svcCtx *svc.ServiceContext 21 | } 22 | 23 | func NewDeleteSmsLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSmsLogLogic { 24 | return &DeleteSmsLogLogic{ 25 | Logger: logx.WithContext(ctx), 26 | ctx: ctx, 27 | svcCtx: svcCtx, 28 | } 29 | } 30 | 31 | func (l *DeleteSmsLogLogic) DeleteSmsLog(req *types.UUIDsReq) (resp *types.BaseMsgResp, err error) { 32 | if !l.svcCtx.Config.McmsRpc.Enabled { 33 | return nil, errorx.NewCodeUnavailableError(i18n.ServiceUnavailable) 34 | } 35 | data, err := l.svcCtx.McmsRpc.DeleteSmsLog(l.ctx, &mcms.UUIDsReq{ 36 | Ids: req.Ids, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/internal/logic/smsprovider/delete_sms_provider_logic.go: -------------------------------------------------------------------------------- 1 | package smsprovider 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | "github.com/zeromicro/go-zero/core/errorx" 8 | 9 | "github.com/suyuan32/simple-admin-message-center/types/mcms" 10 | 11 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 12 | "github.com/suyuan32/simple-admin-core/api/internal/types" 13 | 14 | "github.com/zeromicro/go-zero/core/logx" 15 | ) 16 | 17 | type DeleteSmsProviderLogic struct { 18 | logx.Logger 19 | ctx context.Context 20 | svcCtx *svc.ServiceContext 21 | } 22 | 23 | func NewDeleteSmsProviderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteSmsProviderLogic { 24 | return &DeleteSmsProviderLogic{ 25 | Logger: logx.WithContext(ctx), 26 | ctx: ctx, 27 | svcCtx: svcCtx, 28 | } 29 | } 30 | 31 | func (l *DeleteSmsProviderLogic) DeleteSmsProvider(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 32 | if !l.svcCtx.Config.McmsRpc.Enabled { 33 | return nil, errorx.NewCodeUnavailableError(i18n.ServiceUnavailable) 34 | } 35 | data, err := l.svcCtx.McmsRpc.DeleteSmsProvider(l.ctx, &mcms.IDsReq{ 36 | Ids: req.Ids, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/internal/logic/task/delete_task_logic.go: -------------------------------------------------------------------------------- 1 | package task 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | "github.com/zeromicro/go-zero/core/errorx" 8 | 9 | "github.com/suyuan32/simple-admin-job/types/job" 10 | 11 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 12 | "github.com/suyuan32/simple-admin-core/api/internal/types" 13 | 14 | "github.com/zeromicro/go-zero/core/logx" 15 | ) 16 | 17 | type DeleteTaskLogic struct { 18 | logx.Logger 19 | ctx context.Context 20 | svcCtx *svc.ServiceContext 21 | } 22 | 23 | func NewDeleteTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTaskLogic { 24 | return &DeleteTaskLogic{ 25 | Logger: logx.WithContext(ctx), 26 | ctx: ctx, 27 | svcCtx: svcCtx, 28 | } 29 | } 30 | 31 | func (l *DeleteTaskLogic) DeleteTask(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 32 | if !l.svcCtx.Config.JobRpc.Enabled { 33 | return nil, errorx.NewCodeUnavailableError(i18n.ServiceUnavailable) 34 | } 35 | result, err := l.svcCtx.JobRpc.DeleteTask(l.ctx, &job.IDsReq{ 36 | Ids: req.Ids, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/internal/logic/tasklog/delete_task_log_logic.go: -------------------------------------------------------------------------------- 1 | package tasklog 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | "github.com/zeromicro/go-zero/core/errorx" 8 | 9 | "github.com/suyuan32/simple-admin-job/types/job" 10 | 11 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 12 | "github.com/suyuan32/simple-admin-core/api/internal/types" 13 | 14 | "github.com/zeromicro/go-zero/core/logx" 15 | ) 16 | 17 | type DeleteTaskLogLogic struct { 18 | logx.Logger 19 | ctx context.Context 20 | svcCtx *svc.ServiceContext 21 | } 22 | 23 | func NewDeleteTaskLogLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTaskLogLogic { 24 | return &DeleteTaskLogLogic{ 25 | Logger: logx.WithContext(ctx), 26 | ctx: ctx, 27 | svcCtx: svcCtx, 28 | } 29 | } 30 | 31 | func (l *DeleteTaskLogLogic) DeleteTaskLog(req *types.IDsReq) (resp *types.BaseMsgResp, err error) { 32 | if !l.svcCtx.Config.JobRpc.Enabled { 33 | return nil, errorx.NewCodeUnavailableError(i18n.ServiceUnavailable) 34 | } 35 | result, err := l.svcCtx.JobRpc.DeleteTaskLog(l.ctx, &job.IDsReq{ 36 | Ids: req.Ids, 37 | }) 38 | if err != nil { 39 | return nil, err 40 | } 41 | 42 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/internal/logic/token/create_token_logic.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type CreateTokenLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewCreateTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateTokenLogic { 20 | return &CreateTokenLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *CreateTokenLogic) CreateToken(req *types.TokenInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.CreateToken(l.ctx, 29 | &core.TokenInfo{ 30 | Status: req.Status, 31 | Uuid: req.Uuid, 32 | Token: req.Token, 33 | Source: req.Source, 34 | Username: req.Username, 35 | ExpiredAt: req.ExpiredAt, 36 | }) 37 | if err != nil { 38 | return nil, err 39 | } 40 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 41 | } 42 | -------------------------------------------------------------------------------- /api/internal/logic/token/delete_token_logic.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteTokenLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTokenLogic { 20 | return &DeleteTokenLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteTokenLogic) DeleteToken(req *types.UUIDsReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeleteToken(l.ctx, &core.UUIDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/token/logout_logic.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type LogoutLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewLogoutLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogoutLogic { 20 | return &LogoutLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *LogoutLogic) Logout(req *types.UUIDReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.BlockUserAllToken(l.ctx, &core.UUIDReq{Id: req.Id}) 29 | if err != nil { 30 | return nil, err 31 | } 32 | 33 | return &types.BaseMsgResp{Msg: result.Msg}, nil 34 | } 35 | -------------------------------------------------------------------------------- /api/internal/logic/token/update_token_logic.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type UpdateTokenLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewUpdateTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateTokenLogic { 20 | return &UpdateTokenLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *UpdateTokenLogic) UpdateToken(req *types.TokenInfo) (resp *types.BaseMsgResp, err error) { 28 | data, err := l.svcCtx.CoreRpc.UpdateToken(l.ctx, &core.TokenInfo{Id: req.Id, Source: req.Source, Status: req.Status}) 29 | 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, data.Msg)}, nil 35 | } 36 | -------------------------------------------------------------------------------- /api/internal/logic/user/delete_user_logic.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type DeleteUserLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewDeleteUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserLogic { 20 | return &DeleteUserLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *DeleteUserLogic) DeleteUser(req *types.UUIDsReq) (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.DeleteUser(l.ctx, &core.UUIDsReq{ 29 | Ids: req.Ids, 30 | }) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 36 | } 37 | -------------------------------------------------------------------------------- /api/internal/logic/user/get_user_perm_code_logic.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "strings" 7 | 8 | "github.com/suyuan32/simple-admin-common/i18n" 9 | "github.com/zeromicro/go-zero/core/errorx" 10 | 11 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 12 | "github.com/suyuan32/simple-admin-core/api/internal/types" 13 | "github.com/zeromicro/go-zero/core/logx" 14 | ) 15 | 16 | type GetUserPermCodeLogic struct { 17 | logx.Logger 18 | ctx context.Context 19 | svcCtx *svc.ServiceContext 20 | } 21 | 22 | func NewGetUserPermCodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserPermCodeLogic { 23 | return &GetUserPermCodeLogic{ 24 | Logger: logx.WithContext(ctx), 25 | ctx: ctx, 26 | svcCtx: svcCtx, 27 | } 28 | } 29 | 30 | func (l *GetUserPermCodeLogic) GetUserPermCode() (resp *types.PermCodeResp, err error) { 31 | roleId := l.ctx.Value("roleId").(string) 32 | if roleId == "" { 33 | return nil, &errorx.ApiError{ 34 | Code: http.StatusUnauthorized, 35 | Msg: "login.requireLogin", 36 | } 37 | } 38 | 39 | return &types.PermCodeResp{ 40 | BaseDataInfo: types.BaseDataInfo{Msg: l.svcCtx.Trans.Trans(l.ctx, i18n.Success)}, 41 | Data: strings.Split(roleId, ","), 42 | }, nil 43 | } 44 | -------------------------------------------------------------------------------- /api/internal/logic/user/get_user_profile_logic.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/i18n" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/api/internal/types" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetUserProfileLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewGetUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserProfileLogic { 22 | return &GetUserProfileLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *GetUserProfileLogic) GetUserProfile() (resp *types.ProfileResp, err error) { 30 | data, err := l.svcCtx.CoreRpc.GetUserById(l.ctx, &core.UUIDReq{Id: l.ctx.Value("userId").(string)}) 31 | if err != nil { 32 | return nil, err 33 | } 34 | 35 | return &types.ProfileResp{ 36 | BaseDataInfo: types.BaseDataInfo{ 37 | Code: 0, 38 | Msg: l.svcCtx.Trans.Trans(l.ctx, i18n.Success), 39 | }, 40 | Data: types.ProfileInfo{ 41 | Nickname: data.Nickname, 42 | Avatar: data.Avatar, 43 | Mobile: data.Mobile, 44 | Email: data.Email, 45 | }, 46 | }, nil 47 | } 48 | -------------------------------------------------------------------------------- /api/internal/logic/user/logout_logic.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/api/internal/types" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | ) 12 | 13 | type LogoutLogic struct { 14 | logx.Logger 15 | ctx context.Context 16 | svcCtx *svc.ServiceContext 17 | } 18 | 19 | func NewLogoutLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LogoutLogic { 20 | return &LogoutLogic{ 21 | Logger: logx.WithContext(ctx), 22 | ctx: ctx, 23 | svcCtx: svcCtx, 24 | } 25 | } 26 | 27 | func (l *LogoutLogic) Logout() (resp *types.BaseMsgResp, err error) { 28 | result, err := l.svcCtx.CoreRpc.BlockUserAllToken(l.ctx, 29 | &core.UUIDReq{Id: l.ctx.Value("userId").(string)}) 30 | if err != nil { 31 | return nil, err 32 | } 33 | 34 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 35 | } 36 | -------------------------------------------------------------------------------- /api/internal/logic/user/update_user_profile_logic.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/utils/pointy" 7 | 8 | "github.com/suyuan32/simple-admin-core/api/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/api/internal/types" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type UpdateUserProfileLogic struct { 16 | logx.Logger 17 | ctx context.Context 18 | svcCtx *svc.ServiceContext 19 | } 20 | 21 | func NewUpdateUserProfileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateUserProfileLogic { 22 | return &UpdateUserProfileLogic{ 23 | Logger: logx.WithContext(ctx), 24 | ctx: ctx, 25 | svcCtx: svcCtx, 26 | } 27 | } 28 | 29 | func (l *UpdateUserProfileLogic) UpdateUserProfile(req *types.ProfileInfo) (resp *types.BaseMsgResp, err error) { 30 | result, err := l.svcCtx.CoreRpc.UpdateUser(l.ctx, &core.UserInfo{ 31 | Id: pointy.GetPointer(l.ctx.Value("userId").(string)), 32 | Nickname: req.Nickname, 33 | Email: req.Email, 34 | Mobile: req.Mobile, 35 | Avatar: req.Avatar, 36 | }) 37 | if err != nil { 38 | return nil, err 39 | } 40 | 41 | return &types.BaseMsgResp{Msg: l.svcCtx.Trans.Trans(l.ctx, result.Msg)}, nil 42 | } 43 | -------------------------------------------------------------------------------- /deploy/docker-compose/all_in_one/postgresql/backend/default.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | listen [::]:80; 4 | server_name localhost; 5 | 6 | location / { 7 | root /usr/share/nginx/html; 8 | index index.html index.htm; 9 | try_files $uri $uri/ /index.html; 10 | } 11 | 12 | location /sys-api/ { 13 | proxy_set_header Host $http_host; 14 | proxy_set_header X-Real-IP $remote_addr; 15 | proxy_set_header REMOTE-HOST $remote_addr; 16 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 17 | proxy_pass http://10.5.0.5:9100/; 18 | } 19 | 20 | # location /file-manager/ { 21 | # proxy_set_header Host $http_host; 22 | # proxy_set_header X-Real-IP $remote_addr; 23 | # proxy_set_header REMOTE-HOST $remote_addr; 24 | # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 25 | # proxy_pass http://10.5.0.7:9102/; 26 | # } 27 | } -------------------------------------------------------------------------------- /deploy/docker-compose/all_in_one/postgresql/rpc/etc/core.yaml: -------------------------------------------------------------------------------- 1 | Name: core.rpc 2 | ListenOn: 0.0.0.0:9101 3 | 4 | DatabaseConf: 5 | Type: postgres 6 | Host: postgresql-server 7 | Port: 5432 8 | DBName: simple_admin 9 | Username: postgres # set your username 10 | Password: simple-admin. # set your password 11 | MaxOpenConn: 100 12 | SSLMode: disable 13 | CacheTime: 5 14 | 15 | RedisConf: 16 | Host: redis-server:6379 17 | Type: node 18 | 19 | Log: 20 | ServiceName: coreRpcLogger 21 | Mode: file 22 | Path: /home/data/logs/core/rpc 23 | Encoding: json 24 | Level: info 25 | Compress: false 26 | KeepDays: 7 27 | StackCoolDownMillis: 100 28 | 29 | Prometheus: 30 | Host: 0.0.0.0 31 | Port: 4001 32 | Path: /metrics 33 | 34 | CasbinConf: 35 | ModelText: | 36 | [request_definition] 37 | r = sub, obj, act 38 | [policy_definition] 39 | p = sub, obj, act 40 | [role_definition] 41 | g = _, _ 42 | [policy_effect] 43 | e = some(where (p.eft == allow)) 44 | [matchers] 45 | m = r.sub == p.sub && keyMatch2(r.obj,p.obj) && r.act == p.act -------------------------------------------------------------------------------- /deploy/docker-compose/all_in_one/readme.md: -------------------------------------------------------------------------------- 1 | # 一键体验 docker-compose 2 | 3 | > 只需两步 4 | 5 | 1. 启动 docker-compose 6 | 7 | ```shell 8 | docker-compose up -d 9 | ``` 10 | 11 | 2. 初始化数据库 12 | 13 | > http://localhost/#/init 14 | 15 | # 该文件夹下有 api 和 rpc 的 etc 配置文件参考 16 | 17 | 18 | -------------------------------------------------------------------------------- /deploy/docker-compose/all_in_one/readme_en.md: -------------------------------------------------------------------------------- 1 | # Quick start with docker-compose 2 | 3 | > 2 Steps 4 | 5 | 1. Run docker-compose 6 | 7 | ```shell 8 | docker-compose up -d 9 | ``` 10 | 11 | 2. Initialize database 12 | 13 | > http://localhost/#/init 14 | 15 | # In this folder, you can check the api and rpc configuration 16 | 17 | 18 | -------------------------------------------------------------------------------- /deploy/docker-compose/jaeger/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | jaeger: 5 | image: jaegertracing/all-in-one:latest 6 | container_name: jaeger 7 | ports: 8 | - "16686:16686" 9 | - "4317:4317" 10 | - "4318:4318" 11 | environment: 12 | # - SPAN_STORAGE_TYPE=elasticsearch 13 | # - ES_SERVER_URLS=http://elasticsearch:9200 14 | - LOG_LEVEL=debug 15 | - COLLECTOR_OTLP_ENABLED=true 16 | deploy: 17 | resources: 18 | limits: 19 | cpus: '0.8' 20 | memory: 500M 21 | reservations: 22 | cpus: '0.05' 23 | memory: 200M 24 | -------------------------------------------------------------------------------- /deploy/docker-compose/mongodb/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | # Use root/example as user/password credentials 2 | version: '3.1' 3 | 4 | services: 5 | mongo: 6 | image: mongo:latest 7 | restart: always 8 | environment: 9 | MONGO_INITDB_ROOT_USERNAME: root 10 | MONGO_INITDB_ROOT_PASSWORD: simple_admin -------------------------------------------------------------------------------- /deploy/docker-compose/mysql_redis/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | volumes: 4 | mysql: 5 | redis: 6 | 7 | networks: 8 | simple-admin: 9 | driver: bridge 10 | 11 | services: 12 | mysql: 13 | image: mysql:8.3.0 14 | container_name: mysql 15 | command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci 16 | restart: always 17 | ports: 18 | - '3306:3306' 19 | environment: 20 | MYSQL_DATABASE: 'simple_admin' 21 | MYSQL_ROOT_PASSWORD: '123456' 22 | volumes: 23 | - mysql:/var/lib/mysql 24 | networks: 25 | simple-admin: 26 | aliases: 27 | - mysqlserver 28 | deploy: 29 | resources: 30 | limits: 31 | cpus: '0.5' 32 | memory: 1000M 33 | reservations: 34 | cpus: '0.05' 35 | memory: 200M 36 | 37 | redis: 38 | image: redis:7.0.5-alpine 39 | container_name: redis 40 | restart: always 41 | ports: 42 | - '6379:6379' 43 | volumes: 44 | - redis:/data 45 | networks: 46 | simple-admin: 47 | aliases: 48 | - redisserver 49 | deploy: 50 | resources: 51 | limits: 52 | cpus: '0.5' 53 | memory: 500M 54 | reservations: 55 | cpus: '0.05' 56 | memory: 200M -------------------------------------------------------------------------------- /deploy/docker-compose/postgresql_redis/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | volumes: 4 | postgresql: 5 | redis: 6 | 7 | networks: 8 | simple-admin: 9 | driver: bridge 10 | 11 | services: 12 | postgresql: 13 | image: bitnami/postgresql:latest 14 | container_name: postgresql 15 | restart: always 16 | ports: 17 | - '5432:5432' 18 | environment: 19 | MYSQL_DATABASE: 'simple_admin' 20 | POSTGRESQL_PASSWORD: '123456' 21 | volumes: 22 | - 'postgresql:/bitnami/postgresql' 23 | networks: 24 | simple-admin: 25 | aliases: 26 | - postgresqlserver 27 | deploy: 28 | resources: 29 | limits: 30 | cpus: '0.5' 31 | memory: 1000M 32 | reservations: 33 | cpus: '0.05' 34 | memory: 200M 35 | 36 | redis: 37 | image: redis:7.0.5-alpine 38 | container_name: redis 39 | restart: always 40 | ports: 41 | - '6379:6379' 42 | volumes: 43 | - redis:/data 44 | networks: 45 | simple-admin: 46 | aliases: 47 | - redisserver 48 | deploy: 49 | resources: 50 | limits: 51 | cpus: '0.5' 52 | memory: 500M 53 | reservations: 54 | cpus: '0.05' 55 | memory: 200M 56 | -------------------------------------------------------------------------------- /deploy/docker-compose/rocketmq/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | volumes: 4 | rocketmq_data: 5 | 6 | services: 7 | rocketmq: 8 | image: xuchengen/rocketmq:latest 9 | container_name: rocketmq 10 | ports: 11 | - '8080:8080' 12 | - '9876:9876' 13 | - '10909:10909' 14 | - '10911:10911' 15 | - '10912:10912' 16 | environment: 17 | NAMESRV_XMX: 1024m 18 | BROKER_XMX: 1024m 19 | volumes: 20 | - rocketmq_data:/home/app/data 21 | - /etc/localtime:/etc/localtime 22 | - /var/run/docker.sock:/var/run/docker.sock 23 | network_mode: host 24 | deploy: 25 | resources: 26 | limits: 27 | cpus: '0.8' 28 | memory: 4000M 29 | reservations: 30 | cpus: '0.05' 31 | memory: 200M 32 | -------------------------------------------------------------------------------- /deploy/k8s/auth.yaml: -------------------------------------------------------------------------------- 1 | #创建账号 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: endpoints-finder 6 | 7 | --- 8 | #创建角色对应操作 9 | apiVersion: rbac.authorization.k8s.io/v1 10 | kind: ClusterRole 11 | metadata: 12 | name: discov-endpoints 13 | rules: 14 | - apiGroups: [""] 15 | resources: ["endpoints"] 16 | verbs: ["get","list","watch"] 17 | 18 | --- 19 | #给账号绑定角色 20 | apiVersion: rbac.authorization.k8s.io/v1 21 | kind: ClusterRoleBinding 22 | metadata: 23 | name: endpoints-finder-discov-endpoints 24 | roleRef: 25 | apiGroup: rbac.authorization.k8s.io 26 | kind: ClusterRole 27 | name: discov-endpoints 28 | subjects: 29 | - kind: ServiceAccount 30 | name: endpoints-finder 31 | namespace: default -------------------------------------------------------------------------------- /deploy/k8s/ingress-patch.yaml: -------------------------------------------------------------------------------- 1 | spec: 2 | template: 3 | spec: 4 | containers: 5 | - name: controller 6 | ports: 7 | - containerPort: 8080 8 | hostPort: 8080 9 | - containerPort: 9100 10 | hostPort: 9100 11 | -------------------------------------------------------------------------------- /deploy/k8s/ingress.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: networking.k8s.io/v1 2 | kind: Ingress 3 | metadata: 4 | name: simple-admin-ingress 5 | annotations: 6 | nginx.ingress.kubernetes.io/rewrite-target: /$1 7 | 8 | spec: 9 | rules: 10 | - host: simple-admin.com 11 | http: 12 | paths: 13 | - path: / 14 | pathType: Prefix 15 | backend: 16 | service: 17 | name: backendui-svc 18 | port: 19 | number: 80 20 | - host: simple-admin.com 21 | http: 22 | paths: 23 | - path: /sys-api/ 24 | pathType: Prefix 25 | backend: 26 | service: 27 | name: coreapi-svc 28 | port: 29 | number: 9100 -------------------------------------------------------------------------------- /deploy/k8s/prometheus/prometheus-service-monitor.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: monitoring.coreos.com/v1 2 | kind: Prometheus 3 | metadata: 4 | name: prometheus 5 | spec: 6 | serviceAccountName: prometheus 7 | serviceMonitorSelector: 8 | matchLabels: 9 | serviceMonitor: prometheus 10 | resources: 11 | requests: 12 | memory: 400Mi 13 | enableAdminAPI: false -------------------------------------------------------------------------------- /deploy/k8s/prometheus/rbac.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: prometheus 5 | 6 | --- 7 | 8 | apiVersion: rbac.authorization.k8s.io/v1 9 | kind: ClusterRole 10 | metadata: 11 | name: prometheus 12 | rules: 13 | - apiGroups: [""] 14 | resources: 15 | - nodes 16 | - nodes/metrics 17 | - services 18 | - endpoints 19 | - pods 20 | verbs: ["get", "list", "watch"] 21 | - apiGroups: [""] 22 | resources: 23 | - configmaps 24 | verbs: ["get"] 25 | - apiGroups: 26 | - networking.k8s.io 27 | resources: 28 | - ingresses 29 | verbs: ["get", "list", "watch"] 30 | - nonResourceURLs: ["/metrics"] 31 | verbs: ["get"] 32 | 33 | --- 34 | 35 | apiVersion: rbac.authorization.k8s.io/v1 36 | kind: ClusterRoleBinding 37 | metadata: 38 | name: prometheus 39 | roleRef: 40 | apiGroup: rbac.authorization.k8s.io 41 | kind: ClusterRole 42 | name: prometheus 43 | subjects: 44 | - kind: ServiceAccount 45 | name: prometheus 46 | namespace: default -------------------------------------------------------------------------------- /deploy/k8s/prometheus/setup.sh: -------------------------------------------------------------------------------- 1 | alias kubectl="minikube kubectl --" 2 | 3 | kubectl apply -f rbac.yaml 4 | 5 | kubectl apply -f prometheus-service-monitor.yaml 6 | 7 | -------------------------------------------------------------------------------- /deploy/k8s/pv.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolume 3 | metadata: 4 | name: simple-admin-pv-volume 5 | labels: 6 | type: local 7 | spec: 8 | storageClassName: manual 9 | capacity: 10 | storage: 5Gi 11 | accessModes: 12 | - ReadWriteMany 13 | hostPath: 14 | path: "/home/data" 15 | 16 | --- 17 | 18 | apiVersion: v1 19 | kind: PersistentVolumeClaim 20 | metadata: 21 | name: simple-admin-pv-claim 22 | spec: 23 | storageClassName: manual 24 | accessModes: 25 | - ReadWriteMany 26 | resources: 27 | requests: 28 | storage: 3Gi 29 | 30 | -------------------------------------------------------------------------------- /deploy/k8s/setup-ingress.sh: -------------------------------------------------------------------------------- 1 | alias kubectl="minikube kubectl --" 2 | 3 | # register core-api into ingress tcp config map 4 | kubectl patch configmap tcp-services -n ingress-nginx --patch '{"data":{"9100":"simple-admin/core-api-svc:9100"}}' 5 | 6 | # register backend-ui, port 8080 is mapped to port 80 of backend-ui 7 | kubectl patch configmap tcp-services -n ingress-nginx --patch '{"data":{"8080":"simple-admin/backend-ui-svc:80"}}' 8 | 9 | # register service into ingress controller 10 | kubectl patch deployment ingress-nginx-controller --patch "$(cat ingress-patch.yaml)" -n ingress-nginx -------------------------------------------------------------------------------- /deploy/k8s/setup.sh: -------------------------------------------------------------------------------- 1 | alias kubectl="minikube kubectl --" 2 | 3 | # create service account 4 | kubectl apply -f auth.yaml 5 | 6 | # create persistent volume for log 7 | kubectl apply -f pv.yaml 8 | 9 | # create core rpc 10 | kubectl apply -f core-rpc.yaml 11 | 12 | # create core api 13 | kubectl apply -f core-api.yaml 14 | 15 | # create backend ui 16 | kubectl apply -f backend-ui.yaml 17 | -------------------------------------------------------------------------------- /rpc/.gitignore: -------------------------------------------------------------------------------- 1 | ### Go template 2 | # Binaries for programs and plugins 3 | *.exe 4 | *.exe~ 5 | *.dll 6 | *.so 7 | *.dylib 8 | 9 | # Test binary, built with `go test -c` 10 | *.test 11 | 12 | # Output of the go coverage tool, specifically when used with LiteIDE 13 | *.out 14 | 15 | # Dependency directories (remove the comment below to include it) 16 | # vendor/ 17 | 18 | *.gz 19 | *.rar 20 | *.tmp 21 | 22 | # Other files and folders 23 | .settings/ 24 | .idea/ 25 | .vscode/ 26 | 27 | # config file avoid exposing private data 28 | *_dev.yaml 29 | 30 | # Build files 31 | *_api 32 | *_rpc 33 | 34 | # VsCode debug files 35 | _debug* -------------------------------------------------------------------------------- /rpc/core.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | 7 | "github.com/suyuan32/simple-admin-core/rpc/internal/config" 8 | "github.com/suyuan32/simple-admin-core/rpc/internal/server" 9 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/conf" 13 | "github.com/zeromicro/go-zero/core/service" 14 | "github.com/zeromicro/go-zero/zrpc" 15 | "google.golang.org/grpc" 16 | "google.golang.org/grpc/reflection" 17 | ) 18 | 19 | var configFile = flag.String("f", "etc/core.yaml", "the config file") 20 | 21 | func main() { 22 | flag.Parse() 23 | 24 | var c config.Config 25 | conf.MustLoad(*configFile, &c, conf.UseEnv()) 26 | ctx := svc.NewServiceContext(c) 27 | 28 | s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { 29 | core.RegisterCoreServer(grpcServer, server.NewCoreServer(ctx)) 30 | 31 | if c.Mode == service.DevMode || c.Mode == service.TestMode { 32 | reflection.Register(grpcServer) 33 | } 34 | }) 35 | defer s.Stop() 36 | 37 | fmt.Printf("Starting rpc server at %s...\n", c.ListenOn) 38 | s.Start() 39 | } 40 | -------------------------------------------------------------------------------- /rpc/desc/api.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // API message 4 | 5 | message ApiInfo { 6 | optional uint64 id = 1; 7 | optional int64 created_at = 2; 8 | optional int64 updated_at = 3; 9 | optional string path = 4; 10 | optional string description = 5; 11 | optional string api_group = 6; 12 | optional string method = 7; 13 | optional bool is_required = 8; 14 | optional string service_name = 9; 15 | } 16 | 17 | message ApiListResp { 18 | uint64 total = 1; 19 | repeated ApiInfo data = 2; 20 | } 21 | 22 | message ApiListReq { 23 | uint64 page = 1; 24 | uint64 page_size = 2; 25 | optional string path = 3; 26 | optional string description = 4; 27 | optional string api_group = 5; 28 | optional string method = 6; 29 | optional string is_default = 7; 30 | optional string service_name = 8; 31 | } 32 | 33 | 34 | service Core { 35 | 36 | // API management 37 | // group: api 38 | rpc createApi (ApiInfo) returns (BaseIDResp); 39 | // group: api 40 | rpc updateApi (ApiInfo) returns (BaseResp); 41 | // group: api 42 | rpc getApiList (ApiListReq) returns (ApiListResp); 43 | // group: api 44 | rpc getApiById (IDReq) returns (ApiInfo); 45 | // group: api 46 | rpc deleteApi (IDsReq) returns (BaseResp); 47 | 48 | 49 | } -------------------------------------------------------------------------------- /rpc/desc/authority.proto: -------------------------------------------------------------------------------- 1 | syntax="proto3"; 2 | 3 | // authorization message 4 | message RoleMenuAuthorityReq { 5 | uint64 role_id = 1; 6 | repeated uint64 menu_ids = 2; 7 | } 8 | // return the role's authorization menu's ids 9 | message RoleMenuAuthorityResp { 10 | repeated uint64 menu_ids = 1; 11 | } 12 | 13 | 14 | service Core { 15 | // authorization management service 16 | 17 | // group: authority 18 | rpc getMenuAuthority (IDReq) returns (RoleMenuAuthorityResp); 19 | // group: authority 20 | rpc createOrUpdateMenuAuthority (RoleMenuAuthorityReq) returns (BaseResp); 21 | } -------------------------------------------------------------------------------- /rpc/desc/base.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package core; 4 | 5 | option go_package = "./core"; 6 | 7 | // base message 8 | message Empty {} 9 | 10 | message IDReq { 11 | uint64 id = 1; 12 | } 13 | 14 | message IDsReq { 15 | repeated uint64 ids = 1; 16 | } 17 | 18 | message UUIDsReq { 19 | repeated string ids = 1; 20 | } 21 | 22 | message UUIDReq { 23 | string id = 1; 24 | } 25 | 26 | message BaseResp { 27 | string msg = 1; 28 | } 29 | 30 | message PageInfoReq { 31 | uint64 page = 1; 32 | uint64 page_size = 2; 33 | } 34 | 35 | message BaseMsg { 36 | string msg = 1; 37 | } 38 | 39 | message BaseIDResp { 40 | uint64 id = 1; 41 | string msg = 2; 42 | } 43 | 44 | message BaseUUIDResp { 45 | string id = 1; 46 | string msg = 2; 47 | } 48 | 49 | service Core { 50 | // group: base 51 | rpc initDatabase (Empty) returns (BaseResp); 52 | } -------------------------------------------------------------------------------- /rpc/desc/dictionary.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // Dictionary message 4 | 5 | message DictionaryInfo { 6 | optional uint64 id = 1; 7 | optional int64 created_at = 2; 8 | optional int64 updated_at = 3; 9 | optional uint32 status = 4; 10 | optional string title = 5; 11 | optional string name = 6; 12 | optional string desc = 7; 13 | } 14 | 15 | message DictionaryListResp { 16 | uint64 total = 1; 17 | repeated DictionaryInfo data = 2; 18 | } 19 | 20 | message DictionaryListReq { 21 | uint64 page = 1; 22 | uint64 page_size = 2; 23 | optional string name = 3; 24 | } 25 | 26 | 27 | service Core { 28 | 29 | // Dictionary management 30 | // group: dictionary 31 | rpc createDictionary (DictionaryInfo) returns (BaseIDResp); 32 | // group: dictionary 33 | rpc updateDictionary (DictionaryInfo) returns (BaseResp); 34 | // group: dictionary 35 | rpc getDictionaryList (DictionaryListReq) returns (DictionaryListResp); 36 | // group: dictionary 37 | rpc getDictionaryById (IDReq) returns (DictionaryInfo); 38 | // group: dictionary 39 | rpc deleteDictionary (IDsReq) returns (BaseResp); 40 | 41 | 42 | } -------------------------------------------------------------------------------- /rpc/desc/position.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // Position message 4 | 5 | message PositionInfo { 6 | optional uint64 id = 1; 7 | optional int64 created_at = 2; 8 | optional int64 updated_at = 3; 9 | optional uint32 status = 4; 10 | optional uint32 sort = 5; 11 | optional string name = 6; 12 | optional string code = 7; 13 | optional string remark = 8; 14 | } 15 | 16 | message PositionListResp { 17 | uint64 total = 1; 18 | repeated PositionInfo data = 2; 19 | } 20 | 21 | message PositionListReq { 22 | uint64 page = 1; 23 | uint64 page_size = 2; 24 | optional string name = 3; 25 | optional string code = 4; 26 | optional string remark = 5; 27 | } 28 | 29 | 30 | service Core { 31 | 32 | // Position management 33 | // group: position 34 | rpc createPosition (PositionInfo) returns (BaseIDResp); 35 | // group: position 36 | rpc updatePosition (PositionInfo) returns (BaseResp); 37 | // group: position 38 | rpc getPositionList (PositionListReq) returns (PositionListResp); 39 | // group: position 40 | rpc getPositionById (IDReq) returns (PositionInfo); 41 | // group: position 42 | rpc deletePosition (IDsReq) returns (BaseResp); 43 | 44 | 45 | } -------------------------------------------------------------------------------- /rpc/desc/role.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // Role message 4 | 5 | message RoleInfo { 6 | optional uint64 id = 1; 7 | optional int64 created_at = 2; 8 | optional int64 updated_at = 3; 9 | optional uint32 status = 4; 10 | optional string name = 5; 11 | optional string code = 6; 12 | optional string default_router = 7; 13 | optional string remark = 8; 14 | optional uint32 sort = 9; 15 | } 16 | 17 | message RoleListResp { 18 | uint64 total = 1; 19 | repeated RoleInfo data = 2; 20 | } 21 | 22 | message RoleListReq { 23 | uint64 page = 1; 24 | uint64 page_size = 2; 25 | optional string name = 3; 26 | optional string code = 4; 27 | optional string default_router = 5; 28 | } 29 | 30 | 31 | service Core { 32 | 33 | // Role management 34 | // group: role 35 | rpc createRole (RoleInfo) returns (BaseIDResp); 36 | // group: role 37 | rpc updateRole (RoleInfo) returns (BaseResp); 38 | // group: role 39 | rpc getRoleList (RoleListReq) returns (RoleListResp); 40 | // group: role 41 | rpc getRoleById (IDReq) returns (RoleInfo); 42 | // group: role 43 | rpc deleteRole (IDsReq) returns (BaseResp); 44 | 45 | 46 | } -------------------------------------------------------------------------------- /rpc/desc/token.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // Token message 4 | 5 | message TokenInfo { 6 | optional string id = 1; 7 | optional int64 created_at = 2; 8 | optional int64 updated_at = 3; 9 | optional uint32 status = 4; 10 | optional string uuid = 5; 11 | optional string token = 6; 12 | optional string source = 7; 13 | optional int64 expired_at = 8; 14 | optional string username = 9; 15 | } 16 | 17 | message TokenListResp { 18 | uint64 total = 1; 19 | repeated TokenInfo data = 2; 20 | } 21 | 22 | message TokenListReq { 23 | uint64 page = 1; 24 | uint64 page_size = 2; 25 | optional string username = 3; 26 | optional string nickname = 4; 27 | optional string email = 5; 28 | optional string uuid = 6; 29 | } 30 | 31 | 32 | service Core { 33 | 34 | // Token management 35 | // group: token 36 | rpc createToken (TokenInfo) returns (BaseUUIDResp); 37 | // group: token 38 | rpc deleteToken (UUIDsReq) returns (BaseResp); 39 | // group: token 40 | rpc getTokenList (TokenListReq) returns (TokenListResp); 41 | // group: token 42 | rpc getTokenById (UUIDReq) returns (TokenInfo); 43 | // group: token 44 | rpc blockUserAllToken (UUIDReq) returns (BaseResp); 45 | // group: token 46 | rpc updateToken (TokenInfo) returns (BaseResp); 47 | } -------------------------------------------------------------------------------- /rpc/ent/generate.go: -------------------------------------------------------------------------------- 1 | package ent 2 | 3 | //go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema 4 | -------------------------------------------------------------------------------- /rpc/ent/predicate/predicate.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package predicate 4 | 5 | import ( 6 | "entgo.io/ent/dialect/sql" 7 | ) 8 | 9 | // API is the predicate function for api builders. 10 | type API func(*sql.Selector) 11 | 12 | // Configuration is the predicate function for configuration builders. 13 | type Configuration func(*sql.Selector) 14 | 15 | // Department is the predicate function for department builders. 16 | type Department func(*sql.Selector) 17 | 18 | // Dictionary is the predicate function for dictionary builders. 19 | type Dictionary func(*sql.Selector) 20 | 21 | // DictionaryDetail is the predicate function for dictionarydetail builders. 22 | type DictionaryDetail func(*sql.Selector) 23 | 24 | // Menu is the predicate function for menu builders. 25 | type Menu func(*sql.Selector) 26 | 27 | // OauthProvider is the predicate function for oauthprovider builders. 28 | type OauthProvider func(*sql.Selector) 29 | 30 | // Position is the predicate function for position builders. 31 | type Position func(*sql.Selector) 32 | 33 | // Role is the predicate function for role builders. 34 | type Role func(*sql.Selector) 35 | 36 | // Token is the predicate function for token builders. 37 | type Token func(*sql.Selector) 38 | 39 | // User is the predicate function for user builders. 40 | type User func(*sql.Selector) 41 | -------------------------------------------------------------------------------- /rpc/ent/runtime.go: -------------------------------------------------------------------------------- 1 | // Code generated by ent, DO NOT EDIT. 2 | 3 | package ent 4 | 5 | // The schema-stitching logic is generated in github.com/suyuan32/simple-admin-core/rpc/ent/runtime/runtime.go 6 | -------------------------------------------------------------------------------- /rpc/ent/schema/dictionary.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/dialect/entsql" 6 | "entgo.io/ent/schema" 7 | "entgo.io/ent/schema/edge" 8 | "entgo.io/ent/schema/field" 9 | "github.com/suyuan32/simple-admin-common/orm/ent/mixins" 10 | ) 11 | 12 | type Dictionary struct { 13 | ent.Schema 14 | } 15 | 16 | func (Dictionary) Fields() []ent.Field { 17 | return []ent.Field{ 18 | field.String("title"). 19 | Comment("The title shown in the ui | 展示名称 (建议配合i18n)"), 20 | field.String("name").Unique(). 21 | Comment("The name of dictionary for search | 字典搜索名称"), 22 | field.String("desc"). 23 | Comment("The description of dictionary | 字典的描述"). 24 | Optional(), 25 | } 26 | } 27 | 28 | func (Dictionary) Mixin() []ent.Mixin { 29 | return []ent.Mixin{ 30 | mixins.IDMixin{}, 31 | mixins.StatusMixin{}, 32 | } 33 | } 34 | 35 | func (Dictionary) Edges() []ent.Edge { 36 | return []ent.Edge{ 37 | edge.To("dictionary_details", DictionaryDetail.Type), 38 | } 39 | } 40 | 41 | func (Dictionary) Annotations() []schema.Annotation { 42 | return []schema.Annotation{ 43 | entsql.WithComments(true), 44 | schema.Comment("Dictionary Table | 字典信息表"), 45 | entsql.Annotation{Table: "sys_dictionaries"}, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /rpc/ent/schema/position.go: -------------------------------------------------------------------------------- 1 | package schema 2 | 3 | import ( 4 | "entgo.io/ent" 5 | "entgo.io/ent/dialect/entsql" 6 | "entgo.io/ent/schema" 7 | "entgo.io/ent/schema/edge" 8 | "entgo.io/ent/schema/field" 9 | "entgo.io/ent/schema/index" 10 | 11 | "github.com/suyuan32/simple-admin-common/orm/ent/mixins" 12 | ) 13 | 14 | type Position struct { 15 | ent.Schema 16 | } 17 | 18 | func (Position) Fields() []ent.Field { 19 | return []ent.Field{ 20 | field.String("name"). 21 | Comment("Position Name | 职位名称"), 22 | field.String("code"). 23 | Comment("The code of position | 职位编码"), 24 | field.String("remark").Optional(). 25 | Comment("Remark | 备注"), 26 | } 27 | } 28 | 29 | func (Position) Mixin() []ent.Mixin { 30 | return []ent.Mixin{ 31 | mixins.IDMixin{}, 32 | mixins.StatusMixin{}, 33 | mixins.SortMixin{}, 34 | } 35 | } 36 | 37 | func (Position) Edges() []ent.Edge { 38 | return []ent.Edge{ 39 | edge.From("users", User.Type).Ref("positions"), 40 | } 41 | } 42 | 43 | func (Position) Indexes() []ent.Index { 44 | return []ent.Index{ 45 | index.Fields("code").Unique(), 46 | } 47 | } 48 | 49 | func (Position) Annotations() []schema.Annotation { 50 | return []schema.Annotation{ 51 | entsql.WithComments(true), 52 | schema.Comment("Position Table | 职位信息表"), 53 | entsql.Annotation{Table: "sys_positions"}, 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /rpc/ent/template/set_not_nil.tmpl: -------------------------------------------------------------------------------- 1 | {{/* 2 | Copyright 2022-present Ryan SU (github.com/suyuan32). All rights reserved. 3 | This source code is licensed under the Apache 2.0 license found 4 | in the LICENSE file in the root directory of this source tree. 5 | */}} 6 | 7 | {{/* gotype: entgo.io/ent/entc/gen.Graph */}} 8 | 9 | 10 | {{ define "set_not_nil" }} 11 | 12 | {{/* Add the base header for the generated file */}} 13 | {{ $pkg := base $.Config.Package }} 14 | {{ template "header" $ }} 15 | 16 | {{/* Loop over all updaters and implement the "SetNotNil" method for all optional fields */}} 17 | {{ range $n := $.Nodes }} 18 | {{ range $f := $n.MutableFields }} 19 | {{ $set := print "Set" $f.StructField }} 20 | 21 | {{ range $updater := list $n.UpdateName $n.UpdateOneName $n.CreateName}} 22 | // set field if value's pointer is not nil. 23 | func ({{ $n.Receiver }} *{{ $updater }}) SetNotNil{{ $f.StructField }}(value {{if not (hasPrefix $f.Type.String "[]") }}*{{end}}{{ $f.Type }}) *{{ $updater }} { 24 | if value != nil { 25 | return {{ $n.Receiver }}.{{ $set }}({{if not (hasPrefix $f.Type.String "[]") }}*{{end}}value) 26 | } 27 | return {{ $n.Receiver }} 28 | } 29 | {{ end }} 30 | {{ end }} 31 | {{ end }} 32 | {{ end }} -------------------------------------------------------------------------------- /rpc/etc/core.yaml: -------------------------------------------------------------------------------- 1 | Name: core.rpc 2 | ListenOn: 0.0.0.0:9101 3 | 4 | DatabaseConf: 5 | Type: mysql 6 | Host: 127.0.0.1 7 | Port: 3306 8 | DBName: simple_admin 9 | Username: # set your username 10 | Password: # set your password 11 | MaxOpenConn: 100 12 | SSLMode: disable # disable or require 13 | CacheTime: 5 14 | 15 | Log: 16 | ServiceName: coreRpcLogger 17 | Mode: file 18 | Path: /home/data/logs/core/rpc 19 | Encoding: json 20 | Level: info 21 | Compress: false 22 | KeepDays: 7 23 | StackCoolDownMillis: 100 24 | 25 | RedisConf: 26 | Host: 127.0.0.1:6379 27 | 28 | Prometheus: 29 | Host: 0.0.0.0 30 | Port: 4001 31 | Path: /metrics 32 | 33 | CasbinConf: 34 | ModelText: | 35 | [request_definition] 36 | r = sub, obj, act 37 | [policy_definition] 38 | p = sub, obj, act 39 | [role_definition] 40 | g = _, _ 41 | [policy_effect] 42 | e = some(where (p.eft == allow)) 43 | [matchers] 44 | m = r.sub == p.sub && keyMatch2(r.obj,p.obj) && r.act == p.act 45 | 46 | # Tracing Analysis 47 | 48 | #Telemetry: 49 | # Name: core-rpc 50 | # Endpoint: localhost:4317 51 | # Sampler: 1.0 52 | # Batcher: otlpgrpc # grpc -------------------------------------------------------------------------------- /rpc/internal/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "github.com/suyuan32/simple-admin-common/plugins/casbin" 5 | "github.com/zeromicro/go-zero/zrpc" 6 | 7 | "github.com/suyuan32/simple-admin-common/config" 8 | ) 9 | 10 | type Config struct { 11 | zrpc.RpcServerConf 12 | DatabaseConf config.DatabaseConf 13 | CasbinConf casbin.CasbinConf 14 | RedisConf config.RedisConf 15 | } 16 | -------------------------------------------------------------------------------- /rpc/internal/logic/api/delete_api_logic.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/rpc/ent/api" 7 | 8 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | 14 | "github.com/suyuan32/simple-admin-common/i18n" 15 | ) 16 | 17 | type DeleteApiLogic struct { 18 | ctx context.Context 19 | svcCtx *svc.ServiceContext 20 | logx.Logger 21 | } 22 | 23 | func NewDeleteApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteApiLogic { 24 | return &DeleteApiLogic{ 25 | ctx: ctx, 26 | svcCtx: svcCtx, 27 | Logger: logx.WithContext(ctx), 28 | } 29 | } 30 | 31 | func (l *DeleteApiLogic) DeleteApi(in *core.IDsReq) (*core.BaseResp, error) { 32 | _, err := l.svcCtx.DB.API.Delete().Where(api.IDIn(in.Ids...)).Exec(l.ctx) 33 | if err != nil { 34 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 35 | } 36 | 37 | return &core.BaseResp{Msg: i18n.DeleteSuccess}, nil 38 | } 39 | -------------------------------------------------------------------------------- /rpc/internal/logic/api/update_api_logic.go: -------------------------------------------------------------------------------- 1 | package api 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 7 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 8 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 9 | 10 | "github.com/zeromicro/go-zero/core/logx" 11 | 12 | "github.com/suyuan32/simple-admin-common/i18n" 13 | ) 14 | 15 | type UpdateApiLogic struct { 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | logx.Logger 19 | } 20 | 21 | func NewUpdateApiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateApiLogic { 22 | return &UpdateApiLogic{ 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | Logger: logx.WithContext(ctx), 26 | } 27 | } 28 | 29 | func (l *UpdateApiLogic) UpdateApi(in *core.ApiInfo) (*core.BaseResp, error) { 30 | err := l.svcCtx.DB.API.UpdateOneID(*in.Id). 31 | SetNotNilPath(in.Path). 32 | SetNotNilDescription(in.Description). 33 | SetNotNilAPIGroup(in.ApiGroup). 34 | SetNotNilMethod(in.Method). 35 | SetNotNilIsRequired(in.IsRequired). 36 | SetNotNilServiceName(in.ServiceName). 37 | Exec(l.ctx) 38 | if err != nil { 39 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 40 | } 41 | 42 | return &core.BaseResp{Msg: i18n.UpdateSuccess}, nil 43 | } 44 | -------------------------------------------------------------------------------- /rpc/internal/logic/authority/get_menu_authority_logic.go: -------------------------------------------------------------------------------- 1 | package authority 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/rpc/ent/role" 7 | 8 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type GetMenuAuthorityLogic struct { 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | logx.Logger 19 | } 20 | 21 | func NewGetMenuAuthorityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetMenuAuthorityLogic { 22 | return &GetMenuAuthorityLogic{ 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | Logger: logx.WithContext(ctx), 26 | } 27 | } 28 | 29 | func (l *GetMenuAuthorityLogic) GetMenuAuthority(in *core.IDReq) (*core.RoleMenuAuthorityResp, error) { 30 | menus, err := l.svcCtx.DB.Role.Query().Where(role.ID(in.Id)).QueryMenus().IDs(l.ctx) 31 | if err != nil { 32 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 33 | } 34 | 35 | return &core.RoleMenuAuthorityResp{MenuIds: menus}, nil 36 | } 37 | -------------------------------------------------------------------------------- /rpc/internal/logic/configuration/delete_configuration_logic.go: -------------------------------------------------------------------------------- 1 | package configuration 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/rpc/ent/configuration" 7 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 8 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 9 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 10 | 11 | "github.com/suyuan32/simple-admin-common/i18n" 12 | "github.com/zeromicro/go-zero/core/logx" 13 | ) 14 | 15 | type DeleteConfigurationLogic struct { 16 | ctx context.Context 17 | svcCtx *svc.ServiceContext 18 | logx.Logger 19 | } 20 | 21 | func NewDeleteConfigurationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteConfigurationLogic { 22 | return &DeleteConfigurationLogic{ 23 | ctx: ctx, 24 | svcCtx: svcCtx, 25 | Logger: logx.WithContext(ctx), 26 | } 27 | } 28 | 29 | func (l *DeleteConfigurationLogic) DeleteConfiguration(in *core.IDsReq) (*core.BaseResp, error) { 30 | _, err := l.svcCtx.DB.Configuration.Delete().Where(configuration.IDIn(in.Ids...)).Exec(l.ctx) 31 | 32 | if err != nil { 33 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 34 | } 35 | 36 | return &core.BaseResp{Msg: i18n.DeleteSuccess}, nil 37 | } 38 | -------------------------------------------------------------------------------- /rpc/internal/logic/dictionary/update_dictionary_logic.go: -------------------------------------------------------------------------------- 1 | package dictionary 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/utils/pointy" 7 | 8 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | 14 | "github.com/suyuan32/simple-admin-common/i18n" 15 | ) 16 | 17 | type UpdateDictionaryLogic struct { 18 | ctx context.Context 19 | svcCtx *svc.ServiceContext 20 | logx.Logger 21 | } 22 | 23 | func NewUpdateDictionaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateDictionaryLogic { 24 | return &UpdateDictionaryLogic{ 25 | ctx: ctx, 26 | svcCtx: svcCtx, 27 | Logger: logx.WithContext(ctx), 28 | } 29 | } 30 | 31 | func (l *UpdateDictionaryLogic) UpdateDictionary(in *core.DictionaryInfo) (*core.BaseResp, error) { 32 | err := l.svcCtx.DB.Dictionary.UpdateOneID(*in.Id). 33 | SetNotNilStatus(pointy.GetStatusPointer(in.Status)). 34 | SetNotNilTitle(in.Title). 35 | SetNotNilName(in.Name). 36 | SetNotNilDesc(in.Desc). 37 | Exec(l.ctx) 38 | if err != nil { 39 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 40 | } 41 | 42 | return &core.BaseResp{Msg: i18n.UpdateSuccess}, nil 43 | } 44 | -------------------------------------------------------------------------------- /rpc/internal/logic/dictionarydetail/delete_dictionary_detail_logic.go: -------------------------------------------------------------------------------- 1 | package dictionarydetail 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/rpc/ent/dictionarydetail" 7 | 8 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | 14 | "github.com/suyuan32/simple-admin-common/i18n" 15 | ) 16 | 17 | type DeleteDictionaryDetailLogic struct { 18 | ctx context.Context 19 | svcCtx *svc.ServiceContext 20 | logx.Logger 21 | } 22 | 23 | func NewDeleteDictionaryDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteDictionaryDetailLogic { 24 | return &DeleteDictionaryDetailLogic{ 25 | ctx: ctx, 26 | svcCtx: svcCtx, 27 | Logger: logx.WithContext(ctx), 28 | } 29 | } 30 | 31 | func (l *DeleteDictionaryDetailLogic) DeleteDictionaryDetail(in *core.IDsReq) (*core.BaseResp, error) { 32 | _, err := l.svcCtx.DB.DictionaryDetail.Delete().Where(dictionarydetail.IDIn(in.Ids...)).Exec(l.ctx) 33 | if err != nil { 34 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 35 | } 36 | 37 | return &core.BaseResp{Msg: i18n.DeleteSuccess}, nil 38 | } 39 | -------------------------------------------------------------------------------- /rpc/internal/logic/oauthprovider/delete_oauth_provider_logic.go: -------------------------------------------------------------------------------- 1 | package oauthprovider 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-core/rpc/ent/oauthprovider" 7 | 8 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | 14 | "github.com/suyuan32/simple-admin-common/i18n" 15 | ) 16 | 17 | type DeleteOauthProviderLogic struct { 18 | ctx context.Context 19 | svcCtx *svc.ServiceContext 20 | logx.Logger 21 | } 22 | 23 | func NewDeleteOauthProviderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteOauthProviderLogic { 24 | return &DeleteOauthProviderLogic{ 25 | ctx: ctx, 26 | svcCtx: svcCtx, 27 | Logger: logx.WithContext(ctx), 28 | } 29 | } 30 | 31 | func (l *DeleteOauthProviderLogic) DeleteOauthProvider(in *core.IDsReq) (*core.BaseResp, error) { 32 | _, err := l.svcCtx.DB.OauthProvider.Delete().Where(oauthprovider.IDIn(in.Ids...)).Exec(l.ctx) 33 | if err != nil { 34 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 35 | } 36 | 37 | return &core.BaseResp{Msg: i18n.DeleteSuccess}, nil 38 | } 39 | -------------------------------------------------------------------------------- /rpc/internal/logic/position/update_position_logic.go: -------------------------------------------------------------------------------- 1 | package position 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/utils/pointy" 7 | 8 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 9 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 10 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 11 | 12 | "github.com/zeromicro/go-zero/core/logx" 13 | 14 | "github.com/suyuan32/simple-admin-common/i18n" 15 | ) 16 | 17 | type UpdatePositionLogic struct { 18 | ctx context.Context 19 | svcCtx *svc.ServiceContext 20 | logx.Logger 21 | } 22 | 23 | func NewUpdatePositionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdatePositionLogic { 24 | return &UpdatePositionLogic{ 25 | ctx: ctx, 26 | svcCtx: svcCtx, 27 | Logger: logx.WithContext(ctx), 28 | } 29 | } 30 | 31 | func (l *UpdatePositionLogic) UpdatePosition(in *core.PositionInfo) (*core.BaseResp, error) { 32 | err := l.svcCtx.DB.Position.UpdateOneID(*in.Id). 33 | SetNotNilStatus(pointy.GetStatusPointer(in.Status)). 34 | SetNotNilSort(in.Sort). 35 | SetNotNilName(in.Name). 36 | SetNotNilCode(in.Code). 37 | SetNotNilRemark(in.Remark). 38 | Exec(l.ctx) 39 | if err != nil { 40 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 41 | } 42 | 43 | return &core.BaseResp{Msg: i18n.UpdateSuccess}, nil 44 | } 45 | -------------------------------------------------------------------------------- /rpc/internal/logic/token/delete_token_logic.go: -------------------------------------------------------------------------------- 1 | package token 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/utils/uuidx" 7 | "github.com/zeromicro/go-zero/core/logx" 8 | 9 | "github.com/suyuan32/simple-admin-common/i18n" 10 | 11 | "github.com/suyuan32/simple-admin-core/rpc/ent/token" 12 | 13 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 14 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 15 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 16 | ) 17 | 18 | type DeleteTokenLogic struct { 19 | ctx context.Context 20 | svcCtx *svc.ServiceContext 21 | logx.Logger 22 | } 23 | 24 | func NewDeleteTokenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteTokenLogic { 25 | return &DeleteTokenLogic{ 26 | ctx: ctx, 27 | svcCtx: svcCtx, 28 | Logger: logx.WithContext(ctx), 29 | } 30 | } 31 | 32 | func (l *DeleteTokenLogic) DeleteToken(in *core.UUIDsReq) (*core.BaseResp, error) { 33 | _, err := l.svcCtx.DB.Token.Delete().Where(token.IDIn(uuidx.ParseUUIDSlice(in.Ids)...)).Exec(l.ctx) 34 | if err != nil { 35 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 36 | } 37 | 38 | return &core.BaseResp{Msg: i18n.DeleteSuccess}, nil 39 | } 40 | -------------------------------------------------------------------------------- /rpc/internal/logic/user/delete_user_logic.go: -------------------------------------------------------------------------------- 1 | package user 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/suyuan32/simple-admin-common/utils/uuidx" 7 | 8 | "github.com/suyuan32/simple-admin-common/i18n" 9 | 10 | "github.com/suyuan32/simple-admin-core/rpc/ent/user" 11 | 12 | "github.com/suyuan32/simple-admin-core/rpc/internal/svc" 13 | "github.com/suyuan32/simple-admin-core/rpc/internal/utils/dberrorhandler" 14 | "github.com/suyuan32/simple-admin-core/rpc/types/core" 15 | 16 | "github.com/zeromicro/go-zero/core/logx" 17 | ) 18 | 19 | type DeleteUserLogic struct { 20 | ctx context.Context 21 | svcCtx *svc.ServiceContext 22 | logx.Logger 23 | } 24 | 25 | func NewDeleteUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserLogic { 26 | return &DeleteUserLogic{ 27 | ctx: ctx, 28 | svcCtx: svcCtx, 29 | Logger: logx.WithContext(ctx), 30 | } 31 | } 32 | 33 | func (l *DeleteUserLogic) DeleteUser(in *core.UUIDsReq) (*core.BaseResp, error) { 34 | _, err := l.svcCtx.DB.User.Delete().Where(user.IDIn(uuidx.ParseUUIDSlice(in.Ids)...)).Exec(l.ctx) 35 | if err != nil { 36 | return nil, dberrorhandler.DefaultEntError(l.Logger, err, in) 37 | } 38 | return &core.BaseResp{Msg: i18n.DeleteSuccess}, nil 39 | } 40 | -------------------------------------------------------------------------------- /rpc/internal/svc/service_context.go: -------------------------------------------------------------------------------- 1 | package svc 2 | 3 | import ( 4 | "github.com/redis/go-redis/v9" 5 | "github.com/suyuan32/simple-admin-core/rpc/ent" 6 | "github.com/suyuan32/simple-admin-core/rpc/internal/config" 7 | 8 | "github.com/zeromicro/go-zero/core/logx" 9 | 10 | _ "github.com/suyuan32/simple-admin-core/rpc/ent/runtime" 11 | ) 12 | 13 | type ServiceContext struct { 14 | Config config.Config 15 | DB *ent.Client 16 | Redis redis.UniversalClient 17 | } 18 | 19 | func NewServiceContext(c config.Config) *ServiceContext { 20 | db := ent.NewClient( 21 | ent.Log(logx.Error), // logger 22 | ent.Driver(c.DatabaseConf.NewNoCacheDriver()), 23 | ) 24 | 25 | return &ServiceContext{ 26 | Config: c, 27 | DB: db, 28 | Redis: c.RedisConf.MustNewUniversalRedis(), 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /rpc/internal/utils/entx/ent_tx.go: -------------------------------------------------------------------------------- 1 | package entx 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/zeromicro/go-zero/core/logx" 8 | 9 | "github.com/suyuan32/simple-admin-core/rpc/ent" 10 | ) 11 | 12 | // WithTx uses transaction in ent. 13 | func WithTx(ctx context.Context, client *ent.Client, fn func(tx *ent.Tx) error) error { 14 | tx, err := client.Tx(ctx) 15 | if err != nil { 16 | logx.Errorw("failed to start transaction", logx.Field("detail", err.Error())) 17 | return err 18 | } 19 | defer func() { 20 | if v := recover(); v != nil { 21 | _ = tx.Rollback() 22 | panic(v) 23 | } 24 | }() 25 | if err := fn(tx); err != nil { 26 | if rollBackErr := tx.Rollback(); rollBackErr != nil { 27 | err = fmt.Errorf("%w: rolling back transaction: %v", err, rollBackErr) 28 | } 29 | logx.Errorw("errors occur in transaction", logx.Field("detail", err.Error())) 30 | return err 31 | } 32 | if err := tx.Commit(); err != nil { 33 | logx.Errorw("failed to commit transaction", logx.Field("detail", err.Error())) 34 | return err 35 | } 36 | return nil 37 | } 38 | --------------------------------------------------------------------------------