晏有为
2024-05-23 10de56ca16261e6a4eec49dfd32f0a6b232f7baf
framework/src/main/java/com/yuanchu/mom/utils/GiveCode.java
@@ -13,13 +13,14 @@
    @Resource
    private SystemLogMapper systemLogMapper;
    public String giveCode(String code, String tableName){
    public String giveCode(String code, String tableName, String symbol, String patten){
        String date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
        String date2 = LocalDate.now().format(DateTimeFormatter.ofPattern(patten));
        int num = systemLogMapper.countRowsByNow(tableName, LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))) + 1;
        String nums = num + "";
        if(nums.length() == 1) nums = "00" + num;
        else if(nums.length() == 2) nums = "0" + num;
        return code + date + "-" + nums;
        return code + (date2==null?date:date2) + symbol + nums;
    }
}