程序员的资源宝库

网站首页 > gitee 正文

使用人人开源快速开发

sanyeah 2024-04-13 16:11:18 gitee 3 ℃ 0 评论

使用人人开源快速开发

1.1人人开源搭建后台管理系统

(1)clone

地址:https://gitee.com/renrenio

$ git clone git@gitee.com:renrenio/renren-fast-vue.git

image-20220211222822716

$ git clone git@gitee.com:renrenio/renren-fast.git

image-20220211222841114

(2)复制到项目中

<modules>
    <module>gulimail-product</module>
    <module>gulimall-coupon</module>
    <module>gulimall-member</module>
    <module>gulimall-order</module>
    <module>gulimall-ware</module>
    <module>renren-fast</module>
</modules>

image-20220211223049763

(3)执行mysql

image-20220211225704433

(4)修改启动端口号(默认80,容易冲突)和数据库连接地址

server:
  port: 8888

url: jdbc:mysql://192.168.56.10:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root

image-20220212001119603

(5)运行

image-20220211225412670

1.2 搭建前端环境

(1)安装node

地址:https://nodejs.org/zh-cn/download/

下载后选择安装地址(不建议c盘),一路next即可

检查node版本

node -v 

设置npm镜像地址

npm config set registry http://registry.npm.taobao.org/

(2)前后联调

项目安装npm

npm install

image-20220211230326893

启动

npm run dev 

访问http://localhost:8001/#/login

输出用户名admin密码admin 验证码,登录成功,前后端联调成功

image-20220211230622359

1.3逆向工程搭建&使用

(1)下载代码人人开源代码生成器

$ git clone git@gitee.com:renrenio/renren-generator.git

image-20220211231046749

(2)renren-generator加载到项目中

image-20220211232849028

(3)修改mysql数据库相关配置

url: jdbc:mysql://192.168.10.56:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root

image-20220211233140996

(4)修改代码生成配置

# 主目录
mainPath=com.peng
#包名
package=com.peng.gulimall
moduleName=product
#作者
author=peng
#Email
email=pengpeng6135@163.com
#表前缀(类名不会包含表前缀)
tablePrefix=pms_

image-20220211233506098

(5)修改contoller模板
注释import org.apache.shiro.authz.annotation.RequiresPermissions命名空间

image-20220212002343153

注释Controller.java.vm模板中所有的@RequiresPermissions("${moduleName}??{pathName}:list")

image-20220211233741331

(6)新建公共模块

新建模块

image-20220211234026550

选择maven项目

image-20220211234046280

新建gulimall-common

image-20220211234115991

配置gulimall-common的pom.xml

<parent>
    <artifactId>gulimall</artifactId>
    <groupId>com.peng.gulimall</groupId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<packaging>pom</packaging>
<artifactId>gulimall-common</artifactId>
<description>每一个微服务公共的的依赖、bean、工具类</description>

image-20220211234657141

gulimall-common添加到pom.xml

image-20220211234518726

(7)gulimall-common依赖

  <dependencies>
        <!-- mybatisPLUS -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.3.2</version>
        </dependency>

        <!--简化实体类,用@Data代替getset方法-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.8</version>
        </dependency>
        <!-- httpcomponent包 -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.13</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.4.1</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>

        <!-- 数据库驱动 https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.17</version>
        </dependency>


    </dependencies>

(8)启动,访问 http://localhost:8888/#generator.html

image-20220212001308228

(9)生成代码

image-20220212001402745

(10)生成的代码复制到项目中去

image-20220212013646489

1.4测试基本基本的CRUD功能

(1)整合MyBatis-Plus

<!-- mybatisPLUS -->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.3.2</version>
</dependency>

image-20220212005230572

(2)@MapperScan配置注入的数据访问层

image-20220212013121589

(3)配置application.yml

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_pms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    driver-class-name: com.mysql.jdbc.Driver

mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto

image-20220212013545826

(4)测试

image-20220212013814420

1.5 所有微服务的CURD(例子)

  • 商品服务product
  • 存储服务ware
  • 订单服务order
  • 优惠券服务coupon
  • 用户服务member

如果UndoLog的有关服务报错,可以都先注释掉,暂时用不上

image-20220212164459645

1.5.1 coupon 优惠卷服务

renren-generator工程,修改generator.properties

image-20220212160222795

#主目录
mainPath=com.peng
#包名
package=com.peng.gulimall
#模块名
moduleName=coupon
#作者
author=peng
#email
email=pengpeng6135@163.com
#表前缀(类名不会包含表前缀) # 我们的sms数据库中的表的前缀都sms
如果写了表前缀,每一张表对于的javaBean就不会添加前缀了
tablePrefix=sms_ 

renren-generator工程,修改application.yml数据库信息

image-20220212160450187

server:
  port: 8888

# mysql
spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    #MySQL配置
    driverClassName: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://192.168.56.10:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    username: root
    password: root

gulimall-coupon工程,依赖于common,修改pom.xml

image-20220212160852383

<dependency>
    <groupId>com.peng.gulimall</groupId>
    <artifactId>gulimall-common</artifactId>
    <version>0.0.1-SNAPSHOT</version>        
</dependency>

gulimall-coupon工程,修改application.yml数据库配置

image-20220212160923654

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_sms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    driver-class-name: com.mysql.cj.jdbc.Driver


mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto
      logic-delete-value: 1
      logic-not-delete-value: 0

server:
  port: 7001

运行gulimallCouponApplication.java

image-20220212161128218

访问http://localhost:8888/#generator.html

image-20220212161210063

生成完的代码赋值到gulimall-coupon,以下是项目结构

image-20220212163848164

配置mapper映射,并启动

image-20220212164032885

@MapperScan("com.peng.gulimall.coupon.dao")

测试gulimall-coupon,访问http://localhost:7001/coupon/coupon/list

image-20220212164051551

1.5.2 member 用户服务

(1)renren-generator修改generator.properties

#模块名
moduleName=member
#表前缀(类名不会包含表前缀) # 我们的ums数据库中的表的前缀都ums
如果写了表前缀,每一张表对于的javaBean就不会添加前缀了
tablePrefix=ums_ 

image-20220212165609185

(2)renren-generator修改application.yml

 url: jdbc:mysql://192.168.56.10:3306/gulimall_ums?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai  

image-20220212165703440

(3)gulimall-member修改pom.xml

<dependency>
    <groupId>com.peng.gulimall</groupId>
    <artifactId>gulimall-common</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

image-20220212165823132

(4)gulimall-member修改application.yml

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_ums?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    driver-class-name: com.mysql.cj.jdbc.Driver


mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto
      logic-delete-value: 1
      logic-not-delete-value: 0

server:
  port: 8002

(5)入口增加mapper映射

image-20220212170017639

(6)访问:http://localhost:8002/member/growthchangehistory/list

1.5.3 order 订单服务

(1)renren-generator修改generator.properties

#模块名
moduleName=order
#表前缀(类名不会包含表前缀) # 我们的oms数据库中的表的前缀都oms
如果写了表前缀,每一张表对于的javaBean就不会添加前缀了
tablePrefix=oms_ 

(2)renren-generator修改application.yml

url: jdbc:mysql://192.168.56.10:3306/gulimall_oms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai

(3)gulimall-member修改pom.xml

<dependency>
    <groupId>com.peng.gulimall</groupId>
    <artifactId>gulimall-common</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

(4)gulimall-member修改application.yml

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_oms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    driver-class-name: com.mysql.cj.jdbc.Driver


mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto
      logic-delete-value: 1
      logic-not-delete-value: 0

server:
  port: 9000

(5)入口增加mapper映射
@MapperScan("com.peng.gulimall.order.dao")

(6)访问:http://localhost:9000/order/mqmessage/list

1.5.4 ware 存储服务

(1)renren-generator修改generator.properties

#模块名
moduleName=ware
#表前缀(类名不会包含表前缀) # 我们的wms数据库中的表的前缀都wms
如果写了表前缀,每一张表对于的javaBean就不会添加前缀了
tablePrefix=wms_ 

(2)renren-generator修改application.yml

url: jdbc:mysql://192.168.56.10:3306/gulimall_wms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai

(3)gulimall-member修改pom.xml

<dependency>
    <groupId>com.peng.gulimall</groupId>
    <artifactId>gulimall-common</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

(4)gulimall-member修改application.yml

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_wms?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
    driver-class-name: com.mysql.cj.jdbc.Driver


mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto
      logic-delete-value: 1
      logic-not-delete-value: 0

server:
  port: 10000

(5)入口增加mapper映射

@MapperScan("com.peng.gulimall.ware.dao")

(6)访问:http://localhost:10000/ware/purchase/list

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表