Browse Source

后端框架第三版接口

Houduan1
huangqizhen 5 months ago
parent
commit
67401a998c
  1. 9
      demo/admin/src/main/resources/application.yml
  2. 9
      demo/audit/src/main/resources/application.yml
  3. 2
      demo/commons/src/main/java/com/example/commons/sevice/RefundService.java
  4. 9
      demo/consume/src/main/resources/application.yml
  5. 2
      demo/recharge/src/main/java/com/example/recharge/mapper/RechargeMapper.java
  6. 9
      demo/recharge/src/main/resources/application.yml
  7. 17
      demo/refund/src/main/java/com/example/refund/controller/RefundController.java
  8. 12
      demo/refund/src/main/java/com/example/refund/mapper/RefundMapper.java
  9. 5
      demo/refund/src/main/java/com/example/refund/service/RefundServiceImpl.java
  10. 9
      demo/refund/src/main/resources/application.yml
  11. 8
      demo/statistics/pom.xml
  12. 10
      demo/statistics/src/main/resources/application.yml
  13. 9
      demo/user/src/main/resources/application.yml

9
demo/admin/src/main/resources/application.yml

@ -3,8 +3,13 @@ server:
spring: spring:
datasource: datasource:
hikari:
maximum-pool-size: 50
hikari: # HikariCP连接池配置
maximum-pool-size: 10 # 最大连接数
minimum-idle: 5 # 最小空闲连接数
idle-timeout: 30000 # 空闲连接超时时间(毫秒)
max-lifetime: 1800000 # 连接最大存活时间(毫秒)
connection-timeout: 30000 # 连接超时时间(毫秒)
pool-name: HwgoldHikariCP # 连接池名称
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8 url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8
username: hwgold username: hwgold

9
demo/audit/src/main/resources/application.yml

@ -3,8 +3,13 @@ server:
spring: spring:
datasource: datasource:
hikari:
maximum-pool-size: 50
hikari: # HikariCP连接池配置
maximum-pool-size: 10 # 最大连接数
minimum-idle: 5 # 最小空闲连接数
idle-timeout: 30000 # 空闲连接超时时间(毫秒)
max-lifetime: 1800000 # 连接最大存活时间(毫秒)
connection-timeout: 30000 # 连接超时时间(毫秒)
pool-name: HwgoldHikariCP # 连接池名称
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8 url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8
username: hwgold username: hwgold

2
demo/commons/src/main/java/com/example/commons/sevice/RefundService.java

@ -1,6 +1,7 @@
package com.example.commons.sevice; package com.example.commons.sevice;
import com.example.commons.domain.entity.Detail; import com.example.commons.domain.entity.Detail;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -11,6 +12,7 @@ public interface RefundService {
int add(Detail detail) ; int add(Detail detail) ;
int addAudit(Detail detail); int addAudit(Detail detail);
void edit(Detail newDetail) ; void edit(Detail newDetail) ;
boolean existsByContactId(Integer contactId);
int softDelete(Integer detailId) ; int softDelete(Integer detailId) ;
Detail selectByDetailId(Integer detailId); Detail selectByDetailId(Integer detailId);
List<Detail> search(Detail detail); List<Detail> search(Detail detail);

9
demo/consume/src/main/resources/application.yml

@ -3,8 +3,13 @@ server:
spring: spring:
datasource: datasource:
hikari:
maximum-pool-size: 50
hikari: # HikariCP连接池配置
maximum-pool-size: 10 # 最大连接数
minimum-idle: 5 # 最小空闲连接数
idle-timeout: 30000 # 空闲连接超时时间(毫秒)
max-lifetime: 1800000 # 连接最大存活时间(毫秒)
connection-timeout: 30000 # 连接超时时间(毫秒)
pool-name: HwgoldHikariCP # 连接池名称
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://39.101.133.168:3306/hwgold?serverTimezone=GMT%2b8&serverTimezone=Asia/Shanghai url: jdbc:mysql://39.101.133.168:3306/hwgold?serverTimezone=GMT%2b8&serverTimezone=Asia/Shanghai
username: hwgold username: hwgold

2
demo/recharge/src/main/java/com/example/recharge/mapper/RechargeMapper.java

@ -49,7 +49,7 @@ public interface RechargeMapper {
}) })
List<RechargeVo> select(RechargeVo rechargeVo); List<RechargeVo> select(RechargeVo rechargeVo);
//根据jwcode和充值类型判断有没有有首充标识设为0否者设为1 //根据jwcode和充值类型判断有没有有首充标识设为0否者设为1
@Select({"select * from detail",
@Select({"select count(*) from detail",
"where jwcode=#{jwcode} and update_type='充值'"}) "where jwcode=#{jwcode} and update_type='充值'"})
int getAllByjwAndup(String jwcode); int getAllByjwAndup(String jwcode);
} }

9
demo/recharge/src/main/resources/application.yml

@ -3,8 +3,13 @@ server:
spring: spring:
datasource: datasource:
hikari:
maximum-pool-size: 50
hikari: # HikariCP连接池配置
maximum-pool-size: 10 # 最大连接数
minimum-idle: 5 # 最小空闲连接数
idle-timeout: 30000 # 空闲连接超时时间(毫秒)
max-lifetime: 1800000 # 连接最大存活时间(毫秒)
connection-timeout: 30000 # 连接超时时间(毫秒)
pool-name: HwgoldHikariCP # 连接池名称
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8 url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8
username: hwgold username: hwgold

17
demo/refund/src/main/java/com/example/refund/controller/RefundController.java

@ -1,17 +1,16 @@
package com.example.refund.controller; package com.example.refund.controller;
import com.example.commons.domain.entity.Detail; import com.example.commons.domain.entity.Detail;
import com.example.commons.domain.vo.Page; import com.example.commons.domain.vo.Page;
import com.example.commons.domain.vo.Result; import com.example.commons.domain.vo.Result;
import com.example.commons.sevice.RefundService; import com.example.commons.sevice.RefundService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Arrays; import java.util.Arrays;
@RestController @RestController
@ -25,6 +24,9 @@ public class RefundController {
@PostMapping("/add") @PostMapping("/add")
public Result add(@RequestBody Detail detail) { public Result add(@RequestBody Detail detail) {
// try { // try {
if (refundService.existsByContactId(detail.getContactId())) {
return Result.error("该订单已退款: " + detail.getContactId());
}
refundService.add(detail); refundService.add(detail);
refundService.addAudit(detail); refundService.addAudit(detail);
return Result.success(); return Result.success();
@ -37,6 +39,12 @@ public class RefundController {
@PostMapping("/softDelete") @PostMapping("/softDelete")
public Result softDelete(@RequestParam Integer detailId) { public Result softDelete(@RequestParam Integer detailId) {
// try { // try {
// 获取旧的明细记录
Detail oldDetail = refundService.selectByDetailId(detailId);
if (oldDetail == null || oldDetail.getDetailFlag() ==0) {
return Result.error("该订单不存在: " + detailId);
}
refundService.softDelete(detailId); refundService.softDelete(detailId);
return Result.success(); return Result.success();
// } catch (Exception e) { // } catch (Exception e) {
@ -51,8 +59,7 @@ public class RefundController {
refundService.edit(newDetail); refundService.edit(newDetail);
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
log.error(e.getMessage());
log.warn(Arrays.toString(e.getStackTrace()));
return Result.error(e.getMessage()); return Result.error(e.getMessage());
} }
} }

12
demo/refund/src/main/java/com/example/refund/mapper/RefundMapper.java

@ -10,21 +10,25 @@ public interface RefundMapper {
@Insert({ @Insert({
"insert into detail", "insert into detail",
"(jwcode,refund_type,refund_goods,recharge_coin,free_coin,task_coin,remark,admin_id,create_time,update_type)",
"(jwcode,refund_type,refund_goods,contact_id,recharge_coin,free_coin,task_coin,remark,admin_id,create_time,update_type)",
"values", "values",
"(#{jwcode},#{refundType},#{refundGoods},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),'退款')"
"(#{jwcode},#{refundType},#{refundGoods},#{contactId},#{rechargeCoin},#{freeCoin},#{taskCoin},#{remark},#{adminId},now(),'退款')"
}) })
@Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId") @Options(useGeneratedKeys = true, keyColumn = "detail_id", keyProperty = "detailId")
int insert(Detail detail); int insert(Detail detail);
@Select({
@Insert({
"insert into audit", "insert into audit",
"(jwcode,refund_id,admin_id,create_time,detail_id)", "(jwcode,refund_id,admin_id,create_time,detail_id)",
"values", "values",
"(,#{jwcode},#{refundId},#{adminId},now(),#{detailId})"
"(#{jwcode},#{detailId},#{adminId},now(),#{detailId})"
}) })
int insertAudit(Detail detail); int insertAudit(Detail detail);
// 检查 contactId 是否存在
@Select("SELECT EXISTS (SELECT 1 FROM detail WHERE contact_id = #{contactId})")
boolean existsByContactId(@Param("contactId") Integer contactId);
@Update("update detail set detail_flag = 0 where detail_id = #{detailId}") @Update("update detail set detail_flag = 0 where detail_id = #{detailId}")
int update(@Param("detailId") Integer detailId); int update(@Param("detailId") Integer detailId);

5
demo/refund/src/main/java/com/example/refund/service/RefundServiceImpl.java

@ -58,6 +58,11 @@ public class RefundServiceImpl implements RefundService {
} }
@Override @Override
public boolean existsByContactId(Integer contactId) {
return refundMapper.existsByContactId(contactId);
}
@Override
public int softDelete(Integer detailId) { public int softDelete(Integer detailId) {
return refundMapper.update(detailId); return refundMapper.update(detailId);
} }

9
demo/refund/src/main/resources/application.yml

@ -3,8 +3,13 @@ server:
spring: spring:
datasource: datasource:
hikari:
maximum-pool-size: 50
hikari: # HikariCP连接池配置
maximum-pool-size: 10 # 最大连接数
minimum-idle: 5 # 最小空闲连接数
idle-timeout: 30000 # 空闲连接超时时间(毫秒)
max-lifetime: 1800000 # 连接最大存活时间(毫秒)
connection-timeout: 30000 # 连接超时时间(毫秒)
pool-name: HwgoldHikariCP # 连接池名称
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8 url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8
username: hwgold username: hwgold

8
demo/statistics/pom.xml

@ -66,14 +66,6 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

10
demo/statistics/src/main/resources/application.yml

@ -3,9 +3,13 @@ server:
spring: spring:
datasource: datasource:
hikari:
maximum-pool-size: 50
hikari: # HikariCP连接池配置
maximum-pool-size: 10 # 最大连接数
minimum-idle: 5 # 最小空闲连接数
idle-timeout: 30000 # 空闲连接超时时间(毫秒)
max-lifetime: 1800000 # 连接最大存活时间(毫秒)
connection-timeout: 30000 # 连接超时时间(毫秒)
pool-name: HwgoldHikariCP # 连接池名称
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8 url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8
username: hwgold username: hwgold

9
demo/user/src/main/resources/application.yml

@ -2,8 +2,13 @@ server:
port: 10020 port: 10020
spring: spring:
datasource: datasource:
hikari:
maximum-pool-size: 50
hikari: # HikariCP连接池配置
maximum-pool-size: 10 # 最大连接数
minimum-idle: 5 # 最小空闲连接数
idle-timeout: 30000 # 空闲连接超时时间(毫秒)
max-lifetime: 1800000 # 连接最大存活时间(毫秒)
connection-timeout: 30000 # 连接超时时间(毫秒)
pool-name: HwgoldHikariCP # 连接池名称
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8 url: jdbc:mysql://39.101.133.168/hwgold?serverTimezone=GMT%2b8
username: hwgold username: hwgold

Loading…
Cancel
Save