jsk 健康
This commit is contained in:
parent
9ec6670a51
commit
a667b8ef68
|
|
@ -2,18 +2,22 @@ package com.bonus.canteen.core.nutrition.controller;
|
|||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bonus.canteen.core.nutrition.common.dto.HealthInfoFullDto;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo;
|
||||
import com.bonus.canteen.core.nutrition.domain.HealthPopularScience;
|
||||
import com.bonus.canteen.core.nutrition.service.HealthInfoService;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
import static com.bonus.common.core.web.domain.AjaxResult.success;
|
||||
|
||||
@RestController
|
||||
|
|
@ -21,18 +25,30 @@ import static com.bonus.common.core.web.domain.AjaxResult.success;
|
|||
tags = {"健康档案"}
|
||||
)
|
||||
@RequestMapping({"/health/info"})
|
||||
public class HealthInfoController {
|
||||
public class HealthInfoController extends BaseController {
|
||||
private static final Logger log = LoggerFactory.getLogger(HealthInfoController.class);
|
||||
@Resource
|
||||
private HealthInfoService healthInfoService;
|
||||
|
||||
/**
|
||||
* 查询营养科普列表
|
||||
*/
|
||||
@ApiOperation(value = "查询健康档案列表")
|
||||
//@RequiresPermissions("nutrition:science:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(HealthInfoSimpleVo healthInfoSimpleVo) {
|
||||
startPage();
|
||||
List<HealthInfoSimpleVo> list = healthInfoService.selectHealthInfoList(healthInfoSimpleVo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@ApiOperation("获取人员档案详情")
|
||||
@PostMapping({"/detail-health-info"})
|
||||
public AjaxResult detailHealthInfo(@RequestBody HealthInfoFullDto dto) {
|
||||
if (ObjectUtil.isNull(dto.getUserId())) {
|
||||
throw new ServiceException("用户id不能为空");
|
||||
} else {
|
||||
return success(this.healthInfoService.detailHealthInfo(dto.getUserId()));
|
||||
return success(healthInfoService.detailHealthInfo(dto.getUserId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -42,7 +58,7 @@ public class HealthInfoController {
|
|||
if (ObjectUtil.isNull(healthInfoFullDto.getUserId())) {
|
||||
throw new ServiceException("用户id不能为空");
|
||||
} else {
|
||||
return success(this.healthInfoService.editHealthInfo(healthInfoFullDto));
|
||||
return success(healthInfoService.editHealthInfo(healthInfoFullDto));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,22 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
import com.bonus.canteen.core.nutrition.common.model.HealthInfo;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo;
|
||||
import com.bonus.canteen.core.nutrition.domain.HealthPopularScience;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface HealthInfoMapper extends BaseMapper<HealthInfo> {
|
||||
|
||||
/**
|
||||
* 查询健康档案列表
|
||||
*
|
||||
* @param healthInfoSimpleVo 健康档案
|
||||
* @return 健康档案集合
|
||||
*/
|
||||
public List<HealthInfoSimpleVo> selectHealthInfoList(HealthInfoSimpleVo healthInfoSimpleVo);
|
||||
|
||||
HealthInfoSimpleVo getSimpleInfo(Long userId);
|
||||
|
||||
HealthInfoFullVo fullHealthInfo(Long userId);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,20 @@ package com.bonus.canteen.core.nutrition.service;
|
|||
import com.bonus.canteen.core.nutrition.common.dto.HealthInfoFullDto;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo;
|
||||
import com.bonus.canteen.core.nutrition.domain.HealthPopularScience;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface HealthInfoService {
|
||||
|
||||
/**
|
||||
* 查询健康档案列表
|
||||
*
|
||||
* @param healthInfoSimpleVo 健康档案
|
||||
* @return 健康档案集合
|
||||
*/
|
||||
public List<HealthInfoSimpleVo> selectHealthInfoList(HealthInfoSimpleVo healthInfoSimpleVo);
|
||||
|
||||
HealthInfoSimpleVo simplifyHealthInfo(Long userId);
|
||||
|
||||
HealthInfoFullVo detailHealthInfo(Long userId);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.bonus.canteen.core.nutrition.common.dto.HealthInfoFullDto;
|
||||
import com.bonus.canteen.core.nutrition.common.enums.CustAgeEnum;
|
||||
import com.bonus.canteen.core.nutrition.common.enums.HealthInfoSourceEnum;
|
||||
import com.bonus.canteen.core.nutrition.domain.HealthPopularScience;
|
||||
import com.bonus.canteen.core.nutrition.mapper.HealthInfoMapper;
|
||||
import com.bonus.canteen.core.nutrition.common.model.HealthBodyRecord;
|
||||
import com.bonus.canteen.core.nutrition.common.model.HealthInfo;
|
||||
|
|
@ -18,6 +19,7 @@ import com.bonus.canteen.core.nutrition.service.HealthInfoService;
|
|||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoFullVo;
|
||||
import com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo;
|
||||
import com.bonus.canteen.core.nutrition.common.utils.NuConvertUtil;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.houqin.utils.LeBeanUtil;
|
||||
import com.bonus.common.houqin.utils.id.Id;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -43,11 +45,28 @@ public class HealthInfoServiceImpl extends ServiceImpl<HealthInfoMapper, HealthI
|
|||
@Autowired
|
||||
private HealthInfoMapper healthInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询健康档案列表
|
||||
*
|
||||
* @param healthInfoSimpleVo 健康档案
|
||||
* @return 健康档案
|
||||
*/
|
||||
@Override
|
||||
public List<HealthInfoSimpleVo> selectHealthInfoList(HealthInfoSimpleVo healthInfoSimpleVo) {
|
||||
// String chronicIds = healthPopularScience.getChronicIds();
|
||||
// if (StringUtils.isNotEmpty(chronicIds)) {
|
||||
// String[] chronicIdArray = chronicIds.split(",");
|
||||
// healthPopularScience.setChronicIdArray(chronicIdArray);
|
||||
// }
|
||||
return healthInfoMapper.selectHealthInfoList(healthInfoSimpleVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HealthInfoSimpleVo simplifyHealthInfo(Long userId) {
|
||||
return healthInfoMapper.getSimpleInfo(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HealthInfoFullVo detailHealthInfo(Long userId) {
|
||||
HealthInfoFullVo healthInfoFullVo = ((HealthInfoMapper)this.baseMapper).fullHealthInfo(userId);
|
||||
healthInfoFullVo.setAge(CustAgeEnum.getAge(healthInfoFullVo.getBirthday()));
|
||||
|
|
@ -57,6 +76,7 @@ public class HealthInfoServiceImpl extends ServiceImpl<HealthInfoMapper, HealthI
|
|||
@Transactional(
|
||||
rollbackFor = {Exception.class}
|
||||
)
|
||||
@Override
|
||||
public Integer editHealthInfo(HealthInfoFullDto content) {
|
||||
Long userId = content.getUserId();
|
||||
BigDecimal bmi = NuConvertUtil.getBMI(content.getWeight(), content.getHeight());
|
||||
|
|
|
|||
|
|
@ -3,6 +3,40 @@
|
|||
|
||||
<mapper namespace="com.bonus.canteen.core.nutrition.mapper.HealthInfoMapper">
|
||||
|
||||
<select id="selectHealthInfoList" resultType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo">
|
||||
SELECT a.user_id,
|
||||
a.nick_name,
|
||||
a.phonenumber as mobile,
|
||||
a.photo_url as custPhotoUrl,
|
||||
a.sex,
|
||||
d.height,
|
||||
d.weight,
|
||||
d.bmi,
|
||||
b.doctor_advice,
|
||||
b.allergen,
|
||||
b.labour_intensity,
|
||||
b.pregnant_status,
|
||||
GROUP_CONCAT(c.chronic_name ORDER BY c.chronic_id desc) AS chronic_names,
|
||||
GROUP_CONCAT(c.chronic_id ORDER BY c.chronic_id desc) AS chronic_ids
|
||||
from sys_user a
|
||||
left join health_info b on a.user_id = b.user_id
|
||||
left join health_info_chronic c on a.user_id = c.user_id
|
||||
left join health_body_record d on a.user_id = d.user_id and d.if_latest = 1
|
||||
where 1 = 1
|
||||
group by a.user_id,
|
||||
a.nick_name,
|
||||
a.dept_id,
|
||||
a.phonenumber,
|
||||
a.photo_url,
|
||||
a.sex,
|
||||
d.height,
|
||||
d.weight,
|
||||
d.bmi,
|
||||
b.doctor_advice,
|
||||
b.allergen,
|
||||
b.labour_intensity,
|
||||
b.pregnant_status
|
||||
</select>
|
||||
<select id="getSimpleInfo" resultType="com.bonus.canteen.core.nutrition.common.vo.HealthInfoSimpleVo">
|
||||
SELECT a.user_id,
|
||||
a.nick_name,
|
||||
|
|
|
|||
Loading…
Reference in New Issue