commit
bc2911b5ab
17 changed files with 684 additions and 0 deletions
-
33.gitignore
-
74crowdfunding_system.sql
-
93pom.xml
-
14src/main/java/com/lh/CrowdfundingSystemApplication.java
-
27src/main/java/com/lh/bean/CrowdfundingInfo.java
-
23src/main/java/com/lh/bean/Participant.java
-
82src/main/java/com/lh/bean/RespBean.java
-
25src/main/java/com/lh/config/ParamExceptionHandler.java
-
62src/main/java/com/lh/controller/CrowdfundingController.java
-
7src/main/java/com/lh/exception/MyException.java
-
35src/main/java/com/lh/mapper/CrowdfundingMapper.java
-
27src/main/java/com/lh/service/CrowdfundingService.java
-
82src/main/java/com/lh/service/CrowdfundingServiceImpl.java
-
29src/main/resources/application.properties
-
36src/main/resources/com/lh/mapper/CrowdfundingMapper.xml
-
6src/main/resources/static/index.html
-
29src/test/java/com/lh/CrowdfundingSystemApplicationTests.java
@ -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,74 @@ |
|||
/* |
|||
Navicat Premium Data Transfer |
|||
|
|||
Source Server : test |
|||
Source Server Type : MySQL |
|||
Source Server Version : 80026 (8.0.26) |
|||
Source Host : localhost:3306 |
|||
Source Schema : crowdfunding_system |
|||
|
|||
Target Server Type : MySQL |
|||
Target Server Version : 80026 (8.0.26) |
|||
File Encoding : 65001 |
|||
|
|||
Date: 20/12/2024 15:52:53 |
|||
*/ |
|||
|
|||
SET NAMES utf8mb4; |
|||
SET FOREIGN_KEY_CHECKS = 0; |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for crowdfundinginfo |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS `crowdfundinginfo`; |
|||
CREATE TABLE `crowdfundinginfo` ( |
|||
`id` int NOT NULL AUTO_INCREMENT, |
|||
`title` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, |
|||
`target_number` int NOT NULL, |
|||
`now_number` int NOT NULL, |
|||
`status` int NOT NULL, |
|||
PRIMARY KEY (`id`) USING BTREE |
|||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; |
|||
|
|||
-- ---------------------------- |
|||
-- Records of crowdfundinginfo |
|||
-- ---------------------------- |
|||
INSERT INTO `crowdfundinginfo` VALUES (1, '请给我钱', 100, 5, 1); |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for participants |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS `participants`; |
|||
CREATE TABLE `participants` ( |
|||
`id` int NOT NULL AUTO_INCREMENT, |
|||
`jwcode` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, |
|||
`identity` int NOT NULL, |
|||
`creat_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
|||
PRIMARY KEY (`id`) USING BTREE |
|||
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; |
|||
|
|||
-- ---------------------------- |
|||
-- Records of participants |
|||
-- ---------------------------- |
|||
INSERT INTO `participants` VALUES (6, '10052', 0, '2024-12-20 14:59:29'); |
|||
|
|||
-- ---------------------------- |
|||
-- Table structure for participants_del_save |
|||
-- ---------------------------- |
|||
DROP TABLE IF EXISTS `participants_del_save`; |
|||
CREATE TABLE `participants_del_save` ( |
|||
`id` int NOT NULL AUTO_INCREMENT, |
|||
`jwcode` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, |
|||
`identity` int NOT NULL, |
|||
`creat_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
|||
PRIMARY KEY (`id`) USING BTREE |
|||
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic; |
|||
|
|||
-- ---------------------------- |
|||
-- Records of participants_del_save |
|||
-- ---------------------------- |
|||
INSERT INTO `participants_del_save` VALUES (5, '10012', 1, '2024-12-20 14:59:42'); |
|||
INSERT INTO `participants_del_save` VALUES (6, '10010', 1, '2024-12-20 15:00:48'); |
|||
INSERT INTO `participants_del_save` VALUES (7, '10011', 1, '2024-12-20 15:24:18'); |
|||
|
|||
SET FOREIGN_KEY_CHECKS = 1; |
@ -0,0 +1,93 @@ |
|||
<?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.lh</groupId> |
|||
<artifactId>crowdfunding_system</artifactId> |
|||
<version>0.0.1-SNAPSHOT</version> |
|||
<name>crowdfunding_system</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.4.2</spring-boot.version> |
|||
</properties> |
|||
<dependencies> |
|||
<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> |
|||
<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> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>mysql</groupId> |
|||
<artifactId>mysql-connector-java</artifactId> |
|||
<scope>runtime</scope> |
|||
</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.lh.CrowdfundingSystemApplication</mainClass> |
|||
<skip>true</skip> |
|||
</configuration> |
|||
<executions> |
|||
<execution> |
|||
<id>repackage</id> |
|||
<goals> |
|||
<goal>repackage</goal> |
|||
</goals> |
|||
</execution> |
|||
</executions> |
|||
</plugin> |
|||
</plugins> |
|||
</build> |
|||
|
|||
</project> |
@ -0,0 +1,14 @@ |
|||
package com.lh; |
|||
|
|||
import org.mybatis.spring.annotation.MapperScan; |
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
@MapperScan(basePackages = "com.lh.mapper") |
|||
@SpringBootApplication |
|||
public class CrowdfundingSystemApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(CrowdfundingSystemApplication.class, args); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.lh.bean; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
@NoArgsConstructor |
|||
@AllArgsConstructor |
|||
@Data |
|||
public class CrowdfundingInfo implements Serializable { |
|||
private Integer id; |
|||
|
|||
private String title; |
|||
|
|||
private Integer targetNumber; |
|||
|
|||
private Integer nowNumber; |
|||
|
|||
private Integer status; |
|||
|
|||
private List<Participant> participantList; |
|||
|
|||
|
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.lh.bean; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@Data |
|||
public class Participant implements Serializable { |
|||
|
|||
private Integer id; |
|||
|
|||
private String jwcode; |
|||
|
|||
private Integer identity; |
|||
|
|||
private Date creatTime; |
|||
|
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.lh.bean; |
|||
|
|||
public class RespBean { |
|||
//状态码 10000-成功 10001-失败 |
|||
private Integer code; |
|||
//返回的附件信息 |
|||
private String msg; |
|||
//返回的数据 |
|||
private Object data; |
|||
|
|||
public Integer getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(Integer code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getMsg() { |
|||
return msg; |
|||
} |
|||
|
|||
public void setMsg(String msg) { |
|||
this.msg = msg; |
|||
} |
|||
|
|||
public Object getData() { |
|||
return data; |
|||
} |
|||
|
|||
public void setData(Object data) { |
|||
this.data = data; |
|||
} |
|||
|
|||
public static RespBean ok() { |
|||
RespBean respBean = new RespBean(); |
|||
respBean.setCode(10000); |
|||
|
|||
return respBean; |
|||
} |
|||
|
|||
public static RespBean ok(String msg) { |
|||
RespBean respBean = new RespBean(); |
|||
respBean.setCode(10000); |
|||
respBean.setMsg(msg); |
|||
|
|||
return respBean; |
|||
} |
|||
|
|||
public static RespBean ok(String msg, Object data) { |
|||
RespBean respBean = new RespBean(); |
|||
respBean.setCode(10000); |
|||
respBean.setMsg(msg); |
|||
respBean.setData(data); |
|||
|
|||
return respBean; |
|||
} |
|||
|
|||
public static RespBean error() { |
|||
RespBean respBean = new RespBean(); |
|||
respBean.setCode(10001); |
|||
|
|||
return respBean; |
|||
} |
|||
|
|||
public static RespBean error(String msg) { |
|||
RespBean respBean = new RespBean(); |
|||
respBean.setCode(10001); |
|||
respBean.setMsg(msg); |
|||
|
|||
return respBean; |
|||
} |
|||
|
|||
public static RespBean error(String msg, Object data) { |
|||
RespBean respBean = new RespBean(); |
|||
respBean.setCode(10001); |
|||
respBean.setMsg(msg); |
|||
respBean.setData(data); |
|||
|
|||
return respBean; |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.lh.config; |
|||
|
|||
import com.lh.bean.RespBean; |
|||
import com.lh.exception.MyException; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.web.bind.annotation.ExceptionHandler; |
|||
import org.springframework.web.bind.annotation.RestControllerAdvice; |
|||
|
|||
@Configuration |
|||
@RestControllerAdvice |
|||
public class ParamExceptionHandler { |
|||
@ExceptionHandler(MyException.class) |
|||
public RespBean myException(MyException e){ |
|||
e.printStackTrace(); |
|||
return RespBean.error(e.getMessage()); |
|||
} |
|||
|
|||
@ExceptionHandler(Exception.class) |
|||
public RespBean exception(Exception e){ |
|||
e.printStackTrace(); |
|||
return RespBean.error("未知错误,请联系管理员"); |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
package com.lh.controller; |
|||
|
|||
import com.lh.bean.CrowdfundingInfo; |
|||
import com.lh.bean.Participant; |
|||
import com.lh.bean.RespBean; |
|||
import com.lh.exception.MyException; |
|||
import com.lh.service.CrowdfundingService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
@CrossOrigin |
|||
@RestController |
|||
@RequestMapping |
|||
public class CrowdfundingController { |
|||
|
|||
@Autowired |
|||
private CrowdfundingService crowdfundingService; |
|||
|
|||
// 加载页面 |
|||
@GetMapping("/page") |
|||
public RespBean loadPage() { |
|||
CrowdfundingInfo crowdfundingInfo = crowdfundingService.loadPage(); |
|||
return RespBean.ok("请求成功",crowdfundingInfo); |
|||
} |
|||
|
|||
// 修改标题 |
|||
@PutMapping("/title") |
|||
public RespBean updateTitle(@RequestParam("title") String title) throws MyException { |
|||
crowdfundingService.updateTitle(title); |
|||
return RespBean.ok("修改标题成功"); |
|||
} |
|||
|
|||
// 修改众筹目标 |
|||
@PutMapping("/target") |
|||
public RespBean updateTarget(@RequestParam("targetNumber") Integer targetNumber) throws MyException { |
|||
crowdfundingService.updateTarget(targetNumber); |
|||
return RespBean.ok("修改目标成功"); |
|||
} |
|||
|
|||
// 添加众筹用户 |
|||
@PostMapping("/addUser") |
|||
public RespBean addCrowdUser(@RequestBody Participant participant) throws MyException { |
|||
crowdfundingService.addCrowdUser(participant); |
|||
return RespBean.ok("添加成功"); |
|||
} |
|||
|
|||
// 删除众筹用户 |
|||
@DeleteMapping("/delUser/{jwcode}") |
|||
public RespBean deleteCrowdUser(@PathVariable String jwcode) throws MyException { |
|||
crowdfundingService.deleteCrowdUser(jwcode); |
|||
return RespBean.ok("删除成功"); |
|||
} |
|||
|
|||
// 查询众筹用户 |
|||
@PostMapping("/users") |
|||
public RespBean queryCrowdUser(@RequestBody(required = false) Participant participant) { |
|||
List<Participant> participants = crowdfundingService.queryCrowdUser(participant); |
|||
return RespBean.ok("查询成功",participants); |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
package com.lh.exception; |
|||
|
|||
public class MyException extends Exception{ |
|||
public MyException(String msg){ |
|||
super(msg); |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
package com.lh.mapper; |
|||
|
|||
import com.lh.bean.CrowdfundingInfo; |
|||
import com.lh.bean.Participant; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
@Mapper |
|||
public interface CrowdfundingMapper { |
|||
//加载页面 |
|||
CrowdfundingInfo loadPage(); |
|||
|
|||
//修改标题 |
|||
void updateTitle(String title); |
|||
|
|||
//修改众筹目标 |
|||
void updateTarget(Integer target); |
|||
|
|||
//当前众筹数量+1 |
|||
void updateNowNumber(); |
|||
|
|||
//添加众筹用户 |
|||
void addCrowdUser(Participant participant); |
|||
|
|||
//删除众筹用户 |
|||
void deleteCrowdUser(String jwcode); |
|||
|
|||
//删除用户添加到另一个表 |
|||
void saveDeleteCrowdUser(Participant participant); |
|||
|
|||
//查询众筹用户 |
|||
List<Participant> queryCrowdUser(Participant participant); |
|||
|
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.lh.service; |
|||
|
|||
import com.lh.bean.CrowdfundingInfo; |
|||
import com.lh.bean.Participant; |
|||
import com.lh.exception.MyException; |
|||
|
|||
import java.util.List; |
|||
|
|||
public interface CrowdfundingService { |
|||
//加载页面 |
|||
CrowdfundingInfo loadPage(); |
|||
|
|||
//修改标题 |
|||
void updateTitle(String title) throws MyException; |
|||
|
|||
//修改众筹目标 |
|||
void updateTarget(Integer target) throws MyException; |
|||
|
|||
//添加众筹用户 |
|||
void addCrowdUser(Participant participant) throws MyException; |
|||
|
|||
//删除众筹用户 |
|||
void deleteCrowdUser(String jwcode) throws MyException; |
|||
|
|||
//查询众筹用户 |
|||
List<Participant> queryCrowdUser(Participant participant); |
|||
} |
@ -0,0 +1,82 @@ |
|||
package com.lh.service; |
|||
|
|||
import com.lh.bean.CrowdfundingInfo; |
|||
import com.lh.bean.Participant; |
|||
import com.lh.exception.MyException; |
|||
import com.lh.mapper.CrowdfundingMapper; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
@Service |
|||
public class CrowdfundingServiceImpl implements CrowdfundingService { |
|||
@Autowired |
|||
private CrowdfundingMapper crowdfundingMapper; |
|||
@Override |
|||
public CrowdfundingInfo loadPage() { |
|||
CrowdfundingInfo crowdfundingInfoList = crowdfundingMapper.loadPage(); |
|||
List<Participant> participants = crowdfundingMapper.queryCrowdUser(null); |
|||
crowdfundingInfoList.setParticipantList(participants); |
|||
return crowdfundingInfoList; |
|||
} |
|||
|
|||
@Override |
|||
public void updateTitle(String title) throws MyException { |
|||
if (title.length() == 0) { |
|||
throw new MyException("标题不能为空"); |
|||
} |
|||
crowdfundingMapper.updateTitle(title); |
|||
} |
|||
|
|||
@Override |
|||
public void updateTarget(Integer target) throws MyException { |
|||
//target不能为空 |
|||
if (target == null) { |
|||
throw new MyException("目标不能为空"); |
|||
} |
|||
//target只能输入数字且必须大于0 |
|||
if (target <= 0) { |
|||
throw new MyException("目标必须大于0"); |
|||
} |
|||
if (target.toString().matches("[0-9]+") == false) { |
|||
throw new MyException("目标只能输入数字"); |
|||
} |
|||
crowdfundingMapper.updateTarget(target); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void addCrowdUser(Participant participant) throws MyException { |
|||
//精网号重复 |
|||
if (crowdfundingMapper.queryCrowdUser(new Participant(null,participant.getJwcode(),null,null)) != null) { |
|||
throw new MyException("精网号重复"); |
|||
} |
|||
//精网号不能为空 |
|||
if (participant.getJwcode() == null) { |
|||
throw new MyException("精网号不能为空"); |
|||
} |
|||
//精网号不能为空 |
|||
if (participant.getIdentity() == null) { |
|||
throw new MyException("身份不能为空"); |
|||
} |
|||
crowdfundingMapper.updateNowNumber(); |
|||
crowdfundingMapper.addCrowdUser(participant); |
|||
} |
|||
|
|||
@Override |
|||
public void deleteCrowdUser(String jwcode) throws MyException { |
|||
if (crowdfundingMapper.queryCrowdUser(new Participant(null,jwcode,null,null)) == null) { |
|||
throw new MyException("删除失败,用户不存在"); |
|||
} |
|||
List<Participant> participants = crowdfundingMapper.queryCrowdUser(new Participant(null, jwcode, null, null)); |
|||
Participant participant = participants.get(0); |
|||
crowdfundingMapper.saveDeleteCrowdUser(participant); |
|||
crowdfundingMapper.deleteCrowdUser(jwcode); |
|||
} |
|||
|
|||
@Override |
|||
public List<Participant> queryCrowdUser(Participant participant) { |
|||
return crowdfundingMapper.queryCrowdUser(participant); |
|||
} |
|||
} |
@ -0,0 +1,29 @@ |
|||
# 配置连接池 |
|||
spring.datasource.driver-class-name=com.mysql.jdbc.Driver |
|||
spring.datasource.url=jdbc:mysql://localhost:3306/crowdfunding_system?serverTimezone=UTC |
|||
spring.datasource.username=root |
|||
spring.datasource.password=123456 |
|||
# HikariCP连接池配置 |
|||
spring.datasource.hikari.maximum-pool-size=10 |
|||
spring.datasource.hikari.minimum-idle=5 |
|||
spring.datasource.hikari.idle-timeout=30000 |
|||
spring.datasource.hikari.max-lifetime=1800000 |
|||
spring.datasource.hikari.connection-timeout=30000 |
|||
spring.datasource.hikari.pool-name=HwgoldHikariCP |
|||
|
|||
# mybatis配置 |
|||
# 打印log信息 |
|||
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl |
|||
# 开启驼峰命名法,自动将数据库的命名方式,映射成Java中的命名方式 |
|||
mybatis.configuration.map-underscore-to-camel-case: true |
|||
#下面这些内容是为了让MyBatis映射 |
|||
#指定Mybatis的Mapper文件 |
|||
mybatis.mapper-locations=classpath:mappers/*xml |
|||
#指定Mybatis的实体目录 |
|||
mybatis.type-aliases-package=com.lh.mybatis.entity |
|||
|
|||
# 应用服务 WEB 访问端口 |
|||
server.port=8092 |
|||
|
|||
|
|||
|
@ -0,0 +1,36 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
|||
<mapper namespace="com.lh.mapper.CrowdfundingMapper"> |
|||
<insert id="addCrowdUser"> |
|||
insert into participants (jwcode, identity) values (#{jwcode}, #{identity}) |
|||
</insert> |
|||
<insert id="saveDeleteCrowdUser"> |
|||
insert into participants_del_save (jwcode, identity) values (#{jwcode}, #{identity}) |
|||
</insert> |
|||
<update id="updateTitle"> |
|||
update crowdfundinginfo set title=#{title} |
|||
</update> |
|||
<update id="updateTarget"> |
|||
update crowdfundinginfo set target_number=#{target} |
|||
</update> |
|||
<update id="updateNowNumber"> |
|||
update crowdfundinginfo set now_number=now_number+1 |
|||
</update> |
|||
<delete id="deleteCrowdUser"> |
|||
delete from participants where jwcode=#{jwcode} |
|||
</delete> |
|||
<select id="loadPage" resultType="com.lh.bean.CrowdfundingInfo"> |
|||
select * from crowdfundinginfo |
|||
</select> |
|||
<select id="queryCrowdUser" resultType="com.lh.bean.Participant"> |
|||
select * from participants |
|||
<where> |
|||
<if test="jwcode!=null and jwcode.length>0"> |
|||
jwcode like concat('%',#{jwcode},'%') |
|||
</if> |
|||
<if test="identity!=null"> |
|||
and identity=#{identity} |
|||
</if> |
|||
</where> |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,6 @@ |
|||
<html> |
|||
<body> |
|||
<h1>hello word!!!</h1> |
|||
<p>this is a html page</p> |
|||
</body> |
|||
</html> |
@ -0,0 +1,29 @@ |
|||
package com.lh; |
|||
|
|||
import com.lh.bean.CrowdfundingInfo; |
|||
import com.lh.mapper.CrowdfundingMapper; |
|||
import com.lh.service.CrowdfundingService; |
|||
import org.junit.jupiter.api.Test; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.boot.test.context.SpringBootTest; |
|||
|
|||
@SpringBootTest |
|||
class CrowdfundingSystemApplicationTests { |
|||
@Autowired |
|||
private CrowdfundingMapper crowdfundingMapper; |
|||
|
|||
@Autowired |
|||
private CrowdfundingService crowdfundingService; |
|||
|
|||
@Test |
|||
void contextLoads() { |
|||
CrowdfundingInfo crowdfundingInfo = crowdfundingMapper.loadPage(); |
|||
} |
|||
|
|||
@Test |
|||
void contextLoads1() { |
|||
System.out.println(crowdfundingService.loadPage()); |
|||
} |
|||
|
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue