欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

报销申请的编写(后端)

程序员文章站 2022-12-20 18:56:44
1. 使用mybatis generater自动生成entity、service、mapper1.1 entity:ExpenseAccount注意entity的LocalDateTime都改成Date在create_time和update_time前分别加 @TableField(fill = FieldFill.INSERT)和 @TableField(fill = FieldFill.UPDATE)1.2 sevice:ExpenseAccountService1.2.1 生成流水号se...

1. 使用mybatis generater自动生成entity、service、mapper

1.1 entity:ExpenseAccount

注意entity的LocalDateTime都改成Date
在create_time和update_time前分别加 @TableField(fill = FieldFill.INSERT)@TableField(fill = FieldFill.UPDATE)

1.2 sevice:ExpenseAccountService

1.2.1 生成流水号serialNumberUtil

package com.realdd.medcost.common.utils;

import cn.hutool.core.date.format.FastDateFormat;
import org.springframework.stereotype.Component;
import java.util.Date;

/**
 * Created by duanduan on 2020/11/8 17:42
 */
@Component
public class SerialNumberUtil {


    public String getSerialNumber(){
        //1.获取当前时间
        String t=FastDateFormat.getInstance("yyyyMMddHHmmssSSS").format(new Date());
        //2.获取3位随机数
        int x=(int)(Math.random()*900)+100;
        return t+x;

    }
}

1.2.2 ExpenseAccountServiceImpl

 @Autowired
    SerialNumberUtil serialNumberUtil;

    @Override
    public boolean create(ExpenseAccount expenseAccount) {
        expenseAccount.setSerialNum(serialNumberUtil.getSerialNumber());
        return save(expenseAccount);
    }

1.3controller:ExpenseAccountController

 @Autowired
    ExpenseAccountService expenseAccountService;

    @ApiOperation("添加报销单")
    @PostMapping(value = "/create")
    public CommonResult create(ExpenseAccount expenseAccount){
        boolean success=expenseAccountService.create(expenseAccount);
        if(success){
            return CommonResult.success(null);
        }
        return CommonResult.failed();
    }

本文地址:https://blog.csdn.net/weixin_38730264/article/details/109562990

相关标签: 医疗报销系统