This commit is contained in:
skjia 2025-06-09 15:57:19 +08:00
parent 3fe1cb6e88
commit d4357b9949
5 changed files with 104 additions and 23 deletions

View File

@ -10,7 +10,7 @@ import com.bonus.common.core.web.domain.BaseEntity;
/**
* 营养科普对象 health_popular_article
*
*
* @author xsheng
* @date 2025-05-25
*/
@ -74,6 +74,8 @@ public class HealthPopularArticle extends BaseEntity {
@Excel(name = "文章摘要")
@ApiModelProperty(value = "文章摘要")
private String summary;
private String chronicIds;
private String chronicId;
private String chronicName;
private String chronicNames;
}

View File

@ -1,18 +1,21 @@
package com.bonus.canteen.core.health.mapper;
import java.util.List;
import com.bonus.canteen.core.health.domain.HealthPersonInfo;
import com.bonus.canteen.core.health.domain.HealthPopularArticle;
import org.apache.ibatis.annotations.Param;
/**
* 营养科普Mapper接口
*
*
* @author xsheng
* @date 2025-05-25
*/
public interface HealthPopularArticleMapper {
/**
* 查询营养科普
*
*
* @param articleId 营养科普主键
* @return 营养科普
*/
@ -20,15 +23,15 @@ public interface HealthPopularArticleMapper {
/**
* 查询营养科普列表
*
*
* @param healthPopularArticle 营养科普
* @return 营养科普集合
*/
public List<HealthPopularArticle> selectHealthPopularArticleList(HealthPopularArticle healthPopularArticle);
/**
* 新增营养科普
*
*
* @param healthPopularArticle 营养科普
* @return 结果
*/
@ -36,7 +39,7 @@ public interface HealthPopularArticleMapper {
/**
* 修改营养科普
*
*
* @param healthPopularArticle 营养科普
* @return 结果
*/
@ -44,7 +47,7 @@ public interface HealthPopularArticleMapper {
/**
* 删除营养科普
*
*
* @param articleId 营养科普主键
* @return 结果
*/
@ -52,9 +55,13 @@ public interface HealthPopularArticleMapper {
/**
* 批量删除营养科普
*
*
* @param articleIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteHealthPopularArticleByArticleIds(Long[] articleIds);
int insertHealthArticleChronic(@Param("entities") List<HealthPopularArticle> entities);
public int deleteHealthArticleChronic(HealthPopularArticle healthPopularArticle);
}

View File

@ -1,6 +1,10 @@
package com.bonus.canteen.core.health.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.bonus.canteen.core.health.domain.HealthPersonInfo;
import com.bonus.canteen.core.health.mapper.HealthPersonInfoMapper;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,6 +24,9 @@ public class HealthPopularArticleServiceImpl implements IHealthPopularArticleSer
@Autowired
private HealthPopularArticleMapper healthPopularArticleMapper;
@Autowired
private HealthPersonInfoMapper healthPersonInfoMapper;
/**
* 查询营养科普
*
@ -68,6 +75,27 @@ public class HealthPopularArticleServiceImpl implements IHealthPopularArticleSer
public int updateHealthPopularArticle(HealthPopularArticle healthPopularArticle) {
healthPopularArticle.setUpdateTime(DateUtils.getNowDate());
try {
HealthPersonInfo chronicVo=new HealthPersonInfo();
chronicVo.setChronicIds(healthPopularArticle.getChronicIds());
List<HealthPersonInfo> chronicVos=healthPersonInfoMapper.selectHealthChronicList(chronicVo);
if(chronicVos!=null&&chronicVos.size()>0){
/**
* 清空疾病信息
*/
healthPopularArticleMapper.deleteHealthArticleChronic(healthPopularArticle);
List<HealthPopularArticle> articleVos=new ArrayList<>();
for(HealthPersonInfo vo:chronicVos){
HealthPopularArticle hpa=new HealthPopularArticle();
hpa.setArticleId(healthPopularArticle.getArticleId());
hpa.setChronicId(vo.getChronicIds());
hpa.setChronicName(vo.getChronicNames());
articleVos.add(hpa);
}
/**
* 重新录入疾病信息
*/
healthPopularArticleMapper.insertHealthArticleChronic(articleVos);
}
return healthPopularArticleMapper.updateHealthPopularArticle(healthPopularArticle);
} catch (Exception e) {
throw new ServiceException(e.getMessage());

View File

@ -159,7 +159,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select medical_project_id as medicalprojectid,medical_project_name as medicalprojectname,medical_id as medicalid
from health_person_medical_report_project a
where medical_id = #{medicalId}
ORDER BY create_time ASC
ORDER BY id ASC
</select>
<select id="getReportDetailById" parameterType="com.bonus.canteen.core.health.domain.HealthMedicalReportDetails" resultType="com.bonus.canteen.core.health.domain.HealthMedicalReportDetail">
select medical_project_id as medicalprojectid,medical_project_detail_name as medicalprojectdetailname,medical_project_detail_unit as medicalprojectdetailunit

View File

@ -26,19 +26,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectHealthPopularArticleList" parameterType="com.bonus.canteen.core.health.domain.HealthPopularArticle" resultMap="HealthPopularArticleResult">
<include refid="selectHealthPopularArticleVo"/>
select
aa.article_id,
aa.article_title,
aa.cover_photo,
aa.article_type,
aa.article_content,
aa.article_url,
aa.if_visible,
aa.hits,
aa.if_pushed,
aa.push_time,
aa.summary,
aa.create_by,
aa.create_time,
aa.update_by,
aa.update_time ,
GROUP_CONCAT(bb.chronic_name ORDER BY bb.chronic_id desc) AS chronic_names,
GROUP_CONCAT(bb.chronic_id ORDER BY bb.chronic_id desc) AS chronic_ids
from health_popular_article aa
left join health_popular_article_chronic bb on aa.article_id=bb.article_id
<where>
<if test="articleTitle != null and articleTitle != ''"> and article_title = #{articleTitle}</if>
<if test="coverPhoto != null and coverPhoto != ''"> and cover_photo = #{coverPhoto}</if>
<if test="articleType != null "> and article_type = #{articleType}</if>
<if test="articleContent != null and articleContent != ''"> and article_content = #{articleContent}</if>
<if test="articleUrl != null and articleUrl != ''"> and article_url = #{articleUrl}</if>
<if test="ifVisible != null "> and if_visible = #{ifVisible}</if>
<if test="hits != null "> and hits = #{hits}</if>
<if test="ifPushed != null "> and if_pushed = #{ifPushed}</if>
<if test="pushTime != null "> and push_time = #{pushTime}</if>
<if test="summary != null and summary != ''"> and summary = #{summary}</if>
<if test="articleTitle != null and articleTitle != ''"> and aa.article_title = #{articleTitle}</if>
<if test="coverPhoto != null and coverPhoto != ''"> and aa.cover_photo = #{coverPhoto}</if>
<if test="articleType != null "> and aa.article_type = #{articleType}</if>
<if test="articleContent != null and articleContent != ''"> and aa.article_content = #{articleContent}</if>
<if test="articleUrl != null and articleUrl != ''"> and aa.article_url = #{articleUrl}</if>
<if test="ifVisible != null "> and aa.if_visible = #{ifVisible}</if>
<if test="hits != null "> and aa.hits = #{hits}</if>
<if test="ifPushed != null "> and aa.if_pushed = #{ifPushed}</if>
<if test="pushTime != null "> and aa.push_time = #{pushTime}</if>
<if test="summary != null and summary != ''"> and aa.summary = #{summary}</if>
</where>
group by aa.article_id,
aa.article_title,
aa.cover_photo,
aa.article_type,
aa.article_content,
aa.article_url,
aa.if_visible,
aa.hits,
aa.if_pushed,
aa.push_time,
aa.summary,
aa.create_by,
aa.create_time,
aa.update_by,
aa.update_time
</select>
<select id="selectHealthPopularArticleByArticleId" parameterType="Long" resultMap="HealthPopularArticleResult">
@ -113,4 +147,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{articleId}
</foreach>
</delete>
<delete id="deleteHealthArticleChronic" parameterType="Long">
delete from health_popular_article_chronic where article_id = #{articleId}
</delete>
<insert id="insertHealthArticleChronic" parameterType="com.bonus.canteen.core.health.domain.HealthPopularArticle">
insert into health_popular_article_chronic(article_id, chronic_id, chronic_name)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.articleId}, #{entity.chronicId}, #{entity.chronicName})
</foreach>
</insert>
</mapper>