提交 18ec6bcc authored 作者: Whispa's avatar Whispa

Merge remote-tracking branch 'origin/master'

package com.example.afrishop_v3.controllers; package com.example.afrishop_v3.controllers;
import com.example.afrishop_v3.base.Result; import com.example.afrishop_v3.base.Result;
import com.example.afrishop_v3.models.TbCfProblem;
import com.example.afrishop_v3.repository.TbCfProblemRepository; import com.example.afrishop_v3.repository.TbCfProblemRepository;
import org.springframework.beans.factory.parsing.Problem;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import java.net.URLDecoder;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/problem") @RequestMapping("/problem")
...@@ -17,12 +18,24 @@ public class ProblemController { ...@@ -17,12 +18,24 @@ public class ProblemController {
this.repository = repository; this.repository = repository;
} }
// type 0:Problem 1:ShippingClause
@GetMapping @GetMapping
public Result getProblemList(@RequestParam(required = false) Integer pageNum, public Result getProblemList(@RequestParam(required = false) Integer pageNum,
@RequestParam(required = false) Integer pageSize) { @RequestParam(required = false) Integer pageSize) {
pageNum = pageNum == null ? 1 : pageNum; pageNum = pageNum == null ? 1 : pageNum;
pageSize = pageSize == null ? 10 : pageSize; pageSize = pageSize == null ? 10 : pageSize;
return new Result<>(repository.findAll(PageRequest.of(pageNum,pageSize))); return new Result<>(repository.findAll(PageRequest.of(pageNum, pageSize)));
}
@GetMapping("/{type}")
public Result getShippingClause(@PathVariable Integer type) throws Exception {
TbCfProblem clause = repository.findFirstByType(type);
String shippingClause = URLDecoder.decode(clause.getAnswer(), "utf-8");
TbCfProblem problem = new TbCfProblem();
problem.setQuestion(clause.getQuestion());
problem.setAnswer(shippingClause);
return new Result(problem);
} }
} }
...@@ -37,6 +37,16 @@ public class TbCfProblem { ...@@ -37,6 +37,16 @@ public class TbCfProblem {
*/ */
private Date createTime; private Date createTime;
private Integer type;
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
/** /**
* 设置:问题id * 设置:问题id
*/ */
...@@ -50,6 +60,7 @@ public class TbCfProblem { ...@@ -50,6 +60,7 @@ public class TbCfProblem {
public String getProblemId() { public String getProblemId() {
return problemId; return problemId;
} }
/** /**
* 设置:问题明细 * 设置:问题明细
*/ */
...@@ -63,6 +74,7 @@ public class TbCfProblem { ...@@ -63,6 +74,7 @@ public class TbCfProblem {
public String getQuestion() { public String getQuestion() {
return question; return question;
} }
/** /**
* 设置:答案 * 设置:答案
*/ */
...@@ -76,6 +88,7 @@ public class TbCfProblem { ...@@ -76,6 +88,7 @@ public class TbCfProblem {
public String getAnswer() { public String getAnswer() {
return answer; return answer;
} }
/** /**
* 设置:是否展示 * 设置:是否展示
*/ */
...@@ -89,6 +102,7 @@ public class TbCfProblem { ...@@ -89,6 +102,7 @@ public class TbCfProblem {
public Integer getEnableFlag() { public Integer getEnableFlag() {
return enableFlag; return enableFlag;
} }
/** /**
* 设置:创建时间 * 设置:创建时间
*/ */
......
...@@ -3,5 +3,7 @@ package com.example.afrishop_v3.repository; ...@@ -3,5 +3,7 @@ package com.example.afrishop_v3.repository;
import com.example.afrishop_v3.models.TbCfProblem; import com.example.afrishop_v3.models.TbCfProblem;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
public interface TbCfProblemRepository extends PagingAndSortingRepository<TbCfProblem,String> { public interface TbCfProblemRepository extends PagingAndSortingRepository<TbCfProblem, String> {
TbCfProblem findFirstByType(Integer type);
} }
spring: spring:
datasource: datasource:
url: jdbc:mysql://47.106.242.175:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC url: jdbc:mysql://159.138.48.71:3306/chinafrica_ref?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
username: root username: root
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
password: diaoyun666 password: Diaoyunnuli.8
redis: redis:
#Redis数据库分片索引(默认为0) #Redis数据库分片索引(默认为0)
......
server.servlet.context-path=/zion server.servlet.context-path=/afrishop
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
server.port = 7000 server.port = 8099
#spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC #spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
#spring.datasource.username=root #spring.datasource.username=root
#spring.datasource.password=Diaoyunnuli.8 #spring.datasource.password=Diaoyunnuli.8
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论