uniapp微信小程序投票系统实战 (SpringBoot2+vue3.2+element plus ) -后端架构搭建

锋哥原创的uniapp微信小程序投票系统实战:

uniapp微信小程序投票系统实战课程 (SpringBoot2+vue3.2+element plus ) ( 火爆连载更新中... )_哔哩哔哩_bilibiliuniapp微信小程序投票系统实战课程 (SpringBoot2+vue3.2+element plus ) ( 火爆连载更新中... )共计21条视频,包括:uniapp微信小程序投票系统实战课程 (SpringBoot2+vue3.2+element plus ) ( 火爆连载更新中... )、第2讲 投票项目后端架构搭建、第3讲 小程序端 TabBar搭建等,UP主更多精彩视频,请关注UP账号。https://www.bilibili.com/video/BV1ea4y137xf/

idea新建项目:java1234-vote3

pom.xml

XML 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.java1234</groupId>
    <artifactId>java1234-vote3</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>java1234-vote3</name>
    <description>java1234-vote3</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>


        <!-- 连接池 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.10</version>
        </dependency>
        <!-- mybatis-plus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.3.2</version>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.40</version>
        </dependency>

        <!-- JWT -->
        <dependency>
            <groupId>com.auth0</groupId>
            <artifactId>java-jwt</artifactId>
            <version>3.2.0</version>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.9.1</version>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- spring boot redis 缓存引入 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <!-- lettuce pool 缓存连接池 -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
        </dependency>

        <!-- hutool工具类-->
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.3.3</version>
        </dependency>

        <!-- 验证码依赖-->
        <dependency>
            <groupId>com.github.axet</groupId>
            <artifactId>kaptcha</artifactId>
            <version>0.0.9</version>
        </dependency>

        <!-- 添加Httpclient支持 -->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.2</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.3.2.RELEASE</version>
            </plugin>
        </plugins>
    </build>

</project>

application.yml

XML 复制代码
server:
  port: 8866
  servlet:
    context-path: /

spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/db_vote3?serverTimezone=Asia/Shanghai
    username: root
    password: 123456


mybatis-plus:
  global-config:
    db-config:
      id-type: auto
  configuration:
    map-underscore-to-camel-case: true
    auto-mapping-behavior: full
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath:mapper/*.xml

启动类加上,扫描mapper接口:@MapperScan("com.java1234.mapper")

项目结构;


测试接口:

java 复制代码
/**
 * 测试
 * @return
 */
@RequestMapping("/test")
public R test(){
    List<WxUserInfo> list = wxUserInfoService.list();
    HashMap<String,Object> result=new HashMap<>();
    result.put("list",list);
    return R.ok(result);
}

浏览器地址栏输入:

java 复制代码
http://localhost:8866/user/test

测试OK

新建数据库:db_vote3

新建微信用户信息表:t_wxuserinfo

sql 复制代码
/*
SQLyog Ultimate v11.33 (64 bit)
MySQL - 5.7.18-log 
*********************************************************************
*/
/*!40101 SET NAMES utf8 */;

create table `t_wxuserinfo` (
	`id` int (11),
	`openid` varchar (90),
	`nick_name` varchar (150),
	`avatar_url` varchar (600),
	`register_date` datetime ,
	`last_login_date` datetime ,
	`status` char (3)
); 
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('6','o30ur5JpAsAUyGBkR0uW4IxvahR8','小锋老师@java1234','20230324082340000000882.jpeg','2023-02-27 17:48:29','2023-05-04 21:06:40','0');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('7','o30ur5PiPOr52bBsetXcIV93NL-U','小锋四号@java1234','20230410102248000000487.jpg','2023-04-10 10:21:30','2023-05-04 21:20:38','0');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('9','o30ur5JpAsAUyGBkR0uW4IxvahR0','微信用户','default.png','2023-04-30 07:42:19','2023-04-30 07:42:19','1');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('10','1',NULL,NULL,NULL,NULL,'1');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('11','2',NULL,NULL,NULL,NULL,'1');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('12','3',NULL,NULL,NULL,NULL,'1');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('13','4',NULL,NULL,NULL,NULL,'1');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('14','5',NULL,NULL,NULL,NULL,'1');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('15','6',NULL,NULL,NULL,NULL,'1');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('16','7',NULL,NULL,NULL,NULL,'1');
insert into `t_wxuserinfo` (`id`, `openid`, `nick_name`, `avatar_url`, `register_date`, `last_login_date`, `status`) values('17','8',NULL,NULL,NULL,NULL,'1');

(*记得要设置下主键自增)

相关推荐
断墨先生2 小时前
uniapp—android原生插件开发(3Android真机调试)
android·uni-app
guai_guai_guai4 小时前
uniapp
前端·javascript·vue.js·uni-app
阿伟来咯~9 小时前
一些 uniapp相关bug
uni-app·bug
丁总学Java12 小时前
微信小程序,点击bindtap事件后,没有跳转到详情页,有可能是app.json中没有正确配置页面路径
微信小程序·小程序·json
瑶琴AI前端13 小时前
uniapp组件实现省市区三级联动选择
java·前端·uni-app
mosen86813 小时前
Uniapp去除顶部导航栏-小程序、H5、APP适用
vue.js·微信小程序·小程序·uni-app·uniapp
qq229511650214 小时前
微信小程序的汽车维修预约管理系统
微信小程序·小程序·汽车
尚梦21 小时前
uni-app 封装刘海状态栏(适用小程序, h5, 头条小程序)
前端·小程序·uni-app
小飞哥liac1 天前
微信小程序的组件
微信小程序
stormjun1 天前
Java基于微信小程序的私家车位共享系统(附源码,文档)
java·微信小程序·共享停车位·私家车共享停车位小程序·停车位共享