day13
commit
6367b09cf2
|
@ -0,0 +1,33 @@
|
|||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
|
@ -0,0 +1,152 @@
|
|||
<?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>
|
||||
<groupId>com.bwie</groupId>
|
||||
<artifactId>Zg6-Day13</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Zg6-Day13</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<spring-boot.version>2.3.12.RELEASE</spring-boot.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.6</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 添加servlet依赖模块 -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- 添加jstl标签库依赖模块 -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
</dependency>
|
||||
<!--添加tomcat依赖模块.-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- 使用jsp引擎,springboot内置tomcat没有此依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat.embed</groupId>
|
||||
<artifactId>tomcat-embed-jasper</artifactId>
|
||||
</dependency>
|
||||
<!-- sqring框架依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
<!-- 热部署依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- mysql数据库依赖 -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.32</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!-- lombok小辣椒依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!-- 测试类依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
<version>4.4.14</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<configuration>
|
||||
<mainClass>com.bwie.Zg6Day13Application</mainClass>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>repackage</id>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Zg6Day13Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Zg6Day13Application.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.bwie.controller;
|
||||
|
||||
import com.bwie.pojo.User;
|
||||
import com.bwie.service.UserService;
|
||||
import lombok.extern.java.Log;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.controller
|
||||
* @Project:Zg6-Day13
|
||||
* @name:UserController
|
||||
* @Date:2024/8/1 8:58
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public User login(@RequestBody User user){
|
||||
return userService.login(user);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bwie.pojo.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.mapper
|
||||
* @Project:Zg6-Day13
|
||||
* @name:UserMapper
|
||||
* @Date:2024/8/1 8:48
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.bwie.pojo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.pojo
|
||||
* @Project:Zg6-Day13
|
||||
* @name:User
|
||||
* @Date:2024/8/1 8:47
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@TableName(value = "user",autoResultMap = true)
|
||||
public class User {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "uid",type = IdType.AUTO)
|
||||
private Integer uId;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String userPwd;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bwie.service;
|
||||
|
||||
import com.bwie.pojo.User;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.service
|
||||
* @Project:Zg6-Day13
|
||||
* @name:UserService
|
||||
* @Date:2024/8/1 8:57
|
||||
*/
|
||||
public interface UserService {
|
||||
|
||||
|
||||
User login(User user);
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.bwie.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bwie.mapper.UserMapper;
|
||||
import com.bwie.pojo.User;
|
||||
import com.bwie.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.bwie.service.impl
|
||||
* @Project:Zg6-Day13
|
||||
* @name:UserServiceImpl
|
||||
* @Date:2024/8/1 8:57
|
||||
*/
|
||||
@Service
|
||||
public class UserServiceImpl
|
||||
extends ServiceImpl<UserMapper, User>
|
||||
implements UserService {
|
||||
|
||||
@Resource(type = User.class)
|
||||
private UserMapper userMapper;
|
||||
@Override
|
||||
public User login(User user) {
|
||||
if (StringUtils.isEmpty(user.getUserName()) || StringUtils.isEmpty(user.getUserPwd())){
|
||||
System.out.println("用户名或密码不能为空");
|
||||
}
|
||||
User uu = userMapper.selectById(1);
|
||||
if (null == uu){
|
||||
System.out.println("用户不存在请重试");
|
||||
}
|
||||
|
||||
return uu;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
# 应用服务 WEB 访问端口号
|
||||
server.port=8080
|
||||
|
||||
# 日志输出
|
||||
logging.level.com.bawei=debug
|
||||
# 数据库驱动:
|
||||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
|
||||
# 数据源名称
|
||||
#spring.datasource.name=defaultDataSource
|
||||
# 数据库连接地址
|
||||
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/zg6_day13?characterEncoding=utf-8&useUnicode=true
|
||||
# 数据库用户名&密码:
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=root
|
||||
# 视图解析器
|
||||
spring.mvc.view.prefix=/WEB-INF/view/
|
||||
spring.mvc.view.suffix=.jsp
|
||||
|
||||
# mybatis下划线转小驼峰
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
|
||||
|
||||
# pageHelper插件
|
||||
# 分页合理化
|
||||
pagehelper.reasonable=true
|
||||
# 分页自动转换方言。。。不同的数据库 分页的语句是不同的 mysql--limit oracle--rownum
|
||||
pagehelper.auto-dialect=true
|
|
@ -0,0 +1,13 @@
|
|||
package com.bwie;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class Zg6Day13ApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue