Files
todo-backend/src/main/java/com/example/building/service/SystemConfigService.java

44 lines
1.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.example.building.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.building.entity.SystemConfig;
import com.example.building.mapper.SystemConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
@Service
public class SystemConfigService {
@Autowired
private SystemConfigMapper systemConfigMapper;
/**
* 获取顾客订单可见天数配置
* 默认180天半年
*/
public int getCustomerOrderVisibleDays() {
LambdaQueryWrapper<SystemConfig> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SystemConfig::getConfigKey, "customer_order_visible_days");
SystemConfig config = systemConfigMapper.selectOne(wrapper);
if (config != null && config.getConfigValue() != null) {
try {
return Integer.parseInt(config.getConfigValue());
} catch (NumberFormatException e) {
return 180;
}
}
return 180; // 默认半年
}
/**
* 获取顾客可见订单开始日期
*/
public LocalDate getCustomerOrderStartDate() {
int days = getCustomerOrderVisibleDays();
return LocalDate.now().minusDays(days);
}
}