From 3eaf07b62f9fab8e509b9ed531705eea10ca8435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=87=95?= <1851502614@qq.com> Date: Thu, 15 Jul 2021 17:45:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=9D=8E=E7=87=95--=E4=BD=9C=E4=B8=9A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/JavaSpringBootController.java | 21 ------ .../swpu/liyan/JavaSpringBootController.java | 66 +++++++++++++++++++ 2 files changed, 66 insertions(+), 21 deletions(-) delete mode 100644 src/main/java/com/swpu/controller/JavaSpringBootController.java create mode 100644 src/main/java/com/swpu/liyan/JavaSpringBootController.java diff --git a/src/main/java/com/swpu/controller/JavaSpringBootController.java b/src/main/java/com/swpu/controller/JavaSpringBootController.java deleted file mode 100644 index a927b7f..0000000 --- a/src/main/java/com/swpu/controller/JavaSpringBootController.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.swpu.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(value = "/") -public class JavaSpringBootController { - - @GetMapping(value = "/test") - public Object test() { - return "Hello World !"; - } - - @GetMapping(value = "/add") - public int add() { - var y = 1 + 1; - return y; - } -} diff --git a/src/main/java/com/swpu/liyan/JavaSpringBootController.java b/src/main/java/com/swpu/liyan/JavaSpringBootController.java new file mode 100644 index 0000000..3e92604 --- /dev/null +++ b/src/main/java/com/swpu/liyan/JavaSpringBootController.java @@ -0,0 +1,66 @@ +package com.swpu.liyan; + +import org.springframework.web.bind.annotation.*; + +/** + * @author wales + *

+ * Spring Boot Controller 接口开发基础 + * + *

+ */ +@RestController +@RequestMapping(value = "/login") +public class JavaSpringBootController { + + /** + * GetMapping - 代表着当前的方法只能通过 GET 请求来访问 http://localhost:8080/login/find + * + * @return object + */ + @GetMapping(value = "/find") + public Object add(@RequestParam(value = "a") int a, @RequestParam(value = "c") int c, + @RequestParam(value = "z") int z) { + var y = (c + a) * z; + return "计算结果为: " + y; + } + public Object set(@RequestParam(value="s") String s) { + + return "计算结果为: " + s; + } + + /** + * PostMapping - 代表着当前的方法只能通过 POST 请求来访问 http://localhost:8080/login/insert + * + * @return object + */ + @PostMapping(value = "/insert") + public Object test() { + return "This is Post !"; + } + + /** + * PutMapping - 代表着当前的方法只能通过 PUT 请求来访问 http://localhost:8080/login/update + * + * @return object + */ + @PutMapping(value = "/update") + public Object update() { + return "Want Update !"; + } + + /** + * DeleteMapping - 代表着当前的方法只能通过 DELETE 请求来访问 http://localhost:8080/login/delete + * + * @return object + */ + @DeleteMapping(value = "/delete") + public Object delete() { + return "Hello Delete"; + } + +} -- Gitee From 15241c3e13aa1162539b4e75f864a8f0903976b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=87=95?= <1851502614@qq.com> Date: Sat, 17 Jul 2021 11:53:23 +0800 Subject: [PATCH 2/4] sql--liyan --- sql/liyan | 0 sql/swpu_user.sql | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 sql/liyan diff --git a/sql/liyan b/sql/liyan new file mode 100644 index 0000000..e69de29 diff --git a/sql/swpu_user.sql b/sql/swpu_user.sql index 0970965..0726ffd 100644 --- a/sql/swpu_user.sql +++ b/sql/swpu_user.sql @@ -1,4 +1,4 @@ -create table swpu_user +create table swpu_userliyan ( id varchar(100) not null comment '主键ID' primary key, -- Gitee From effd5e21f33f7d98f7e1fef9ffb094b62c4397ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=87=95?= <1851502614@qq.com> Date: Tue, 20 Jul 2021 10:48:20 +0800 Subject: [PATCH 3/4] =?UTF-8?q?shixun=E2=80=94=E2=80=94mvc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 111/pom.xml | 37 ++++++ 12/pom.xml | 44 +++++++ .../main/java/com/swpu/PersonApplication.java | 18 +++ .../com/swpu/controller/PersonController.java | 49 ++++++++ 12/src/main/java/com/swpu/dao/PersonDao.java | 14 +++ .../java/com/swpu/entity/PersonEntity.java | 16 +++ 12/src/main/resources/application.yml | 23 ++++ 12/src/main/resources/mapper/Personmapper.xml | 114 ++++++++++++++++++ pom.xml | 26 ++-- sql/liyan | 0 sql/swpu_info.sql | 24 ++-- sql/swpu_user.sql | 26 ++-- ...pplication.java => PersonApplication.java} | 4 +- .../java/com/swpu/entity/PersonEntity.java | 5 + .../src/main/resources/application.yml | 5 + swpu-springboot-liyan-projects/pom.xml | 37 ++++++ .../com/swpu/SwpuSpringAppAplication.java | 7 ++ 17 files changed, 411 insertions(+), 38 deletions(-) create mode 100644 111/pom.xml create mode 100644 12/pom.xml create mode 100644 12/src/main/java/com/swpu/PersonApplication.java create mode 100644 12/src/main/java/com/swpu/controller/PersonController.java create mode 100644 12/src/main/java/com/swpu/dao/PersonDao.java create mode 100644 12/src/main/java/com/swpu/entity/PersonEntity.java create mode 100644 12/src/main/resources/application.yml create mode 100644 12/src/main/resources/mapper/Personmapper.xml delete mode 100644 sql/liyan rename swpu-spring-projects-boot/src/main/java/com/swpu/{SwpuSpringProjectsApplication.java => PersonApplication.java} (83%) create mode 100644 swpu-spring-projects-boot/src/main/java/com/swpu/entity/PersonEntity.java create mode 100644 swpu-springboot-liyan-projects/pom.xml create mode 100644 swpu-springboot-liyan-projects/src/main/java/com/swpu/SwpuSpringAppAplication.java diff --git a/111/pom.xml b/111/pom.xml new file mode 100644 index 0000000..d51c88a --- /dev/null +++ b/111/pom.xml @@ -0,0 +1,37 @@ + + + + swpu-spring-projects + com.swpu + 0.0.1-SNAPSHOT + + 4.0.0 + + 111 + + + 11 + 11 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.2 + + + + org.projectlombok + lombok + + + + + + + \ No newline at end of file diff --git a/12/pom.xml b/12/pom.xml new file mode 100644 index 0000000..21fd0e4 --- /dev/null +++ b/12/pom.xml @@ -0,0 +1,44 @@ + + + + swpu-spring-projects + com.swpu + 0.0.1-SNAPSHOT + + 4.0.0 + + 12 + + + org.mybatis + mybatis + 3.5.7 + + + + + 11 + 11 + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.2 + + + + org.projectlombok + lombok + + + + + + + + \ No newline at end of file diff --git a/12/src/main/java/com/swpu/PersonApplication.java b/12/src/main/java/com/swpu/PersonApplication.java new file mode 100644 index 0000000..a3adf7c --- /dev/null +++ b/12/src/main/java/com/swpu/PersonApplication.java @@ -0,0 +1,18 @@ +package com.swpu; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@MapperScan({"com.swpu.dao.**"}) +@SpringBootApplication + +public class PersonApplication { + public static void main(String[] args) { + SpringApplication.run(PersonApplication.class,args); + } + + + + +} diff --git a/12/src/main/java/com/swpu/controller/PersonController.java b/12/src/main/java/com/swpu/controller/PersonController.java new file mode 100644 index 0000000..01a3706 --- /dev/null +++ b/12/src/main/java/com/swpu/controller/PersonController.java @@ -0,0 +1,49 @@ +package com.swpu.controller; + + +import com.swpu.dao.PersonDao; +import com.swpu.entity.PersonEntity; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping(value="/libuliyan") +public class PersonController { + + @Resource + private PersonDao personDao; + + @GetMapping(value="/findAll") + public Object findAll(){ + List list= personDao.findAll(); + return list; + } + @GetMapping(value="/findbyId") + public Object findbyId(@RequestParam(value ="id") int id){ + return personDao.FindId(id); + } + + @PostMapping(value="/insert") + public Object insert(@RequestBody PersonEntity entity){ + + personDao.insert(entity); + return "插入成功"; + } + + @PutMapping(value = "/update") + public Object update(@RequestBody PersonEntity entity){ + + personDao.update(entity); + return "更新成功"; + } + + @DeleteMapping(value="/delete") + public Object delete(@RequestParam(value = "id") int id){ + personDao.delete(id); + return "删除成功"; + } + + +} diff --git a/12/src/main/java/com/swpu/dao/PersonDao.java b/12/src/main/java/com/swpu/dao/PersonDao.java new file mode 100644 index 0000000..4085d13 --- /dev/null +++ b/12/src/main/java/com/swpu/dao/PersonDao.java @@ -0,0 +1,14 @@ +package com.swpu.dao; + +import com.swpu.entity.PersonEntity; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface PersonDao { + PersonEntity FindId(@Param(value="id") int Id); + List findAll(); + int insert(PersonEntity entity); + int update(PersonEntity entity); + int delete(@Param(value="Id") int Id); +} diff --git a/12/src/main/java/com/swpu/entity/PersonEntity.java b/12/src/main/java/com/swpu/entity/PersonEntity.java new file mode 100644 index 0000000..107d528 --- /dev/null +++ b/12/src/main/java/com/swpu/entity/PersonEntity.java @@ -0,0 +1,16 @@ +package com.swpu.entity; + + +import lombok.Data; + +@Data +public class PersonEntity { + private int Id; + private String Name; + private String School; + private int RoomNumber; + private int Grade; + + + +} diff --git a/12/src/main/resources/application.yml b/12/src/main/resources/application.yml new file mode 100644 index 0000000..f6702d1 --- /dev/null +++ b/12/src/main/resources/application.yml @@ -0,0 +1,23 @@ +spring: + application: + name: swpu-spring-projects + # 数据库连接信息 + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.126.129:20000/swpu_db + username: swpu_user + password: '2121709a*' + # 数据库连接池 + type: com.zaxxer.hikari.HikariDataSource + hikari: + maximum-pool-size: 10000 +# 项目端口 +server: + port: 20000 + +# MyBatis XML 配置 +mybatis: + mapper-locations: classpath:mapper/**.xml + # 开启 驼峰支持 + configuration: + map-underscore-to-camel-case: true diff --git a/12/src/main/resources/mapper/Personmapper.xml b/12/src/main/resources/mapper/Personmapper.xml new file mode 100644 index 0000000..16218ae --- /dev/null +++ b/12/src/main/resources/mapper/Personmapper.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + insert into person (id, name, school, roomNumber, grade) + values (#{Id, javaType = Integer}, #{Name,javaType =String}, + #{School, javaType = String},#{RoomNumber,javaType=Integer},#{Grade,javaType=Integer}) + + + + update person + set + name = #{Name,javaType =String}, + school = #{School, javaType = String}, + roomNumber = #{RoomNumber,javaType=Integer}, + grade = #{Grade,javaType=Integer} + where id=#{Id, javaType = Integer} + + + + delete + from person su + where 1 = 1 + and su.id = #{id, javaType = Integer} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index e118f32..53ccef4 100644 --- a/pom.xml +++ b/pom.xml @@ -5,6 +5,9 @@ pom swpu-spring-projects-boot + swpu-springboot-liyan-projects + 111 + 12 org.springframework.boot @@ -55,17 +58,17 @@ org.springframework.boot spring-boot-starter-web - - - - - + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.2.0 + - - - - - + + mysql + mysql-connector-java + runtime + org.projectlombok lombok @@ -76,7 +79,8 @@ spring-boot-starter-test test - + + diff --git a/sql/liyan b/sql/liyan deleted file mode 100644 index e69de29..0000000 diff --git a/sql/swpu_info.sql b/sql/swpu_info.sql index 0b54a2d..05dbd15 100644 --- a/sql/swpu_info.sql +++ b/sql/swpu_info.sql @@ -1,12 +1,12 @@ -create table swpu_info -( - id varchar(100) not null comment '主键ID' - primary key, - p_id int not null comment '联合ID', - contract_term double null comment '合同期限', - conversion_time date null comment '转正日期', - notWork_date date null comment '离职日期', - begin_contract date null comment '合同起始日期', - end_contract date null comment '合同终止日期', - work_age int null comment '工龄' -) charset = utf8; +# create table swpu_info +# ( +# id varchar(100) not null comment '主键ID' +# primary key, +# p_id int not null comment '联合ID', +# contract_term double null comment '合同期限', +# conversion_time date null comment '转正日期', +# notWork_date date null comment '离职日期', +# begin_contract date null comment '合同起始日期', +# end_contract date null comment '合同终止日期', +# work_age int null comment '工龄' +# ) charset = utf8; diff --git a/sql/swpu_user.sql b/sql/swpu_user.sql index 0726ffd..8c0f67d 100644 --- a/sql/swpu_user.sql +++ b/sql/swpu_user.sql @@ -1,13 +1,13 @@ -create table swpu_userliyan -( - id varchar(100) not null comment '主键ID' - primary key, - department_id int null comment '所属部门', - job_level_id int null comment '职称ID', - posId int null comment '职位ID', - engage_form varchar(8) null comment '聘用形式', - specialty varchar(32) null comment '所属专业', - school varchar(32) null comment '毕业院校', - begin_date date null comment '入职日期', - work_id char(8) null comment '工号' -) charset = utf8; +# create table swpu_userliyan +# ( +# id varchar(100) not null comment '主键ID' +# primary key, +# department_id int null comment '所属部门', +# job_level_id int null comment '职称ID', +# posId int null comment '职位ID', +# engage_form varchar(8) null comment '聘用形式', +# specialty varchar(32) null comment '所属专业', +# school varchar(32) null comment '毕业院校', +# begin_date date null comment '入职日期', +# work_id char(8) null comment '工号' +# ) charset = utf8; diff --git a/swpu-spring-projects-boot/src/main/java/com/swpu/SwpuSpringProjectsApplication.java b/swpu-spring-projects-boot/src/main/java/com/swpu/PersonApplication.java similarity index 83% rename from swpu-spring-projects-boot/src/main/java/com/swpu/SwpuSpringProjectsApplication.java rename to swpu-spring-projects-boot/src/main/java/com/swpu/PersonApplication.java index 27dddf7..0b93890 100644 --- a/swpu-spring-projects-boot/src/main/java/com/swpu/SwpuSpringProjectsApplication.java +++ b/swpu-spring-projects-boot/src/main/java/com/swpu/PersonApplication.java @@ -14,14 +14,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * */ @SpringBootApplication -public class SwpuSpringProjectsApplication { +public class PersonApplication { /** * 主函数 仅仅只比我们的 Java-Base-Projects 项目多了一个 Spring 自己的 方法调用 * @param args */ public static void main(String[] args) { - SpringApplication.run(SwpuSpringProjectsApplication.class, args); + SpringApplication.run(PersonApplication.class, args); } } diff --git a/swpu-spring-projects-boot/src/main/java/com/swpu/entity/PersonEntity.java b/swpu-spring-projects-boot/src/main/java/com/swpu/entity/PersonEntity.java new file mode 100644 index 0000000..a373914 --- /dev/null +++ b/swpu-spring-projects-boot/src/main/java/com/swpu/entity/PersonEntity.java @@ -0,0 +1,5 @@ +package com.swpu.entity; + +public class PersonEntity { + +} diff --git a/swpu-spring-projects-boot/src/main/resources/application.yml b/swpu-spring-projects-boot/src/main/resources/application.yml index 8594e42..6074415 100644 --- a/swpu-spring-projects-boot/src/main/resources/application.yml +++ b/swpu-spring-projects-boot/src/main/resources/application.yml @@ -1,5 +1,10 @@ spring: application: name: swpu-spring-projects + + + + + server: port: 20000 diff --git a/swpu-springboot-liyan-projects/pom.xml b/swpu-springboot-liyan-projects/pom.xml new file mode 100644 index 0000000..c691c42 --- /dev/null +++ b/swpu-springboot-liyan-projects/pom.xml @@ -0,0 +1,37 @@ + + + + swpu-spring-projects + com.swpu + 0.0.1-SNAPSHOT + + 4.0.0 + + swpu-springboot-liyan-projects + + + 11 + 11 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.2 + + + + org.projectlombok + lombok + + + + + + + \ No newline at end of file diff --git a/swpu-springboot-liyan-projects/src/main/java/com/swpu/SwpuSpringAppAplication.java b/swpu-springboot-liyan-projects/src/main/java/com/swpu/SwpuSpringAppAplication.java new file mode 100644 index 0000000..0b93201 --- /dev/null +++ b/swpu-springboot-liyan-projects/src/main/java/com/swpu/SwpuSpringAppAplication.java @@ -0,0 +1,7 @@ +package com.swpu; + +public class SwpuSpringAppAplication { + public static void main(String[] args) { + + } +} -- Gitee From 520adbb1af30fd75820ba96570bff917e7e975fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=87=95?= <1851502614@qq.com> Date: Wed, 21 Jul 2021 09:06:50 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=8A=B6=E6=80=81--mvc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swpu/controller/SwpuAuthController.java | 147 ++++++++++++++++++ .../main/java/com/swpu/dao/SwpuAuthDao.java | 54 +++++++ .../java/com/swpu/entity/SwpuAuthEntity.java | 32 ++++ 12/src/main/java/com/swpu/util/Result.java | 26 ++++ .../main/resources/mapper/SwpuAuthMapper.xml | 59 +++++++ 5 files changed, 318 insertions(+) create mode 100644 12/src/main/java/com/swpu/controller/SwpuAuthController.java create mode 100644 12/src/main/java/com/swpu/dao/SwpuAuthDao.java create mode 100644 12/src/main/java/com/swpu/entity/SwpuAuthEntity.java create mode 100644 12/src/main/java/com/swpu/util/Result.java create mode 100644 12/src/main/resources/mapper/SwpuAuthMapper.xml diff --git a/12/src/main/java/com/swpu/controller/SwpuAuthController.java b/12/src/main/java/com/swpu/controller/SwpuAuthController.java new file mode 100644 index 0000000..fc59ddb --- /dev/null +++ b/12/src/main/java/com/swpu/controller/SwpuAuthController.java @@ -0,0 +1,147 @@ +package com.swpu.controller; + +import com.swpu.dao.SwpuAuthDao; +import com.swpu.entity.SwpuAuthEntity; +import com.swpu.util.Result; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; +import java.util.UUID; + +@RestController +@RequestMapping(value = "/libuli") + + +public class SwpuAuthController { + + @Resource + private SwpuAuthDao swpuAuthDao; + + + @GetMapping(value = "/findAll") + public Result findAll(){ + + Result result = new Result(); + List list =null; + try { + list = swpuAuthDao.findAll(); + } catch (Exception e) { + result.setStatus(false); + result.setData(-1); + result.setMessage(e.getMessage()); + } + if(list!=null){ + result.setStatus(true); + result.setData(list); + result.setMessage("查找相符"); + } + else{ + result.setStatus(false); + result.setData(-1); + result.setMessage("没有相符的"); + } + + return result; + } + + + @GetMapping(value = "/login") + public Result findByUserAndPassword(@RequestParam ("username") String userName, @RequestParam("password") String password){ + + Result result = new Result(); + SwpuAuthEntity X = swpuAuthDao.findByUserAndPassword(userName, password); + if(X!=null){ + result.setStatus(true); + result.setData(X); + result.setMessage("查找相符"); + } + else{ + result.setStatus(false); + result.setData(-1); + result.setMessage("没有相符的"); + } + return result; + } + + @PostMapping(value = "/register") + public Result insert(@RequestBody SwpuAuthEntity entity){ + + Result result = new Result(); + String id = UUID.randomUUID().toString().replace("_",""); + entity.setId(id); + + int flag = 0; + try { + flag = swpuAuthDao.insert(entity); + + } + + catch (Exception e) { + result.setStatus(false); + result.setData(-1); + result.setMessage(e.getMessage()); + } + if(flag >0){ + result.setStatus(true); + result.setData(1); + result.setMessage("已插入"); + } + else{ + result.setStatus(false); + result.setData(-1); + result.setMessage("插入失败"); } + + + + + + return result; + + } + + @PutMapping(value = "/update") + public Result update(@RequestBody SwpuAuthEntity entity){ + + Result result = new Result(); + int flag = 0; + try { + flag = swpuAuthDao.update(entity); + } catch (Exception e) { + result.setStatus(false); + result.setData(-1); + result.setMessage(e.getMessage()); + } + if(flag >0){ + result.setStatus(true); + result.setData(1); + result.setMessage("已更新"); + } + else{ + result.setStatus(false); + result.setData(-1); + result.setMessage("更新失败"); + + } + return result; + } + + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam("id") String id){ + + Result result = new Result(); + int flag = swpuAuthDao.delete(id); + if(flag >0){ + result.setStatus(true); + result.setData(1); + result.setMessage("已删除"); + } + else{ + result.setStatus(false); + result.setData(-1); + result.setMessage("删除失败"); + } + return result; + } + +} diff --git a/12/src/main/java/com/swpu/dao/SwpuAuthDao.java b/12/src/main/java/com/swpu/dao/SwpuAuthDao.java new file mode 100644 index 0000000..346b122 --- /dev/null +++ b/12/src/main/java/com/swpu/dao/SwpuAuthDao.java @@ -0,0 +1,54 @@ +package com.swpu.dao; + +import com.swpu.entity.SwpuAuthEntity; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author wales + *

+ * 第一阶段 - DAO + */ +public interface SwpuAuthDao { + + /** + * 查询所有 + * + * @return {@link SwpuAuthEntity} + */ + List findAll(); + + /** + * 根据 用户名 和 密码 查询数据库数据 + * + * @param username 用户名 + * @param password 密码 + * @return {@link SwpuAuthEntity} + */ + SwpuAuthEntity findByUserAndPassword(@Param("userName") String username, @Param("password") String password); + + /** + * 增加操作 + * + * @param entity {@link SwpuAuthEntity} + * @return {@link Integer} + */ + int insert(SwpuAuthEntity entity); + + /** + * 修改操作 + * + * @param entity {@link SwpuAuthEntity} + * @return {@link Integer} + */ + int update(SwpuAuthEntity entity); + + /** + * 删除操作 + * + * @param id id + * @return {@link Integer} + */ + int delete(@Param("id") String id); +} diff --git a/12/src/main/java/com/swpu/entity/SwpuAuthEntity.java b/12/src/main/java/com/swpu/entity/SwpuAuthEntity.java new file mode 100644 index 0000000..a85eb79 --- /dev/null +++ b/12/src/main/java/com/swpu/entity/SwpuAuthEntity.java @@ -0,0 +1,32 @@ +package com.swpu.entity; + +import lombok.Data; + +/** + * @author wales + *

+ * 用户信息验证表 + */ +@Data +public class SwpuAuthEntity { + + /** + * ID + */ + private String id; + + /** + * 用户名 + */ + private String userName; + + /** + * 密码 + */ + private String password; + + /** + * 学校 + */ + private String school; +} diff --git a/12/src/main/java/com/swpu/util/Result.java b/12/src/main/java/com/swpu/util/Result.java new file mode 100644 index 0000000..bdcb1db --- /dev/null +++ b/12/src/main/java/com/swpu/util/Result.java @@ -0,0 +1,26 @@ +package com.swpu.util; + +import lombok.Data; + +/** + * @author wales + *

+ * 自定义的返回值 + *

+ * 目的是为了告诉前端当前的数据是否正确,并作出相应的处理 + * + *

    + *
  • 1. 如果后台当前数据是正确的,那么 status 赋值为 true、反之为 false
  • + *
  • 2. 如果 status 为 true,那么就需要将返回的数据赋值给 data,所有正确的数据都存放在 data 中,一并返回给前端
  • + *
  • 3. 如果 status 为 false,那么 data 中则不需要存任何数据,可以象征性的给 data 赋值为 -1,只要需要给 message 赋值,告诉前端错误的内容、理由
  • + *
+ */ +@Data +public class Result { + + private boolean status; + + private Object data; + + private String message; +} diff --git a/12/src/main/resources/mapper/SwpuAuthMapper.xml b/12/src/main/resources/mapper/SwpuAuthMapper.xml new file mode 100644 index 0000000..aeabd6e --- /dev/null +++ b/12/src/main/resources/mapper/SwpuAuthMapper.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + id, username, password, school + + + + + + + + + + + insert into swpu_auths (id, username, password, school) + values (#{id, javaType = String}, #{userName, javaType = String}, + #{password, javaType = String}, #{school, javaType = String}) + + + + + update swpu_auths + set username = #{userName, javaType = String}, + password = #{password, javaType = String}, + school = #{school, javaType = String} + where id = #{id, javaType = String} + + + + + delete + from swpu_auths sa + where 1 = 1 + and sa.id = #{id, javaType = String} + + -- Gitee