营养科普

This commit is contained in:
sxu 2025-05-13 14:29:26 +08:00
parent 07c6a93413
commit 86deb2e639
2 changed files with 10 additions and 3 deletions

View File

@ -3,6 +3,8 @@ package com.bonus.canteen.core.nutrition.service.impl;
import java.util.List;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.houqin.utils.id.Id;
import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bonus.canteen.core.nutrition.mapper.HealthChronicMapper;
@ -51,10 +53,12 @@ public class HealthChronicServiceImpl implements IHealthChronicService {
@Override
public int insertHealthChronic(HealthChronic healthChronic) {
healthChronic.setCreateTime(DateUtils.getNowDate());
healthChronic.setCreateBy(SecurityUtils.getUsername());
try {
healthChronic.setChronicId(Id.next());
return healthChronicMapper.insertHealthChronic(healthChronic);
} catch (Exception e) {
throw new ServiceException("错误信息描述, " + e.getMessage());
throw new ServiceException("新增错误, " + e.getMessage());
}
}
@ -70,7 +74,7 @@ public class HealthChronicServiceImpl implements IHealthChronicService {
try {
return healthChronicMapper.updateHealthChronic(healthChronic);
} catch (Exception e) {
throw new ServiceException("错误信息描述, " + e.getMessage());
throw new ServiceException("更新错误, " + e.getMessage());
}
}

View File

@ -8,6 +8,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.bonus.canteen.core.nutrition.domain.HealthArticleChronic;
import com.bonus.canteen.core.nutrition.mapper.HealthArticleChronicMapper;
import com.bonus.canteen.core.nutrition.mapper.HealthChronicMapper;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.security.utils.SecurityUtils;
@ -29,6 +30,8 @@ public class HealthPopularScienceServiceImpl implements IHealthPopularScienceSer
private HealthPopularScienceMapper healthPopularScienceMapper;
@Autowired
HealthArticleChronicMapper healthArticleChronicMapper;
@Autowired
HealthChronicMapper healthChronicMapper;
/**
* 查询营养科普
@ -78,7 +81,7 @@ public class HealthPopularScienceServiceImpl implements IHealthPopularScienceSer
for (Long chronicId : chronicIdList) {
vo.setArticleId(healthPopularScience.getArticleId());
vo.setChronicId(chronicId);
vo.setChronicName(healthArticleChronicMapper.selectHealthArticleChronicById(chronicId).getChronicName());
vo.setChronicName(healthChronicMapper.selectHealthChronicById(chronicId).getChronicName());
healthArticleChronicMapper.insertHealthArticleChronic(vo);
}
}