feat(用户余额): 新增用户余额变更日志控制器

添加用户余额变更日志的CRUD接口,包括根据用户余额ID、订单ID、审批ID等多种条件查询日志的功能
This commit is contained in:
dzq 2025-12-06 17:37:26 +08:00
parent 348b932556
commit 048afd5dfc
1 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,125 @@
package com.agileboot.admin.controller.ab98;
import com.agileboot.admin.customize.aop.accessLog.AccessLog;
import com.agileboot.common.core.base.BaseController;
import com.agileboot.common.core.dto.ResponseDTO;
import com.agileboot.common.core.page.PageDTO;
import com.agileboot.common.enums.common.BusinessTypeEnum;
import com.agileboot.domain.ab98.user_balance_log.UserBalanceLogApplicationService;
import com.agileboot.domain.ab98.user_balance_log.command.AddUserBalanceLogCommand;
import com.agileboot.domain.ab98.user_balance_log.command.UpdateUserBalanceLogCommand;
import com.agileboot.domain.ab98.user_balance_log.dto.UserBalanceLogDTO;
import com.agileboot.domain.ab98.user_balance_log.query.SearchUserBalanceLogQuery;
import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import javax.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 用户余额变更日志控制器
* </p>
*
* @author valarchie
* @since 2025-12-06
*/
@RestController
@RequestMapping("/ab98/balance-log")
@RequiredArgsConstructor
@Validated
public class UserBalanceLogController extends BaseController {
private final UserBalanceLogApplicationService userBalanceLogApplicationService;
@Operation(summary = "用户余额变更日志列表")
@GetMapping
public ResponseDTO<PageDTO<UserBalanceLogDTO>> list(SearchUserBalanceLogQuery query) {
PageDTO<UserBalanceLogDTO> page = userBalanceLogApplicationService.getList(query);
return ResponseDTO.ok(page);
}
@Operation(summary = "用户余额变更日志详情")
@GetMapping("/{id}")
public ResponseDTO<UserBalanceLogDTO> detail(@PathVariable Long id) {
UserBalanceLogDTO userBalanceLogDTO = userBalanceLogApplicationService.getById(id);
return ResponseDTO.ok(userBalanceLogDTO);
}
@Operation(summary = "根据用户余额ID查询变更日志")
@GetMapping("/byUserBalanceId/{userBalanceId}")
public ResponseDTO<List<UserBalanceLogDTO>> getByUserBalanceId(@PathVariable Long userBalanceId) {
List<UserBalanceLogDTO> userBalanceLogDTOList = userBalanceLogApplicationService.getByUserBalanceId(userBalanceId);
return ResponseDTO.ok(userBalanceLogDTOList);
}
@Operation(summary = "根据订单ID查询变更日志")
@GetMapping("/byOrderId/{orderId}")
public ResponseDTO<List<UserBalanceLogDTO>> getByOrderId(@PathVariable Long orderId) {
List<UserBalanceLogDTO> userBalanceLogDTOList = userBalanceLogApplicationService.getByOrderId(orderId);
return ResponseDTO.ok(userBalanceLogDTOList);
}
@Operation(summary = "根据审批ID查询变更日志")
@GetMapping("/byApprovalId/{approvalId}")
public ResponseDTO<List<UserBalanceLogDTO>> getByApprovalId(@PathVariable Long approvalId) {
List<UserBalanceLogDTO> userBalanceLogDTOList = userBalanceLogApplicationService.getByApprovalId(approvalId);
return ResponseDTO.ok(userBalanceLogDTOList);
}
@Operation(summary = "根据订单商品ID查询变更日志")
@GetMapping("/byOrderGoodsId/{orderGoodsId}")
public ResponseDTO<List<UserBalanceLogDTO>> getByOrderGoodsId(@PathVariable Long orderGoodsId) {
List<UserBalanceLogDTO> userBalanceLogDTOList = userBalanceLogApplicationService.getByOrderGoodsId(orderGoodsId);
return ResponseDTO.ok(userBalanceLogDTOList);
}
@Operation(summary = "根据变更类型查询变更日志")
@GetMapping("/byChangeType/{changeType}")
public ResponseDTO<List<UserBalanceLogDTO>> getByChangeType(@PathVariable Integer changeType) {
List<UserBalanceLogDTO> userBalanceLogDTOList = userBalanceLogApplicationService.getByChangeType(changeType);
return ResponseDTO.ok(userBalanceLogDTOList);
}
@Operation(summary = "新增用户余额变更日志")
@AccessLog(title = "用户余额变更日志管理", businessType = BusinessTypeEnum.ADD)
@PostMapping
public ResponseDTO<UserBalanceLogDTO> add(@Validated @RequestBody AddUserBalanceLogCommand command) {
UserBalanceLogDTO userBalanceLogDTO = userBalanceLogApplicationService.add(command);
return ResponseDTO.ok(userBalanceLogDTO);
}
@Operation(summary = "修改用户余额变更日志")
@AccessLog(title = "用户余额变更日志管理", businessType = BusinessTypeEnum.MODIFY)
@PutMapping("/{id}")
public ResponseDTO<UserBalanceLogDTO> edit(@PathVariable Long id, @Validated @RequestBody UpdateUserBalanceLogCommand command) {
command.setLogId(id);
UserBalanceLogDTO userBalanceLogDTO = userBalanceLogApplicationService.update(command);
return ResponseDTO.ok(userBalanceLogDTO);
}
@Operation(summary = "删除用户余额变更日志")
@AccessLog(title = "用户余额变更日志管理", businessType = BusinessTypeEnum.DELETE)
@DeleteMapping("/{id}")
public ResponseDTO<Void> remove(@PathVariable Long id) {
userBalanceLogApplicationService.delete(id);
return ResponseDTO.ok();
}
@Operation(summary = "批量删除用户余额变更日志")
@AccessLog(title = "用户余额变更日志管理", businessType = BusinessTypeEnum.DELETE)
@DeleteMapping("/batch/{ids}")
public ResponseDTO<Void> batchRemove(@PathVariable @NotNull List<Long> ids) {
userBalanceLogApplicationService.batchDelete(ids);
return ResponseDTO.ok();
}
}