commit 2cb733a04b85c220bedccf3e0a279bb20eb79d6b
Author: 冷调 <3084898776@qq.com>
Date: Mon Jul 29 09:13:14 2024 +0800
日考10
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/.idea/$PROJECT_FILE$ b/.idea/$PROJECT_FILE$
new file mode 100644
index 0000000..58b7e3e
--- /dev/null
+++ b/.idea/$PROJECT_FILE$
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..63574ec
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..8d66637
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..f25c597
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+ {
+ "isMigrated": true
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml
new file mode 100644
index 0000000..3dfd21f
--- /dev/null
+++ b/.idea/qaplug_profiles.xml
@@ -0,0 +1,465 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..8f0003f
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,40 @@
+
+
+ 4.0.0
+
+ com.bwie
+ zg6rk10
+ 1.0-SNAPSHOT
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+ mysql
+ mysql-connector-java
+ 8.0.33
+
+
+ org.projectlombok
+ lombok
+ 1.18.34
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.5.7
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ 2.7.18
+ compile
+
+
+
+
diff --git a/src/main/java/com/bwie/UserApplication.java b/src/main/java/com/bwie/UserApplication.java
new file mode 100644
index 0000000..ff2e4f9
--- /dev/null
+++ b/src/main/java/com/bwie/UserApplication.java
@@ -0,0 +1,14 @@
+package com.bwie;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author Lenovo
+ */
+@SpringBootApplication
+public class UserApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(UserApplication.class);
+ }
+}
diff --git a/src/main/java/com/bwie/admin/User.java b/src/main/java/com/bwie/admin/User.java
new file mode 100644
index 0000000..7071045
--- /dev/null
+++ b/src/main/java/com/bwie/admin/User.java
@@ -0,0 +1,25 @@
+package com.bwie.admin;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * @author Lenovo
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class User {
+ @TableId(type = IdType.AUTO)
+ private Integer uid;
+ private String userName;
+ private String pwd;
+ private String sex;
+ private Date birthday;
+ private Integer age;
+}
diff --git a/src/main/java/com/bwie/controller/UserController.java b/src/main/java/com/bwie/controller/UserController.java
new file mode 100644
index 0000000..d801278
--- /dev/null
+++ b/src/main/java/com/bwie/controller/UserController.java
@@ -0,0 +1,46 @@
+package com.bwie.controller;
+
+import com.bwie.admin.User;
+import com.bwie.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * @author Lenovo
+ */
+@RestController
+public class UserController {
+ @Autowired
+ private UserService userService;
+
+ /**
+ * 实现查询功能
+ * @return
+ */
+ @GetMapping("/selectUserAll")
+ public List selectUserAll(){
+ return userService.selectUserAll();
+ }
+
+ /**
+ * 实现删除功能
+ * @param uid
+ */
+ @DeleteMapping("/deleteUserById/{uid}")
+ public void deleteById(@PathVariable Integer uid){
+ userService.deleteById(uid);
+ }
+
+ /**
+ * 列表查询年龄降序排序,
+ * @param limit
+ * @return
+ */
+ @PostMapping("/selectUserAge")
+ public List selectUserAge(int limit){
+ return userService.selectUserAge(limit);
+ }
+
+}
diff --git a/src/main/java/com/bwie/mapper/UserMapper.java b/src/main/java/com/bwie/mapper/UserMapper.java
new file mode 100644
index 0000000..ca86660
--- /dev/null
+++ b/src/main/java/com/bwie/mapper/UserMapper.java
@@ -0,0 +1,12 @@
+package com.bwie.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.bwie.admin.User;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author Lenovo
+ */
+@Mapper
+public interface UserMapper extends BaseMapper {
+}
diff --git a/src/main/java/com/bwie/service/UserService.java b/src/main/java/com/bwie/service/UserService.java
new file mode 100644
index 0000000..472d4c1
--- /dev/null
+++ b/src/main/java/com/bwie/service/UserService.java
@@ -0,0 +1,16 @@
+package com.bwie.service;
+
+import com.bwie.admin.User;
+
+import java.util.List;
+
+/**
+ * @author Lenovo
+ */
+public interface UserService {
+ List selectUserAll();
+
+ void deleteById(Integer uid);
+
+ List selectUserAge(int limit);
+}
diff --git a/src/main/java/com/bwie/service/impl/UserServiceImpl.java b/src/main/java/com/bwie/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..2a18cce
--- /dev/null
+++ b/src/main/java/com/bwie/service/impl/UserServiceImpl.java
@@ -0,0 +1,39 @@
+package com.bwie.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.bwie.admin.User;
+import com.bwie.mapper.UserMapper;
+import com.bwie.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author Lenovo
+ */
+@Service
+public class UserServiceImpl implements UserService {
+ @Autowired
+ private UserMapper userMapper;
+
+ @Override
+ public List selectUserAll() {
+ return userMapper.selectList(null);
+ }
+
+ @Override
+ public void deleteById(Integer uid) {
+ userMapper.deleteById(uid);
+ }
+
+ @Override
+ public List selectUserAge(int limit) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.orderByDesc("age");
+ Page objectPage = new Page<>(12,limit);
+ List users = userMapper.selectList(objectPage, queryWrapper);
+ return users;
+ }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
new file mode 100644
index 0000000..4d2fdeb
--- /dev/null
+++ b/src/main/resources/application.yml
@@ -0,0 +1,17 @@
+
+server:
+ port: 8080
+
+spring:
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://129.211.0.187:3306/zhuangao61010
+ username: root
+ password: wmw1234
+
+
+mybatis-plus:
+ mapper-locations: classpath*:mapper/*.xml
+ configuration:
+ # 设置Mybatis的日志实现类为控制台输出
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl