├── .gitattributes ├── LICENSE ├── README.md ├── ap.sql ├── assets ├── 1715073518663.png ├── 1715074436113.png ├── 1715074605894.png ├── 1715074939471.png ├── 1715074960389.png ├── 1715075095647.png ├── 1715075279497.png ├── 1715075616524.png ├── 1715075796103.png ├── 1715076130925.png ├── 1715076152054.png ├── 1715076209454.png ├── 1715076237946.png ├── 1715076791950.png ├── 1715083993843.png ├── 1715084059128.png ├── 1715084144489.png └── show.mp4 └── back-me ├── .idea ├── .gitignore ├── compiler.xml ├── dataSources.local.xml ├── dataSources.xml ├── dataSources │ ├── 537877e8-b6d0-4cad-a950-176bfc0d3637.xml │ └── 537877e8-b6d0-4cad-a950-176bfc0d3637 │ │ └── storage_v2 │ │ └── _src_ │ │ └── schema │ │ ├── information_schema.FNRwLQ.meta │ │ ├── mysql.osA4Bg.meta │ │ ├── performance_schema.kIw0nw.meta │ │ └── sys.zb4BAA.meta ├── encodings.xml ├── httpRequests │ └── http-requests-log.http ├── inspectionProfiles │ └── Project_Default.xml ├── jarRepositories.xml ├── misc.xml ├── sqldialects.xml ├── uiDesigner.xml ├── vcs.xml └── workspace.xml ├── RENAME.md ├── admin ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── qhx │ │ │ └── admin │ │ │ ├── AdminApplication.java │ │ │ ├── config │ │ │ ├── WebMvcConfig.java │ │ │ ├── fisco │ │ │ │ ├── ContractConfig.java │ │ │ │ ├── FiscoConfig.java │ │ │ │ ├── SdkBeanConfig.java │ │ │ │ ├── contract │ │ │ │ │ ├── ContractErrCode.java │ │ │ │ │ ├── ContractException.java │ │ │ │ │ └── ContractResponse.java │ │ │ │ └── service │ │ │ │ │ ├── ContractService.java │ │ │ │ │ └── WeFrontService.java │ │ │ ├── mybatisplus │ │ │ │ └── MybatisPlusConfig.java │ │ │ └── security │ │ │ │ ├── SecurityConfig.java │ │ │ │ └── filter │ │ │ │ └── TokenFilter.java │ │ │ ├── controller │ │ │ ├── LoginController.java │ │ │ ├── TestController.java │ │ │ ├── monitor │ │ │ │ ├── CacheController.java │ │ │ │ ├── ChainController.java │ │ │ │ ├── OnlineController.java │ │ │ │ └── ServerController.java │ │ │ └── system │ │ │ │ ├── CaptchaController.java │ │ │ │ ├── CategoryController.java │ │ │ │ ├── FrontUserController.java │ │ │ │ ├── GoodsController.java │ │ │ │ ├── IndexController.java │ │ │ │ ├── MessageController.java │ │ │ │ ├── OrderController.java │ │ │ │ ├── ShopController.java │ │ │ │ ├── UploadController.java │ │ │ │ └── backUser │ │ │ │ ├── BackUserController.java │ │ │ │ └── FarmerController.java │ │ │ ├── domain │ │ │ ├── BackUser.java │ │ │ ├── Category.java │ │ │ ├── FrontUser.java │ │ │ ├── Goods.java │ │ │ ├── GoodsCategory.java │ │ │ ├── GoodsImg.java │ │ │ ├── Menu.java │ │ │ ├── Message.java │ │ │ ├── Order.java │ │ │ ├── Shop.java │ │ │ ├── UserRole.java │ │ │ └── web │ │ │ │ ├── Server.java │ │ │ │ └── server │ │ │ │ ├── Cpu.java │ │ │ │ ├── Jvm.java │ │ │ │ ├── Mem.java │ │ │ │ ├── Sys.java │ │ │ │ └── SysFile.java │ │ │ ├── mapper │ │ │ ├── BackUserMapper.java │ │ │ ├── CategoryMapper.java │ │ │ ├── FrontUserMapper.java │ │ │ ├── GoodsCategoryMapper.java │ │ │ ├── GoodsImgMapper.java │ │ │ ├── GoodsMapper.java │ │ │ ├── MessageMapper.java │ │ │ ├── OrderMapper.java │ │ │ ├── ShopMapper.java │ │ │ └── UserRoleMapper.java │ │ │ ├── model │ │ │ ├── to │ │ │ │ ├── LoginTo.java │ │ │ │ ├── OnlineUserForceTo.java │ │ │ │ ├── OnlineUserQueryTo.java │ │ │ │ ├── backUser │ │ │ │ │ ├── BackUserDeleteTo.java │ │ │ │ │ └── BackUserQueryTo.java │ │ │ │ ├── category │ │ │ │ │ ├── CategoryDeleteTo.java │ │ │ │ │ ├── CategoryQueryTo.java │ │ │ │ │ └── CategoryTo.java │ │ │ │ ├── frontUser │ │ │ │ │ ├── FrontUserDeleteTo.java │ │ │ │ │ ├── FrontUserQueryTo.java │ │ │ │ │ └── InviCodeTo.java │ │ │ │ ├── goods │ │ │ │ │ ├── GoodsDeleteTo.java │ │ │ │ │ ├── GoodsImgDeleteTo.java │ │ │ │ │ ├── GoodsQueryTo.java │ │ │ │ │ └── GoodsTo.java │ │ │ │ ├── message │ │ │ │ │ ├── MessDeleteTo.java │ │ │ │ │ └── MessQueryTo.java │ │ │ │ └── order │ │ │ │ │ ├── OrderDeleteTo.java │ │ │ │ │ └── OrderQueryTo.java │ │ │ └── vo │ │ │ │ ├── CategoryVo.java │ │ │ │ ├── FarmerVo.java │ │ │ │ ├── GoodsImgVo.java │ │ │ │ ├── GoodsVo.java │ │ │ │ ├── LoginUserVo.java │ │ │ │ ├── MenuVo.java │ │ │ │ ├── OnlineUserVo.java │ │ │ │ ├── OrderVo.java │ │ │ │ └── index │ │ │ │ ├── IndexCountVo.java │ │ │ │ └── main │ │ │ │ ├── CategoryMain.java │ │ │ │ ├── IndexMainVo.java │ │ │ │ └── UserMain.java │ │ │ ├── service │ │ │ ├── BackUserService.java │ │ │ ├── CaptchaService.java │ │ │ ├── CategoryService.java │ │ │ ├── FrontUserService.java │ │ │ ├── GoodsCategoryService.java │ │ │ ├── GoodsImgService.java │ │ │ ├── GoodsService.java │ │ │ ├── LoginService.java │ │ │ ├── MessageService.java │ │ │ ├── OrderService.java │ │ │ ├── ShopService.java │ │ │ ├── UserRoleService.java │ │ │ └── impl │ │ │ │ ├── BackUserServiceImpl.java │ │ │ │ ├── CategoryServiceImpl.java │ │ │ │ ├── FrontUserServiceImpl.java │ │ │ │ ├── GoodsCategoryServiceImpl.java │ │ │ │ ├── GoodsImgServiceImpl.java │ │ │ │ ├── GoodsServiceImpl.java │ │ │ │ ├── MessageServiceImpl.java │ │ │ │ ├── OrderServiceImpl.java │ │ │ │ ├── ShopServiceImpl.java │ │ │ │ └── UserRoleServiceImpl.java │ │ │ └── test │ │ │ └── HelloWorldService.java │ └── resources │ │ ├── application-druid.yml │ │ ├── application-redis.yml │ │ ├── application.yml │ │ ├── conf │ │ ├── ca.crt │ │ ├── sdk.crt │ │ └── sdk.key │ │ └── mapper │ │ ├── BackUserMapper.xml │ │ ├── CategoryMapper.xml │ │ ├── FrontUserMapper.xml │ │ ├── GoodsCategoryMapper.xml │ │ ├── GoodsImgMapper.xml │ │ ├── GoodsMapper.xml │ │ ├── MessageMapper.xml │ │ ├── OrderMapper.xml │ │ ├── RoleMapper.xml │ │ ├── ShopMapper.xml │ │ └── UserRoleMapper.xml │ └── test │ └── java │ └── com │ └── qhx │ └── admin │ ├── AdminApplicationTest.java │ ├── controller │ └── CacheControllerTest.java │ ├── service │ ├── AliYunSdkTest.java │ ├── BackUserServiceTest.java │ ├── GoodsServiceTest.java │ ├── LoginServiceTest.java │ ├── OrderServiceTest.java │ ├── RedisTest.java │ └── ShopServiceTest.java │ └── util │ └── NotEmptyUtilTest.java ├── client ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── qhx │ │ │ └── client │ │ │ ├── ClientApplication.java │ │ │ ├── config │ │ │ ├── AppConfig.java │ │ │ └── MybatisPlusConfig.java │ │ │ ├── context │ │ │ └── LoginUserContext.java │ │ │ ├── controller │ │ │ └── LoginController.java │ │ │ ├── domain │ │ │ ├── BackUser.java │ │ │ └── FrontUser.java │ │ │ ├── interceptor │ │ │ └── TokenInterceptor.java │ │ │ ├── mapper │ │ │ ├── BackUserMapper.java │ │ │ └── FrontUserMapper.java │ │ │ ├── model │ │ │ └── to │ │ │ │ ├── LoginTo.java │ │ │ │ ├── RegisterTo.java │ │ │ │ └── frontUser │ │ │ │ └── InviCodeTo.java │ │ │ └── service │ │ │ ├── FrontUserService.java │ │ │ ├── LoginService.java │ │ │ └── impl │ │ │ ├── FrontUserServiceImpl.java │ │ │ └── LoginServiceImpl.java │ └── resources │ │ ├── application-druid.yml │ │ ├── application-redis.yml │ │ └── application.yml │ └── test │ └── java │ └── com │ └── qhx │ └── client │ └── service │ └── BackUserServiceTest.java ├── common ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── qhx │ └── common │ ├── annotation │ ├── DataSource.java │ └── NotEmpty.java │ ├── aop │ └── DataSourceAspect.java │ ├── config │ ├── DateConverterConfig.java │ ├── DruidConfig.java │ ├── DruidDataSourceProperties.java │ ├── Swagger2Config.java │ ├── datasource │ │ ├── DynamicDataSource.java │ │ └── DynamicDataSourceContextHolder.java │ └── redis │ │ ├── FastJson2JsonRedisSerializer.java │ │ └── RedisConfig.java │ ├── constant │ ├── CacheConstant.java │ ├── Constant.java │ ├── HeaderConstant.java │ ├── HttpStatus.java │ └── UserConstant.java │ ├── controller │ ├── BaseController.java │ └── BaseUploadController.java │ ├── domain │ ├── BaseEntity.java │ └── User.java │ ├── enums │ ├── DataSourceType.java │ └── UserStatus.java │ ├── exception │ ├── GlobalException.java │ ├── PermissionException.java │ ├── base │ │ └── BaseException.java │ └── system │ │ └── SystemException.java │ ├── handler │ └── GlobalExceptionHandler.java │ ├── model │ ├── AjaxResult.java │ ├── PageResult.java │ └── to │ │ ├── BasePageTo.java │ │ ├── LoginTo.java │ │ └── user │ │ ├── PassTo.java │ │ ├── PasswordNotOldTo.java │ │ ├── UserDeleteTo.java │ │ └── UserQueryTo.java │ └── util │ ├── Arith.java │ ├── CommonUtil.java │ ├── DateUtil.java │ ├── MessageUtil.java │ ├── NotEmptyUtil.java │ ├── OSSUtil.java │ ├── PageUtil.java │ ├── ServletUtil.java │ ├── StringUtil.java │ ├── TokenUtil.java │ ├── UploadFIleUtil.java │ ├── ip │ ├── AddressUtil.java │ └── IpUtil.java │ ├── redis │ └── RedisCache.java │ ├── security │ └── SecurityUtil.java │ └── user │ └── UserUtil.java ├── generator ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── qhx │ └── generator │ └── JzmGenerate.java ├── message ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── qhx │ │ └── message │ │ ├── MessageApplication.java │ │ ├── config │ │ ├── WebSocketConfig.java │ │ └── rabbitMq │ │ │ ├── RabbitMqConfig.java │ │ │ ├── domain │ │ │ └── Message.java │ │ │ ├── listener │ │ │ └── DynamicListener.java │ │ │ └── service │ │ │ └── RabbitMqService.java │ │ ├── controller │ │ ├── ChatController.java │ │ └── ChatServerEndpoint.java │ │ ├── exception │ │ └── MessageException.java │ │ └── service │ │ ├── ChatSessionService.java │ │ └── impl │ │ └── ChatSessionServiceImpl.java │ └── resources │ └── application.yml └── pom.xml /.gitattributes: -------------------------------------------------------------------------------- 1 | *.vue linguist-language=java 2 | *.java linguist-language=java 3 | *.css linguist-language=java 4 | *.js linguist-language=java 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 本郡主是喵 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 农产品供销管理系统 2 | ## 项目概述 3 | 本项目,可作为一个练手项目学习,虽然代码写的有点烂。但是还是能够作为管理系统能够使用学习的。该项目大部分是可复用的,供大家学习使用,不喜勿喷。 4 | 5 | 6 | ## 涉及用到的技术栈 7 | 8 | (浅浅说一下,我们拿了fisco-bcos的数据,但是并没有部署合约,就是只实现了区块链网络监控的效果。但是封装了2连接工具类,开箱即用,看下面图片。 9 | 10 | 再提一句,Druid连接池跟fisco-java-sdk冲突,我合约交互用的WeFrontService来实现,因此数据库配置那里就没改,如果想用ContractService,就是将数据库连接池配置改成其他连接池配置) 11 | 12 | `![1715073518663](assets/1715073518663.png) 13 | 14 | 服务端:SpringBoot、SpringSecurity、Mybatis-plus、Redis、Fisco-Bcos、Druid、Hutool、阿里云OSS 15 | 16 | 客户端:Vue、axios、Vuex、Vue-router、Element-UI、Echars 17 | 18 | ## 安装使用 19 | 20 | 先说一下,本系统,用到了Fisco-bcos的中间件平台webase的子系统webase-front。这里不做赘述。 21 | back-me为后端工程目录、front-me为前端工程目录 22 | 23 | 服务端: 24 | 25 | 1.fisco配置更改: 26 | 27 | 将下图fisco配置更改为自己搭建的fisco链、webase-front配置。如果要进行合约部署,并且要用WeFrontService合约交互,将合约配置里面填上 28 | 29 | ![1715074605894](assets/1715074605894.png) 30 | 31 | 2.在back-me的admin模块下的application-druid.yml 、application-redis.yml更改MySQL、Redis服务器的连接配置。本地运行创建ap数据库运行ap.sql文件。 32 | 33 | 3.德鲁伊监控配置更改: 34 | 35 | 在common模块下面,该位置。默认是账号:admin,密码: 123456 36 | 37 | ![1715076791950](assets/1715076791950.png) 38 | 39 | 4.阿里云OSS配置更改。在common模块下面util包下面的OSSUtil更改自己的配置。 40 | 41 | 5.swagger配置修改:ctrl + n全局搜索,Swagger2Config文件,更改为自己配置 42 | 43 | 登录系统之后,访问http://localhost:8110/swagger-ui.html进入以下页面。 44 | 45 | ![1715083993843](assets/1715083993843.png) 46 | 47 | 默认无法接口调用,需要:随便一个点击接口调用,点击红色叹号、填写Bearer+登录token、点击Authorize之后,即可请求携带token,才能进行接口调用。 48 | 49 | ![1715084059128](assets/1715084059128.png) 50 | 51 | 启动back-me项目下面admin模块 52 | 53 | 客户端: 54 | 用控制台打开front-me目录下的front-admin目录 55 | ``` 56 | # 先执行 57 | npm i 58 | # 之后执行 59 | npm run serve 60 | ``` 61 | 62 | 63 | 64 | ## 项目演示 65 | 66 | 这里只演示部分页面 67 | 68 | ### 项目视频演示 69 | 视频项目标题因需求改了。但实际一个项目。 70 | 71 | [assets/show.mp4](https://github.com/junzhumiao/goods-manage/assets/119744044/45ecc7f6-5fc0-4420-94de-2796ec882ff2) 72 | 73 | 74 | 75 | ### 登录 76 | 77 | ![1715074939471](assets/1715074939471.png) 78 | 79 | ### 注册 80 | 81 | ![1715074960389](assets/1715074960389.png) 82 | 83 | ### 首页 84 | 85 | ![1715075616524](assets/1715075616524.png) 86 | 87 | ### 用户管理 88 | 89 | 就是展示一些前台用户信息,还有对用户的增删改查。 90 | 91 | ![1715075279497](assets/1715075279497.png) 92 | 93 | ### 服务监控 94 | 95 | ![1715075796103](assets/1715075796103.png) 96 | 97 | ### 区块链监控 98 | 99 | 输入块高,点击查询,可显示区块信息 100 | 101 | ![1715076209454](assets/1715076209454.png) 102 | 103 | ### 缓存监控 104 | 105 | ![1715076152054](assets/1715076152054.png) 106 | 107 | ### 个人中心 108 | 109 | ![1715076237946](assets/1715076237946.png) 110 | -------------------------------------------------------------------------------- /assets/1715073518663.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715073518663.png -------------------------------------------------------------------------------- /assets/1715074436113.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715074436113.png -------------------------------------------------------------------------------- /assets/1715074605894.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715074605894.png -------------------------------------------------------------------------------- /assets/1715074939471.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715074939471.png -------------------------------------------------------------------------------- /assets/1715074960389.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715074960389.png -------------------------------------------------------------------------------- /assets/1715075095647.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715075095647.png -------------------------------------------------------------------------------- /assets/1715075279497.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715075279497.png -------------------------------------------------------------------------------- /assets/1715075616524.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715075616524.png -------------------------------------------------------------------------------- /assets/1715075796103.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715075796103.png -------------------------------------------------------------------------------- /assets/1715076130925.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715076130925.png -------------------------------------------------------------------------------- /assets/1715076152054.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715076152054.png -------------------------------------------------------------------------------- /assets/1715076209454.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715076209454.png -------------------------------------------------------------------------------- /assets/1715076237946.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715076237946.png -------------------------------------------------------------------------------- /assets/1715076791950.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715076791950.png -------------------------------------------------------------------------------- /assets/1715083993843.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715083993843.png -------------------------------------------------------------------------------- /assets/1715084059128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715084059128.png -------------------------------------------------------------------------------- /assets/1715084144489.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/1715084144489.png -------------------------------------------------------------------------------- /assets/show.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/assets/show.mp4 -------------------------------------------------------------------------------- /back-me/.idea/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/back-me/.idea/.gitignore -------------------------------------------------------------------------------- /back-me/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | -------------------------------------------------------------------------------- /back-me/.idea/dataSources.local.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #@ 7 | ` 8 | 9 | 10 | master_key 11 | root 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /back-me/.idea/dataSources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mysql.8 6 | true 7 | com.mysql.cj.jdbc.Driver 8 | jdbc:mysql://localhost:3306 9 | $ProjectFileDir$ 10 | 11 | 12 | -------------------------------------------------------------------------------- /back-me/.idea/dataSources/537877e8-b6d0-4cad-a950-176bfc0d3637/storage_v2/_src_/schema/information_schema.FNRwLQ.meta: -------------------------------------------------------------------------------- 1 | #n:information_schema 2 | ! [null, 0, null, null, -2147483648, -2147483648] 3 | -------------------------------------------------------------------------------- /back-me/.idea/dataSources/537877e8-b6d0-4cad-a950-176bfc0d3637/storage_v2/_src_/schema/mysql.osA4Bg.meta: -------------------------------------------------------------------------------- 1 | #n:mysql 2 | ! [null, 0, null, null, -2147483648, -2147483648] 3 | -------------------------------------------------------------------------------- /back-me/.idea/dataSources/537877e8-b6d0-4cad-a950-176bfc0d3637/storage_v2/_src_/schema/performance_schema.kIw0nw.meta: -------------------------------------------------------------------------------- 1 | #n:performance_schema 2 | ! [null, 0, null, null, -2147483648, -2147483648] 3 | -------------------------------------------------------------------------------- /back-me/.idea/dataSources/537877e8-b6d0-4cad-a950-176bfc0d3637/storage_v2/_src_/schema/sys.zb4BAA.meta: -------------------------------------------------------------------------------- 1 | #n:sys 2 | ! [null, 0, null, null, -2147483648, -2147483648] 3 | -------------------------------------------------------------------------------- /back-me/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /back-me/.idea/httpRequests/http-requests-log.http: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/back-me/.idea/httpRequests/http-requests-log.http -------------------------------------------------------------------------------- /back-me/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /back-me/.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /back-me/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /back-me/.idea/sqldialects.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/RENAME.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/junzhumiao/goods-manage/e3538dcd49a36b0ab1878100d5999bbdd9c3b7a3/back-me/RENAME.md -------------------------------------------------------------------------------- /back-me/admin/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /back-me/admin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | back-me 6 | com.qhx 7 | 1.0 8 | 9 | 10 | 11 | 4.0.0 12 | admin 13 | 14 | 15 | 16 | 17 | com.qhx 18 | common 19 | 20 | 21 | 22 | com.github.oshi 23 | oshi-core 24 | 6.4.8 25 | 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-test 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/AdminApplication.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 7 | 8 | @SpringBootApplication(exclude = DataSourceAutoConfiguration.class, 9 | scanBasePackages = {"com.qhx.common","com.qhx.admin"}) 10 | @EnableConfigurationProperties( 11 | value = {com.qhx.admin.config.fisco.ContractConfig.class} 12 | ) 13 | public class AdminApplication 14 | { 15 | 16 | public static void main(String[] args) 17 | { 18 | SpringApplication.run(AdminApplication.class, args); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.http.CacheControl; 6 | import org.springframework.web.cors.CorsConfiguration; 7 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; 8 | import org.springframework.web.filter.CorsFilter; 9 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 10 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 11 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 12 | 13 | import java.util.concurrent.TimeUnit; 14 | 15 | /** 16 | * @author: jzm 17 | * @date: 2024-02-28 12:20 18 | **/ 19 | 20 | @Configuration 21 | public class WebMvcConfig implements WebMvcConfigurer 22 | { 23 | 24 | 25 | @Override 26 | public void addResourceHandlers(ResourceHandlerRegistry registry) 27 | { 28 | // 映射上传文件路径 29 | registry.addResourceHandler("/profile/upload") 30 | .addResourceLocations("file:"+"D:/profile/"); 31 | 32 | 33 | /** swagger配置 */ 34 | registry.addResourceHandler("/swagger-ui/**") 35 | .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") 36 | .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());; 37 | } 38 | 39 | @Override 40 | public void addCorsMappings(CorsRegistry registry) { 41 | // 设置允许跨域的路径 42 | registry.addMapping("/**") 43 | // 设置允许跨域请求的域名 44 | .allowedOriginPatterns("*") 45 | // 是否允许cookie 46 | .allowCredentials(true) 47 | // 设置允许的请求方式 48 | .allowedMethods("*") 49 | // 设置允许的header属性 50 | .allowedHeaders("*") 51 | // 跨域允许时间 52 | .maxAge(3600); 53 | } 54 | 55 | /** 56 | * 跨域配置 57 | */ 58 | @Bean 59 | public CorsFilter corsFilter() 60 | { 61 | CorsConfiguration config = new CorsConfiguration(); 62 | config.setAllowCredentials(true); 63 | // 设置访问源地址 64 | config.addAllowedOriginPattern("*"); 65 | // 设置访问源请求头 66 | config.addAllowedHeader("*"); 67 | // 设置访问源请求方法 68 | config.addAllowedMethod("*"); 69 | // 有效期 1800秒 70 | config.setMaxAge(1800L); 71 | // 添加映射路径,拦截一切请求 72 | UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); 73 | source.registerCorsConfiguration("/**", config); 74 | // 返回新的CorsFilter 75 | return new CorsFilter(source); 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/config/fisco/ContractConfig.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.config.fisco; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | 6 | /** 7 | * 与指定合约交互的配置 8 | */ 9 | @Data 10 | @ConfigurationProperties(prefix = "fisco.contract") 11 | public class ContractConfig 12 | { 13 | private String address; 14 | private String name; 15 | private String owner; 16 | private String bin; 17 | private String abi; 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/config/fisco/FiscoConfig.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.config.fisco; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.boot.context.properties.NestedConfigurationProperty; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.stereotype.Component; 8 | 9 | /** 10 | * fisco网络连接配置 11 | */ 12 | @Data 13 | @Configuration 14 | @ConfigurationProperties(prefix = "fisco") 15 | @Component 16 | 17 | public class FiscoConfig 18 | { 19 | private String peers; 20 | 21 | private int groupId = 1; 22 | 23 | private String certPath = "conf"; 24 | 25 | private String hexPrivateKey; 26 | 27 | // 嵌套属性映射,作为一个嵌套属性注入 28 | @NestedConfigurationProperty 29 | private ContractConfig contract; // 选填属性 30 | 31 | private String frontUrl; // 选填属性 32 | } 33 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/config/fisco/contract/ContractErrCode.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.config.fisco.contract; 2 | 3 | 4 | import com.qhx.common.util.StringUtil; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-04-16 19:34 12 | **/ 13 | 14 | public class ContractErrCode 15 | { 16 | public static final Map errCode = new HashMap(); 17 | 18 | { 19 | errCode.put("40001", "账户地址不能为空地址"); 20 | errCode.put("40002", "参数租客地址与合同租客地址不相等"); 21 | errCode.put("40003", "参数租客地址与合同租客地址不相等"); 22 | errCode.put("40004", "房东终止合同失败:租客实际缴租金 + 保证金 < 应缴纳租金"); 23 | errCode.put("40005", "租客终止合同失败:租客实际缴租金 < 应缴纳租金 + 2个月租金"); 24 | errCode.put("40006", "参数房东地址与合同房东地址不相等"); 25 | errCode.put("40007", "账户地址不能是空地址"); 26 | errCode.put("40008", "账户月不足以支付money"); 27 | errCode.put("40010", ""); 28 | errCode.put("40011", "签署合同不存在"); 29 | errCode.put("40012", "签署合同已经过了签署时间"); 30 | errCode.put("40013", "这个Person account 不存在"); 31 | errCode.put("40014", "调用者必须是房东角色"); 32 | errCode.put("40015", "调用者必须是租客角色"); 33 | errCode.put("40016", "调用者必须是管理员"); 34 | } 35 | 36 | // 根据错误码匹配 37 | public static ContractException get(String code) 38 | { 39 | String val = errCode.get(code); 40 | if (StringUtil.isEmpty(val)) 41 | { // 匹配不到,直接返回 42 | return new ContractException(code); 43 | } 44 | return new ContractException(val); 45 | } 46 | 47 | public static ContractException get(ContractResponse contractResponse) 48 | { 49 | String code = contractResponse.getMes(); 50 | return get(code); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/config/fisco/contract/ContractException.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.config.fisco.contract; 2 | 3 | 4 | import com.qhx.common.exception.base.BaseException; 5 | 6 | /** 7 | * @author: jzm 8 | * @date: 2024-04-16 19:30 9 | **/ 10 | 11 | public class ContractException extends BaseException 12 | { 13 | public ContractException(String message, int code) 14 | { 15 | super(message, code); 16 | } 17 | 18 | public ContractException(String message) 19 | { 20 | super(message, 400); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/config/fisco/contract/ContractResponse.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.config.fisco.contract; 2 | 3 | import cn.hutool.json.JSONArray; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class ContractResponse 8 | { 9 | private JSONArray vals; 10 | 11 | private String mes; // 响应消息 12 | } 13 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/config/mybatisplus/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.config.mybatisplus; 2 | 3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; 4 | import com.qhx.admin.service.LoginService; 5 | import com.qhx.common.util.security.SecurityUtil; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.apache.ibatis.reflection.MetaObject; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | import org.springframework.transaction.annotation.EnableTransactionManagement; 11 | 12 | import java.time.LocalDateTime; 13 | 14 | @Slf4j 15 | @Component 16 | @EnableTransactionManagement 17 | // 插入: 首先可以确定的,mybatis-plus是可以对插入操作可以对设置默认值,(插入为null时自动忽略的。) 18 | // 更新: 目前情况看,更新时,也是只更新非null字段。 19 | // 查询: 要求返回数据字段 -> 在类中映射字段都能找到(反正不能多了,也不能少了) 20 | public class MybatisPlusConfig implements MetaObjectHandler 21 | { 22 | 23 | @Autowired 24 | private LoginService loginService; 25 | 26 | 27 | @Override 28 | public void insertFill(MetaObject metaObject) { 29 | log.info("start insert fill ...."); 30 | this.strictInsertFill(metaObject, "createTime", LocalDateTime::now, LocalDateTime.class); 31 | Object user = SecurityUtil.getPrincipal(); 32 | if(!(user instanceof String)){ 33 | this.strictInsertFill(metaObject, "createBy", () -> loginService.getUserId(), Long.class); 34 | } 35 | } 36 | 37 | @Override 38 | public void updateFill(MetaObject metaObject) { 39 | log.info("start update fill ...."); 40 | this.strictUpdateFill(metaObject,"updateTime", LocalDateTime::now, LocalDateTime.class); 41 | Object user = SecurityUtil.getPrincipal(); 42 | if(!(user instanceof String)){ 43 | this.strictInsertFill(metaObject, "updateBy", () -> loginService.getUserId(), Long.class); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/config/security/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.config.security; 2 | 3 | import com.qhx.admin.config.security.filter.TokenFilter; 4 | import com.qhx.common.constant.UserConstant; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.http.HttpMethod; 9 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 11 | import org.springframework.security.config.http.SessionCreationPolicy; 12 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 13 | import org.springframework.security.crypto.password.PasswordEncoder; 14 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 15 | import org.springframework.security.web.authentication.logout.LogoutFilter; 16 | import org.springframework.web.filter.CorsFilter; 17 | 18 | @Configuration 19 | public class SecurityConfig extends WebSecurityConfigurerAdapter 20 | { 21 | @Autowired 22 | private CorsFilter corsFilter; 23 | 24 | @Autowired 25 | private TokenFilter tokenFilter; 26 | 27 | @Bean 28 | public PasswordEncoder passwordEncoder(){ 29 | return new BCryptPasswordEncoder(); 30 | } 31 | 32 | @Override 33 | protected void configure(HttpSecurity http) throws Exception { 34 | http 35 | //不通过Session获取SecurityContext 36 | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) 37 | .and() 38 | .authorizeRequests() 39 | // 对于部分接口,直接允许匿名访问 40 | .antMatchers(UserConstant.ExclusionList).permitAll() 41 | .antMatchers("/**").permitAll() 42 | // 静态资源,可匿名访问 43 | .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() 44 | // 除上面外的所有请求全部需要鉴权认证 45 | .anyRequest().authenticated() 46 | .and().headers().frameOptions().disable() // 设置framer允许访问本服务器资源 47 | .and().csrf().disable(); 48 | 49 | 50 | //把token校验过滤器添加到过滤器链中,就是在 UsernamePasswordAuthenticationFilter之前 51 | http.addFilterBefore(tokenFilter, UsernamePasswordAuthenticationFilter.class); 52 | // 添加CORS filter 53 | http.addFilterBefore(corsFilter, TokenFilter.class); 54 | http.addFilterBefore(corsFilter, LogoutFilter.class); 55 | // 处理退出逻辑 56 | http.logout().logoutUrl("/logout").disable(); 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller; 2 | 3 | import cn.hutool.json.JSONUtil; 4 | import com.qhx.common.model.AjaxResult; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | 11 | /** 12 | * @author: jzm 13 | * @date: 2024-02-28 18:46 14 | **/ 15 | 16 | @RestController 17 | public class TestController 18 | { 19 | 20 | 21 | // 请求接口,但是没有响应 22 | @GetMapping("/test") 23 | public String test(LocalDateTime startTime){ 24 | System.out.println(startTime); 25 | return JSONUtil.toJsonStr(AjaxResult.success("test 测试成功")); 26 | } 27 | 28 | 29 | @GetMapping("/test1") 30 | public String test1(){ 31 | return JSONUtil.toJsonStr(AjaxResult.success("test 测试成功")); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/controller/monitor/CacheController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller.monitor; 2 | 3 | import com.qhx.admin.service.LoginService; 4 | import com.qhx.common.model.AjaxResult; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.data.redis.core.RedisCallback; 8 | import org.springframework.data.redis.core.RedisTemplate; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.util.*; 14 | 15 | /** 16 | * Redis缓存监控Controller接口 17 | * 18 | * @author csp 19 | */ 20 | @RestController 21 | @RequestMapping("/monitor/cache") 22 | public class CacheController 23 | { 24 | @Autowired 25 | private RedisTemplate redisTemplate; 26 | 27 | @Autowired 28 | private LoginService loginService; 29 | 30 | @RequestMapping(method = RequestMethod.GET) 31 | public AjaxResult getInfo() throws Exception 32 | { 33 | loginService.checkAdmin(); 34 | Properties info = (Properties) redisTemplate.execute((RedisCallback) connection -> connection.info()); 35 | Properties commandStats = (Properties) redisTemplate.execute((RedisCallback) connection -> connection.info("commandstats")); 36 | Object dbSize = redisTemplate.execute((RedisCallback) connection -> connection.dbSize()); 37 | 38 | Map result = new HashMap<>(3); 39 | result.put("info", info); 40 | result.put("dbSize", dbSize); 41 | 42 | List> pieList = new ArrayList<>(); 43 | commandStats.stringPropertyNames().forEach(key -> { 44 | Map data = new HashMap<>(2); 45 | String property = commandStats.getProperty(key); 46 | data.put("name", StringUtils.removeStart(key, "cmdstat_")); 47 | data.put("value", StringUtils.substringBetween(property, "calls=", ",usec")); 48 | pieList.add(data); 49 | }); 50 | result.put("commandStats", pieList); 51 | return AjaxResult.success(result); 52 | } 53 | } -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/controller/monitor/ChainController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller.monitor; 2 | 3 | import cn.hutool.http.HttpUtil; 4 | import cn.hutool.json.JSONArray; 5 | import cn.hutool.json.JSONObject; 6 | import cn.hutool.json.JSONUtil; 7 | import com.qhx.common.model.AjaxResult; 8 | import io.swagger.annotations.Api; 9 | import io.swagger.annotations.ApiOperation; 10 | import org.springframework.beans.factory.annotation.Value; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | /** 16 | * @author: jzm 17 | * @date: 2024-03-28 09:17 18 | **/ 19 | 20 | @RestController 21 | @RequestMapping("/monitor/chain") 22 | @Api("区块链监控") // TODO 抽时间替换fisco-java-sdk 23 | public class ChainController 24 | { 25 | 26 | private String urlPre; 27 | 28 | @Value("${fisco.url}") 29 | public void setUrlPre(String url){ 30 | this.urlPre = url + ":5002/WeBASE-Front/1/web3"; 31 | } 32 | 33 | @RequestMapping(value = "/getNodeList",method = RequestMethod.GET) 34 | @ApiOperation("获取节点信息") 35 | public AjaxResult getNodeStatusList(){ 36 | String body = HttpUtil.createGet(urlPre + "/getNodeStatusList").execute().body(); 37 | JSONArray jsonAry = JSONUtil.parseArray(body); 38 | return AjaxResult.success(jsonAry); 39 | } 40 | 41 | @RequestMapping(value = "/getTxTotal",method = RequestMethod.GET) 42 | @ApiOperation("获取tx数量") 43 | public AjaxResult getTransactionTotal(){ 44 | // 交易数量、区块数量 45 | String body = HttpUtil.createGet(urlPre + "/transaction-total").execute().body(); 46 | JSONObject resObj = JSONUtil.parseObj(body); 47 | // 节点数量 48 | JSONArray nodeAry = JSONUtil.parseArray(HttpUtil.createGet(urlPre + "/groupPeers").execute().body()); 49 | resObj.set("nodeTotal",nodeAry.size()); 50 | // 待交易数量 51 | String pendTxTotal = HttpUtil.createGet(urlPre + "/pending-transactions-count").execute().body(); 52 | resObj.set("pendTxSum",pendTxTotal); 53 | return AjaxResult.success(resObj); 54 | } 55 | 56 | 57 | @RequestMapping(value = "/searchBlock",method = RequestMethod.GET) 58 | @ApiOperation("查询区块详细信息") 59 | public AjaxResult searchBlock( String blockId){ 60 | String body = HttpUtil.createGet(urlPre + "/search?input="+blockId).execute().body(); 61 | JSONObject jsonObj = JSONUtil.parseObj(body); 62 | return AjaxResult.success(jsonObj); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/controller/monitor/ServerController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller.monitor; 2 | 3 | import com.qhx.admin.domain.web.Server; 4 | import com.qhx.common.model.AjaxResult; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-03-20 08:42 12 | **/ 13 | 14 | @RestController 15 | @RequestMapping("/monitor/server") 16 | public class ServerController 17 | { 18 | @RequestMapping(method = RequestMethod.GET) 19 | public AjaxResult getInfo() throws Exception 20 | { 21 | Server server = new Server(); 22 | server.copyTo(); 23 | return AjaxResult.success(server); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/controller/system/CaptchaController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller.system; 2 | 3 | import com.qhx.admin.service.CaptchaService; 4 | import com.qhx.common.model.AjaxResult; 5 | import io.swagger.annotations.ApiOperation; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | /** 12 | * 验证码控制器 13 | * 14 | * @author: jzm 15 | * @date: 2024-03-01 19:52 16 | **/ 17 | @RestController 18 | public class CaptchaController 19 | { 20 | @Autowired 21 | private CaptchaService captchaService; 22 | 23 | @RequestMapping (path = "/get/captcha",method = RequestMethod.GET) 24 | @ApiOperation("获取验证码") 25 | public AjaxResult getCaptcha(){ 26 | return captchaService.getCaptcha(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/controller/system/MessageController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller.system; 2 | 3 | import com.qhx.common.controller.BaseController; 4 | import io.swagger.annotations.Api; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | /** 9 | *

10 | * 前端控制器 11 | *

12 | * 13 | * @author qhx2004 14 | * @since 2024-03-11 15 | */ 16 | @RestController 17 | @RequestMapping("/message") 18 | @Api("消息控制器暂定---") 19 | public class MessageController extends BaseController 20 | { 21 | // 22 | //@Autowired 23 | //private MessageService messageService; 24 | // 25 | // 26 | //@RequestMapping(path = "/getAll") 27 | //@ApiOperation("获取全部消息") 28 | //public PageResult getAll(MessQueryTo messQueryTo){ 29 | // Integer page = messQueryTo.getPage(); 30 | // Integer pageSize = messQueryTo.getPageSize(); 31 | // PageInfo pageInfo = startOrderPage(page, pageSize, () -> 32 | // { 33 | // messageService.getAllMes(messQueryTo); 34 | // }); 35 | // return toAjax(pageInfo); 36 | //} 37 | // 38 | // 39 | //@RequestMapping(path = "/delete",method = RequestMethod.POST) 40 | //@ApiOperation("删除消息") 41 | //public AjaxResult delete(MessDeleteTo messDeleteTo){ 42 | // boolean end = messageService.deleteMes(messDeleteTo); 43 | // return toAjax(end); 44 | //} 45 | // 46 | // 47 | //@RequestMapping(path = "/updateStatus") 48 | //@ApiOperation("修改消息状态(审核消息)") 49 | //public AjaxResult updateStatus(@RequestBody Message message){ 50 | // boolean end = messageService.updateStatus(message); 51 | // return toAjax(end); 52 | //} 53 | // 54 | // 55 | // 56 | // 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/controller/system/ShopController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller.system; 2 | 3 | import com.qhx.admin.domain.Shop; 4 | import com.qhx.admin.service.LoginService; 5 | import com.qhx.admin.service.ShopService; 6 | import com.qhx.common.controller.BaseController; 7 | import com.qhx.common.model.AjaxResult; 8 | import com.qhx.common.util.StringUtil; 9 | import com.qhx.common.util.user.UserUtil; 10 | import io.swagger.annotations.ApiOperation; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | /** 18 | * 商家控制器(是后台用户个人信息修改的附属展示。) 19 | * 20 | * @author: jzm 21 | * @date: 2024-03-19 21:13 22 | **/ 23 | 24 | @RestController 25 | @RequestMapping("/shop") 26 | // 商家是农户的附加账号 27 | public class ShopController extends BaseController 28 | { 29 | 30 | @Autowired 31 | private LoginService loginService; 32 | 33 | @Autowired 34 | private ShopService shopService; 35 | 36 | 37 | @RequestMapping(path = "/update",method = RequestMethod.POST) 38 | @ApiOperation("修改商家信息") 39 | public AjaxResult updateShop(@RequestBody Shop shop){ 40 | boolean end = shopService.updateShop(shop); 41 | return toAjax(end); 42 | } 43 | 44 | 45 | 46 | @RequestMapping(path = "/get/one" ,method = RequestMethod.GET) 47 | @ApiOperation("获取商家信息") 48 | public AjaxResult getShop(){ 49 | Long userId = loginService.getUserId(); 50 | return toAjax(shopService.getShop(userId)); 51 | } 52 | 53 | @RequestMapping(path = "/open",method = RequestMethod.POST) 54 | @ApiOperation("开通商家信息") 55 | public AjaxResult openShop(@RequestBody Shop shop){ 56 | shop.setUserId(loginService.getUserId()); 57 | if(StringUtil.isEmpty(shop.getShopName())){ 58 | return error("商家名称不能为空!"); 59 | } 60 | boolean end = shopService.createShop(shop); 61 | return AjaxResult.success(end); 62 | } 63 | 64 | @RequestMapping(path = "/update/avatar",method = RequestMethod.POST) 65 | @ApiOperation("修改商家头像") 66 | public AjaxResult updateShopAvatar(@RequestBody Shop shop){ 67 | if(StringUtil.isEmpty(shop.getShopAvatar()) || !UserUtil.checkAvatar(shop.getShopAvatar())){ 68 | return error("上传头像地址不合法!"); 69 | } 70 | boolean end = shopService.updateShopAvatar(shop); 71 | return AjaxResult.success(end); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/controller/system/UploadController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller.system; 2 | 3 | import com.qhx.common.controller.BaseUploadController; 4 | import com.qhx.common.model.AjaxResult; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | import org.springframework.web.multipart.MultipartFile; 11 | 12 | /** 13 | * 上传控制器 14 | * 15 | * @author: jzm 16 | * @date: 2024-03-03 11:05 17 | **/ 18 | @Slf4j 19 | @RestController 20 | @RequestMapping("/upload") 21 | public class UploadController extends BaseUploadController 22 | { 23 | private static final String[] imgTypes = new String[]{"jpg","png"}; 24 | 25 | private static final String AVATAR_PATH_prefix = "img/avatar/"; 26 | private static final String GoodsImg_PATH_prefix = "img/goods/"; 27 | 28 | @RequestMapping(value = "/avatar",method = RequestMethod.POST) 29 | public AjaxResult uploadAvatar(@RequestParam MultipartFile file){ 30 | return uploadImg(AVATAR_PATH_prefix,MAX_FILE_SIZE,imgTypes,file); 31 | } 32 | 33 | @RequestMapping(value = "/goods/img",method = RequestMethod.POST) 34 | public AjaxResult uploadGoodsImg(@RequestParam MultipartFile[] file){ 35 | return uploadImg(GoodsImg_PATH_prefix,MAX_FILE_SIZE,imgTypes,file); 36 | } 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/BackUser.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import com.qhx.common.domain.User; 5 | import io.swagger.annotations.ApiModel; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | *

11 | * 用户信息表 12 | *

13 | * 14 | * @author qhx2004 15 | * @since 2024-02-27 16 | */ 17 | @Getter 18 | @Setter 19 | @TableName("ap_back_user") 20 | @ApiModel(value = "BackUser对象", description = "用户信息表") 21 | public class BackUser extends User 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/Category.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import java.io.Serializable; 7 | import java.time.LocalDateTime; 8 | 9 | import com.qhx.common.domain.BaseEntity; 10 | import io.swagger.annotations.ApiModel; 11 | import io.swagger.annotations.ApiModelProperty; 12 | import lombok.Getter; 13 | import lombok.Setter; 14 | 15 | /** 16 | *

17 | * 18 | *

19 | * 20 | * @author qhx2004 21 | * @since 2024-03-07 22 | */ 23 | @Getter 24 | @Setter 25 | @TableName("ap_category") 26 | @ApiModel(value = "Category对象", description = "") 27 | public class Category extends BaseEntity implements Serializable { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | @ApiModelProperty("分类id") 32 | @TableId(value = "category_id", type = IdType.AUTO) 33 | private Integer categoryId; 34 | 35 | @ApiModelProperty("分类名称") 36 | private String categoryName; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/FrontUser.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import com.qhx.common.domain.User; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | /** 11 | *

12 | * 用户信息表 13 | *

14 | * 15 | * @author qhx2004 16 | * @since 2024-03-07 17 | */ 18 | @Getter 19 | @Setter 20 | @TableName("ap_front_user") 21 | @ApiModel(value = "FrontUser对象", description = "用户信息表") 22 | public class FrontUser extends User{ 23 | 24 | @ApiModelProperty("邀请码") 25 | private String invitationCode; 26 | } 27 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/Goods.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import com.qhx.common.annotation.NotEmpty; 7 | import com.qhx.common.domain.BaseEntity; 8 | import io.swagger.annotations.ApiModel; 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Getter; 11 | import lombok.Setter; 12 | 13 | import java.io.Serializable; 14 | import java.math.BigDecimal; 15 | 16 | /** 17 | *

18 | * 19 | *

20 | * 21 | * @author qhx2004 22 | * @since 2024-03-19 23 | */ 24 | @Getter 25 | @Setter 26 | @TableName("ap_goods") 27 | @ApiModel(value = "Goods对象", description = "") 28 | public class Goods extends BaseEntity implements Serializable { 29 | 30 | private static final long serialVersionUID = 1L; 31 | 32 | 33 | @ApiModelProperty("农产品id") 34 | @TableId(value = "goods_id", type = IdType.AUTO) 35 | private Long goodsId; 36 | 37 | @ApiModelProperty("农产品名称") 38 | @NotEmpty(extra = "农产品名称") 39 | private String goodsName; 40 | 41 | @ApiModelProperty("产品描述") 42 | private String description; 43 | 44 | @ApiModelProperty("价格") 45 | @NotEmpty(extra = "价格") 46 | private BigDecimal price; 47 | 48 | @ApiModelProperty("商品所属商家id。") 49 | private Long shopId; 50 | 51 | @ApiModelProperty("产品库存数量") 52 | @NotEmpty(extra = "产品库存数量") 53 | private Integer balance; 54 | 55 | 56 | @ApiModelProperty("已售产品数量") 57 | @NotEmpty(extra = "已售产品数量") 58 | private Integer sold; 59 | 60 | @ApiModelProperty("状态(0正常 1停用)") 61 | private String status; 62 | 63 | // 后端自定义生成的 64 | @ApiModelProperty("产品的唯一编码") 65 | private String goodsNum; 66 | } 67 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/GoodsCategory.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | import java.io.Serializable; 11 | 12 | /** 13 | *

14 | * 15 | *

16 | * 17 | * @author qhx2004 18 | * @since 2024-03-08 19 | */ 20 | @Getter 21 | @Setter 22 | @TableName("ap_goods_category") 23 | @ApiModel(value = "GoodsCategory对象", description = "") 24 | @AllArgsConstructor 25 | public class GoodsCategory implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @ApiModelProperty("产品id") 30 | private Long goodsId; 31 | 32 | @ApiModelProperty("产品分类id") 33 | private Integer categoryId; 34 | } 35 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/GoodsImg.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.*; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | import java.io.Serializable; 10 | import java.time.LocalDateTime; 11 | 12 | /** 13 | *

14 | * 15 | *

16 | * 17 | * @author qhx2004 18 | * @since 2024-03-17 19 | */ 20 | @Getter 21 | @Setter 22 | @TableName("ap_goods_img") 23 | @ApiModel(value = "GoodsImg对象", description = "") // 添加孩子欧 24 | public class GoodsImg implements Serializable { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | @ApiModelProperty("商品图片id") 29 | @TableId(value = "img_id", type = IdType.AUTO) 30 | private Long imgId; 31 | 32 | @ApiModelProperty("图片网络地址") 33 | private String imgUrl; 34 | 35 | @ApiModelProperty("商品id") 36 | private Long goodsId; 37 | 38 | @ApiModelProperty("创建者") 39 | @TableField(fill = FieldFill.INSERT) 40 | private Long createBy; 41 | 42 | @ApiModelProperty("创建时间") 43 | @TableField(fill = FieldFill.INSERT) 44 | private LocalDateTime createTime; 45 | 46 | @ApiModelProperty("更新者") 47 | @TableField(fill = FieldFill.INSERT_UPDATE) 48 | private Long updateBy; 49 | 50 | @ApiModelProperty("更新时间") 51 | @TableField(fill = FieldFill.INSERT_UPDATE) 52 | private LocalDateTime updateTime; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/Menu.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | import java.io.Serializable; 12 | 13 | /** 14 | * @author: jzm 15 | * @date: 2024-03-10 09:00 16 | **/ 17 | 18 | @Getter 19 | @Setter 20 | @TableName("ap_menu") 21 | @ApiModel(value = "menu对象", description = "") 22 | public class Menu implements Serializable 23 | { 24 | private static final long serialVersionUID = 1L; 25 | 26 | @ApiModelProperty("菜单id") 27 | @TableId(value = "menu_id", type = IdType.AUTO) 28 | private Integer menuId; 29 | 30 | @ApiModelProperty("菜单路径") 31 | private String menuPath; 32 | 33 | @ApiModelProperty("菜单名字") 34 | private String menuName; 35 | 36 | @ApiModelProperty("菜单图标") 37 | private String menuIcon; 38 | 39 | @ApiModelProperty("根菜单id") 40 | private Integer rootId; 41 | } 42 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/Message.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import java.io.Serializable; 7 | import java.time.LocalDateTime; 8 | import io.swagger.annotations.ApiModel; 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Getter; 11 | import lombok.Setter; 12 | 13 | /** 14 | *

15 | * 16 | *

17 | * 18 | * @author qhx2004 19 | * @since 2024-03-11 20 | */ 21 | @Getter 22 | @Setter 23 | @TableName("ap_message") 24 | @ApiModel(value = "Message对象", description = "") 25 | public class Message implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @ApiModelProperty("消息id") 30 | @TableId(value = "message_id", type = IdType.AUTO) 31 | private Integer messageId; 32 | 33 | @ApiModelProperty("消息发送者id") 34 | private Long senderId; 35 | 36 | @ApiModelProperty("消息接受者(一般农户id)") 37 | private Long receiverId; 38 | 39 | @ApiModelProperty("消息内容") 40 | private String content; 41 | 42 | @ApiModelProperty("发送这条消息的时间") 43 | private LocalDateTime senderTime; 44 | 45 | @ApiModelProperty("消息接受时间") 46 | private LocalDateTime receiverTime; 47 | 48 | @ApiModelProperty("状态(0正常 1停用)") 49 | private String status; 50 | 51 | @ApiModelProperty("删除标志(0代表存在 1代表删除)") 52 | private String delFlag; 53 | } 54 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/Order.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import com.qhx.common.annotation.NotEmpty; 7 | import com.qhx.common.domain.BaseEntity; 8 | import io.swagger.annotations.ApiModel; 9 | import io.swagger.annotations.ApiModelProperty; 10 | import lombok.Getter; 11 | import lombok.Setter; 12 | 13 | import java.io.Serializable; 14 | import java.math.BigDecimal; 15 | 16 | /** 17 | * 18 | * @author qhx2004 19 | * @since 2024-03-19 20 | */ 21 | @Getter 22 | @Setter 23 | @TableName("ap_order") 24 | @ApiModel(value = "Order对象", description = "") 25 | public class Order extends BaseEntity implements Serializable { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @ApiModelProperty("订单id") 30 | @NotEmpty(extra = "订单编号") 31 | @TableId(value = "order_id", type = IdType.AUTO) 32 | private Long orderId; 33 | 34 | @ApiModelProperty("购买者用户id") 35 | @NotEmpty(extra = "购买者用户编号") 36 | private Long buyerId; 37 | 38 | @ApiModelProperty("商家id(后台农户id)") 39 | @NotEmpty(extra = "商家编号") 40 | private Long shopId; 41 | 42 | @ApiModelProperty("农产品id") 43 | @NotEmpty(extra = "农产品编号") 44 | private Long goodsId; 45 | 46 | @ApiModelProperty("订单交易数量") 47 | @NotEmpty(extra = "订单交易数量") 48 | private Integer amount; 49 | 50 | @ApiModelProperty("订单总价") 51 | @NotEmpty(extra = "订单总价") 52 | private BigDecimal totalPrice; 53 | 54 | @ApiModelProperty("订单状态(0 待支付,1 未发货 , 2 已发货 , 3 已完成)") 55 | private String status; 56 | 57 | @ApiModelProperty("收货人姓名") 58 | @NotEmpty(extra = "收货人姓名") 59 | private String receiverName; 60 | 61 | @ApiModelProperty("收货人电话") 62 | @NotEmpty(extra = "收货人电话") 63 | private String receiverPhone; 64 | 65 | @ApiModelProperty("收货地址") 66 | @NotEmpty(extra = "收货人地址") 67 | private String receiverAddress; 68 | 69 | @ApiModelProperty("快递名称") 70 | private String expressName; 71 | 72 | @ApiModelProperty("快递单号") 73 | private String expressNum; 74 | 75 | @ApiModelProperty("发货人地址") 76 | private String senderAddress; 77 | 78 | @ApiModelProperty("发货人姓名") 79 | private String senderName; 80 | 81 | @ApiModelProperty("发货人电话") 82 | private String senderPhone; 83 | 84 | @ApiModelProperty("是否退款('0' 代表未退款,'1'代表退款)") 85 | private String refund; 86 | 87 | @ApiModelProperty("是否取消订单('0' 代表取消订单,'1'代表为取消订单)") 88 | private String cancel; 89 | 90 | @ApiModelProperty("订单序列号") 91 | private String orderNum; 92 | 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/Shop.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 14 | *

15 | * 16 | * @author qhx2004 17 | * @since 2024-03-19 18 | */ 19 | @Getter 20 | @Setter 21 | @TableName("ap_shop") 22 | @ApiModel(value = "Shop对象", description = "") 23 | public class Shop implements Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | @ApiModelProperty("后台用户id(绑定的是后台农户)") 28 | private Long userId; 29 | 30 | @ApiModelProperty("商家名称(指店铺名称,不是用户名称)") 31 | private String shopName; 32 | 33 | @ApiModelProperty("评分人数") 34 | private Long scoreNum; 35 | 36 | @ApiModelProperty("购买人数") 37 | private Long buyNum; 38 | 39 | @ApiModelProperty("收藏人数") 40 | private Long collectNum; 41 | 42 | @ApiModelProperty("总评分") 43 | private Short totalScore; 44 | 45 | @ApiModelProperty("商家头像") 46 | private String shopAvatar; 47 | 48 | 49 | @ApiModelProperty("开通时间") 50 | private String createTime; 51 | 52 | @ApiModelProperty("修改时间") 53 | private String updateTime; 54 | 55 | } 56 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import java.io.Serializable; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.AllArgsConstructor; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | /** 12 | *

13 | * 14 | *

15 | * 16 | * @author qhx2004 17 | * @since 2024-03-01 18 | */ 19 | @Getter 20 | @Setter 21 | @AllArgsConstructor 22 | @TableName("ap_user_role") 23 | @ApiModel(value = "UserRole对象", description = "") 24 | public class UserRole implements Serializable { 25 | 26 | private static final long serialVersionUID = 1L; 27 | 28 | @ApiModelProperty("后台用户id") 29 | private Long userId; 30 | 31 | @ApiModelProperty("角色id") 32 | private Integer roleId; 33 | } 34 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/web/server/Cpu.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain.web.server; 2 | 3 | 4 | import com.qhx.common.util.Arith; 5 | 6 | /** 7 | * CPU相关信息 8 | * 9 | * @author ruoyi 10 | */ 11 | public class Cpu 12 | { 13 | /** 14 | * 核心数 15 | */ 16 | private int cpuNum; 17 | 18 | /** 19 | * CPU总的使用率 20 | */ 21 | private double total; 22 | 23 | /** 24 | * CPU系统使用率 25 | */ 26 | private double sys; 27 | 28 | /** 29 | * CPU用户使用率 30 | */ 31 | private double used; 32 | 33 | /** 34 | * CPU当前等待率 35 | */ 36 | private double wait; 37 | 38 | /** 39 | * CPU当前空闲率 40 | */ 41 | private double free; 42 | 43 | public int getCpuNum() 44 | { 45 | return cpuNum; 46 | } 47 | 48 | public void setCpuNum(int cpuNum) 49 | { 50 | this.cpuNum = cpuNum; 51 | } 52 | 53 | public double getTotal() 54 | { 55 | return Arith.round(Arith.mul(total, 100), 2); 56 | } 57 | 58 | public void setTotal(double total) 59 | { 60 | this.total = total; 61 | } 62 | 63 | public double getSys() 64 | { 65 | return Arith.round(Arith.mul(sys / total, 100), 2); 66 | } 67 | 68 | public void setSys(double sys) 69 | { 70 | this.sys = sys; 71 | } 72 | 73 | public double getUsed() 74 | { 75 | return Arith.round(Arith.mul(used / total, 100), 2); 76 | } 77 | 78 | public void setUsed(double used) 79 | { 80 | this.used = used; 81 | } 82 | 83 | public double getWait() 84 | { 85 | return Arith.round(Arith.mul(wait / total, 100), 2); 86 | } 87 | 88 | public void setWait(double wait) 89 | { 90 | this.wait = wait; 91 | } 92 | 93 | public double getFree() 94 | { 95 | return Arith.round(Arith.mul(free / total, 100), 2); 96 | } 97 | 98 | public void setFree(double free) 99 | { 100 | this.free = free; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/web/server/Mem.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain.web.server; 2 | 3 | 4 | import com.qhx.common.util.Arith; 5 | 6 | /** 7 | * 內存相关信息 8 | * 9 | * @author ruoyi 10 | */ 11 | public class Mem 12 | { 13 | /** 14 | * 内存总量 15 | */ 16 | private double total; 17 | 18 | /** 19 | * 已用内存 20 | */ 21 | private double used; 22 | 23 | /** 24 | * 剩余内存 25 | */ 26 | private double free; 27 | 28 | public double getTotal() 29 | { 30 | return Arith.div(total, (1024 * 1024 * 1024), 2); 31 | } 32 | 33 | public void setTotal(long total) 34 | { 35 | this.total = total; 36 | } 37 | 38 | public double getUsed() 39 | { 40 | return Arith.div(used, (1024 * 1024 * 1024), 2); 41 | } 42 | 43 | public void setUsed(long used) 44 | { 45 | this.used = used; 46 | } 47 | 48 | public double getFree() 49 | { 50 | return Arith.div(free, (1024 * 1024 * 1024), 2); 51 | } 52 | 53 | public void setFree(long free) 54 | { 55 | this.free = free; 56 | } 57 | 58 | public double getUsage() 59 | { 60 | return Arith.mul(Arith.div(used, total, 4), 100); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/web/server/Sys.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain.web.server; 2 | 3 | /** 4 | * 系统相关信息 5 | * 6 | * @author ruoyi 7 | */ 8 | public class Sys 9 | { 10 | /** 11 | * 服务器名称 12 | */ 13 | private String computerName; 14 | 15 | /** 16 | * 服务器Ip 17 | */ 18 | private String computerIp; 19 | 20 | /** 21 | * 项目路径 22 | */ 23 | private String userDir; 24 | 25 | /** 26 | * 操作系统 27 | */ 28 | private String osName; 29 | 30 | /** 31 | * 系统架构 32 | */ 33 | private String osArch; 34 | 35 | public String getComputerName() 36 | { 37 | return computerName; 38 | } 39 | 40 | public void setComputerName(String computerName) 41 | { 42 | this.computerName = computerName; 43 | } 44 | 45 | public String getComputerIp() 46 | { 47 | return computerIp; 48 | } 49 | 50 | public void setComputerIp(String computerIp) 51 | { 52 | this.computerIp = computerIp; 53 | } 54 | 55 | public String getUserDir() 56 | { 57 | return userDir; 58 | } 59 | 60 | public void setUserDir(String userDir) 61 | { 62 | this.userDir = userDir; 63 | } 64 | 65 | public String getOsName() 66 | { 67 | return osName; 68 | } 69 | 70 | public void setOsName(String osName) 71 | { 72 | this.osName = osName; 73 | } 74 | 75 | public String getOsArch() 76 | { 77 | return osArch; 78 | } 79 | 80 | public void setOsArch(String osArch) 81 | { 82 | this.osArch = osArch; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/domain/web/server/SysFile.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.domain.web.server; 2 | 3 | /** 4 | * 系统文件相关信息 5 | * 6 | * @author ruoyi 7 | */ 8 | public class SysFile 9 | { 10 | /** 11 | * 盘符路径 12 | */ 13 | private String dirName; 14 | 15 | /** 16 | * 盘符类型 17 | */ 18 | private String sysTypeName; 19 | 20 | /** 21 | * 文件类型 22 | */ 23 | private String typeName; 24 | 25 | /** 26 | * 总大小 27 | */ 28 | private String total; 29 | 30 | /** 31 | * 剩余大小 32 | */ 33 | private String free; 34 | 35 | /** 36 | * 已经使用量 37 | */ 38 | private String used; 39 | 40 | /** 41 | * 资源的使用率 42 | */ 43 | private double usage; 44 | 45 | public String getDirName() 46 | { 47 | return dirName; 48 | } 49 | 50 | public void setDirName(String dirName) 51 | { 52 | this.dirName = dirName; 53 | } 54 | 55 | public String getSysTypeName() 56 | { 57 | return sysTypeName; 58 | } 59 | 60 | public void setSysTypeName(String sysTypeName) 61 | { 62 | this.sysTypeName = sysTypeName; 63 | } 64 | 65 | public String getTypeName() 66 | { 67 | return typeName; 68 | } 69 | 70 | public void setTypeName(String typeName) 71 | { 72 | this.typeName = typeName; 73 | } 74 | 75 | public String getTotal() 76 | { 77 | return total; 78 | } 79 | 80 | public void setTotal(String total) 81 | { 82 | this.total = total; 83 | } 84 | 85 | public String getFree() 86 | { 87 | return free; 88 | } 89 | 90 | public void setFree(String free) 91 | { 92 | this.free = free; 93 | } 94 | 95 | public String getUsed() 96 | { 97 | return used; 98 | } 99 | 100 | public void setUsed(String used) 101 | { 102 | this.used = used; 103 | } 104 | 105 | public double getUsage() 106 | { 107 | return usage; 108 | } 109 | 110 | public void setUsage(double usage) 111 | { 112 | this.usage = usage; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/BackUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.BackUser; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import com.qhx.admin.domain.Menu; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Param; 8 | 9 | import java.util.HashMap; 10 | import java.util.List; 11 | 12 | /** 13 | *

14 | * 用户信息表 Mapper 接口 15 | *

16 | * 17 | * @author qhx2004 18 | * @since 2024-02-27 19 | */ 20 | @Mapper 21 | public interface BackUserMapper extends BaseMapper { 22 | 23 | List selectMenuByUserId(Long userId); 24 | 25 | List selectAllUser(@Param("map") HashMap map); 26 | } 27 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/CategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.Category; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author qhx2004 13 | * @since 2024-03-07 14 | */ 15 | @Mapper 16 | public interface CategoryMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/FrontUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.FrontUser; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | *

9 | * 用户信息表 Mapper 接口 10 | *

11 | * 12 | * @author qhx2004 13 | * @since 2024-03-07 14 | */ 15 | @Mapper 16 | public interface FrontUserMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/GoodsCategoryMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.Category; 4 | import com.qhx.admin.domain.GoodsCategory; 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 6 | import org.apache.ibatis.annotations.Mapper; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | *

12 | * Mapper 接口 13 | *

14 | * 15 | * @author qhx2004 16 | * @since 2024-03-08 17 | */ 18 | @Mapper 19 | public interface GoodsCategoryMapper extends BaseMapper { 20 | 21 | List selectAllCategoryByGoodsId(Long goodsId); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/GoodsImgMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.GoodsImg; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author qhx2004 13 | * @since 2024-03-10 14 | */ 15 | @Mapper 16 | public interface GoodsImgMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/GoodsMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.qhx.admin.domain.Goods; 5 | import org.apache.ibatis.annotations.Mapper; 6 | import org.apache.ibatis.annotations.Param; 7 | 8 | import java.util.HashMap; 9 | import java.util.List; 10 | 11 | /** 12 | *

13 | * Mapper 接口 14 | *

15 | * 16 | * @author qhx2004 17 | * @since 2024-03-07 18 | */ 19 | @Mapper 20 | public interface GoodsMapper extends BaseMapper { 21 | 22 | List selectAllGoods(@Param("map") HashMap map); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/MessageMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.Message; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author qhx2004 13 | * @since 2024-03-11 14 | */ 15 | @Mapper 16 | public interface MessageMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/OrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.Order; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author qhx2004 13 | * @since 2024-03-08 14 | */ 15 | @Mapper 16 | public interface OrderMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/ShopMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.Shop; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author qhx2004 13 | * @since 2024-03-10 14 | */ 15 | @Mapper 16 | public interface ShopMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/mapper/UserRoleMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.mapper; 2 | 3 | import com.qhx.admin.domain.UserRole; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author qhx2004 13 | * @since 2024-03-01 14 | */ 15 | @Mapper 16 | public interface UserRoleMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/LoginTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 登录To 7 | * 8 | * @author: jzm 9 | * @date: 2024-02-27 09:22 10 | **/ 11 | 12 | @Data 13 | public class LoginTo 14 | { 15 | private String username; 16 | private String password; 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/OnlineUserForceTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-03-29 10:38 8 | **/ 9 | 10 | @Data 11 | public class OnlineUserForceTo 12 | { 13 | private Long userId; 14 | } 15 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/OnlineUserQueryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to; 2 | 3 | import com.qhx.common.model.to.BasePageTo; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author: jzm 8 | * @date: 2024-03-28 20:41 9 | **/ 10 | 11 | @Data 12 | public class OnlineUserQueryTo extends BasePageTo 13 | { 14 | private String loginIp; 15 | private String username; 16 | } 17 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/backUser/BackUserDeleteTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.backUser; 2 | 3 | import com.qhx.common.model.to.user.UserDeleteTo; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * @author: jzm 12 | * @date: 2024-03-02 09:05 13 | **/ 14 | 15 | @AllArgsConstructor 16 | public class BackUserDeleteTo extends UserDeleteTo 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/backUser/BackUserQueryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.backUser; 2 | 3 | 4 | import com.qhx.common.model.to.user.UserQueryTo; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | /** 9 | * 后端用户查询 10 | * 11 | * @author: jzm 12 | * @date: 2024-03-03 21:07 13 | **/ 14 | 15 | 16 | public class BackUserQueryTo extends UserQueryTo 17 | { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/category/CategoryDeleteTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.category; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-08 08:13 11 | **/ 12 | @Setter 13 | @Getter 14 | public class CategoryDeleteTo 15 | { 16 | private List categoryIds; 17 | } 18 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/category/CategoryQueryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.category; 2 | 3 | import com.qhx.common.model.to.BasePageTo; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | import java.time.LocalDateTime; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-03-07 22:23 12 | **/ 13 | 14 | @Setter 15 | @Getter 16 | public class CategoryQueryTo extends BasePageTo 17 | { 18 | private String categoryName; 19 | private String status; 20 | private LocalDateTime beginTime; 21 | private LocalDateTime endTime; 22 | } 23 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/category/CategoryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.category; 2 | 3 | import com.qhx.admin.domain.Category; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-07 22:21 11 | **/ 12 | 13 | @Setter 14 | @Getter 15 | public class CategoryTo extends Category 16 | { 17 | private String categoryName; 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/frontUser/FrontUserDeleteTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.frontUser; 2 | 3 | import com.qhx.common.model.to.user.UserDeleteTo; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-07 14:42 11 | **/ 12 | 13 | @AllArgsConstructor 14 | public class FrontUserDeleteTo extends UserDeleteTo 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/frontUser/FrontUserQueryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.frontUser; 2 | 3 | import com.qhx.common.model.to.user.UserQueryTo; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-07 14:27 11 | **/ 12 | 13 | 14 | public class FrontUserQueryTo extends UserQueryTo 15 | { 16 | } 17 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/frontUser/InviCodeTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.frontUser; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * 邀请码to 8 | * 9 | * @author: jzm 10 | * @date: 2024-03-10 22:03 11 | **/ 12 | 13 | @Data 14 | public class InviCodeTo 15 | { 16 | @ApiModelProperty("邀请码") 17 | private String invitationCode; 18 | } 19 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/goods/GoodsDeleteTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.goods; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author: jzm 9 | * @date: 2024-03-08 18:50 10 | **/ 11 | 12 | @Data 13 | public class GoodsDeleteTo 14 | { 15 | private List goodsIds; 16 | } 17 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/goods/GoodsImgDeleteTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.goods; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author: jzm 9 | * @date: 2024-03-27 10:12 10 | **/ 11 | 12 | @Data 13 | public class GoodsImgDeleteTo 14 | { 15 | private List imgIds; 16 | } 17 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/goods/GoodsQueryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.goods; 2 | 3 | import com.qhx.common.model.to.BasePageTo; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | import java.math.BigDecimal; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-03-08 17:53 12 | **/ 13 | 14 | @Setter 15 | @Getter 16 | public class GoodsQueryTo extends BasePageTo 17 | { 18 | private String goodsName; 19 | private String goodsNum; // 产品唯一号 20 | private Long shopId; 21 | private String status; 22 | private Long categoryId; 23 | private BigDecimal minPrice; 24 | private BigDecimal maxPrice; 25 | } 26 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/goods/GoodsTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.goods; 2 | 3 | import com.qhx.admin.domain.Goods; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 商品to 10 | * 11 | * @author: jzm 12 | * @date: 2024-03-07 22:15 13 | **/ 14 | 15 | @Data 16 | public class GoodsTo extends Goods 17 | { 18 | // 图片Url的合法性 19 | private List imgUrls; 20 | 21 | // 商品分类id 22 | private List categoryIds; 23 | } 24 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/message/MessDeleteTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.message; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author: jzm 9 | * @date: 2024-03-11 08:24 10 | **/ 11 | 12 | @Data 13 | public class MessDeleteTo 14 | { 15 | private List mesIds; 16 | } 17 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/message/MessQueryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.message; 2 | 3 | import com.qhx.common.model.to.BasePageTo; 4 | import lombok.Data; 5 | import lombok.EqualsAndHashCode; 6 | 7 | import java.time.LocalDateTime; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-03-11 08:19 12 | **/ 13 | 14 | @Data 15 | @EqualsAndHashCode(callSuper=false) 16 | public class MessQueryTo extends BasePageTo 17 | { 18 | private LocalDateTime beginTime; 19 | private LocalDateTime endTime; 20 | private String content; 21 | } 22 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/order/OrderDeleteTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.order; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author: jzm 9 | * @date: 2024-03-10 14:13 10 | **/ 11 | 12 | @Data 13 | public class OrderDeleteTo 14 | { 15 | private List orderIds; 16 | } 17 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/to/order/OrderQueryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.to.order; 2 | 3 | import com.qhx.common.model.to.BasePageTo; 4 | import lombok.Data; 5 | 6 | import java.time.LocalDateTime; 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-10 11:10 11 | **/ 12 | 13 | @Data 14 | public class OrderQueryTo extends BasePageTo 15 | { 16 | private String receiverPhone; // 联系电话 17 | private String senderPhone; // 发货人电话 18 | private String orderNum; // 订单序列号 19 | private LocalDateTime beginTime; 20 | private LocalDateTime endTime; 21 | } 22 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/CategoryVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-03-26 14:49 8 | **/ 9 | 10 | @Data 11 | public class CategoryVo 12 | { 13 | private Long categoryId; 14 | private String categoryName; 15 | } 16 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/FarmerVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo; 2 | 3 | import com.qhx.admin.domain.BackUser; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author: jzm 8 | * @date: 2024-03-31 18:08 9 | **/ 10 | 11 | @Data 12 | public class FarmerVo extends BackUser 13 | { 14 | private boolean isShop; // 是否开通商家,0未开通,1开通 15 | } 16 | 17 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/GoodsImgVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-27 09:39 11 | **/ 12 | 13 | @Data 14 | public class GoodsImgVo 15 | { 16 | @ApiModelProperty("商品图片id") 17 | @TableId(value = "img_id", type = IdType.AUTO) 18 | private Long imgId; 19 | 20 | @ApiModelProperty("图片网络地址") 21 | private String imgUrl; 22 | } 23 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/GoodsVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo; 2 | 3 | import com.qhx.admin.domain.Goods; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * goods响应类 10 | * 11 | * @author: jzm 12 | * @date: 2024-03-26 14:44 13 | **/ 14 | 15 | @Data 16 | public class GoodsVo extends Goods 17 | { 18 | private List categoryVos; 19 | 20 | private List goodsImgVos; 21 | } 22 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/MenuVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo; 2 | 3 | import com.qhx.admin.domain.Menu; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 响应菜单Vo 10 | * 11 | * @author: jzm 12 | * @date: 2024-03-10 08:57 13 | **/ 14 | 15 | @Data 16 | public class MenuVo extends Menu 17 | { 18 | private List children; 19 | } 20 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/OnlineUserVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo; 2 | 3 | import lombok.Data; 4 | 5 | import java.time.LocalDateTime; 6 | 7 | /** 8 | * @author: jzm 9 | * @date: 2024-03-28 16:53 10 | **/ 11 | 12 | @Data 13 | public class OnlineUserVo 14 | { 15 | private Long userId; 16 | 17 | private String username; 18 | private String loginIp; 19 | private LocalDateTime loginDate; 20 | 21 | private String tokenId; 22 | private String loginLocation; 23 | private String browserName; 24 | private String osName; 25 | } 26 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/OrderVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo; 2 | 3 | import com.qhx.admin.domain.Order; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | /** 8 | * 订单响应To 9 | * 10 | * @author: jzm 11 | * @date: 2024-03-10 17:13 12 | **/ 13 | 14 | @Data 15 | public class OrderVo extends Order 16 | { 17 | 18 | @ApiModelProperty("店铺名称") 19 | private String shopName; 20 | 21 | @ApiModelProperty("店铺头像") 22 | private String shopAvatar; 23 | 24 | @ApiModelProperty("商品名称") 25 | private String goodsName; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/index/IndexCountVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo.index; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-03-21 15:42 8 | **/ 9 | 10 | @Data 11 | public class IndexCountVo 12 | { 13 | private String goodsCount; 14 | private String userCount; 15 | private String orderCount; 16 | private String shopCount; 17 | } 18 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/index/main/CategoryMain.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo.index.main; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | @Data 7 | public class CategoryMain { 8 | @ApiModelProperty("分类名") 9 | private String name; 10 | @ApiModelProperty("分类下面产品数量") 11 | private String value; 12 | } -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/index/main/IndexMainVo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo.index.main; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author: jzm 9 | * @date: 2024-03-21 16:31 10 | **/ 11 | 12 | @Data 13 | public class IndexMainVo 14 | { 15 | private UserMain userMain; 16 | private List categoryMains; 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/model/vo/index/main/UserMain.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.model.vo.index.main; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.List; 9 | 10 | @Data 11 | @AllArgsConstructor 12 | @NoArgsConstructor 13 | public class UserMain 14 | { 15 | @ApiModelProperty("用户安创建时间分类数") 16 | private List users; 17 | @ApiModelProperty("用户创建时间分类数") 18 | private List times; 19 | } 20 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/BackUserService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.qhx.admin.domain.BackUser; 6 | import com.qhx.admin.domain.Menu; 7 | import com.qhx.admin.model.to.LoginTo; 8 | import com.qhx.admin.model.to.backUser.BackUserDeleteTo; 9 | import com.qhx.admin.model.to.backUser.BackUserQueryTo; 10 | import com.qhx.common.model.to.user.PassTo; 11 | import com.qhx.common.model.to.user.PasswordNotOldTo; 12 | 13 | import java.util.List; 14 | 15 | /** 16 | * 农户业务类 17 | * @author: jzm 18 | * @date: 2024-03-01 19:47 19 | **/ 20 | 21 | public interface BackUserService extends IService 22 | { 23 | 24 | BackUser login(LoginTo loginTo); 25 | boolean isPasswordExists(String password); 26 | boolean isMD5PassExists(String password); 27 | 28 | // 不存在返回true 29 | boolean checkPasswordUnique(String password); 30 | 31 | boolean checkPhoneUnique(BackUser backUser); 32 | // 忽略当前电话和查询用户电话是否相等。 33 | boolean checkUpPhoneUnique(BackUser backUser); 34 | boolean checkEmailUnique(BackUser backUser); 35 | boolean checkUpEmailUnique(BackUser backUser); 36 | 37 | 38 | 39 | // 拿到用户拥有的权限路径 40 | List getMenuByUserId(Long userId); 41 | 42 | List getAllBackUser(BackUserQueryTo backUserQueryTo, int roleId); 43 | 44 | BackUser getBackUserByUserId(long userId); 45 | 46 | boolean createBackUser(BackUser backUser); 47 | 48 | // 我想想,我对于表的限制策略: ,要求:密码和password是必填项且唯一。其他可以为null。电话号可以唯一。 49 | boolean updateBackUser(BackUser backUser); 50 | 51 | boolean updatePassword(PassTo passTo); 52 | boolean updateMD5Pass(PasswordNotOldTo passwordNotOldTo); 53 | 54 | boolean deleteBackUser(BackUserDeleteTo backUserDeleteTo); 55 | 56 | boolean updateStatus(BackUser backUser); 57 | 58 | 59 | BackUser getBackUserByField(SFunction colum,Object val); 60 | 61 | boolean updateAvatar(BackUser backUser); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/CaptchaService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import cn.hutool.captcha.CaptchaUtil; 4 | import cn.hutool.captcha.LineCaptcha; 5 | import cn.hutool.core.util.IdUtil; 6 | import com.qhx.common.constant.CacheConstant; 7 | import com.qhx.common.model.AjaxResult; 8 | import com.qhx.common.util.redis.RedisCache; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.util.HashMap; 13 | import java.util.concurrent.TimeUnit; 14 | 15 | /** 16 | * 验证码业务类 17 | * 18 | * @author: jzm 19 | * @date: 2024-02-28 12:12 20 | **/ 21 | 22 | @Component 23 | public class CaptchaService 24 | { 25 | 26 | @Autowired 27 | RedisCache redisCache; 28 | 29 | public AjaxResult getCaptcha(){ 30 | LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(128, 50); 31 | String uuid = IdUtil.randomUUID(); 32 | // 验证码缓存到redis 33 | String codeKey = CacheConstant.CAPTCHA_CODE_KEY + uuid; 34 | redisCache.setCacheObject(codeKey,lineCaptcha.getCode(),60, TimeUnit.SECONDS); 35 | HashMap result = new HashMap<>(); 36 | result.put("codeUrl",lineCaptcha.getImageBase64Data()); 37 | result.put("codeKey",uuid); 38 | return AjaxResult.success(result); 39 | } 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/CategoryService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.qhx.admin.domain.Category; 5 | import com.qhx.admin.model.to.category.CategoryDeleteTo; 6 | import com.qhx.admin.model.to.category.CategoryQueryTo; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | *

12 | * 服务类 13 | *

14 | * 15 | * @author qhx2004 16 | * @since 2024-03-07 17 | */ 18 | public interface CategoryService extends IService { 19 | 20 | List getAllCategory(CategoryQueryTo categoryQueryTo); 21 | 22 | // 校验类名唯一性 23 | boolean checkCategoryNameUnique(String categoryName); 24 | 25 | 26 | boolean createCategory(Category category); 27 | 28 | boolean deleteCategory(CategoryDeleteTo categoryDeleteTo); 29 | 30 | boolean updateCategory(Category category); 31 | 32 | 33 | boolean updateStatus(Category category); 34 | 35 | 36 | 37 | 38 | 39 | } 40 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/FrontUserService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; 4 | import com.qhx.admin.domain.BackUser; 5 | import com.qhx.admin.domain.FrontUser; 6 | import com.baomidou.mybatisplus.extension.service.IService; 7 | import com.qhx.common.model.to.user.PassTo; 8 | import com.qhx.admin.model.to.frontUser.FrontUserDeleteTo; 9 | import com.qhx.admin.model.to.frontUser.FrontUserQueryTo; 10 | import com.qhx.common.model.to.user.PasswordNotOldTo; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | *

16 | * 用户信息表 服务类 17 | *

18 | * 19 | * @author qhx2004 20 | * @since 2024-03-07 21 | */ 22 | public interface FrontUserService extends IService 23 | { 24 | 25 | FrontUser getOneByUserId(Long userId); 26 | 27 | List getAllFrontUser(FrontUserQueryTo frontUserQueryTo); 28 | 29 | boolean createFrontUser(FrontUser frontUser); 30 | 31 | /** 32 | * 前台用户修改密码 33 | * @param passTo 34 | * @return 35 | */ 36 | boolean updatePassword(PassTo passTo); 37 | 38 | boolean updateStatus(FrontUser frontUser); 39 | 40 | boolean updateFrontUser(FrontUser frontUser); 41 | 42 | boolean deleteFrontUser(FrontUserDeleteTo frontUserDeleteTo); 43 | 44 | 45 | boolean checkPasswordUnique(String password); 46 | boolean checkMD5PassUnique(String password); 47 | boolean isPasswordExists(String password); 48 | 49 | boolean checkPhoneUnique(FrontUser backUser); 50 | boolean checkUpPhoneUnique(FrontUser frontUser); 51 | 52 | 53 | boolean checkEmailUnique(FrontUser backUser); 54 | boolean checkUpEmailUnique(FrontUser frontUser); 55 | 56 | 57 | boolean isMD5PassExists(String password); 58 | 59 | boolean updateMD5Pass(PasswordNotOldTo passwordNotOldTo); 60 | 61 | FrontUser getFrontUserByField(SFunction colum,Object val); 62 | 63 | BackUser isBindBackUser(String md5Pass); 64 | 65 | 66 | } 67 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/GoodsCategoryService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.qhx.admin.domain.Category; 5 | import com.qhx.admin.domain.GoodsCategory; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | *

11 | * 服务类 12 | *

13 | * 14 | * @author qhx2004 15 | * @since 2024-03-08 16 | */ 17 | public interface GoodsCategoryService extends IService { 18 | 19 | List geAllByCategoryId(List categoryIds); 20 | Integer getCountByCategoryId(List categoryIds); 21 | 22 | boolean createGoodsCategory(List categoryIds,Long goodsId); 23 | 24 | // 添加不同的,删除没有的 25 | boolean updateGoodsCategory(List categoryIds, Long goodsId); 26 | 27 | int getCountByCategoryId(Integer categoryId); 28 | 29 | List getAllCategoryByGoodsId(Long goodsId); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/GoodsImgService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.qhx.admin.domain.GoodsImg; 6 | import com.qhx.admin.model.to.goods.GoodsImgDeleteTo; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | *

12 | * 服务类 13 | *

14 | * 15 | * @author qhx2004 16 | * @since 2024-03-10 17 | */ 18 | public interface GoodsImgService extends IService { 19 | 20 | 21 | boolean createGoodImgUrls(List imgUrls,Long goodsId); 22 | 23 | 24 | /** 25 | * 查询图片是否存在,不存在插入新数据 26 | * 27 | * @param imgUrls 商品图片url 28 | * @param goodsId 商品id 29 | * @return 30 | */ 31 | boolean updateGoodsImgUrls(List imgUrls, Long goodsId); 32 | 33 | GoodsImg getGoodsImgByFiled(SFunction colum, Object val); 34 | 35 | List getAllByGoodsId(Long goodsId); 36 | 37 | boolean deleteGoodsImg(GoodsImgDeleteTo goodsImg); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/GoodsService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.qhx.admin.domain.Goods; 6 | import com.qhx.admin.model.to.goods.GoodsDeleteTo; 7 | import com.qhx.admin.model.to.goods.GoodsQueryTo; 8 | import com.qhx.admin.model.to.goods.GoodsTo; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | *

14 | * 服务类 15 | *

16 | * 17 | * @author qhx2004 18 | * @since 2024-03-08 19 | */ 20 | public interface GoodsService extends IService { 21 | 22 | 23 | Goods getOneGoodById(Long goodsId); 24 | 25 | List getAllGoods(GoodsQueryTo goodsQueryTo, Long userId); 26 | 27 | boolean updateGoods(GoodsTo goods); 28 | 29 | Goods getOneGoodsByFiled(SFunction column, Object val); 30 | 31 | boolean deleteGoods(GoodsDeleteTo goodsDeleteTo); 32 | 33 | boolean updateStatus(Goods goods); 34 | 35 | // 判断未完成订单 36 | boolean isBindNoDoneOrder(Long goodsId); 37 | 38 | // 校验商品列表能否删除 39 | boolean isBindNoDoneOrder(List goodsIds); 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/MessageService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.qhx.admin.domain.Message; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.qhx.admin.model.to.message.MessDeleteTo; 6 | import com.qhx.admin.model.to.message.MessQueryTo; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | *

12 | * 服务类 13 | *

14 | * 15 | * @author qhx2004 16 | * @since 2024-03-11 17 | */ 18 | public interface MessageService extends IService { 19 | 20 | List getAllMes(MessQueryTo messQueryTo); 21 | 22 | boolean deleteMes(MessDeleteTo messDeleteTo); 23 | 24 | boolean updateStatus(Message message); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.qhx.admin.domain.Order; 5 | import com.qhx.admin.model.to.order.OrderDeleteTo; 6 | import com.qhx.admin.model.to.order.OrderQueryTo; 7 | import com.qhx.admin.model.vo.OrderVo; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | *

13 | * 服务类 14 | *

15 | * 16 | * @author qhx2004 17 | * @since 2024-03-08 18 | */ 19 | public interface OrderService extends IService { 20 | 21 | 22 | // 获取未完成订单 23 | List getNoDoneOrder(Long goodsId); 24 | 25 | List getAllOrder(OrderQueryTo orderQueryTo,Long shopId); 26 | 27 | OrderVo getOneByOrderId(Long orderId); 28 | 29 | boolean createOrder(Order order); 30 | 31 | boolean updateOrder(Order order); 32 | 33 | boolean updateStatus(Order order); 34 | 35 | boolean isCanDeleteOrder(OrderDeleteTo orderDeleteTo); 36 | boolean deleteOrder(OrderDeleteTo orderDeleteTo); 37 | 38 | boolean updateRefund(Order order); 39 | 40 | boolean updateCancel(Order order); 41 | } 42 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/ShopService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.qhx.admin.domain.Shop; 5 | 6 | /** 7 | *

8 | * 后台用户 - 额外数据表(商家表) 9 | *

10 | * 11 | * @author qhx2004 12 | * @since 2024-03-10 13 | */ 14 | public interface ShopService extends IService { 15 | boolean createShop(Shop shop); 16 | 17 | boolean updateShop(Shop shop); 18 | 19 | Shop getShop(Long userId); 20 | 21 | boolean updateShopAvatar(Shop shop); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/UserRoleService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.extension.service.IService; 4 | import com.qhx.admin.domain.UserRole; 5 | 6 | /** 7 | *

8 | * 服务类 9 | *

10 | * 11 | * @author qhx2004 12 | * @since 2024-03-03 13 | */ 14 | public interface UserRoleService extends IService { 15 | 16 | boolean isAdmin(Long userId); 17 | 18 | boolean createUserRole(Long userId, Integer role_farmer); 19 | } 20 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/impl/MessageServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 4 | import com.qhx.admin.domain.Message; 5 | import com.qhx.admin.mapper.MessageMapper; 6 | import com.qhx.admin.model.to.message.MessDeleteTo; 7 | import com.qhx.admin.model.to.message.MessQueryTo; 8 | import com.qhx.admin.service.MessageService; 9 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 10 | import com.qhx.common.util.StringUtil; 11 | import org.springframework.stereotype.Service; 12 | 13 | import java.time.LocalDateTime; 14 | import java.util.List; 15 | 16 | /** 17 | *

18 | * 服务实现类 19 | *

20 | * 21 | * @author qhx2004 22 | * @since 2024-03-11 23 | */ 24 | @Service 25 | public class MessageServiceImpl extends ServiceImpl implements MessageService { 26 | 27 | @Override 28 | public List getAllMes(MessQueryTo messQueryTo) 29 | { 30 | String content = messQueryTo.getContent(); 31 | LocalDateTime beginTime = messQueryTo.getBeginTime(); 32 | LocalDateTime endTime = messQueryTo.getEndTime(); 33 | 34 | LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() 35 | .like(StringUtil.isNotEmpty(content), Message::getContent, content) 36 | .ge(StringUtil.isNotEmpty(beginTime), Message::getSenderTime, beginTime) 37 | .le(StringUtil.isNotEmpty(endTime), Message::getSenderTime, endTime); 38 | 39 | return this.list(queryWrapper); 40 | } 41 | 42 | @Override 43 | public boolean deleteMes(MessDeleteTo messDeleteTo) 44 | { 45 | List mesIds = messDeleteTo.getMesIds(); // 变相的减少连接 46 | if(StringUtil.isEmpty(mesIds) || mesIds.size() == 0){ 47 | return true; 48 | } 49 | LambdaQueryWrapper deleteWrapper = new LambdaQueryWrapper() 50 | .in(Message::getMessageId, messDeleteTo.getMesIds()); 51 | 52 | return this.remove(deleteWrapper); 53 | } 54 | 55 | @Override 56 | public boolean updateStatus(Message message) 57 | { 58 | LambdaQueryWrapper updateWrapper = new LambdaQueryWrapper() 59 | .eq(Message::getMessageId, message.getMessageId()); 60 | 61 | Message newMes = new Message(); 62 | newMes.setStatus( message.getStatus()); 63 | return this.update(newMes,updateWrapper); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/impl/ShopServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.qhx.admin.domain.Shop; 6 | import com.qhx.admin.mapper.ShopMapper; 7 | import com.qhx.admin.service.ShopService; 8 | import org.springframework.stereotype.Service; 9 | 10 | /** 11 | *

12 | * 服务实现类 13 | *

14 | * 15 | * @author qhx2004 16 | * @since 2024-03-10 17 | */ 18 | @Service 19 | public class ShopServiceImpl extends ServiceImpl implements ShopService { 20 | 21 | @Override 22 | public boolean createShop(Shop shop) 23 | { 24 | return this.save(shop); 25 | } 26 | 27 | @Override 28 | public boolean updateShop(Shop shop) 29 | { 30 | LambdaQueryWrapper updateWrapper = new LambdaQueryWrapper() 31 | .eq(Shop::getUserId, shop.getUserId()); 32 | return this.update(shop,updateWrapper); 33 | } 34 | 35 | @Override 36 | public Shop getShop(Long userId) 37 | { 38 | LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() 39 | .eq(Shop::getUserId, userId); 40 | 41 | return this.getOne(queryWrapper); 42 | } 43 | 44 | @Override 45 | public boolean updateShopAvatar(Shop shop) 46 | { 47 | LambdaQueryWrapper updateWrapper = new LambdaQueryWrapper() 48 | .eq(Shop::getUserId, shop.getUserId()); 49 | 50 | Shop newShop = new Shop(); 51 | newShop.setShopAvatar(shop.getShopAvatar()); 52 | 53 | return this.update(newShop,updateWrapper); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/service/impl/UserRoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service.impl; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 4 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 5 | import com.qhx.admin.domain.UserRole; 6 | import com.qhx.admin.mapper.UserRoleMapper; 7 | import com.qhx.admin.service.UserRoleService; 8 | import com.qhx.common.constant.Constant; 9 | import com.qhx.common.util.StringUtil; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Service; 12 | 13 | /** 14 | *

15 | * 服务实现类 16 | *

17 | * 18 | * @author qhx2004 19 | * @since 2024-03-03 20 | */ 21 | @Service 22 | public class UserRoleServiceImpl extends ServiceImpl implements UserRoleService { 23 | 24 | 25 | @Autowired 26 | private UserRoleMapper userRoleMapper; 27 | 28 | @Override 29 | public boolean isAdmin(Long userId) 30 | { 31 | LambdaQueryWrapper userRoleLambdaQueryWrapper = new LambdaQueryWrapper<>(); 32 | userRoleLambdaQueryWrapper.eq(UserRole::getUserId,userId); 33 | UserRole userRole = userRoleMapper.selectOne(userRoleLambdaQueryWrapper); 34 | 35 | return StringUtil.equals(userRole.getRoleId(), Constant.Role_Admin); 36 | } 37 | 38 | @Override 39 | public boolean createUserRole(Long userId, Integer roleId) 40 | { 41 | UserRole userRole = new UserRole(userId, roleId); 42 | int end = userRoleMapper.insert(userRole); 43 | return end > 0; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /back-me/admin/src/main/java/com/qhx/admin/test/HelloWorldService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.test; 2 | 3 | 4 | import com.qhx.admin.config.fisco.service.ContractService; 5 | import org.fisco.bcos.sdk.client.Client; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-03-22 20:46 12 | **/ 13 | 14 | @Service 15 | public class HelloWorldService extends ContractService 16 | { 17 | 18 | // 一开始加载地址 19 | private String ABI = "[{\"constant\":true,\"inputs\":[],\"name\":\"age\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getAge\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_age\",\"type\":\"uint256\"}],\"name\":\"setAge\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"; 20 | 21 | private String contractAddress = "0x172f6ad77e759705144f9ed1d6817275bc4bced8"; 22 | 23 | private String BIN = "608060405234801561001057600080fd5b5061019c806100206000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063262a9dff1461005c578063967e6e6514610087578063d5dcf127146100b2575b600080fd5b34801561006857600080fd5b506100716100df565b6040518082815260200191505060405180910390f35b34801561009357600080fd5b5061009c6100e5565b6040518082815260200191505060405180910390f35b3480156100be57600080fd5b506100dd600480360381019080803590602001909291905050506100ee565b005b60005481565b60008054905090565b600a81111515610166576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f616765206973206d757374206265203e2031300000000000000000000000000081525060200191505060405180910390fd5b80600081905550505600a165627a7a72305820acdcc78cd997e0bb157107011ce344823efd6f695e51d4e01480b1eaa35d628d0029"; 24 | 25 | @Autowired 26 | public HelloWorldService(Client client){ 27 | super.client(client); 28 | super.initConfig(ABI,BIN,contractAddress); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/application-redis.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | # redis 配置 3 | redis: 4 | # 地址 5 | host: 192.168.233.131 6 | # 端口,默认为6379 7 | port: 6379 8 | # 数据库索引 9 | database: 0 10 | # 密码 11 | password: 12 | # 连接超时时间 13 | timeout: 10s 14 | lettuce: 15 | pool: 16 | # 连接池中的最小空闲连接 17 | min-idle: 0 18 | # 连接池中的最大空闲连接 19 | max-idle: 8 20 | # 连接池的最大数据库连接数 21 | max-active: 8 22 | # #连接池最大阻塞等待时间(使用负值表示没有限制) 23 | max-wait: -1ms 24 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/conf/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBvTCCAWSgAwIBAgIUe5Dq+UN79J8FcPLUCsvb0RctSS0wCgYIKoZIzj0EAwIw 3 | NTEOMAwGA1UEAwwFY2hhaW4xEzARBgNVBAoMCmZpc2NvLWJjb3MxDjAMBgNVBAsM 4 | BWNoYWluMCAXDTIzMTIwNDA2NDMxNloYDzIxMjMxMTEwMDY0MzE2WjA1MQ4wDAYD 5 | VQQDDAVjaGFpbjETMBEGA1UECgwKZmlzY28tYmNvczEOMAwGA1UECwwFY2hhaW4w 6 | VjAQBgcqhkjOPQIBBgUrgQQACgNCAAQteBjP4iIy7d5xNwW1GCAAi5bKVoydrSjj 7 | zCKjXXoCVZ5AtDJkbPVcZAVjsDHsB5vCdwpO7U+dcqQPGbEeImnEo1MwUTAdBgNV 8 | HQ4EFgQUgdJZ+PurR4/WRE8AZMQS8NpBIEMwHwYDVR0jBBgwFoAUgdJZ+PurR4/W 9 | RE8AZMQS8NpBIEMwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiA9 10 | VuTIuxFI0Z3cu1sHo6k+uRoG8DTg7HtvhRfo2Wg1egIgfMtC4I7InDjCCZg389HH 11 | 5kVvaOwBDaedDrr3tBhDikA= 12 | -----END CERTIFICATE----- 13 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/conf/sdk.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIBgzCCASmgAwIBAgIUWSelVr59R4Bw2nanXt1aayhqLCswCgYIKoZIzj0EAwIw 3 | NzEPMA0GA1UEAwwGYWdlbmN5MRMwEQYDVQQKDApmaXNjby1iY29zMQ8wDQYDVQQL 4 | DAZhZ2VuY3kwIBcNMjMxMjA0MDY0MzE2WhgPMjEyMzExMTAwNjQzMTZaMDExDDAK 5 | BgNVBAMMA3NkazETMBEGA1UECgwKZmlzY28tYmNvczEMMAoGA1UECwwDc2RrMFYw 6 | EAYHKoZIzj0CAQYFK4EEAAoDQgAE4tnW7Lyyju1twQPrJYtG+SZZ8ML06XCVQlmO 7 | wxeXJP8jFUTxBhH5nz64jz3fT/RSJpMOb5wTm0tso6BX3wPP6KMaMBgwCQYDVR0T 8 | BAIwADALBgNVHQ8EBAMCBeAwCgYIKoZIzj0EAwIDSAAwRQIgc3DZpg/mCnauO+V9 9 | MTuigUmoip7yrsgdzQ/xlpeZOp0CIQDwLmXdTXWWOLaWKFSpldKhEJ5qK5PFAHCB 10 | YO/EizFJZg== 11 | -----END CERTIFICATE----- 12 | -----BEGIN CERTIFICATE----- 13 | MIIBezCCASGgAwIBAgIUCGNvVIwZalLbnIAZ/hgImi8RKK0wCgYIKoZIzj0EAwIw 14 | NTEOMAwGA1UEAwwFY2hhaW4xEzARBgNVBAoMCmZpc2NvLWJjb3MxDjAMBgNVBAsM 15 | BWNoYWluMB4XDTIzMTIwNDA2NDMxNloXDTMzMTIwMTA2NDMxNlowNzEPMA0GA1UE 16 | AwwGYWdlbmN5MRMwEQYDVQQKDApmaXNjby1iY29zMQ8wDQYDVQQLDAZhZ2VuY3kw 17 | VjAQBgcqhkjOPQIBBgUrgQQACgNCAATYNEiWjAmH7MFQNBjVX3pVbAGNnAZ2pn39 18 | wfToxN08Ri6qNVsLrSdkPr1U7Z9wkrRP7MjwoHgS+I14owiNZHgDoxAwDjAMBgNV 19 | HRMEBTADAQH/MAoGCCqGSM49BAMCA0gAMEUCIHY0kdzXI4o52rSv7Dl6Z6FBudfO 20 | zpKfo/xVvBPM40oeAiEAuj2EfpVfWb+lm5o2VTykI/5oPaM/tJxRX35h9L3rnW8= 21 | -----END CERTIFICATE----- 22 | -----BEGIN CERTIFICATE----- 23 | MIIBvTCCAWSgAwIBAgIUe5Dq+UN79J8FcPLUCsvb0RctSS0wCgYIKoZIzj0EAwIw 24 | NTEOMAwGA1UEAwwFY2hhaW4xEzARBgNVBAoMCmZpc2NvLWJjb3MxDjAMBgNVBAsM 25 | BWNoYWluMCAXDTIzMTIwNDA2NDMxNloYDzIxMjMxMTEwMDY0MzE2WjA1MQ4wDAYD 26 | VQQDDAVjaGFpbjETMBEGA1UECgwKZmlzY28tYmNvczEOMAwGA1UECwwFY2hhaW4w 27 | VjAQBgcqhkjOPQIBBgUrgQQACgNCAAQteBjP4iIy7d5xNwW1GCAAi5bKVoydrSjj 28 | zCKjXXoCVZ5AtDJkbPVcZAVjsDHsB5vCdwpO7U+dcqQPGbEeImnEo1MwUTAdBgNV 29 | HQ4EFgQUgdJZ+PurR4/WRE8AZMQS8NpBIEMwHwYDVR0jBBgwFoAUgdJZ+PurR4/W 30 | RE8AZMQS8NpBIEMwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAgNHADBEAiA9 31 | VuTIuxFI0Z3cu1sHo6k+uRoG8DTg7HtvhRfo2Wg1egIgfMtC4I7InDjCCZg389HH 32 | 5kVvaOwBDaedDrr3tBhDikA= 33 | -----END CERTIFICATE----- 34 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/conf/sdk.key: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgOieuhKo81RmTgxlh52HO 3 | aASLbrrLPd2GtbaNkmLOYWuhRANCAATi2dbsvLKO7W3BA+sli0b5JlnwwvTpcJVC 4 | WY7DF5ck/yMVRPEGEfmfPriPPd9P9FImkw5vnBObS2yjoFffA8/o 5 | -----END PRIVATE KEY----- 6 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/BackUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/CategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/FrontUserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/GoodsCategoryMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/GoodsImgMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/GoodsMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 36 | 37 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/MessageMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/OrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/RoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 12 | 13 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/ShopMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/admin/src/main/resources/mapper/UserRoleMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/controller/CacheControllerTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.controller; 2 | 3 | import com.qhx.admin.controller.monitor.CacheController; 4 | import com.qhx.common.model.AjaxResult; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-03-29 19:06 12 | **/ 13 | 14 | @SpringBootTest 15 | public class CacheControllerTest 16 | { 17 | @Autowired 18 | private CacheController cacheController; 19 | 20 | @Test 21 | public void test() throws Exception 22 | { 23 | AjaxResult info = cacheController.getInfo(); 24 | System.out.println(12); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/service/AliYunSdkTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.aliyun.oss.OSS; 4 | import com.aliyun.oss.OSSClient; 5 | import com.aliyun.oss.OSSClientBuilder; 6 | import com.aliyun.oss.OSSException; 7 | import com.aliyun.oss.common.auth.*; 8 | import com.aliyun.oss.internal.OSSHeaders; 9 | import com.aliyun.oss.model.*; 10 | import com.aliyuncs.exceptions.ClientException; 11 | import com.qhx.common.util.OSSUtil; 12 | import org.junit.jupiter.api.Test; 13 | import org.springframework.boot.test.context.SpringBootTest; 14 | 15 | import java.io.*; 16 | 17 | /** 18 | * @author: jzm 19 | * @date: 2024-03-06 20:12 20 | **/ 21 | 22 | @SpringBootTest 23 | public class AliYunSdkTest 24 | { 25 | 26 | @Test 27 | public void test() throws ClientException 28 | { 29 | OSS oss = OSSUtil.getOssClient(); 30 | String filePath = OSSUtil.uploadFile(oss, "img/qhx.png", new File("C:\\Users\\qhx20\\Pictures\\Sc" + 31 | "reenshots\\屏幕截图 2023-06-26 110841.png")); 32 | 33 | String url = "https://jzm2004.oss-cn-zhangjiakou.aliyuncs.com/img/test.png"; 34 | OSSUtil.deleteObject(oss,url); 35 | System.out.println(12); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/service/BackUserServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import cn.hutool.core.bean.BeanUtil; 4 | import com.qhx.admin.domain.BackUser; 5 | import com.qhx.admin.domain.Menu; 6 | import com.qhx.admin.model.to.backUser.BackUserDeleteTo; 7 | import com.qhx.admin.model.vo.MenuVo; 8 | import com.qhx.common.model.AjaxResult; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.Objects; 16 | 17 | /** 18 | * @author: jzm 19 | * @date: 2024-03-02 10:06 20 | **/ 21 | 22 | @SpringBootTest 23 | public class BackUserServiceTest 24 | { 25 | @Autowired 26 | private BackUserService backUserService; 27 | 28 | 29 | @Test 30 | void getAllMenu() 31 | { 32 | List paths = backUserService.getMenuByUserId(1L); 33 | List menuVos = BeanUtil.copyToList(paths, MenuVo.class); 34 | List rootMenuVos = new ArrayList<>(); 35 | // 找到根菜单 36 | for (MenuVo menuVo : menuVos) 37 | { 38 | if(menuVo.getRootId() == -1) 39 | { 40 | rootMenuVos.add(menuVo); 41 | } 42 | } 43 | // 将子菜单放到根菜单 44 | for (MenuVo rMenuVo : rootMenuVos) 45 | { 46 | for (MenuVo menuVo : menuVos) 47 | { 48 | if(Objects.equals(rMenuVo.getMenuId(), menuVo.getRootId())) 49 | { 50 | if(rMenuVo.getChildren() == null) 51 | rMenuVo.setChildren(new ArrayList<>()); 52 | rMenuVo.getChildren().add(menuVo); 53 | } 54 | } 55 | } 56 | 57 | System.out.println( rootMenuVos); 58 | } 59 | 60 | @Test 61 | void createBackUser() 62 | { 63 | } 64 | 65 | @Test 66 | void deleteBackUser() 67 | { 68 | List ids = new ArrayList<>(); 69 | ids.add(1L); 70 | BackUserDeleteTo backUserDeleteTo = new BackUserDeleteTo(); 71 | backUserDeleteTo.setUserIds(ids); 72 | System.out.println(12); 73 | 74 | } 75 | 76 | @Test 77 | void getAllBackUser() 78 | { 79 | } 80 | 81 | @Test 82 | void updateBackUser() 83 | { 84 | } 85 | 86 | @Test 87 | void getBackUserByUserId() 88 | { 89 | } 90 | 91 | @Test 92 | void updateFarmerStatus() 93 | { 94 | } 95 | 96 | @Test 97 | void updateBackUserPassword() 98 | { 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/service/GoodsServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.qhx.admin.controller.system.GoodsController; 4 | import com.qhx.admin.domain.Goods; 5 | import com.qhx.admin.mapper.GoodsMapper; 6 | import com.qhx.admin.model.to.goods.GoodsQueryTo; 7 | import com.qhx.common.model.PageResult; 8 | import org.junit.jupiter.api.Test; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | 12 | import java.util.HashMap; 13 | import java.util.List; 14 | 15 | /** 16 | * @author: jzm 17 | * @date: 2024-03-26 14:32 18 | **/ 19 | 20 | @SpringBootTest 21 | public class GoodsServiceTest 22 | { 23 | @Autowired 24 | private GoodsMapper goodsMapper; 25 | 26 | @Test 27 | public void testGoodsService(){ 28 | GoodsQueryTo goodsQueryTo = new GoodsQueryTo(); 29 | //goodsQueryTo.setGoodsName("a"); 30 | HashMap map = new HashMap<>(); 31 | map.put("q",goodsQueryTo); 32 | map.put("userId",null); 33 | 34 | List goodsList = goodsMapper.selectAllGoods(map); 35 | System.out.println(12); 36 | } 37 | 38 | @Autowired 39 | private GoodsController goodsController; 40 | 41 | 42 | @Test 43 | public void testGetGoodsVos(){ 44 | GoodsQueryTo goodsQueryTo = new GoodsQueryTo(); 45 | goodsQueryTo.setPage(1); 46 | goodsQueryTo.setPageSize(10); 47 | PageResult all = goodsController.getAll(goodsQueryTo); 48 | System.out.println(12); 49 | 50 | //6e041ec4935948638ffdcd2927698590 51 | } 52 | 53 | @Test 54 | public void testCreateGoods(){ 55 | 56 | Goods goods = new Goods(); 57 | goods.setGoodsNum("6e041ec4935948638ffdcd2927698590"); 58 | try 59 | { 60 | // 夜约束绑定外键? 61 | int insert = goodsMapper.insert(goods); 62 | }catch (Exception e){ 63 | System.out.println(e); 64 | } 65 | //6e041ec4935948638ffdcd2927698590 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/service/LoginServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.qhx.admin.model.to.LoginTo; 4 | import com.qhx.common.model.AjaxResult; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-02-28 17:21 12 | **/ 13 | 14 | @SpringBootTest 15 | public class LoginServiceTest 16 | { 17 | 18 | @Autowired 19 | private BackUserService loginService; 20 | 21 | @Test 22 | public void login(){ 23 | LoginTo loginTo = new LoginTo(); 24 | loginTo.setPassword("123456"); 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/service/OrderServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.qhx.admin.domain.Order; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-29 21:03 11 | **/ 12 | @SpringBootTest 13 | public class OrderServiceTest 14 | { 15 | @Autowired 16 | private OrderService orderService; 17 | 18 | @Test 19 | public void updateOrderStatus(){ 20 | Order order = new Order(); 21 | order.setCancel("1"); 22 | order.setOrderId(2L); 23 | boolean updateOrder = orderService.updateCancel(order); 24 | System.out.println(12); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/service/RedisTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import cn.hutool.core.date.DateUtil; 4 | import com.qhx.common.util.redis.RedisCache; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-03-04 17:58 12 | **/ 13 | 14 | @SpringBootTest 15 | public class RedisTest 16 | { 17 | @Autowired 18 | private RedisCache redisCache; 19 | 20 | 21 | @Test 22 | public void test1(){ 23 | // 返回这个是s 24 | long expire = redisCache.getExpire("people:2"); 25 | 26 | System.out.println(12); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/service/ShopServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.service; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 4 | import com.qhx.admin.domain.Shop; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | 9 | /** 10 | * @author: jzm 11 | * @date: 2024-03-11 09:00 12 | **/ 13 | 14 | @SpringBootTest 15 | public class ShopServiceTest 16 | { 17 | @Autowired 18 | private ShopService shopService; 19 | 20 | @Test 21 | public void update(){ 22 | Shop shop = new Shop(); 23 | shop.setUserId(1L); 24 | shop.setShopName("qhx"); 25 | LambdaQueryWrapper updateWrapper = new LambdaQueryWrapper() 26 | .eq(Shop::getUserId, shop.getUserId()); 27 | 28 | shopService.update(shop,updateWrapper); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /back-me/admin/src/test/java/com/qhx/admin/util/NotEmptyUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.admin.util; 2 | 3 | import com.qhx.admin.model.to.goods.GoodsTo; 4 | import com.qhx.common.util.NotEmptyUtil; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-08 14:28 11 | **/ 12 | 13 | @SpringBootTest 14 | public class NotEmptyUtilTest 15 | { 16 | 17 | @Test 18 | public void test(){ 19 | 20 | GoodsTo goodsTo = new GoodsTo(); 21 | goodsTo.setGoodsName("qhx"); 22 | String result = NotEmptyUtil.checkEmptyFiled(goodsTo, GoodsTo.class); 23 | System.out.println(result); 24 | // 反射对象继承对象所有字段,只不过,我们私有字段,不通过反射拉取不到 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /back-me/client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | back-me 7 | com.qhx 8 | 1.0 9 | 10 | 11 | 4.0.0 12 | client 13 | 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-test 18 | 19 | 20 | 21 | com.qhx 22 | common 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-security 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/ClientApplication.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 6 | 7 | /** 8 | * 客户端加载类 9 | * 10 | * @author: jzm 11 | * @date: 2024-02-26 20:43 12 | **/ 13 | 14 | @SpringBootApplication(exclude = DataSourceAutoConfiguration.class, 15 | scanBasePackages = {"com.qhx.common","com.qhx.client"}) 16 | public class ClientApplication 17 | { 18 | public static void main(String[] args) 19 | { 20 | SpringApplication.run(ClientApplication.class, args); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/config/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.config; 2 | 3 | import com.qhx.client.interceptor.TokenInterceptor; 4 | import com.qhx.common.constant.UserConstant; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.http.CacheControl; 8 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 9 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 10 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 11 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 12 | 13 | import java.util.concurrent.TimeUnit; 14 | 15 | /** 16 | * @author: jzm 17 | * @date: 2024-03-17 11:20 18 | **/ 19 | 20 | @Configuration 21 | public class AppConfig implements WebMvcConfigurer 22 | { 23 | 24 | @Autowired 25 | private TokenInterceptor tokenInterceptor; 26 | 27 | 28 | @Override 29 | public void addResourceHandlers(ResourceHandlerRegistry registry) 30 | { 31 | /** swagger配置 */ 32 | registry.addResourceHandler("/swagger-ui/**") 33 | .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") 34 | .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic()); 35 | } 36 | 37 | @Override 38 | public void addInterceptors(InterceptorRegistry registry) 39 | { 40 | registry.addInterceptor(tokenInterceptor) 41 | .excludePathPatterns(UserConstant.ExclusionList); 42 | } 43 | 44 | @Override 45 | public void addCorsMappings(CorsRegistry registry) { 46 | // 设置允许跨域的路径 47 | registry.addMapping("/**") 48 | // 设置允许跨域请求的域名 49 | .allowedOriginPatterns("*") 50 | // 是否允许cookie 51 | .allowCredentials(true) 52 | // 设置允许的请求方式 53 | .allowedMethods("*") 54 | // 设置允许的header属性 55 | .allowedHeaders("*") 56 | // 跨域允许时间 57 | .maxAge(3600); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.config; 2 | 3 | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; 4 | import com.qhx.client.context.LoginUserContext; 5 | import com.qhx.client.domain.FrontUser; 6 | import com.qhx.common.util.StringUtil; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.apache.ibatis.reflection.MetaObject; 9 | import org.springframework.stereotype.Component; 10 | 11 | import java.time.LocalDateTime; 12 | 13 | @Slf4j 14 | @Component 15 | // 插入: 首先可以确定的,mybatis-plus是可以对插入操作可以对设置默认值,(插入为null时自动忽略的。) 16 | // 更新: 目前情况看,更新时,也是只更新非null字段。 17 | public class MybatisPlusConfig implements MetaObjectHandler 18 | { 19 | 20 | 21 | @Override 22 | public void insertFill(MetaObject metaObject) { 23 | log.info("start insert fill ...."); 24 | this.strictInsertFill(metaObject, "createTime", () -> LocalDateTime.now(), LocalDateTime.class); 25 | FrontUser user = LoginUserContext.getUser(); 26 | if(StringUtil.isNotEmpty(user)){ 27 | this.strictInsertFill(metaObject, "createId", () -> user.getUserId(), Long.class); 28 | } 29 | } 30 | 31 | @Override 32 | public void updateFill(MetaObject metaObject) { 33 | log.info("start update fill ...."); 34 | this.strictUpdateFill(metaObject,"updateTime",() -> LocalDateTime.now(), LocalDateTime.class); 35 | FrontUser user = LoginUserContext.getUser(); 36 | if(StringUtil.isNotEmpty(user)) 37 | { 38 | this.strictUpdateFill(metaObject,"updateId",() -> LoginUserContext.getUser().getUserId(), Long.class); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/context/LoginUserContext.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.context; 2 | 3 | import com.qhx.client.domain.FrontUser; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-03-17 11:40 8 | **/ 9 | 10 | public class LoginUserContext 11 | { 12 | private static ThreadLocal local = new ThreadLocal<>(); 13 | 14 | public static void setUser(FrontUser user) 15 | { 16 | local.set(user); 17 | } 18 | 19 | public static FrontUser getUser() 20 | { 21 | return local.get(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/domain/BackUser.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import com.qhx.common.domain.User; 5 | import io.swagger.annotations.ApiModel; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | *

11 | * 用户信息表 12 | *

13 | * 14 | * @author qhx2004 15 | * @since 2024-02-27 16 | */ 17 | @Getter 18 | @Setter 19 | @TableName("ap_back_user") 20 | @ApiModel(value = "BackUser对象", description = "用户信息表") 21 | public class BackUser extends User 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/domain/FrontUser.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import com.qhx.common.domain.User; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | /** 11 | *

12 | * 用户信息表 13 | *

14 | * 15 | * @author qhx2004 16 | * @since 2024-03-07 17 | */ 18 | @Getter 19 | @Setter 20 | @TableName("ap_front_user") 21 | @ApiModel(value = "FrontUser对象", description = "用户信息表") 22 | public class FrontUser extends User{ 23 | 24 | @ApiModelProperty("邀请码") 25 | private String invitationCode; 26 | } 27 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/interceptor/TokenInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.interceptor; 2 | 3 | import cn.hutool.json.JSONUtil; 4 | import com.qhx.client.context.LoginUserContext; 5 | import com.qhx.client.domain.FrontUser; 6 | import com.qhx.common.constant.CacheConstant; 7 | import com.qhx.common.constant.Constant; 8 | import com.qhx.common.constant.HeaderConstant; 9 | import com.qhx.common.constant.HttpStatus; 10 | import com.qhx.common.util.ServletUtil; 11 | import com.qhx.common.util.StringUtil; 12 | import com.qhx.common.util.TokenUtil; 13 | import com.qhx.common.util.redis.RedisCache; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Component; 16 | import org.springframework.web.servlet.HandlerInterceptor; 17 | 18 | import javax.servlet.http.HttpServletRequest; 19 | import javax.servlet.http.HttpServletResponse; 20 | 21 | /** 22 | * @author: jzm 23 | * @date: 2024-03-17 11:25 24 | **/ 25 | 26 | @Component 27 | public class TokenInterceptor implements HandlerInterceptor 28 | { 29 | @Autowired 30 | private RedisCache redisCache; 31 | 32 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) 33 | throws Exception { 34 | String authorization = request.getHeader(HeaderConstant.AUTHORIZATION); 35 | // 这个跟后台不一样,后台为空,证明没登录,后台一点不让看,这个是允许访问的 36 | if(StringUtil.isNotEmpty(authorization)) 37 | { 38 | if(!authorization.startsWith(Constant.TOKEN_PREFIX)){ 39 | ServletUtil.renderString(response, JSONUtil.toJsonStr(HttpStatus.USER_TOKEN_ILLICIT)); 40 | return false; 41 | } 42 | String token = authorization.substring(Constant.TOKEN_PREFIX.length()); 43 | String userId = TokenUtil.parseTokenGetUserId(token); 44 | FrontUser user = redisCache.getCacheObject(CacheConstant.LOGIN_FRONT_USER_KEY + userId); 45 | if(StringUtil.isEmpty(user)) // 校验登录过期 46 | { 47 | ServletUtil.renderString(response,JSONUtil.toJsonStr(HttpStatus.USER_LOGIN_EXPIRED)); 48 | return false; 49 | } 50 | // 缓存FrontUser 51 | LoginUserContext.setUser(user); 52 | } 53 | return true; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/mapper/BackUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.qhx.client.domain.BackUser; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | /** 8 | *

9 | * 用户信息表 Mapper 接口 10 | *

11 | * 12 | * @author qhx2004 13 | * @since 2024-02-27 14 | */ 15 | @Mapper 16 | public interface BackUserMapper extends BaseMapper { 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/mapper/FrontUserMapper.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.qhx.client.domain.FrontUser; 5 | import org.apache.ibatis.annotations.Mapper; 6 | 7 | @Mapper 8 | public interface FrontUserMapper extends BaseMapper 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/model/to/LoginTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.model.to; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-02-28 17:50 8 | **/ 9 | 10 | @Data 11 | public class LoginTo 12 | { 13 | private String phone; 14 | private String password; 15 | } 16 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/model/to/RegisterTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.model.to; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-03-17 10:06 8 | **/ 9 | 10 | @Data 11 | public class RegisterTo 12 | { 13 | private String phone; 14 | private String password; 15 | private String username; 16 | private String invitationCode; // 邀请码 17 | } 18 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/model/to/frontUser/InviCodeTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.model.to.frontUser; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | /** 7 | * 邀请码to 8 | * 9 | * @author: jzm 10 | * @date: 2024-03-10 22:03 11 | **/ 12 | 13 | @Data 14 | public class InviCodeTo 15 | { 16 | @ApiModelProperty("邀请码") 17 | private String invitationCode; 18 | } 19 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/service/FrontUserService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.service; 2 | 3 | import com.baomidou.mybatisplus.core.toolkit.support.SFunction; 4 | import com.baomidou.mybatisplus.extension.service.IService; 5 | import com.qhx.client.domain.BackUser; 6 | import com.qhx.client.domain.FrontUser; 7 | import com.qhx.client.model.to.LoginTo; 8 | import com.qhx.client.model.to.RegisterTo; 9 | 10 | public interface FrontUserService extends IService 11 | { 12 | FrontUser login(LoginTo loginTo); 13 | 14 | boolean checkPasswordUnique(String password); 15 | 16 | boolean checkPhoneUnique(String phone); 17 | 18 | boolean checkEmailUnique(String email); 19 | 20 | FrontUser getFrontUserByField(SFunction colum, Object val); 21 | 22 | boolean createFrontUser(RegisterTo registerTo); 23 | 24 | boolean createFrontUser(FrontUser frontUser); 25 | 26 | BackUser isBindBackUser(String md5Pass); 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/service/LoginService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.service; 2 | 3 | /** 4 | * @author: jzm 5 | * @date: 2024-03-17 09:18 6 | **/ 7 | 8 | public interface LoginService 9 | { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /back-me/client/src/main/java/com/qhx/client/service/impl/LoginServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.service.impl; 2 | 3 | import com.qhx.client.service.LoginService; 4 | import org.springframework.stereotype.Service; 5 | 6 | /** 7 | * @author: jzm 8 | * @date: 2024-03-17 09:26 9 | **/ 10 | 11 | @Service 12 | public class LoginServiceImpl implements LoginService 13 | { 14 | } 15 | -------------------------------------------------------------------------------- /back-me/client/src/main/resources/application-redis.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | # redis 配置 3 | redis: 4 | # 地址 5 | host: 192.168.233.131 6 | # 端口,默认为6379 7 | port: 6379 8 | # 数据库索引 9 | database: 1 10 | # 密码 11 | password: 12 | # 连接超时时间 13 | timeout: 10s 14 | lettuce: 15 | pool: 16 | # 连接池中的最小空闲连接 17 | min-idle: 0 18 | # 连接池中的最大空闲连接 19 | max-idle: 8 20 | # 连接池的最大数据库连接数 21 | max-active: 8 22 | # #连接池最大阻塞等待时间(使用负值表示没有限制) 23 | max-wait: -1ms 24 | -------------------------------------------------------------------------------- /back-me/client/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8111 3 | 4 | spring: 5 | 6 | profiles: 7 | active: druid,redis 8 | # swagger(路径) 配置 9 | mvc: 10 | pathmatch: 11 | matching-strategy: ant_path_matcher 12 | 13 | 14 | 15 | # mybatis-plus 我严重怀疑,mybatis-plus默认就是以下作为逻辑删除字段 16 | mybatis-plus: 17 | global-config: 18 | db-config: 19 | logic-delete-field: deFlag # 全局逻辑删除的实体字段名 20 | logic-delete-value: "1" # 逻辑已删除值 21 | logic-not-delete-value: "0" # 逻辑未删除值 22 | 23 | 24 | -------------------------------------------------------------------------------- /back-me/client/src/test/java/com/qhx/client/service/BackUserServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.qhx.client.service; 2 | 3 | import cn.hutool.crypto.digest.MD5; 4 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 5 | import com.qhx.client.domain.BackUser; 6 | import com.qhx.client.mapper.BackUserMapper; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author: jzm 15 | * @date: 2024-03-17 17:18 16 | **/ 17 | 18 | @SpringBootTest 19 | public class BackUserServiceTest 20 | { 21 | 22 | @Autowired 23 | private BackUserMapper backUserMapper; 24 | 25 | @Test 26 | public void getOneTest(){ 27 | LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() 28 | //.eq(BackUser::getPassword, "e10adc3949ba59abbe56e057f20f883e") 29 | .eq(BackUser::getUsername, "admin"); 30 | // 拿不出数据的原因 31 | BackUser backUser = backUserMapper.selectOne(queryWrapper); 32 | List backUsers = backUserMapper.selectList(null); 33 | System.out.println(backUsers.toString()); 34 | System.out.println(backUser); 35 | } 36 | 37 | @Test 38 | public void test(){ 39 | System.out.println(MD5.create().digestHex("qhx2009")); 40 | } 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/annotation/DataSource.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.annotation; 2 | 3 | 4 | 5 | import com.qhx.common.enums.DataSourceType; 6 | 7 | import java.lang.annotation.*; 8 | 9 | /** 10 | * 自定义多数据源切换注解 11 | * 12 | * 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准 13 | * 14 | * @author ruoyi 15 | */ 16 | @Target({ ElementType.METHOD, ElementType.TYPE }) 17 | @Retention(RetentionPolicy.RUNTIME) 18 | @Documented 19 | @Inherited 20 | public @interface DataSource 21 | { 22 | /** 23 | * 切换数据源名称 24 | */ 25 | DataSourceType value() default DataSourceType.MASTER; 26 | } 27 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/annotation/NotEmpty.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | *空字段校验注解 10 | */ 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ElementType.FIELD,ElementType.TYPE}) 13 | 14 | public @interface NotEmpty 15 | { 16 | // 必填: 就是不为null、"" 17 | boolean required() default true; 18 | String extra() default ""; 19 | } 20 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/aop/DataSourceAspect.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.aop; 2 | 3 | import com.qhx.common.annotation.DataSource; 4 | import com.qhx.common.config.datasource.DynamicDataSource; 5 | import com.qhx.common.enums.DataSourceType; 6 | import org.aspectj.lang.ProceedingJoinPoint; 7 | import org.aspectj.lang.annotation.Around; 8 | import org.aspectj.lang.annotation.Aspect; 9 | import org.aspectj.lang.annotation.Pointcut; 10 | import org.aspectj.lang.reflect.MethodSignature; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | import org.springframework.core.Ordered; 14 | import org.springframework.stereotype.Component; 15 | 16 | import java.lang.reflect.Method; 17 | 18 | /** 19 | * 多数据源,切面处理类 20 | * 21 | * @author jzm 22 | * @version V1.0.0 23 | */ 24 | @Aspect 25 | @Component 26 | public class DataSourceAspect implements Ordered { 27 | 28 | Logger log = LoggerFactory.getLogger(DataSourceAspect.class); 29 | 30 | @Pointcut("@annotation(com.qhx.common.annotation.DataSource)") 31 | public void dataSourcePointCut() { 32 | 33 | } 34 | 35 | @Around("dataSourcePointCut()") 36 | public Object around(ProceedingJoinPoint point) throws Throwable { 37 | 38 | MethodSignature signature = (MethodSignature) point.getSignature(); 39 | // 处理方法 40 | Method method = signature.getMethod(); 41 | // 处理类 42 | Class cls = method.getDeclaringClass(); 43 | DataSource clsDs = cls.getAnnotation(DataSource.class); 44 | 45 | DataSource meDs = method.getAnnotation(DataSource.class); 46 | 47 | // 处理设置数据源 48 | if (meDs == null ) { 49 | if(clsDs == null){ 50 | log.debug("set datasource is " + DataSourceType.MASTER); 51 | }else{ 52 | DynamicDataSource.setDataSource(clsDs.value().name()); 53 | log.debug("set datasource is" + clsDs.value().name()); 54 | } 55 | } else { 56 | DynamicDataSource.setDataSource(meDs.value().name()); 57 | log.debug("set datasource is " + meDs.value().name()); 58 | } 59 | 60 | try { 61 | return point.proceed(); 62 | } finally { 63 | DynamicDataSource.clearDataSource(); 64 | log.debug("clean datasource"); 65 | } 66 | } 67 | 68 | @Override 69 | public int getOrder() { 70 | return 1; 71 | } 72 | } 73 | 74 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/config/Swagger2Config.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import springfox.documentation.builders.ApiInfoBuilder; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.service.*; 9 | import springfox.documentation.spi.DocumentationType; 10 | import springfox.documentation.spi.service.contexts.SecurityContext; 11 | import springfox.documentation.spring.web.plugins.Docket; 12 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 13 | 14 | import java.util.Arrays; 15 | import java.util.List; 16 | 17 | @Configuration 18 | @EnableSwagger2 // 3.0版本加不加无所谓 19 | public class Swagger2Config { 20 | 21 | private boolean enabled = true; 22 | 23 | @Bean 24 | public Docket coreApiConfig(){ 25 | return new Docket(DocumentationType.SWAGGER_2) 26 | .apiInfo(adminApiInfo()) 27 | .groupName("group1") 28 | .enable(enabled) 29 | .securityContexts(Arrays.asList(securityContexts())) 30 | .securitySchemes(Arrays.asList(securitySchemes())) 31 | .select() 32 | // 指定要扫描的controller包 33 | .apis(RequestHandlerSelectors.basePackage("com.qhx.admin.controller")) 34 | .build(); 35 | } 36 | 37 | 38 | 39 | 40 | private ApiInfo adminApiInfo(){ 41 | return new ApiInfoBuilder() 42 | .title("农产品供销管理系统--api文档") 43 | .description("系统接口描述") 44 | .version("2.0") 45 | .contact(new Contact("郡主喵","https://blog.csdn.net/Qhx20040819","15069680202@163.com")) 46 | .build(); 47 | } 48 | 49 | //通过 securitySchemes 来配置全局参数,这里的配置是一个名为 Authorization 的请求头( 50 | //securityContexts 则用来配置有哪些请求需要携带 Token,这里我们配置了所有请求 51 | 52 | private SecurityScheme securitySchemes() { 53 | return new ApiKey("Authorization", "Authorization", "header"); 54 | } 55 | 56 | private SecurityContext securityContexts() { 57 | return SecurityContext.builder() 58 | .securityReferences(defaultAuth()) 59 | .forPaths(PathSelectors.any()) 60 | .build(); 61 | } 62 | 63 | private List defaultAuth() { 64 | AuthorizationScope authorizationScope = new AuthorizationScope("xxx", "描述信息"); 65 | AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; 66 | authorizationScopes[0] = authorizationScope; 67 | return Arrays.asList(new SecurityReference("Authorization", authorizationScopes)); 68 | } 69 | } -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/config/datasource/DynamicDataSource.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.config.datasource; 2 | 3 | import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; 4 | import javax.sql.DataSource; 5 | import java.util.Map; 6 | 7 | /** 8 | * 动态数据源 9 | * 10 | * @author jzm 11 | */ 12 | public class DynamicDataSource extends AbstractRoutingDataSource 13 | { 14 | public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) 15 | { 16 | super.setDefaultTargetDataSource(defaultTargetDataSource); 17 | super.setTargetDataSources(targetDataSources); 18 | super.afterPropertiesSet(); 19 | } 20 | 21 | 22 | /** 23 | * 获取当前线程正在用的数据源 24 | */ 25 | @Override 26 | protected Object determineCurrentLookupKey() 27 | { 28 | return DynamicDataSourceContextHolder.getDataSourceType(); 29 | } 30 | 31 | public static void setDataSource(String dataSource){ 32 | DynamicDataSourceContextHolder.setDataSourceType(dataSource); 33 | } 34 | 35 | public static void clearDataSource(){ 36 | DynamicDataSourceContextHolder.clearDataSourceType(); 37 | } 38 | } -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/config/datasource/DynamicDataSourceContextHolder.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.config.datasource; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | /** 7 | * 数据源切换处理 8 | * 9 | * @author jzm 10 | */ 11 | public class DynamicDataSourceContextHolder 12 | { 13 | public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class); 14 | 15 | /** 16 | * 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本, 17 | * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。 18 | */ 19 | private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); 20 | 21 | /** 22 | * 设置数据源的变量 23 | */ 24 | public static void setDataSourceType(String dsType) 25 | { 26 | log.info("切换到{}数据源", dsType); 27 | CONTEXT_HOLDER.set(dsType); 28 | } 29 | 30 | /** 31 | * 获得数据源的变量 32 | */ 33 | public static String getDataSourceType() 34 | { 35 | return CONTEXT_HOLDER.get(); 36 | } 37 | 38 | /** 39 | * 清空数据源变量 40 | */ 41 | public static void clearDataSourceType() 42 | { 43 | CONTEXT_HOLDER.remove(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/config/redis/FastJson2JsonRedisSerializer.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.config.redis; 2 | 3 | import com.alibaba.fastjson2.JSON; 4 | import com.alibaba.fastjson2.JSONReader; 5 | import com.alibaba.fastjson2.JSONWriter; 6 | import com.alibaba.fastjson2.filter.Filter; 7 | import com.qhx.common.constant.Constant; 8 | import org.springframework.data.redis.serializer.RedisSerializer; 9 | import org.springframework.data.redis.serializer.SerializationException; 10 | 11 | import java.nio.charset.Charset; 12 | 13 | /** 14 | * Redis使用FastJson序列化 15 | * 16 | * @author jzm 17 | */ 18 | public class FastJson2JsonRedisSerializer implements RedisSerializer 19 | { 20 | public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); 21 | 22 | static final Filter AUTO_TYPE_FILTER = JSONReader.autoTypeFilter(Constant.JSON_WHITELIST_STR); 23 | 24 | 25 | private Class clazz; 26 | 27 | public FastJson2JsonRedisSerializer(Class clazz) 28 | { 29 | super(); 30 | this.clazz = clazz; 31 | } 32 | 33 | @Override 34 | public byte[] serialize(T t) throws SerializationException 35 | { 36 | if (t == null) 37 | { 38 | return new byte[0]; 39 | } 40 | return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET); 41 | } 42 | 43 | @Override 44 | public T deserialize(byte[] bytes) throws SerializationException 45 | { 46 | if (bytes == null || bytes.length <= 0) 47 | { 48 | return null; 49 | } 50 | String str = new String(bytes, DEFAULT_CHARSET); 51 | 52 | return JSON.parseObject(str, clazz, AUTO_TYPE_FILTER); 53 | } 54 | } -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/constant/CacheConstant.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.constant; 2 | 3 | /** 4 | * 缓存的key 常量 5 | * 6 | * @author ruoyi 7 | */ 8 | public class CacheConstant 9 | { 10 | 11 | /** 12 | * 登录用户 redis key 13 | */ 14 | public static final String LOGIN_BACK_USER_KEY = "login_back_users:"; 15 | public static final String LOGIN_FRONT_USER_KEY = "login_front_users:"; 16 | 17 | /** 18 | * 验证码 redis key 19 | */ 20 | public static final String CAPTCHA_CODE_KEY = "captcha_codes:"; 21 | 22 | 23 | /** 24 | * 防重提交 redis key 25 | */ 26 | public static final String REPEAT_SUBMIT_KEY = "repeat_submit:"; 27 | 28 | /** 29 | * 限流 redis key 30 | */ 31 | public static final String RATE_LIMIT_KEY = "rate_limit:"; 32 | 33 | /** 34 | * 登录账户密码错误次数 redis key 35 | */ 36 | // 剩余次数 37 | public static final String PWD_ERR_REM_CNT_KEY = "pwd_err_rem_cnt:"; 38 | public static final String PWD_ERR_MAX_CNT_KEY = "pwd_err_max_cnt:"; 39 | } 40 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/constant/Constant.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.constant; 2 | 3 | 4 | /** 5 | * 常量 6 | * 7 | * @author: jzm 8 | * @date: 2024-02-26 21:40 9 | **/ 10 | 11 | public class Constant 12 | { 13 | 14 | 15 | /** 16 | * 响应成功、失败标识 17 | */ 18 | public static final int OK_CODE = 200; 19 | public static final int ERROR_CODE = 400; 20 | public static final int WARN_CODE = 300; 21 | public static final String OK_MES = "ok"; 22 | public static final String FAIL_MES = "fail"; 23 | 24 | public static String UTF_8 = "utf-8"; 25 | 26 | 27 | /** 28 | * 密码错误允许最大次数 29 | */ 30 | public static final Integer PWD_ERR_MAX_CNT = 5; 31 | 32 | /** 33 | * token自定义字段 34 | */ 35 | public static String USER_ID = "userId"; 36 | public static String PASSWORD = "password"; 37 | 38 | /** 39 | * 产品相关 40 | */ 41 | public static final int CATEGORY_NAME_MIN_LEN = 1; 42 | public static final int CATEGORY_NAME_MAX_LEN = 5; 43 | 44 | 45 | /** 46 | * 令牌前缀 47 | */ 48 | public static final String TOKEN_PREFIX = "Bearer"; 49 | 50 | 51 | /** 52 | * 前缀 53 | */ 54 | public static final String HTTPS_PREFIX = "https://"; 55 | 56 | public static final String HTTP_PREFIX = "http://"; 57 | 58 | public static int In_Code_Pre_Len = 6; // 就是随机的6位数字。 59 | 60 | 61 | 62 | 63 | /** 64 | * 自动识别json对象白名单配置(仅允许解析的包名,范围越小越安全) 65 | */ 66 | public static final String[] JSON_WHITELIST_STR = { "org.springframework", "com.qhx" }; 67 | 68 | // 角色id 69 | public static final Integer Role_Admin = 0; 70 | public static final Integer Role_Farmer = 1; 71 | // 订单状态: 待支付,未发货,已发货,已完成 72 | public static final String Order_UnPaid = "0"; 73 | public static final String Order_UnShipped = "1"; 74 | public static final String Order_Shipped = "2"; 75 | public static final String Order_Done = "3"; 76 | // 通用status判断 77 | public static final CharSequence Enable = "0"; 78 | public static final CharSequence Disable = "1"; 79 | // 商品默认图片:适用于,商品没上传图片,但是需要一张默认图片展示(插入这个) 80 | public static final CharSequence DefGoodsImg = "https://jzm2004.oss-cn-zhangjiakou.aliyuncs.com/img/goods/default.png"; 81 | } 82 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/constant/HeaderConstant.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.constant; 2 | 3 | /** 4 | * 请求头常量 5 | * 6 | * @author: jzm 7 | * @date: 2024-02-28 14:40 8 | **/ 9 | 10 | public class HeaderConstant 11 | { 12 | 13 | 14 | /** 15 | * 请求头 16 | */ 17 | public static final String CAPTCHA_KEY = "captcha-key"; 18 | public static final String CAPTCHA_VAL = "captcha-val"; 19 | public static final String AUTHORIZATION = "Authorization"; 20 | public static final String REMEMBER_PASS = "remember-pass";// 记住密码 21 | public static String XCliId = "X-Client-Id"; 22 | 23 | /** 24 | * 响应头 25 | */ 26 | public static final String REFRESH_TOKEN = "refresh-token"; 27 | 28 | } 29 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/constant/HttpStatus.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.constant; 2 | 3 | 4 | import com.qhx.common.model.AjaxResult; 5 | 6 | /** 7 | * http错误状态的常量 8 | * 9 | * @author: jzm 10 | * @date: 2024-02-27 08:44 11 | **/ 12 | 13 | public class HttpStatus extends AjaxResult 14 | { 15 | public static final HttpStatus PASSWORD_NOT_MATCH = new HttpStatus(401,"密码长度不匹配!"); 16 | public static final HttpStatus PASSWORD_RETRY_LIMIT_EXCEED(String blockedTime){ 17 | return new HttpStatus(403,"密码输入错误次数达到上限,剩余解禁时间:" + blockedTime); 18 | } 19 | public static final HttpStatus PASSWORD_REMAIN_INPUT_COUNT(int count) { 20 | return new HttpStatus(402,"密码输入错误,当前剩余输入当前次数:" + count); 21 | } 22 | 23 | // 密码重复提交最大次数 24 | public static final HttpStatus USERNAME_NOT_MATCH= new HttpStatus(404,"用户名长度不匹配!"); 25 | public static final HttpStatus USER_NOT_EXISTS= new HttpStatus(405,"用户不存在!"); 26 | public static final HttpStatus USER_DELETE= new HttpStatus(406,"用户已经注销!"); 27 | public static final HttpStatus CAPTCHA_CHECK_FAILED= new HttpStatus(407,"验证码错误!"); 28 | public static final HttpStatus CAPTCHA_EXPIRED= new HttpStatus(407,"验证码已经过期!"); 29 | public static final HttpStatus USER_BLOCKED= new HttpStatus(407,"用户已经被锁定!"); 30 | public static final HttpStatus USER_NOT_LOGIN= new HttpStatus(408, "用户没登录!"); 31 | public static final HttpStatus USER_LOGIN_EXPIRED= new HttpStatus(409, "用户登录过期,需要重新登录!"); 32 | public static final HttpStatus USER_TOKEN_ILLICIT= new HttpStatus(410,"用户令牌格式不对!" ); 33 | public static final HttpStatus PASSWORD_OR_PHONE_NOT_EMPTY= new HttpStatus(411, "用户密码和电话号是不能为空!"); 34 | public static final HttpStatus PHONE_NOT_MATCH= new HttpStatus(412, "电话输入格式不对!"); 35 | public static final HttpStatus USER_EXISTS= new HttpStatus(413, "用户已经存在!"); 36 | public static final HttpStatus PHONE_EXISTS= new HttpStatus(414,"该电话号已经绑定其他账户!" ); 37 | public static final HttpStatus EMAIL_NOT_MATCH= new HttpStatus(415, "邮箱格式不匹配!"); 38 | public static final HttpStatus EMAIL_EXISTS= new HttpStatus(416, "该邮箱已经绑定其他账户!"); 39 | public static final HttpStatus PASSWORD_OR_USERNAME_NOT_EMPTY= new HttpStatus(417, "用户名/密码不能为空"); 40 | public static final HttpStatus PASSWORD_EXISTS = new HttpStatus(418,"该密码已经绑定其他账户"); 41 | public static final HttpStatus REQ_HED_PAM_NOT_ENOUGH = new HttpStatus(419,"请求头部参数不全!"); 42 | public static final HttpStatus OFF_LIMIT_EXCEEDED = new HttpStatus(420,"用户离线超时,请重新登录!"); 43 | 44 | private HttpStatus(int code, String mes){ 45 | super(null,code,mes); 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/constant/UserConstant.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.constant; 2 | 3 | public class UserConstant 4 | { 5 | 6 | /** 用户状态 */ 7 | /** 启用 */ 8 | public static final String NORMAL = "0"; 9 | 10 | /** 禁用 */ 11 | public static final String EXCEPTION = "1"; 12 | 13 | 14 | 15 | /** 是否唯一的返回标识 */ 16 | public final static boolean UNIQUE = true; 17 | public final static boolean NOT_UNIQUE = false; 18 | 19 | /** 20 | * 用户名长度限制 21 | */ 22 | public static final int USERNAME_MIN_LENGTH = 2; 23 | public static final int USERNAME_MAX_LENGTH = 20; 24 | 25 | /** 26 | * 密码长度限制 27 | */ 28 | public static final int PASSWORD_MIN_LENGTH = 5; 29 | public static final int PASSWORD_MAX_LENGTH = 20; 30 | 31 | /** 32 | * 手机号码格式限制 33 | */ 34 | public static final String MOBILE_PHONE_NUMBER_PATTERN = "^0{0,1}(13[0-9]|15[0-9]|14[0-9]|18[0-9])[0-9]{8}$"; 35 | 36 | /** 37 | * 邮箱格式限制 38 | */ 39 | public static final String EMAIL_PATTERN = "^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?"; 40 | 41 | /** 42 | * 排除拦截列表 43 | */ 44 | public static final String[] ExclusionList = new String[]{ 45 | "/test","/login","/register","/get/captcha", 46 | "/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/v2/**","/*/api-docs", "/druid/**" 47 | }; 48 | 49 | public static final Integer LiveTime = 5; // 密码校验机制存活时间 50 | public static final Integer PwdBlockedTime = 10; // 密码输入错误锁定时间 51 | } 52 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/controller/BaseUploadController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.controller; 2 | 3 | import cn.hutool.core.io.FileUtil; 4 | import cn.hutool.core.util.IdUtil; 5 | import com.qhx.common.exception.system.SystemException; 6 | import com.qhx.common.model.AjaxResult; 7 | import com.qhx.common.util.StringUtil; 8 | import com.qhx.common.util.UploadFIleUtil; 9 | import lombok.extern.slf4j.Slf4j; 10 | import org.springframework.web.multipart.MultipartFile; 11 | 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | import java.util.ArrayList; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | 18 | /** 19 | * @author: jzm 20 | * @date: 2024-03-18 15:29 21 | **/ 22 | 23 | @Slf4j 24 | public class BaseUploadController 25 | { 26 | protected static final Long KB = 1024L; 27 | protected static final Long MAX_FILE_SIZE = 800 * KB; 28 | 29 | public AjaxResult uploadImg(String prefix, Long singleFileSize, String[] limitedTypes ,MultipartFile...files){ 30 | return uploadFile("imgUrls",prefix,singleFileSize,limitedTypes,files); 31 | } 32 | 33 | public AjaxResult uploadFile(String resField,String prefix, Long singleFileSize, String[] limitedTypes , MultipartFile... files) 34 | { 35 | List imgUrls = new ArrayList<>(); 36 | for (MultipartFile file : files) 37 | { 38 | // 获得输入输出流 39 | InputStream is ; 40 | try 41 | { 42 | is = file.getInputStream(); 43 | } catch (IOException e) 44 | { 45 | log.error("文件上传出现异常:",e.getMessage()); 46 | throw new SystemException("文件不存在"); 47 | } 48 | 49 | String type = FileUtil.extName(file.getOriginalFilename()); // 原始文件名获取文件类型 50 | if(!StringUtil.equalsAnyIgnoreCase(type,limitedTypes)){ 51 | return AjaxResult.error("文件上传只能是jpg、png格式"); 52 | } 53 | if( file.getSize() > singleFileSize) 54 | { 55 | return AjaxResult.error("文件大小必须为800 KB以内"); 56 | } 57 | String fileName = IdUtil.simpleUUID(); 58 | String imgUrl = UploadFIleUtil.uploadFile(prefix,fileName, type, is); 59 | if(StringUtil.isEmpty(imgUrl)) 60 | { 61 | throw new SystemException("文件上云失败!"); 62 | } 63 | imgUrls.add(imgUrl); 64 | } 65 | HashMap resMap = new HashMap<>(); 66 | resMap.put(resField,imgUrls); // 上传文件,返回图片列表。 67 | return AjaxResult.success(resMap); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/domain/BaseEntity.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.FieldFill; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableLogic; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | import java.time.LocalDateTime; 11 | 12 | @Data 13 | public abstract class BaseEntity implements Serializable 14 | { 15 | @ApiModelProperty("删除标志(0代表存在 1代表删除)") 16 | @TableLogic 17 | private String delFlag; 18 | 19 | @ApiModelProperty("状态") 20 | private String status; 21 | 22 | @ApiModelProperty("创建者") 23 | @TableField(fill = FieldFill.INSERT) 24 | private Long createBy; 25 | 26 | @ApiModelProperty("创建时间") 27 | @TableField(fill = FieldFill.INSERT) 28 | private LocalDateTime createTime; 29 | 30 | @ApiModelProperty("更新者") 31 | @TableField(fill = FieldFill.INSERT_UPDATE) 32 | private Long updateBy; 33 | 34 | @ApiModelProperty("更新时间") 35 | @TableField(fill = FieldFill.INSERT_UPDATE) 36 | private LocalDateTime updateTime; 37 | 38 | 39 | 40 | } 41 | 42 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/domain/User.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | 8 | import java.io.Serializable; 9 | import java.time.LocalDateTime; 10 | 11 | /** 12 | * @author: jzm 13 | * @date: 2024-03-07 14:46 14 | **/ 15 | 16 | @Data 17 | // 前台用户和后台实体公共字段实体 18 | public class User extends BaseEntity implements Serializable 19 | { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | @ApiModelProperty("用户ID") 24 | @TableId(value = "user_id", type = IdType.AUTO) 25 | private Long userId; 26 | 27 | private String nickname; 28 | 29 | @ApiModelProperty("用户昵称") 30 | private String username; 31 | 32 | @ApiModelProperty("用户邮箱") 33 | private String email; 34 | 35 | @ApiModelProperty("手机号码") 36 | private String phone; 37 | 38 | @ApiModelProperty("用户性别(0男 1女 2未知)") 39 | private String sex; 40 | 41 | @ApiModelProperty("头像路径") 42 | private String avatar; 43 | 44 | @ApiModelProperty("密码") 45 | private String password; 46 | 47 | @ApiModelProperty("帐号状态(0正常 1停用)") 48 | private String status; 49 | 50 | @ApiModelProperty("最后登录IP") 51 | private String loginIp; 52 | 53 | @ApiModelProperty("最后登录时间") 54 | private LocalDateTime loginDate; 55 | 56 | @ApiModelProperty("密码最后更新时间") 57 | private LocalDateTime pwdUpdateDate; 58 | 59 | @ApiModelProperty("备注") 60 | private String remark; 61 | 62 | } 63 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/enums/DataSourceType.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.enums; 2 | 3 | /** 4 | * 数据源 5 | * 6 | * @author ruoyi 7 | */ 8 | public enum DataSourceType 9 | { 10 | /** 11 | * 主库 12 | */ 13 | MASTER, 14 | 15 | /** 16 | * 从库 17 | */ 18 | SLAVE 19 | } 20 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/enums/UserStatus.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.enums; 2 | 3 | /** 4 | * 用户状态 5 | * 6 | * @author jzm 7 | */ 8 | public enum UserStatus 9 | { 10 | OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除"); 11 | 12 | private final String code; 13 | private final String info; 14 | 15 | UserStatus(String code, String info) 16 | { 17 | this.code = code; 18 | this.info = info; 19 | } 20 | 21 | public String getCode() 22 | { 23 | return code; 24 | } 25 | 26 | public String getInfo() 27 | { 28 | return info; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/exception/GlobalException.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.exception; 2 | 3 | import com.qhx.common.exception.base.BaseException; 4 | 5 | /** 6 | * 处理业务之外的异常 7 | * @author: jzm 8 | * @date: 2024-03-10 15:27 9 | **/ 10 | 11 | public class GlobalException extends BaseException 12 | { 13 | public GlobalException(String message, int code) 14 | { 15 | super(message, code); 16 | } 17 | 18 | public GlobalException(String message) 19 | { 20 | super(message); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/exception/PermissionException.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.exception; 2 | 3 | import com.qhx.common.exception.base.BaseException; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-03-07 20:34 8 | **/ 9 | 10 | public class PermissionException extends BaseException 11 | { 12 | public PermissionException(String message, int code) 13 | { 14 | super(message, code); 15 | } 16 | 17 | public PermissionException(String message) 18 | { 19 | super(message); 20 | } 21 | 22 | public PermissionException(){ 23 | this("操作者权限不足"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/exception/base/BaseException.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.exception.base; 2 | 3 | 4 | import lombok.Data; 5 | 6 | /** 7 | * 基础异常 8 | * 9 | * @author jzm 10 | */ 11 | @Data 12 | public class BaseException extends RuntimeException 13 | { 14 | private static final long serialVersionUID = 1L; 15 | 16 | private String mes; 17 | private int code; 18 | 19 | public BaseException(String message, int code){ 20 | super(message); 21 | this.mes = message; 22 | this.code = code; 23 | } 24 | 25 | public BaseException(String message){ 26 | super(message); 27 | this.mes = message; 28 | this.code = 400; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/exception/system/SystemException.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.exception.system; 2 | 3 | import com.qhx.common.exception.base.BaseException; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-03-07 08:44 8 | **/ 9 | 10 | public class SystemException extends BaseException 11 | { 12 | public SystemException(String message, int code) 13 | { 14 | super(message, code); 15 | } 16 | 17 | public SystemException(String message) 18 | { 19 | super(message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/handler/GlobalExceptionHandler.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.handler; 2 | 3 | import com.qhx.common.exception.base.BaseException; 4 | import com.qhx.common.model.AjaxResult; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.web.bind.annotation.ControllerAdvice; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | import org.springframework.web.multipart.MaxUploadSizeExceededException; 10 | 11 | /** 12 | * 全局异常处理器 13 | * 14 | * @author: jzm 15 | * @date: 2024-02-28 15:03 16 | **/ 17 | @ControllerAdvice 18 | @ResponseBody 19 | @Slf4j 20 | public class GlobalExceptionHandler 21 | { 22 | 23 | // 捕获基础异常 24 | @ExceptionHandler(BaseException.class) 25 | public AjaxResult handlerBaseException(BaseException ex){ 26 | return AjaxResult.error(ex.getCode(),ex.getMessage()); 27 | } 28 | 29 | 30 | @ExceptionHandler(MaxUploadSizeExceededException.class) 31 | public AjaxResult handlerLimitExceededException(MaxUploadSizeExceededException ex){ 32 | log.error("上传文件超过系统最大限制2MB!"); 33 | return AjaxResult.error("上传文件超过系统最大限制2MB!"); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/model/PageResult.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.model; 2 | 3 | import com.qhx.common.constant.Constant; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | /** 8 | * @author: jzm 9 | * @date: 2024-03-08 18:04 10 | **/ 11 | 12 | @Setter 13 | @Getter 14 | public class PageResult extends AjaxResult 15 | { 16 | private long total; 17 | 18 | protected PageResult(Object data, int code, String mes,long total) 19 | { 20 | super(data, code, mes); 21 | this.total = total; 22 | } 23 | 24 | private static PageResult common(Object data, int code, String mes,long total){ 25 | return new PageResult(data,code,mes,total); 26 | } 27 | public static PageResult success(Object data,long total){ 28 | return common(data, Constant.OK_CODE,Constant.OK_MES,total); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/model/to/BasePageTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.model.to; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * 分页基本to 8 | * 9 | * @author: jzm 10 | * @date: 2024-03-03 21:04 11 | **/ 12 | 13 | @Setter 14 | @Getter 15 | public abstract class BasePageTo 16 | { 17 | private int page; 18 | private int pageSize; 19 | } 20 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/model/to/LoginTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.model.to; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * 登录To 7 | * 8 | * @author: jzm 9 | * @date: 2024-02-27 09:22 10 | **/ 11 | 12 | @Data 13 | public class LoginTo 14 | { 15 | private String username; 16 | private String password; 17 | 18 | } 19 | 20 | 21 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/model/to/user/PassTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.model.to.user; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * 修改密码to 8 | * @author: jzm 9 | * @date: 2024-03-02 11:16 10 | **/ 11 | 12 | @Setter 13 | @Getter 14 | public class PassTo 15 | { 16 | private String oldPassword; 17 | private String newPassword; 18 | } 19 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/model/to/user/PasswordNotOldTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.model.to.user; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | /** 7 | * 重置密码:不需要用户输入旧密码 8 | * @author: jzm 9 | * @date: 2024-03-07 19:13 10 | **/ 11 | 12 | @Setter 13 | @Getter 14 | public class PasswordNotOldTo 15 | { 16 | String password; // MD5加密之后 17 | String newPassword; // 新密码 18 | } 19 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/model/to/user/UserDeleteTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.model.to.user; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * @author: jzm 10 | * @date: 2024-03-07 14:42 11 | **/ 12 | 13 | @Setter 14 | @Getter 15 | public class UserDeleteTo 16 | { 17 | private List userIds; 18 | } 19 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/model/to/user/UserQueryTo.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.model.to.user; 2 | 3 | import cn.hutool.core.date.DatePattern; 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import com.qhx.common.model.to.BasePageTo; 6 | import lombok.Data; 7 | 8 | import java.time.LocalDateTime; 9 | 10 | /** 11 | * @author: jzm 12 | * @date: 2024-03-07 14:28 13 | **/ 14 | 15 | @Data 16 | public class UserQueryTo extends BasePageTo 17 | { 18 | private String username; 19 | private String phone; 20 | private String status; 21 | private LocalDateTime beginTime; 22 | private LocalDateTime endTime; 23 | } 24 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/util/CommonUtil.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * @author: jzm 8 | * @date: 2024-03-18 15:02 9 | **/ 10 | 11 | public class CommonUtil 12 | { 13 | /** 14 | * 把list1对比list2不同的元素返回 15 | * 16 | * @param list1 17 | * @param list2 18 | * @param 19 | * @return 20 | */ 21 | public static List findList1List2(List list1, List list2){ 22 | List resList = new ArrayList<>(); 23 | int l = list2.size(); 24 | loop : for (T item : list1) 25 | { 26 | 27 | for (int i = 0,j = l - 1 ; i < j; i++,j--) 28 | { 29 | if(StringUtil.equals(item.toString(),list2.get(i).toString())) 30 | { 31 | continue loop; 32 | } 33 | if(StringUtil.equals(item.toString(),list2.get(j).toString())) 34 | { 35 | continue loop; 36 | } 37 | 38 | } 39 | resList.add(item); 40 | } 41 | return resList; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/util/MessageUtil.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.util; 2 | 3 | import cn.hutool.extra.spring.SpringUtil; 4 | import org.springframework.context.MessageSource; 5 | import org.springframework.context.i18n.LocaleContextHolder; 6 | 7 | /** 8 | * 获取i18n资源文件 9 | * 10 | * @author jzm 11 | */ 12 | public class MessageUtil 13 | { 14 | /** 15 | * 根据消息键和参数 获取消息 委托给spring messageSource 16 | * 17 | * @param code 消息键 18 | * @param args 参数 19 | * @return 获取国际化翻译值 20 | */ 21 | public static String message(String code, Object... args) 22 | { 23 | MessageSource messageSource = SpringUtil.getBean(MessageSource.class); 24 | return messageSource.getMessage(code, args, LocaleContextHolder.getLocale()); 25 | } 26 | } -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/util/PageUtil.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.util; 2 | 3 | import com.github.pagehelper.ISelect; 4 | import com.github.pagehelper.Page; 5 | import com.github.pagehelper.PageHelper; 6 | import com.github.pagehelper.PageInfo; 7 | 8 | 9 | /** 10 | * 分页工具类 11 | */ 12 | public class PageUtil 13 | { 14 | private static Page _startPage(int pageNum, int pageSize, ISelect select, String orderBy) 15 | { 16 | clearPage(); 17 | Page page = PageHelper.startPage(pageNum, pageSize).doSelectPage(select); 18 | if (orderBy == null) 19 | { 20 | return page; 21 | } 22 | page.setOrderBy(orderBy); 23 | return page; 24 | } 25 | 26 | /** 27 | * 分页 28 | * 29 | * page 起始页 30 | * pageSize 页大小 31 | * 32 | * @param select : () -> userMapper.list() 33 | */ 34 | public static PageInfo startPage(int pageNum, int pageSize, ISelect select) 35 | { 36 | return new PageInfo<>(_startPage(pageNum, pageSize, select, null)); 37 | } 38 | 39 | /** 40 | * 降序 + 分页 41 | */ 42 | public static PageInfo orderByDesc(int pageNum, int pageSize, String filed, ISelect select) 43 | { 44 | return new PageInfo<>(_startPage(pageNum, pageSize, select, filed + " desc")); 45 | } 46 | 47 | 48 | /** 49 | * 升序 + 分页 50 | */ 51 | public static PageInfo orderByAsc(int pageNum, int pageSize, String filed, ISelect select) 52 | { 53 | return new PageInfo<>(_startPage(pageNum, pageSize, select, filed + " asc")); 54 | } 55 | 56 | /** 57 | * 清理分页的线程变量(清除分页数据) 58 | */ 59 | public static void clearPage() 60 | { 61 | PageHelper.clearPage(); 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/util/StringUtil.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.util; 2 | 3 | import cn.hutool.core.util.StrUtil; 4 | 5 | import java.util.Objects; 6 | 7 | /** 8 | * String 工具类 9 | * 10 | * @author: jzm 11 | * @date: 2024-01-08 19:44 12 | **/ 13 | 14 | public class StringUtil extends StrUtil 15 | { 16 | 17 | public static boolean equals(Object a,Object b){ 18 | return Objects.equals(a, b) || StringUtil.equals(a.toString(),b.toString()); 19 | } 20 | 21 | /** 22 | * 是空字符串? 23 | * 24 | * @param str 25 | * @return true:为空 false:非空 26 | */ 27 | public static boolean isEmpty(CharSequence str) 28 | { 29 | if (StrUtil.isEmpty(str)) 30 | { 31 | return true; 32 | } 33 | if (str instanceof String) 34 | { 35 | if (((String) str).trim().equals("")) 36 | { 37 | return true; 38 | } 39 | } 40 | return false; 41 | } 42 | 43 | /** 44 | * 是空? 45 | * 46 | * @param obj 对象 47 | * @return true:为空 false:非空 48 | */ 49 | public static boolean isEmpty(Object obj) 50 | { 51 | return obj == null; 52 | } 53 | 54 | /** 55 | * 不是空? 56 | * 57 | * @param str 58 | * @return true:非空 false:为空 59 | */ 60 | public static boolean isNotEmpty(CharSequence str) 61 | { 62 | return !isEmpty(str); 63 | } 64 | 65 | public static boolean isNotEmpty(Object obj) 66 | { 67 | return !isEmpty(obj); 68 | } 69 | 70 | /** 71 | * 判断字符串列表是否包含被包含字符串 72 | * 73 | * @param str 被包含字符串 74 | * @param strs 字符串列表 75 | * @return 包含返回true 76 | */ 77 | public static boolean inStringIgnoreCase(String str, String... strs) 78 | { 79 | if (str != null && strs != null) 80 | { 81 | for (String s : strs) 82 | { 83 | if (s.equalsIgnoreCase(str)) 84 | { 85 | return true; 86 | } 87 | } 88 | return false; 89 | } 90 | return false; 91 | } 92 | 93 | public static boolean isNull(Object obj) 94 | { 95 | return obj == null; 96 | } 97 | 98 | public static boolean isNotNull(Object obj) 99 | { 100 | return !isNull(obj); 101 | } 102 | 103 | 104 | 105 | 106 | } 107 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/util/UploadFIleUtil.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.util; 2 | 3 | import com.aliyun.oss.OSS; 4 | import com.qhx.common.exception.system.SystemException; 5 | import lombok.extern.slf4j.Slf4j; 6 | 7 | import java.io.File; 8 | import java.io.FileInputStream; 9 | import java.io.FileNotFoundException; 10 | import java.io.InputStream; 11 | 12 | /** 13 | * 上传阿里云文件工具类 14 | * 15 | * @author: jzm 16 | * @date: 2024-03-18 15:27 17 | **/ 18 | 19 | @Slf4j 20 | public class UploadFIleUtil 21 | { 22 | public static String uploadFile(String prefix, String fileName, String type, File file){ 23 | try 24 | { 25 | return uploadFile(prefix,fileName,type,new FileInputStream(file)); 26 | } catch (FileNotFoundException e) 27 | { 28 | log.error("文件上传出现异常:",e.getMessage()); 29 | throw new SystemException(e.getMessage()); 30 | } 31 | } 32 | 33 | // 上传文件 34 | public static String uploadFile(String prefix, String fileName, String type, InputStream is) 35 | { 36 | OSS client = OSSUtil.getOssClient(); 37 | String fileUrl = OSSUtil.uploadFile(client,prefix + getFilePath(fileName, type),is); 38 | return fileUrl; 39 | } 40 | 41 | 42 | /** 43 | * @param name 文件名 44 | * @param type 文件类型 45 | * @return 2004/8/18/123123123/qhx.png 46 | */ 47 | public static String getFilePath(String name,String type){ 48 | StringBuilder sb = new StringBuilder(); 49 | sb.append(getDatePath()); 50 | sb.append(name); 51 | sb.append("."); 52 | sb.append(type); 53 | return sb.toString(); 54 | } 55 | 56 | 57 | /** 58 | * @return 2004/8/18/ 59 | */ 60 | public static String getDatePath(){ 61 | StringBuilder sb = new StringBuilder(); 62 | sb.append(DateUtil.getYear()); 63 | sb.append("/"); 64 | sb.append(DateUtil.getMonth()); 65 | sb.append("/"); 66 | sb.append(DateUtil.getDay()); 67 | sb.append("/"); 68 | return sb.toString(); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/util/ip/AddressUtil.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.util.ip; 2 | 3 | import cn.hutool.core.net.Ipv4Util; 4 | import cn.hutool.http.Header; 5 | import cn.hutool.http.HttpRequest; 6 | import cn.hutool.http.HttpUtil; 7 | import cn.hutool.json.JSONObject; 8 | import cn.hutool.json.JSONUtil; 9 | import com.qhx.common.util.StringUtil; 10 | import lombok.extern.slf4j.Slf4j; 11 | 12 | /** 13 | * @author: jzm 14 | * @date: 2024-03-02 14:24 15 | **/ 16 | 17 | @Slf4j 18 | public class AddressUtil 19 | { 20 | public static final String IP_URL = "https://whois.pconline.com.cn/ipJson.jsp?json=true&ip="; 21 | // 未知地址 22 | public static final String UNKNOWN = "XX XX"; 23 | 24 | private static final String LOCAL_IP = "0:0:0:0:0:0:0:1"; 25 | 26 | 27 | /** 28 | * 通过IP获取真实ip地址 29 | * @param ip 30 | * @return 真实地址 31 | */ 32 | public static String getRealAddressByIP(String ip) 33 | { 34 | if(Ipv4Util.isInnerIP(ip)) 35 | { 36 | return "内网IP"; 37 | } 38 | 39 | JSONObject resObj = getRealAdd(ip); 40 | if(StringUtil.isEmpty( resObj)){ 41 | return UNKNOWN; 42 | } 43 | return resObj.getStr("ip"); 44 | } 45 | 46 | 47 | public static JSONObject getRealAdd(String ip) 48 | { 49 | HttpRequest request = HttpUtil.createGet(IP_URL + ip) 50 | .header(Header.USER_AGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 " + 51 | "(KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0") 52 | .header(Header.CONNECTION, "Keep-Alive") 53 | .header(Header.ACCEPT, "*/*"); 54 | 55 | String body = request.execute().body(); 56 | // 解析body 57 | try 58 | { 59 | return JSONUtil.parseObj(body); 60 | }catch (Exception e){ 61 | log.error("获取地理位置失败: {}",ip); 62 | return null; 63 | } 64 | } 65 | 66 | public static String getRealLocation(String ip){ 67 | if(Ipv4Util.isInnerIP(ip)) 68 | { 69 | return "内网地址"; 70 | } 71 | JSONObject resObj = getRealAdd(ip); 72 | if(StringUtil.isEmpty(resObj)) 73 | { 74 | return "地址未知"; 75 | } 76 | return resObj.getStr("pro") + resObj.getStr("city"); 77 | } 78 | 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /back-me/common/src/main/java/com/qhx/common/util/security/SecurityUtil.java: -------------------------------------------------------------------------------- 1 | package com.qhx.common.util.security; 2 | 3 | import org.springframework.security.core.Authentication; 4 | import org.springframework.security.core.context.SecurityContextHolder; 5 | 6 | /** 7 | * spring security 的工具类、相关安全 8 | * 9 | * @author: jzm 10 | * @date: 2024-03-01 11:05 11 | **/ 12 | 13 | public class SecurityUtil 14 | { 15 | 16 | public static void setAuthentication(Authentication authentication){ 17 | SecurityContextHolder.getContext().setAuthentication(authentication); 18 | } 19 | 20 | public static T getPrincipal(){ 21 | return (T)getAuthentication().getPrincipal(); 22 | } 23 | 24 | 25 | private static Authentication getAuthentication(){ 26 | return SecurityContextHolder.getContext().getAuthentication(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /back-me/generator/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /back-me/generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | com.qhx 6 | generator 7 | 0.0.1-SNAPSHOT 8 | generator 9 | generator 10 | 11 | 12 | 14 13 | UTF-8 14 | UTF-8 15 | 2.6.13 16 | 17 | 18 | 19 | 20 | com.baomidou 21 | mybatis-plus-generator 22 | 3.5.3.1 23 | 24 | 25 | com.baomidou 26 | mybatis-plus-boot-starter 27 | 3.5.3.1 28 | 29 | 30 | 31 | org.freemarker 32 | freemarker 33 | 34 | 35 | 36 | com.mysql 37 | mysql-connector-j 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-dependencies 46 | ${spring-boot.version} 47 | pom 48 | import 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.apache.maven.plugins 57 | maven-compiler-plugin 58 | 3.8.1 59 | 60 | 1.8 61 | 1.8 62 | UTF-8 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | ${spring-boot.version} 69 | 70 | com.qhx.generator.GeneratorApplication 71 | true 72 | 73 | 74 | 75 | repackage 76 | 77 | repackage 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /back-me/message/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /back-me/message/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | back-me 6 | com.qhx 7 | 1.0 8 | 9 | 10 | 4.0.0 11 | 12 | com.qhx 13 | message 14 | 1.0 15 | 16 | message 17 | 消息推送服务 18 | 19 | 20 | 1.8 21 | UTF-8 22 | UTF-8 23 | 2.6.13 24 | 25 | 26 | 27 | com.qhx 28 | common 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-websocket 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-amqp 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | org.apache.maven.plugins 48 | maven-compiler-plugin 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | ${spring-boot.version} 54 | 55 | com.qhx.message.MessageApplication 56 | true 57 | 58 | 59 | 60 | repackage 61 | 62 | repackage 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/MessageApplication.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MessageApplication 8 | { 9 | 10 | public static void main(String[] args) 11 | { 12 | SpringApplication.run(MessageApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/config/WebSocketConfig.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 6 | 7 | /** 8 | * @author: jzm 9 | * @date: 2024-03-11 12:14 10 | **/ 11 | 12 | @Configuration 13 | public class WebSocketConfig 14 | { 15 | @Bean 16 | public ServerEndpointExporter serverEndpointExporter(){ 17 | return new ServerEndpointExporter(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/config/rabbitMq/domain/Message.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message.config.rabbitMq.domain; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableName; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | import java.io.Serializable; 12 | import java.time.LocalDateTime; 13 | 14 | /** 15 | *

16 | * 17 | *

18 | * 19 | * @author qhx2004 20 | * @since 2024-03-11 21 | */ 22 | @Getter 23 | @Setter 24 | @TableName("ap_message") 25 | @ApiModel(value = "Message对象", description = "") 26 | public class Message implements Serializable { 27 | 28 | private static final long serialVersionUID = 1L; 29 | 30 | @ApiModelProperty("消息id") 31 | @TableId(value = "message_id", type = IdType.AUTO) 32 | private Integer messageId; 33 | 34 | @ApiModelProperty("消息发送者id") 35 | private Long senderId; 36 | 37 | @ApiModelProperty("消息接受者(一般农户id)") 38 | private Long receiverId; 39 | 40 | @ApiModelProperty("消息内容") 41 | private String content; 42 | 43 | @ApiModelProperty("发送这条消息的时间") 44 | private LocalDateTime senderTime; 45 | 46 | @ApiModelProperty("消息接受时间") 47 | private LocalDateTime receiverTime; 48 | 49 | @ApiModelProperty("状态(0正常 1停用)") 50 | private String status; 51 | 52 | @ApiModelProperty("删除标志(0代表存在 1代表删除)") 53 | private String delFlag; 54 | } 55 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/config/rabbitMq/listener/DynamicListener.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message.config.rabbitMq.listener; 2 | 3 | import cn.hutool.json.JSONObject; 4 | import cn.hutool.json.JSONUtil; 5 | import com.qhx.message.controller.ChatServerEndpoint; 6 | import com.rabbitmq.client.Channel; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.springframework.amqp.core.Message; 9 | import org.springframework.amqp.rabbit.listener.api.ChannelAwareMessageListener; 10 | import org.springframework.stereotype.Service; 11 | 12 | /** 13 | * 自定义监听器处理 14 | */ 15 | @Slf4j 16 | @Service 17 | public class DynamicListener implements ChannelAwareMessageListener 18 | { 19 | 20 | @Override 21 | public void onMessage(Message message, Channel channel) throws Exception { 22 | byte[] body = message.getBody(); 23 | String mes = new String(body); 24 | try 25 | { 26 | JSONObject userMesJson = JSONUtil.parseObj(mes); 27 | if (userMesJson.containsKey("receiverId")) // 接受者消息 28 | { 29 | ChatServerEndpoint.exSendMes(userMesJson); 30 | } 31 | }catch (Exception e){ 32 | log.error("json 反序列化异常:"+e.getMessage()); 33 | return; 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/config/rabbitMq/service/RabbitMqService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message.config.rabbitMq.service; 2 | 3 | import cn.hutool.json.JSONUtil; 4 | import com.qhx.message.config.rabbitMq.RabbitMqConfig; 5 | import com.qhx.message.config.rabbitMq.domain.Message; 6 | 7 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 8 | import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; 9 | import org.springframework.context.annotation.Lazy; 10 | import org.springframework.stereotype.Service; 11 | 12 | import javax.annotation.Resource; 13 | 14 | /** 15 | * 消息处理 16 | * 17 | * @author: jzm 18 | * @date: 2024-03-11 22:17 19 | **/ 20 | 21 | @Service 22 | @Lazy // 延迟加载,当需要用这个bean时,才会自动加载 23 | public class RabbitMqService 24 | { 25 | 26 | @Resource 27 | private RabbitTemplate rabbitTemplate; 28 | 29 | @Resource 30 | private RabbitMqConfig rabbitMqConfig; 31 | 32 | @Resource 33 | private SimpleMessageListenerContainer simpleMessageListenerContainer; 34 | 35 | public void sendMes(Message message){ 36 | // 创建消息队列,并将消息发送出去 37 | String exchange = "receiverId"; 38 | String queueName = "receiverId:"+message.getReceiverId(); 39 | String routingKey = "receiverId:" +message.getReceiverId(); 40 | rabbitMqConfig.createExchangeBindQueue(queueName,exchange,routingKey); 41 | 42 | rabbitTemplate.convertAndSend(exchange,routingKey, JSONUtil.toJsonStr(message)); 43 | } 44 | 45 | public void createLister(Long userId){ 46 | simpleMessageListenerContainer.addQueueNames("receiverId:"+userId); 47 | simpleMessageListenerContainer.start(); 48 | } 49 | 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/controller/ChatController.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message.controller; 2 | 3 | import com.qhx.common.model.AjaxResult; 4 | import com.qhx.message.config.rabbitMq.domain.Message; 5 | import com.qhx.message.config.rabbitMq.service.RabbitMqService; 6 | import com.qhx.message.service.ChatSessionService; 7 | import io.swagger.annotations.ApiOperation; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import javax.annotation.Resource; 12 | import java.util.List; 13 | 14 | 15 | /** 16 | * @author: jzm 17 | * @date: 2024-03-11 21:57 18 | **/ 19 | 20 | 21 | @RestController 22 | @RequestMapping("/chat") 23 | public class ChatController 24 | { 25 | 26 | @Autowired 27 | private ChatServerEndpoint chatServerEndpoint; 28 | 29 | @Autowired 30 | private ChatSessionService chatSessionService; 31 | 32 | 33 | 34 | @RequestMapping(path = "/sendMes",method = RequestMethod.POST) 35 | public AjaxResult sendMes(@RequestBody Message message){ 36 | chatServerEndpoint.sendMes(message); 37 | return AjaxResult.success(message); 38 | } 39 | 40 | @RequestMapping(path = "/info") 41 | @ApiOperation("根据用户id查找用户信息") 42 | public AjaxResult getUserInfo(Long userId){ 43 | 44 | return AjaxResult.success(); 45 | } 46 | 47 | 48 | @RequestMapping(path = "/self/{senderId}/{receiverId}") 49 | @ApiOperation("获取指定用户的聊天信息内容") 50 | public AjaxResult selfList(@PathVariable("senderId") Long senderId, @PathVariable("receiverId") Long receiverId){ 51 | List messages = chatSessionService.selfList(senderId, receiverId); 52 | return AjaxResult.success(messages); 53 | } 54 | 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/exception/MessageException.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message.exception; 2 | 3 | import com.qhx.common.exception.base.BaseException; 4 | 5 | /** 6 | * @author: jzm 7 | * @date: 2024-03-12 11:42 8 | **/ 9 | 10 | public class MessageException extends BaseException 11 | { 12 | public MessageException(String message, int code) 13 | { 14 | super(message, code); 15 | } 16 | 17 | public MessageException(String message) 18 | { 19 | super(message); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/service/ChatSessionService.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message.service; 2 | 3 | import com.qhx.common.domain.User; 4 | import com.qhx.message.config.rabbitMq.domain.Message; 5 | 6 | import java.util.List; 7 | 8 | public interface ChatSessionService 9 | { 10 | /** 11 | * 根据ID从Redis中查询数据 12 | * 13 | * @param userId 14 | * @return User对象 15 | */ 16 | User findById(Long userId); 17 | 18 | /** 19 | * 推送消息,储存到Redis数据库中 20 | * 21 | * @param message 消息 22 | */ 23 | void pushMessage(Message message); 24 | 25 | /** 26 | * 获取在线用户列表 27 | * 28 | * @return 29 | */ 30 | List onlineList(); 31 | 32 | /** 33 | * 获取公共消息内容 -- 群组 34 | * 35 | * @return 36 | */ 37 | List commonList(); 38 | 39 | /** 40 | * 获取该用户与指定窗口的推送消息 41 | * 42 | * @param senderId 推送方ID 43 | * @param receiverId 接收方ID 44 | * @return 45 | */ 46 | List selfList(Long senderId, Long receiverId); 47 | 48 | /** 49 | * 删除指定ID在Redis中储存的数据 50 | * 51 | * @param userId 52 | */ 53 | void delete(Long userId); 54 | } 55 | -------------------------------------------------------------------------------- /back-me/message/src/main/java/com/qhx/message/service/impl/ChatSessionServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.qhx.message.service.impl; 2 | 3 | import com.qhx.common.domain.User; 4 | import com.qhx.common.util.redis.RedisCache; 5 | import com.qhx.message.config.rabbitMq.domain.Message; 6 | import com.qhx.message.service.ChatSessionService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.context.annotation.Primary; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | /** 14 | * @author: jzm 15 | * @date: 2024-03-12 12:11 16 | **/ 17 | 18 | @Service(value = "chatSessionService") 19 | @Primary 20 | public class ChatSessionServiceImpl implements ChatSessionService 21 | { 22 | 23 | @Autowired 24 | private RedisCache redisCache; 25 | 26 | @Override 27 | public User findById(Long userId) 28 | { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void pushMessage(Message message) 34 | { 35 | 36 | } 37 | 38 | @Override 39 | public List onlineList() 40 | { 41 | return null; 42 | } 43 | 44 | @Override 45 | public List commonList() 46 | { 47 | return null; 48 | } 49 | 50 | @Override 51 | // 前台缓存的用户对话id,缓存的不是用户对话消息 52 | public List selfList(Long senderId, Long receiverId) 53 | { 54 | return null; 55 | } 56 | 57 | @Override 58 | public void delete(Long userId) 59 | { 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /back-me/message/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8089 3 | spring: 4 | application: 5 | name: spirng-boot-rabbitmq 6 | rabbitmq: 7 | host: 192.168.233.131 8 | port: 5672 9 | username: guest 10 | password: guest --------------------------------------------------------------------------------