| | |
| | | package com.iailab.module.infra.api.config; |
| | | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.module.infra.api.file.FileApi; |
| | | import com.iailab.module.infra.api.file.dto.FileCreateReqDTO; |
| | | import com.iailab.module.infra.dal.dataobject.config.ConfigDO; |
| | | import com.iailab.module.infra.service.config.ConfigService; |
| | | import com.iailab.module.infra.service.file.FileService; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | // /** |
| | | // * 查月初或者年初(根据code) |
| | | // * |
| | | // * @return |
| | | // */ |
| | | // @Override |
| | | // public String queryConfigByCode(String configCode, String type){ |
| | | // String result = ""; |
| | | // String value = configService.getValue(configCode); |
| | | // Calendar calendar = Calendar.getInstance(); |
| | | // calendar.setTime(new Date()); |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // if("month".equals(type)){ |
| | | // int nowDay = calendar.get(Calendar.DAY_OF_MONTH); |
| | | // if(nowDay < Integer.parseInt(value)){ |
| | | // calendar.add(Calendar.MONTH, -1); |
| | | // } |
| | | // calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(value)); |
| | | // } else { |
| | | // int month = Integer.parseInt(value.substring(0,value.indexOf("-"))); |
| | | // int day = Integer.parseInt(value.substring(value.indexOf("-") + 1)); |
| | | // int nowMonth = calendar.get(Calendar.MONTH) + 1; |
| | | // int nowDay = calendar.get(Calendar.DAY_OF_MONTH); |
| | | // |
| | | // if(nowMonth == month) { |
| | | // if(nowDay < day){ |
| | | // calendar.add(Calendar.YEAR, -1); |
| | | // } |
| | | // } else if(nowMonth < month) { |
| | | // calendar.add(Calendar.YEAR, -1); |
| | | // } |
| | | // calendar.set(Calendar.MONTH, month - 1); |
| | | // calendar.set(Calendar.DAY_OF_MONTH, day); |
| | | // } |
| | | // |
| | | // result = sdf.format(calendar.getTime()); |
| | | // |
| | | // return result; |
| | | // } |
| | | |
| | | @Override |
| | | public String queryConfigByCode(String configCode) { |
| | | return configService.getValue(configCode); |
| | | ConfigDO configByKey = configService.getConfigByKey(configCode); |
| | | return ObjectUtils.isNotEmpty(configByKey) ? configByKey.getValue() : ""; |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<String> getConfigValueByKey(String key) { |
| | | ConfigDO config = configService.getConfigByKey(key); |
| | | return success(config != null ? config.getValue() : null); |
| | | } |
| | | |
| | | |
| | | } |