8 changed files with 362 additions and 0 deletions
-
75src/main/java/com/example/demo/controller/bean/BeanAuditController.java
-
48src/main/java/com/example/demo/domain/vo/bean/BeanAuditInfo.java
-
1src/main/java/com/example/demo/domain/vo/coin/Page.java
-
31src/main/java/com/example/demo/mapper/coin/BeanAuditMapper.java
-
24src/main/java/com/example/demo/service/bean/BeanAuditService.java
-
81src/main/java/com/example/demo/serviceImpl/bean/BeanAuditServiceImpl.java
-
8src/main/java/com/example/demo/serviceImpl/bean/BeanRechargeServiceImpl.java
-
94src/main/resources/mapper/BeanAuditMapper.xml
@ -0,0 +1,75 @@ |
|||||
|
package com.example.demo.controller.bean; |
||||
|
|
||||
|
import com.example.demo.domain.vo.bean.BeanAuditInfo; |
||||
|
import com.example.demo.domain.vo.coin.Page; |
||||
|
import com.example.demo.domain.vo.coin.Result; |
||||
|
import com.example.demo.service.bean.BeanAuditService; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.util.ObjectUtils; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: gold-java |
||||
|
* @ClassName BeanAuditController |
||||
|
* @description: |
||||
|
* @author: Double |
||||
|
* @create: 2025−08-01 11:03 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/beanAudit") |
||||
|
@RequiredArgsConstructor |
||||
|
@Slf4j |
||||
|
@CrossOrigin |
||||
|
public class BeanAuditController { |
||||
|
|
||||
|
@Autowired |
||||
|
private BeanAuditService beanAuditService; |
||||
|
|
||||
|
//审核查找 |
||||
|
@PostMapping("/selectBy") |
||||
|
public Result selectBy(@RequestBody Page page) { |
||||
|
try { |
||||
|
if (ObjectUtils.isEmpty(page.getPageNum())) { |
||||
|
return Result.error("页码数为空!"); |
||||
|
} |
||||
|
if (ObjectUtils.isEmpty(page.getPageSize())) { |
||||
|
return Result.error("页大小为空!"); |
||||
|
} else { |
||||
|
if (page.getBeanAuditInfo().getStatus() == null) { |
||||
|
return Result.error("状态不能为空"); |
||||
|
} |
||||
|
return Result.success(beanAuditService.selectBy(page.getPageNum(), page.getPageSize(), page.getBeanAuditInfo())); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
return Result.error("请检查筛选数据的格式"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
@PostMapping("/status1") |
||||
|
public Result updateStatus1(@RequestBody BeanAuditInfo beanAuditInfo) { |
||||
|
try { |
||||
|
|
||||
|
return beanAuditService.updateStatus1(beanAuditInfo.getId()); |
||||
|
} catch (Exception e) { |
||||
|
return Result.error("更新失败,查看id"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/status2") |
||||
|
public Result updateStatus2(@RequestBody BeanAuditInfo beanAuditInfo) { |
||||
|
try { |
||||
|
beanAuditService.updateStatus2(beanAuditInfo.getId()); |
||||
|
return Result.success(); |
||||
|
} catch (Exception e) { |
||||
|
return Result.error("更新失败,查看id"); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package com.example.demo.domain.vo.bean; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* @program: gold-java |
||||
|
* @ClassName BeanAuditInfo |
||||
|
* @description: |
||||
|
* @author: Double |
||||
|
* @create: 2025−08-01 11:33 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
|
||||
|
|
||||
|
@Data |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class BeanAuditInfo { |
||||
|
private Long id; // id |
||||
|
private Integer jwcode; // 精网号 |
||||
|
private String name; // 姓名 |
||||
|
private String market; // 所属地区 |
||||
|
private Integer freeBean; // 免费豆 |
||||
|
private Integer permanentBean; // 永久豆 |
||||
|
private String remark; // 备注 |
||||
|
private String submitName; // 提交人名称 |
||||
|
private String auditName; // 审核人名称 |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
|
private Date createTime; //创建时间 |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
|
private Date auditTime; //审核时间 |
||||
|
private String status; // 状态 |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
|
private Date createStartTime; // 开始时间 |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
|
private Date createEndTime; // 结束时间 |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
|
private Date auditStartTime; // 开始时间 |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai") |
||||
|
private Date auditEndTime; // 结束时间 |
||||
|
private String sortField; // 排序字段 |
||||
|
private String sortOrder; // 排序顺序 |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package com.example.demo.mapper.coin; |
||||
|
|
||||
|
|
||||
|
import com.example.demo.domain.vo.bean.BeanAuditInfo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @program: gold-java |
||||
|
* @ClassName BeanAuditMapper |
||||
|
* @description: |
||||
|
* @author: Double |
||||
|
* @create: 2025−08-01 11:44 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
|
||||
|
@Mapper |
||||
|
public interface BeanAuditMapper { |
||||
|
//查找审核信息 |
||||
|
List<BeanAuditInfo> selectBy(BeanAuditInfo beanAuditInfo); |
||||
|
|
||||
|
//根据id查询审核信息 |
||||
|
BeanAuditInfo selectById(Long id); |
||||
|
|
||||
|
//根据id更新状态为1 |
||||
|
void updateStatus1(Long id); |
||||
|
|
||||
|
//根据id更新状态为2 |
||||
|
void updateStatus2(Long id); |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.example.demo.service.bean; |
||||
|
|
||||
|
import com.example.demo.domain.vo.bean.BeanAuditInfo; |
||||
|
import com.example.demo.domain.vo.bean.BeanRechargeInfo; |
||||
|
import com.example.demo.domain.vo.coin.Result; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
|
||||
|
/** |
||||
|
* @program: gold-java |
||||
|
* @ClassName BeanAuditService |
||||
|
* @description: |
||||
|
* @author: Double |
||||
|
* @create: 2025−08-01 11:36 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
|
||||
|
public interface BeanAuditService { |
||||
|
//查找审核信息 |
||||
|
PageInfo<BeanAuditInfo> selectBy(Integer pageNum, Integer pageSize, BeanAuditInfo beanAuditInfo); |
||||
|
|
||||
|
Result updateStatus1(Long id); |
||||
|
|
||||
|
void updateStatus2(Long id); |
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
package com.example.demo.serviceImpl.bean; |
||||
|
|
||||
|
import com.example.demo.domain.vo.bean.BeanAuditInfo; |
||||
|
import com.example.demo.domain.vo.bean.BeanRechargeInfo; |
||||
|
import com.example.demo.domain.vo.coin.Result; |
||||
|
import com.example.demo.mapper.coin.BeanAuditMapper; |
||||
|
import com.example.demo.service.bean.BeanAuditService; |
||||
|
import com.github.pagehelper.PageHelper; |
||||
|
import com.github.pagehelper.PageInfo; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.http.ResponseEntity; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.client.RestTemplate; |
||||
|
import org.springframework.web.util.UriComponentsBuilder; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
/** |
||||
|
* @program: gold-java |
||||
|
* @ClassName BeanAuditServiceImpl |
||||
|
* @description: |
||||
|
* @author: Double |
||||
|
* @create: 2025−08-01 11:37 |
||||
|
* @Version 1.0 |
||||
|
**/ |
||||
|
|
||||
|
@Service |
||||
|
@RequiredArgsConstructor |
||||
|
public class BeanAuditServiceImpl implements BeanAuditService { |
||||
|
|
||||
|
@Autowired |
||||
|
private BeanAuditMapper beanAuditMapper; |
||||
|
|
||||
|
@Autowired |
||||
|
private RestTemplate restTemplate; |
||||
|
|
||||
|
//查找审核信息 |
||||
|
@Override |
||||
|
public PageInfo<BeanAuditInfo> selectBy(Integer pageNum, Integer pageSize, BeanAuditInfo beanAuditInfo) { |
||||
|
PageHelper.startPage(pageNum, pageSize); |
||||
|
List<BeanAuditInfo> beanAuditInfos = beanAuditMapper.selectBy(beanAuditInfo); |
||||
|
return new PageInfo<>(beanAuditInfos); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
@Override |
||||
|
public Result updateStatus1(Long id) { |
||||
|
BeanAuditInfo beanAuditInfo = beanAuditMapper.selectById(id); |
||||
|
String jwcode = beanAuditInfo.getJwcode().toString(); |
||||
|
String op = "recharge"; // 操作类型(根据实际业务定义,例如"recharge"表示充值) |
||||
|
String content = beanAuditInfo.getRemark(); // 备注作为content参数 |
||||
|
String orderNo = UUID.randomUUID().toString().replace("-", ""); // 生成唯一订单号(去除横线) |
||||
|
|
||||
|
// 2. 构建接口URL及参数 |
||||
|
String apiUrl = "http://47.92.148.30:3003/mock/61/hljw/api/user/gold"; |
||||
|
UriComponentsBuilder urlBuilder = UriComponentsBuilder.fromHttpUrl(apiUrl) |
||||
|
.queryParam("jwcode", jwcode) |
||||
|
.queryParam("op", op) |
||||
|
.queryParam("gold", beanAuditInfo.getPermanentBean()) |
||||
|
.queryParam("content", content) |
||||
|
.queryParam("order_no", orderNo); |
||||
|
|
||||
|
// 3. 发送GET请求 |
||||
|
ResponseEntity<String> response = restTemplate.getForEntity(urlBuilder.toUriString(), String.class); |
||||
|
|
||||
|
// 4. 处理响应结果 |
||||
|
if (!response.getStatusCode().is2xxSuccessful()) { |
||||
|
return Result.error("远程接口调用失败,状态码:" + response.getStatusCodeValue()); |
||||
|
} |
||||
|
beanAuditMapper.updateStatus1(id); |
||||
|
return Result.success(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void updateStatus2(Long id) { |
||||
|
beanAuditMapper.updateStatus2(id); |
||||
|
} |
||||
|
} |
@ -0,0 +1,94 @@ |
|||||
|
<?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.coin.BeanAuditMapper"> |
||||
|
|
||||
|
<select id="selectBy" resultType="com.example.demo.domain.vo.bean.BeanAuditInfo"> |
||||
|
SELECT a.id AS id, |
||||
|
a.jwcode AS jwcode, |
||||
|
u.name AS name, |
||||
|
m.name AS market, |
||||
|
a.buy_jd AS permanentBean, |
||||
|
a.free_jd AS freeBean, |
||||
|
a.remark AS remark, |
||||
|
a.admin_name AS submitName, |
||||
|
a.audit_name AS auditName, |
||||
|
a.create_time AS createTime, |
||||
|
a.audit_time AS auditTime |
||||
|
FROM audit a |
||||
|
LEFT JOIN user u ON a.jwcode = u.jwcode |
||||
|
LEFT JOIN market m ON u.market = m.id |
||||
|
<where> |
||||
|
a.audit_status = #{status} |
||||
|
<if test="jwcode != null and jwcode != ''"> |
||||
|
AND a.jwcode = #{jwcode} |
||||
|
</if> |
||||
|
<if test="market != null and market != ''"> |
||||
|
AND m.name = #{market} |
||||
|
</if> |
||||
|
<if test="createStartTime != null and createEndTime != null"> |
||||
|
AND a.create_time BETWEEN #{createStartTime} AND #{createEndTime} |
||||
|
</if> |
||||
|
<if test="auditStartTime != null and auditEndTime != null"> |
||||
|
AND a.audit_time BETWEEN #{auditStartTime} AND #{auditEndTime} |
||||
|
</if> |
||||
|
</where> |
||||
|
<trim prefix="ORDER BY" suffixOverrides=","> |
||||
|
<choose> |
||||
|
<!-- 当指定排序字段时使用指定字段排序 --> |
||||
|
<when test="sortField != null and sortField != ''"> |
||||
|
<choose> |
||||
|
<!-- 对金币数量的排序处理 --> |
||||
|
<when test="sortField == 'permanentBean'">a.buy_jd</when> |
||||
|
<when test="sortField == 'freeBean'">a.free_jd</when> |
||||
|
<!-- 对时间字段的排序处理 --> |
||||
|
<when test="sortField == 'createTime'">a.create_time</when> |
||||
|
<when test="sortField == 'auditTime'">a.audit_time</when> |
||||
|
<!-- 其他字段不支持排序,使用默认排序 --> |
||||
|
<otherwise>a.create_time</otherwise> |
||||
|
</choose> |
||||
|
<!-- 排序方向处理 --> |
||||
|
<if test="sortOrder != null and sortOrder != ''"> |
||||
|
<choose> |
||||
|
<when test="sortOrder == 'ASC'">ASC</when> |
||||
|
<when test="sortOrder == 'DESC'">DESC</when> |
||||
|
<otherwise>DESC</otherwise> |
||||
|
</choose> |
||||
|
</if> |
||||
|
<if test="sortOrder == null or sortOrder == ''"> |
||||
|
DESC |
||||
|
</if> |
||||
|
</when> |
||||
|
<!-- 未指定排序字段时,使用默认的时间降序排序 --> |
||||
|
<otherwise> |
||||
|
a.create_time DESC |
||||
|
</otherwise> |
||||
|
</choose> |
||||
|
</trim> |
||||
|
</select> |
||||
|
|
||||
|
|
||||
|
<update id="updateStatus1"> |
||||
|
update audit |
||||
|
set audit_status = 1 |
||||
|
where id = #{id} |
||||
|
</update> |
||||
|
|
||||
|
|
||||
|
<update id="updateStatus2"> |
||||
|
update audit |
||||
|
set audit_status = 2 |
||||
|
where id = #{id} |
||||
|
</update> |
||||
|
|
||||
|
<select id="selectById" resultType="com.example.demo.domain.vo.bean.BeanAuditInfo"> |
||||
|
select |
||||
|
a.jwcode AS jwcode, |
||||
|
m.name AS market, |
||||
|
a.buy_jd AS permanentBean, |
||||
|
a.free_jd AS freeBean, |
||||
|
a.remark AS remark, |
||||
|
a.admin_name AS submitName, |
||||
|
a.audit_name AS auditName |
||||
|
from audit where id = #{id} |
||||
|
</select> |
||||
|
</mapper> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue