Browse Source
Merge remote-tracking branch 'origin/milestone-20250702-金币重构一期' into milestone-20250702-金币重构一期
huangqizheng/feature-20250626103451-权限页面
Merge remote-tracking branch 'origin/milestone-20250702-金币重构一期' into milestone-20250702-金币重构一期
huangqizheng/feature-20250626103451-权限页面
13 changed files with 361 additions and 24 deletions
-
5pom.xml
-
31src/main/java/com/example/demo/Util/BusinessException.java
-
45src/main/java/com/example/demo/controller/GoldDetailController.java
-
44src/main/java/com/example/demo/domain/vo/GoldDetail.java
-
23src/main/java/com/example/demo/domain/vo/Page.java
-
64src/main/java/com/example/demo/domain/vo/Result.java
-
25src/main/java/com/example/demo/domain/vo/Total.java
-
21src/main/java/com/example/demo/mapper/GoldDetailMapper.java
-
6src/main/java/com/example/demo/security/TokenFilter.java
-
18src/main/java/com/example/demo/service/GoldDetailService.java
-
39src/main/java/com/example/demo/serviceImpl/GoldDetailServiceImpl.java
-
6src/main/resources/application.yml
-
58src/main/resources/mapper/GoldDetailMapper.xml
@ -0,0 +1,31 @@ |
|||||
|
package com.example.demo.Util; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName BusinessException |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2025−06-23 14:58 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
|
||||
|
import lombok.Getter; |
||||
|
|
||||
|
/** |
||||
|
* 业务异常,可抛出到前端 |
||||
|
*/ |
||||
|
@Getter |
||||
|
public class BusinessException extends RuntimeException { |
||||
|
private int code; // 业务状态码 |
||||
|
// 使用默认状态码0的构造方法 |
||||
|
public BusinessException(String message) { |
||||
|
this(400, message); // 默认状态码400 |
||||
|
} |
||||
|
|
||||
|
// 指定状态码的构造方法 |
||||
|
public BusinessException(int code, String message) { |
||||
|
super(message); |
||||
|
this.code = code; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
package com.example.demo.controller; |
||||
|
|
||||
|
import com.example.demo.domain.vo.GoldDetail; |
||||
|
import com.example.demo.domain.vo.Page; |
||||
|
import com.example.demo.domain.vo.Result; |
||||
|
import com.example.demo.service.GoldDetailService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.util.ObjectUtils; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName GoldDetailController |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2025−06-23 14:41 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/goldDetail") |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
@CrossOrigin |
||||
|
public class GoldDetailController { |
||||
|
private final GoldDetailService goldDetailService; |
||||
|
@PostMapping("/getGoldDetail") |
||||
|
public Result getGoldDetail(@RequestBody Page page){ |
||||
|
|
||||
|
if(ObjectUtils.isEmpty(page.getPageNum())){ |
||||
|
return Result.error("页码数为空!"); |
||||
|
} |
||||
|
if(ObjectUtils.isEmpty(page.getPageSize())){ |
||||
|
return Result.error("页大小为空!"); |
||||
|
} |
||||
|
else{ |
||||
|
return Result.success(goldDetailService.getGoldDetail(page.getPageNum(), page.getPageSize(), page.getGoldDetail())); |
||||
|
} |
||||
|
} |
||||
|
@PostMapping("/getTotal") |
||||
|
public Result getTotal(@RequestBody GoldDetail goldDetail) { |
||||
|
return Result.success(goldDetailService.getTotal(goldDetail)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
package com.example.demo.domain.vo; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName GoldDetail |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2025−06-23 13:03 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Data |
||||
|
@NoArgsConstructor |
||||
|
public class GoldDetail { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
private String token; |
||||
|
private String name; // 名称 |
||||
|
private Integer jwcode; // 精网号 |
||||
|
private String market; // 所属地区 |
||||
|
private String payPlatform; // 支付平台 |
||||
|
private Integer type; // 类型 |
||||
|
private Integer sumGold; // 总金币 |
||||
|
private Integer permentGold; //永久金币 |
||||
|
private Integer freeJune; // 免费金币六月到期 |
||||
|
private Integer freeDecember; // 免费金币七月到期 |
||||
|
private Integer taskGold; // 任务金币 |
||||
|
private String adminName; //提交人 |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private Date startTime; // 开始时间 |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd") |
||||
|
private Date endTime; // 结束时间 |
||||
|
private String sortField; //排序字段 |
||||
|
private String sortOrder; //排序顺序 |
||||
|
|
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
package com.example.demo.domain.vo; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName Page |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2025−06-23 16:23 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Data |
||||
|
@NoArgsConstructor |
||||
|
public class Page { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
private Integer pageNum; |
||||
|
private Integer pageSize; |
||||
|
private GoldDetail goldDetail; |
||||
|
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.example.demo.domain.vo; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName Total |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2025−06-23 16:53 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Data |
||||
|
@NoArgsConstructor |
||||
|
public class Total { |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
private String token; |
||||
|
private Integer Goldtotal; |
||||
|
private Integer permanentGold; |
||||
|
private Integer freeGold; |
||||
|
private Integer taskGold; |
||||
|
|
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
package com.example.demo.mapper; |
||||
|
|
||||
|
import com.example.demo.domain.vo.GoldDetail; |
||||
|
import com.example.demo.domain.vo.Total; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName GoldDetailMapper |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2025−06-23 13:47 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Mapper |
||||
|
public interface GoldDetailMapper { |
||||
|
List<GoldDetail> getGoldDetail(GoldDetail goldDetail); |
||||
|
Total getTotal(GoldDetail goldDetail); |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.example.demo.service; |
||||
|
|
||||
|
import com.example.demo.domain.vo.GoldDetail; |
||||
|
import com.example.demo.domain.vo.Total; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName GoldDetailService |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2025−06-23 11:59 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
public interface GoldDetailService { |
||||
|
PageInfo<GoldDetail> getGoldDetail(Integer pageNum, Integer pageSize, GoldDetail goldDetail); |
||||
|
Total getTotal(GoldDetail goldDetail); |
||||
|
} |
@ -0,0 +1,39 @@ |
|||||
|
package com.example.demo.serviceImpl; |
||||
|
|
||||
|
import com.example.demo.domain.vo.GoldDetail; |
||||
|
import com.example.demo.domain.vo.Total; |
||||
|
import com.example.demo.mapper.GoldDetailMapper; |
||||
|
import com.example.demo.service.GoldDetailService; |
||||
|
import com.github.pagehelper.PageHelper; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: GOLD |
||||
|
* @ClassName GoldDetailServiceImpl |
||||
|
* @description: |
||||
|
* @author: huangqizhen |
||||
|
* @create: 2025−06-23 13:44 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
@Service |
||||
|
public class GoldDetailServiceImpl implements GoldDetailService { |
||||
|
|
||||
|
@Autowired |
||||
|
private GoldDetailMapper goldDetailMapper; |
||||
|
@Override |
||||
|
public PageInfo<GoldDetail> getGoldDetail(Integer pageNum, Integer pageSize, GoldDetail goldDetail) { |
||||
|
PageHelper.startPage(pageNum, pageSize); |
||||
|
List<GoldDetail> list= goldDetailMapper.getGoldDetail(goldDetail); |
||||
|
return new PageInfo<>(list); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Total getTotal(GoldDetail goldDetail) { |
||||
|
|
||||
|
return goldDetailMapper.getTotal(goldDetail); |
||||
|
} |
||||
|
} |
@ -0,0 +1,58 @@ |
|||||
|
<?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.example.demo.mapper.GoldDetailMapper"> |
||||
|
|
||||
|
<select id="getGoldDetail" resultType="com.example.demo.domain.vo.GoldDetail"> |
||||
|
select `user`.name, `user`.jwcode, `user`.market, `ugr`.pay_platform, `ugr`.type, `ugr`.sum_gold, `ugr`.permanent_gold, `ugr`.free_june, `ugr`.free_december, `ugr`.task_gold, `admin`.admin_name, `ugr`.audit_time |
||||
|
from user_gold_record ugr |
||||
|
left join `user` on `user`.jwcode = `ugr`.jwcode |
||||
|
left join `admin` on `admin`.id = `ugr`.admin_id |
||||
|
<where> |
||||
|
<if test="jwcode != null and jwcode.length > 0"> |
||||
|
and `ugr`.jwcode = #{jwcode} |
||||
|
</if> |
||||
|
<if test="payPlatform != null and payPlatform.length > 0"> |
||||
|
and `ugr`.pay_platform = #{payPlatform} |
||||
|
</if> |
||||
|
<if test="type != null and type.length > 0"> |
||||
|
and `ugr`.type = #{type} |
||||
|
</if> |
||||
|
<if test="market != null and market.length > 0"> |
||||
|
and `user`.market = #{market} |
||||
|
</if> |
||||
|
<if test="startTime != null and endTime != null"> |
||||
|
and ugr.`audit_time` BETWEEN #{startTime} AND #{endTime} |
||||
|
</if> |
||||
|
</where> |
||||
|
<choose> |
||||
|
<when test="sortField != null and sortField.length > 0 or sortOrder != null and sortOrder.length > 0"> |
||||
|
ORDER BY ${sortField} ${sortOrder} |
||||
|
</when> |
||||
|
<otherwise> |
||||
|
ORDER BY audit_time DESC |
||||
|
</otherwise> |
||||
|
</choose> |
||||
|
|
||||
|
</select> |
||||
|
<select id="getTotal" resultType="com.example.demo.domain.vo.Total"> |
||||
|
select sum(sum_gold) as Goldtotal, sum(permanent_gold) as permanentGold, sum(free_june+free_december) as freeGold, sum(task_gold) as taskGold |
||||
|
from user_gold_record |
||||
|
<where> |
||||
|
<if test="jwcode != null and jwcode.length > 0"> |
||||
|
and `ugr`.jwcode = #{jwcode} |
||||
|
</if> |
||||
|
<if test="payPlatform != null and payPlatform.length > 0"> |
||||
|
and `ugr`.pay_platform = #{payPlatform} |
||||
|
</if> |
||||
|
<if test="type != null and type.length > 0"> |
||||
|
and `ugr`.type = #{type} |
||||
|
</if> |
||||
|
<if test="market != null and market.length > 0"> |
||||
|
and `user`.market = #{market} |
||||
|
</if> |
||||
|
<if test="startTime != null and endTime != null"> |
||||
|
and ugr.`audit_time` BETWEEN #{startTime} AND #{endTime} |
||||
|
</if> |
||||
|
</where> |
||||
|
</select> |
||||
|
</mapper> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue