分组添加门店
This commit is contained in:
@ -168,5 +168,7 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
ErrorCode CONFIG_DATA_NOT_EXISTS = new ErrorCode(1_004_028_00, "配置数据不存在");
|
ErrorCode CONFIG_DATA_NOT_EXISTS = new ErrorCode(1_004_028_00, "配置数据不存在");
|
||||||
ErrorCode CONFIG_TYPE_NOT_EXISTS = new ErrorCode(1_004_029_00, "配置类型不存在");
|
ErrorCode CONFIG_TYPE_NOT_EXISTS = new ErrorCode(1_004_029_00, "配置类型不存在");
|
||||||
|
|
||||||
|
ErrorCode MONEY_NOT_EXISTS = new ErrorCode(1_004_030_00, "金额不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.money;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.money.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.money.MoneyService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 金额")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/member/money")
|
||||||
|
@Validated
|
||||||
|
public class MoneyController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MoneyService moneyService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建金额")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:money:create')")
|
||||||
|
public CommonResult<Long> createMoney(@Valid @RequestBody MoneySaveReqVO createReqVO) {
|
||||||
|
return success(moneyService.createMoney(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新金额")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:money:update')")
|
||||||
|
public CommonResult<Boolean> updateMoney(@Valid @RequestBody MoneySaveReqVO updateReqVO) {
|
||||||
|
moneyService.updateMoney(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除金额")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:money:delete')")
|
||||||
|
public CommonResult<Boolean> deleteMoney(@RequestParam("id") Long id) {
|
||||||
|
moneyService.deleteMoney(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得金额")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:money:query')")
|
||||||
|
public CommonResult<MoneyRespVO> getMoney(@RequestParam("id") Long id) {
|
||||||
|
MoneyDO money = moneyService.getMoney(id);
|
||||||
|
return success(BeanUtils.toBean(money, MoneyRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得金额分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:money:query')")
|
||||||
|
public CommonResult<PageResult<MoneyRespVO>> getMoneyPage(@Valid MoneyPageReqVO pageReqVO) {
|
||||||
|
PageResult<MoneyDO> pageResult = moneyService.getMoneyPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, MoneyRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出金额 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('member:money:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void exportMoneyExcel(@Valid MoneyPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<MoneyDO> list = moneyService.getMoneyPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "金额.xls", "数据", MoneyRespVO.class,
|
||||||
|
BeanUtils.toBean(list, MoneyRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.money.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 金额分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class MoneyPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "用户ID", example = "26917")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "门店ID", example = "27250")
|
||||||
|
private Long carteenId;
|
||||||
|
|
||||||
|
@Schema(description = "现金金额")
|
||||||
|
private BigDecimal cashAmount;
|
||||||
|
|
||||||
|
@Schema(description = "欠款金额")
|
||||||
|
private BigDecimal debtAmount;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.money.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 金额 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class MoneyRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "771")
|
||||||
|
@ExcelProperty("主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "用户ID", example = "26917")
|
||||||
|
@ExcelProperty("用户ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "门店ID", example = "27250")
|
||||||
|
@ExcelProperty("门店ID")
|
||||||
|
private Long carteenId;
|
||||||
|
|
||||||
|
@Schema(description = "现金金额")
|
||||||
|
@ExcelProperty("现金金额")
|
||||||
|
private BigDecimal cashAmount;
|
||||||
|
|
||||||
|
@Schema(description = "欠款金额")
|
||||||
|
@ExcelProperty("欠款金额")
|
||||||
|
private BigDecimal debtAmount;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.admin.money.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 金额新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class MoneySaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "771")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "用户ID", example = "26917")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(description = "门店ID", example = "27250")
|
||||||
|
private Long carteenId;
|
||||||
|
|
||||||
|
@Schema(description = "现金金额")
|
||||||
|
private BigDecimal cashAmount;
|
||||||
|
|
||||||
|
@Schema(description = "欠款金额")
|
||||||
|
private BigDecimal debtAmount;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.dataobject.money;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 金额 DO
|
||||||
|
*
|
||||||
|
* @author 秦俊旗
|
||||||
|
*/
|
||||||
|
@TableName("member_money")
|
||||||
|
@KeySequence("member_money_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MoneyDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 门店ID
|
||||||
|
*/
|
||||||
|
private Long carteenId;
|
||||||
|
/**
|
||||||
|
* 现金金额
|
||||||
|
*/
|
||||||
|
private BigDecimal cashAmount;
|
||||||
|
/**
|
||||||
|
* 欠款金额
|
||||||
|
*/
|
||||||
|
private BigDecimal debtAmount;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.dal.mysql.money;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.money.vo.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 金额 Mapper
|
||||||
|
*
|
||||||
|
* @author 秦俊旗
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MoneyMapper extends BaseMapperX<MoneyDO> {
|
||||||
|
|
||||||
|
default PageResult<MoneyDO> selectPage(MoneyPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<MoneyDO>()
|
||||||
|
.eqIfPresent(MoneyDO::getUserId, reqVO.getUserId())
|
||||||
|
.eqIfPresent(MoneyDO::getCarteenId, reqVO.getCarteenId())
|
||||||
|
.eqIfPresent(MoneyDO::getCashAmount, reqVO.getCashAmount())
|
||||||
|
.eqIfPresent(MoneyDO::getDebtAmount, reqVO.getDebtAmount())
|
||||||
|
.betweenIfPresent(MoneyDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(MoneyDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.money;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.money.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 金额 Service 接口
|
||||||
|
*
|
||||||
|
* @author 秦俊旗
|
||||||
|
*/
|
||||||
|
public interface MoneyService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建金额
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createMoney(@Valid MoneySaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新金额
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateMoney(@Valid MoneySaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除金额
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteMoney(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得金额
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 金额
|
||||||
|
*/
|
||||||
|
MoneyDO getMoney(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得金额分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 金额分页
|
||||||
|
*/
|
||||||
|
PageResult<MoneyDO> getMoneyPage(MoneyPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.service.money;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.money.vo.*;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.money.MoneyDO;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.member.dal.mysql.money.MoneyMapper;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 金额 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 秦俊旗
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class MoneyServiceImpl implements MoneyService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MoneyMapper moneyMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createMoney(MoneySaveReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
MoneyDO money = BeanUtils.toBean(createReqVO, MoneyDO.class);
|
||||||
|
moneyMapper.insert(money);
|
||||||
|
// 返回
|
||||||
|
return money.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateMoney(MoneySaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateMoneyExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
MoneyDO updateObj = BeanUtils.toBean(updateReqVO, MoneyDO.class);
|
||||||
|
moneyMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteMoney(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateMoneyExists(id);
|
||||||
|
// 删除
|
||||||
|
moneyMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateMoneyExists(Long id) {
|
||||||
|
if (moneyMapper.selectById(id) == null) {
|
||||||
|
throw exception(MONEY_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MoneyDO getMoney(Long id) {
|
||||||
|
return moneyMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<MoneyDO> getMoneyPage(MoneyPageReqVO pageReqVO) {
|
||||||
|
return moneyMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user