feat(tenant-balance): 新增租户积分记录管理接口
新增租户积分记录(TenantBalanceTransaction)的完整 CRUD 接口,包括分页查询、创建、更新、删除及批量操作,并补充对应错误码。
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.yolo.keyboard.controller.admin.tenantbalance;
|
package com.yolo.keyboard.controller.admin.tenantbalance;
|
||||||
|
|
||||||
|
import com.yolo.keyboard.dal.dataobject.tenantbalancetransaction.TenantBalanceTransactionDO;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -125,4 +126,56 @@ public class TenantBalanceController {
|
|||||||
return success(BeanUtils.toBean(tenantBalancePage, TenantBalanceRespVO.class));
|
return success(BeanUtils.toBean(tenantBalancePage, TenantBalanceRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ==================== 子表(租户积分记录) ====================
|
||||||
|
|
||||||
|
@GetMapping("/tenant-balance-transaction/page")
|
||||||
|
@Operation(summary = "获得租户积分记录分页")
|
||||||
|
@Parameter(name = "tenantId", description = "租户 Id")
|
||||||
|
@PreAuthorize("@ss.hasPermission('keyboard:tenant-balance:query')")
|
||||||
|
public CommonResult<PageResult<TenantBalanceTransactionDO>> getTenantBalanceTransactionPage(PageParam pageReqVO,
|
||||||
|
@RequestParam("tenantId") Long tenantId) {
|
||||||
|
return success(tenantBalanceService.getTenantBalanceTransactionPage(pageReqVO, tenantId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/tenant-balance-transaction/create")
|
||||||
|
@Operation(summary = "创建租户积分记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('keyboard:tenant-balance:create')")
|
||||||
|
public CommonResult<Long> createTenantBalanceTransaction(@Valid @RequestBody TenantBalanceTransactionDO tenantBalanceTransaction) {
|
||||||
|
return success(tenantBalanceService.createTenantBalanceTransaction(tenantBalanceTransaction));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/tenant-balance-transaction/update")
|
||||||
|
@Operation(summary = "更新租户积分记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('keyboard:tenant-balance:update')")
|
||||||
|
public CommonResult<Boolean> updateTenantBalanceTransaction(@Valid @RequestBody TenantBalanceTransactionDO tenantBalanceTransaction) {
|
||||||
|
tenantBalanceService.updateTenantBalanceTransaction(tenantBalanceTransaction);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/tenant-balance-transaction/delete")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@Operation(summary = "删除租户积分记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('keyboard:tenant-balance:delete')")
|
||||||
|
public CommonResult<Boolean> deleteTenantBalanceTransaction(@RequestParam("id") Long id) {
|
||||||
|
tenantBalanceService.deleteTenantBalanceTransaction(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/tenant-balance-transaction/delete-list")
|
||||||
|
@Parameter(name = "ids", description = "编号", required = true)
|
||||||
|
@Operation(summary = "批量删除租户积分记录")
|
||||||
|
@PreAuthorize("@ss.hasPermission('keyboard:tenant-balance:delete')")
|
||||||
|
public CommonResult<Boolean> deleteTenantBalanceTransactionList(@RequestParam("ids") List<Long> ids) {
|
||||||
|
tenantBalanceService.deleteTenantBalanceTransactionListByIds(ids);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/tenant-balance-transaction/get")
|
||||||
|
@Operation(summary = "获得租户积分记录")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('keyboard:tenant-balance:query')")
|
||||||
|
public CommonResult<TenantBalanceTransactionDO> getTenantBalanceTransaction(@RequestParam("id") Long id) {
|
||||||
|
return success(tenantBalanceService.getTenantBalanceTransaction(id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
package com.yolo.keyboard.dal.mysql.tenantbalancetransaction;
|
package com.yolo.keyboard.dal.mysql.tenantbalancetransaction;
|
||||||
|
|
||||||
import com.yolo.keyboard.dal.dataobject.tenantbalancetransaction.TenantBalanceTransactionDO;
|
import com.yolo.keyboard.dal.dataobject.tenantbalancetransaction.TenantBalanceTransactionDO;
|
||||||
|
import com.yolo.keyboard.framework.common.pojo.PageParam;
|
||||||
|
import com.yolo.keyboard.framework.common.pojo.PageResult;
|
||||||
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
|
import com.yolo.keyboard.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.yolo.keyboard.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户积分记录 Mapper
|
* 租户积分记录 Mapper
|
||||||
*
|
*
|
||||||
@@ -11,4 +16,18 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TenantBalanceTransactionMapper extends BaseMapperX<TenantBalanceTransactionDO> {
|
public interface TenantBalanceTransactionMapper extends BaseMapperX<TenantBalanceTransactionDO> {
|
||||||
|
|
||||||
|
default PageResult<TenantBalanceTransactionDO> selectPage(PageParam reqVO, Long tenantId) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<TenantBalanceTransactionDO>()
|
||||||
|
.eq(TenantBalanceTransactionDO::getTenantId, tenantId)
|
||||||
|
.orderByDesc(TenantBalanceTransactionDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
default int deleteByTenantId(Long tenantId) {
|
||||||
|
return delete(TenantBalanceTransactionDO::getTenantId, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
default int deleteByTenantIds(List<Long> tenantIds) {
|
||||||
|
return deleteBatch(TenantBalanceTransactionDO::getTenantId, tenantIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.yolo.keyboard.service.tenantbalance;
|
package com.yolo.keyboard.service.tenantbalance;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.yolo.keyboard.dal.dataobject.tenantbalancetransaction.TenantBalanceTransactionDO;
|
||||||
import jakarta.validation.*;
|
import jakarta.validation.*;
|
||||||
import com.yolo.keyboard.controller.admin.tenantbalance.vo.*;
|
import com.yolo.keyboard.controller.admin.tenantbalance.vo.*;
|
||||||
import com.yolo.keyboard.dal.dataobject.tenantbalance.TenantBalanceDO;
|
import com.yolo.keyboard.dal.dataobject.tenantbalance.TenantBalanceDO;
|
||||||
@@ -81,4 +83,51 @@ public interface TenantBalanceService {
|
|||||||
*/
|
*/
|
||||||
PageResult<TenantBalanceRespVO> getSelfSubordinateTenantBalancePage(TenantBalancePageReqVO pageReqVO);
|
PageResult<TenantBalanceRespVO> getSelfSubordinateTenantBalancePage(TenantBalancePageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得租户积分记录分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @param tenantId 租户 Id
|
||||||
|
* @return 租户积分记录分页
|
||||||
|
*/
|
||||||
|
PageResult<TenantBalanceTransactionDO> getTenantBalanceTransactionPage(PageParam pageReqVO, Long tenantId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建租户积分记录
|
||||||
|
*
|
||||||
|
* @param tenantBalanceTransaction 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createTenantBalanceTransaction(@Valid TenantBalanceTransactionDO tenantBalanceTransaction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新租户积分记录
|
||||||
|
*
|
||||||
|
* @param tenantBalanceTransaction 更新信息
|
||||||
|
*/
|
||||||
|
void updateTenantBalanceTransaction(@Valid TenantBalanceTransactionDO tenantBalanceTransaction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除租户积分记录
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteTenantBalanceTransaction(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除租户积分记录
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
*/
|
||||||
|
void deleteTenantBalanceTransactionListByIds(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得租户积分记录
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 租户积分记录
|
||||||
|
*/
|
||||||
|
TenantBalanceTransactionDO getTenantBalanceTransaction(Long id);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -28,6 +28,7 @@ import static com.yolo.keyboard.framework.common.exception.util.ServiceException
|
|||||||
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.convertList;
|
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.diffList;
|
import static com.yolo.keyboard.framework.common.util.collection.CollectionUtils.diffList;
|
||||||
import static com.yolo.keyboard.module.infra.enums.ErrorCodeConstants.TENANT_BALANCE_NOT_EXISTS;
|
import static com.yolo.keyboard.module.infra.enums.ErrorCodeConstants.TENANT_BALANCE_NOT_EXISTS;
|
||||||
|
import static com.yolo.keyboard.module.infra.enums.ErrorCodeConstants.TENANT_BALANCE_TRANSACTION_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租户余额 Service 实现类
|
* 租户余额 Service 实现类
|
||||||
@@ -160,4 +161,55 @@ public class TenantBalanceServiceImpl implements TenantBalanceService {
|
|||||||
return BeanUtils.toBean(pageResult, TenantBalanceRespVO.class);
|
return BeanUtils.toBean(pageResult, TenantBalanceRespVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<TenantBalanceTransactionDO> getTenantBalanceTransactionPage(PageParam pageReqVO, Long tenantId) {
|
||||||
|
return tenantBalanceTransactionMapper.selectPage(pageReqVO, tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createTenantBalanceTransaction(TenantBalanceTransactionDO tenantBalanceTransaction) {
|
||||||
|
tenantBalanceTransactionMapper.insert(tenantBalanceTransaction);
|
||||||
|
return tenantBalanceTransaction.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTenantBalanceTransaction(TenantBalanceTransactionDO tenantBalanceTransaction) {
|
||||||
|
// 校验存在
|
||||||
|
validateTenantBalanceTransactionExists(tenantBalanceTransaction.getId());
|
||||||
|
// 更新
|
||||||
|
tenantBalanceTransactionMapper.updateById(tenantBalanceTransaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteTenantBalanceTransaction(Long id) {
|
||||||
|
// 删除
|
||||||
|
tenantBalanceTransactionMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteTenantBalanceTransactionListByIds(List<Long> ids) {
|
||||||
|
// 删除
|
||||||
|
tenantBalanceTransactionMapper.deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TenantBalanceTransactionDO getTenantBalanceTransaction(Long id) {
|
||||||
|
return tenantBalanceTransactionMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateTenantBalanceTransactionExists(Long id) {
|
||||||
|
if (tenantBalanceTransactionMapper.selectById(id) == null) {
|
||||||
|
throw exception(TENANT_BALANCE_TRANSACTION_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteTenantBalanceTransactionByTenantId(Long tenantId) {
|
||||||
|
tenantBalanceTransactionMapper.deleteByTenantId(tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteTenantBalanceTransactionByTenantIds(List<Long> tenantIds) {
|
||||||
|
tenantBalanceTransactionMapper.deleteByTenantIds(tenantIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -86,6 +86,7 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode USER_CHARACTER_NOT_EXISTS = new ErrorCode(1_001_202_012, "用户人设管理不存在");
|
ErrorCode USER_CHARACTER_NOT_EXISTS = new ErrorCode(1_001_202_012, "用户人设管理不存在");
|
||||||
ErrorCode USER_THEMES_NOT_EXISTS = new ErrorCode(1_001_202_013, "用户主题不存在");
|
ErrorCode USER_THEMES_NOT_EXISTS = new ErrorCode(1_001_202_013, "用户主题不存在");
|
||||||
ErrorCode TENANT_BALANCE_NOT_EXISTS = new ErrorCode(1_001_202_014, "租户余额不存在");
|
ErrorCode TENANT_BALANCE_NOT_EXISTS = new ErrorCode(1_001_202_014, "租户余额不存在");
|
||||||
|
ErrorCode TENANT_BALANCE_TRANSACTION_NOT_EXISTS = new ErrorCode(1_001_202_015, "租户积分记录不存在");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user