新建票据模块

This commit is contained in:
vertoryao 2024-01-16 13:36:18 +08:00
parent a292bff7c1
commit f0b1b1bfe6
8 changed files with 369 additions and 0 deletions

View File

@ -0,0 +1,77 @@
package com.zsc.edu.bill.modules.bills.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.query.BillQuery;
import com.zsc.edu.bill.modules.bills.service.BillService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @author ftz
* 票据Controller
* 创建时间:11/1/2024 上午10:57
* 描述: 针对表ticket(票据表)的数据库操作Controller
*/
@AllArgsConstructor
@RestController
@RequestMapping("api/rest/bill")
public class BillController {
private final BillService service;
/**
* 分页查询票据列表
* @return 票据列表
*/
@GetMapping
public Page<Bill> list(BillQuery query, Page<Bill> page) {
return service.page(page, query.wrapper());
}
/**
* 创建票据
* @return ture/false
*/
@PostMapping
public Boolean create(Bill bill){
return service.save(bill);
}
/**
* 更新票据
* @return ture/false
*/
@PatchMapping
public Boolean update(Bill bill){
return service.updateById(bill);
}
/**
* 删除票据
* @return ture/false
*/
@DeleteMapping
public Boolean delete(Long id){
return service.removeById(id);
}
/**
* 批量删除票据
* @return ture/false
*/
@DeleteMapping("batch")
public Boolean deleteBatch(List<Long> ids){
return service.removeByIds(ids);
}
/**
* 获取票据详情
* @return 票据详情
*/
@GetMapping("{id}")
public Bill detail(@PathVariable Long id){
return service.getById(id);
}
}

View File

@ -0,0 +1,48 @@
package com.zsc.edu.bill.modules.bills.dto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @author yao
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BillDto {
/**
* 票据标题
*/
private String title;
/**
* 主体内容 票据详细内容
*/
private String body;
/**
* 金额 票据金额
*/
private BigDecimal money;
/**
* 票据类型
*/
private String type;
/**
* 联系方式email邮箱
*/
private String contactEmail;
/**
* 客户公司名称 票据对应的企业名称
*/
private String companyName;
}

View File

@ -0,0 +1,100 @@
package com.zsc.edu.bill.modules.bills.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonValue;
import com.zsc.edu.bill.modules.system.entity.BaseEntity;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.UUID;
/**
* 票据表
* @author verto
* @TableName bill
*/
@TableName(value ="bill")
@Getter
@Setter
public class Bill extends BaseEntity {
/**
* 票据uuid 提供给前端显示用
*/
private UUID uuid;
/**
* 用户id 票据创建者id
*/
private Long userId;
/**
* 票据标题
*/
private String title;
/**
* 主体内容 票据详细内容
*/
private String body;
/**
* 金额 票据金额
*/
private BigDecimal money;
/**
* 状态 0:未提交草稿;1:未审核2:审核通过3:退回审核未通过
*/
private Status status;
/**
* 票据类型
*/
private String type;
/**
* 联系方式email邮箱
*/
private String contactEmail;
/**
* 客户公司名称 票据对应的企业名称
*/
private String companyName;
@Getter
public enum Status {
SUBMIT(0, "待提交"),
EXAMINE(1, "待审核"),
PASS(2, "审核通过"),
FAILED(3, "审核未通过");
@EnumValue
private final int code;
@JsonValue
private final String name;
Status(int code, String name) {
this.code = code;
this.name = name;
}
public static Status get(String name) {
for (Status item : values()) {
if (item.getName() .equals(name)) {
return item;
}
}
return null;
}
}
}

View File

@ -0,0 +1,21 @@
package com.zsc.edu.bill.modules.bills.mapper;
import com.zsc.edu.bill.common.mapstruct.BaseMapper;
import com.zsc.edu.bill.modules.bills.dto.BillDto;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author yao
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface BillMapper extends BaseMapper<BillDto, Bill> {
}

View File

@ -0,0 +1,71 @@
package com.zsc.edu.bill.modules.bills.query;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.system.entity.Ticket;
import com.zsc.edu.bill.modules.system.query.PageQuery;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
/**
* @author ftz
* 创建时间:11/1/2024 上午11:04
* 描述: 前端传递的查询参数
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BillQuery {
/**
* 票据uuid 提供给前端显示用
*/
private String uuid;
/**
* 用户id 票据创建者id
*/
private Long userId;
/**
* 票据标题
*/
private String title;
/**
* 金额 票据金额
*/
private BigDecimal money;
/**
* 状态 0:未提交草稿;1:未审核2:审核通过3:退回审核未通过
*/
private Bill.Status status;
/**
* 票据类型
*/
private String type;
/**
* 客户公司名称 票据对应的企业名称
*/
private String companyName;
public LambdaQueryWrapper<Bill> wrapper() {
LambdaQueryWrapper<Bill> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StringUtils.hasText(this.uuid), Bill::getUuid, this.uuid);
queryWrapper.eq(StringUtils.hasText(String.valueOf(this.userId)), Bill::getUserId, this.userId);
queryWrapper.eq(StringUtils.hasText(this.title), Bill::getTitle, this.title);
queryWrapper.eq(StringUtils.hasText(String.valueOf(this.money)), Bill::getMoney, this.money);
queryWrapper.eq(StringUtils.hasText(String.valueOf(this.status)), Bill::getStatus, this.status);
queryWrapper.eq(StringUtils.hasText(String.valueOf(this.type)), Bill::getType, this.type);
queryWrapper.eq(StringUtils.hasText(this.companyName), Bill::getCompanyName, this.companyName);
return queryWrapper;
}
}

View File

@ -0,0 +1,11 @@
package com.zsc.edu.bill.modules.bills.repo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zsc.edu.bill.modules.bills.entity.Bill;
/**
* @author yao
*/
public interface BillRepository extends BaseMapper<Bill> {
}

View File

@ -0,0 +1,18 @@
package com.zsc.edu.bill.modules.bills.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.system.query.TicketQuery;
import com.zsc.edu.bill.modules.system.vo.TicketVo;
/**
* @author fantianzhi
* @description 针对表ticket(票据表)的数据库操作Service
* @createDate 2024-01-11 10:13:22
*/
public interface BillService extends IService<Bill> {
}

View File

@ -0,0 +1,23 @@
package com.zsc.edu.bill.modules.bills.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zsc.edu.bill.modules.bills.entity.Bill;
import com.zsc.edu.bill.modules.bills.repo.BillRepository;
import com.zsc.edu.bill.modules.bills.service.BillService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author yao
*/
@AllArgsConstructor
@Service
public class BillServiceImpl extends ServiceImpl<BillRepository, Bill> implements BillService {
}