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

Merge remote-tracking branch 'origin/master'

package com.example.afrishop_v3.controllers;
import com.example.afrishop_v3.base.Result;
import com.example.afrishop_v3.models.TbCfProblem;
import com.example.afrishop_v3.repository.TbCfProblemRepository;
import org.springframework.beans.factory.parsing.Problem;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.net.URLDecoder;
@RestController
@RequestMapping("/problem")
......@@ -17,12 +18,24 @@ public class ProblemController {
this.repository = repository;
}
// type 0:Problem 1:ShippingClause
@GetMapping
public Result getProblemList(@RequestParam(required = false) Integer pageNum,
@RequestParam(required = false) Integer pageSize) {
pageNum = pageNum == null ? 1 : pageNum;
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 {
*/
private Date createTime;
private Integer type;
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
/**
* 设置:问题id
*/
......@@ -50,6 +60,7 @@ public class TbCfProblem {
public String getProblemId() {
return problemId;
}
/**
* 设置:问题明细
*/
......@@ -63,6 +74,7 @@ public class TbCfProblem {
public String getQuestion() {
return question;
}
/**
* 设置:答案
*/
......@@ -76,6 +88,7 @@ public class TbCfProblem {
public String getAnswer() {
return answer;
}
/**
* 设置:是否展示
*/
......@@ -89,6 +102,7 @@ public class TbCfProblem {
public Integer getEnableFlag() {
return enableFlag;
}
/**
* 设置:创建时间
*/
......
......@@ -3,5 +3,7 @@ package com.example.afrishop_v3.repository;
import com.example.afrishop_v3.models.TbCfProblem;
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:
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
driver-class-name: com.mysql.cj.jdbc.Driver
password: diaoyun666
password: Diaoyunnuli.8
redis:
#Redis数据库分片索引(默认为0)
......
server.servlet.context-path=/zion
server.servlet.context-path=/afrishop
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.username=root
#spring.datasource.password=Diaoyunnuli.8
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论