20 changed files with 874 additions and 20 deletions
@ -0,0 +1,66 @@ |
|||
package com.ccsens.yanyuan.api; |
|||
|
|||
import com.ccsens.cloudutil.annotation.MustLogin; |
|||
import com.ccsens.util.CodeError; |
|||
import com.ccsens.util.JsonResponse; |
|||
import com.ccsens.util.bean.dto.QueryDto; |
|||
import com.ccsens.yanyuan.bean.dto.MedicineDto; |
|||
import com.ccsens.yanyuan.bean.dto.ToolDto; |
|||
import com.ccsens.yanyuan.bean.vo.MedicineVo; |
|||
import com.ccsens.yanyuan.bean.vo.ToolVo; |
|||
import com.ccsens.yanyuan.service.IMedicineService; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
@Slf4j |
|||
@Api(tags = "药物使用相关" , description = "MedicineUseController | ") |
|||
@RestController |
|||
@RequestMapping("/medicine") |
|||
public class MedicineUseController { |
|||
|
|||
@Resource |
|||
private IMedicineService medicineService; |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "查询药物使用", notes = "查询药物使用") |
|||
@RequestMapping(value = "/query", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<MedicineVo.MedicineUse> queryMedicineUse(@ApiParam @Validated @RequestBody QueryDto<MedicineDto.QueryMedicineUse> params) throws Exception{ |
|||
log.info("查询药物使用:{}",params); |
|||
MedicineVo.MedicineUse medicineUse = medicineService.queryMedicineUse(params.getParam(),params.getUserId()); |
|||
log.info("查询药物使用结束{}",medicineUse); |
|||
return JsonResponse.newInstance().ok(medicineUse); |
|||
} |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "添加药物使用", notes = "添加药物使用") |
|||
@RequestMapping(value = "/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse addMedicineUse(@ApiParam @Validated @RequestBody QueryDto<MedicineDto.AddMedicineUse> params) throws Exception{ |
|||
log.info("添加药物使用:{}",params); |
|||
CodeError.Code code = medicineService.addMedicineUse(params.getParam(),params.getUserId()); |
|||
log.info("添加药物使用结束{}",code); |
|||
return JsonResponse.newInstance().ok(code); |
|||
} |
|||
|
|||
@MustLogin |
|||
@ApiOperation(value = "修改药物使用", notes = "修改药物使用") |
|||
@RequestMapping(value = "/update", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse updateMedicineUse(@ApiParam @Validated @RequestBody QueryDto<MedicineDto.UpdateMedicineUse> params) throws Exception{ |
|||
log.info("修改药物使用:{}",params); |
|||
CodeError.Code code = medicineService.updateMedicineUse(params.getParam(),params.getUserId()); |
|||
log.info("修改药物使用结束{}",code); |
|||
return JsonResponse.newInstance().ok(code); |
|||
} |
|||
} |
@ -0,0 +1,93 @@ |
|||
package com.ccsens.yanyuan.bean.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
public class MedicineDto { |
|||
@Data |
|||
@ApiModel("查询药物使用记录-入参") |
|||
public static class QueryMedicineUse { |
|||
@ApiModelProperty("项目id") |
|||
private Long projectId; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("添加药物使用记录-入参") |
|||
public static class AddMedicineUse { |
|||
@ApiModelProperty("项目id(使用者id)") |
|||
private Long projectId; |
|||
@ApiModelProperty("是否测评") |
|||
private String isTest; |
|||
@ApiModelProperty("测试时间") |
|||
private Date testAt; |
|||
@ApiModelProperty("Mmse得分") |
|||
private String mmseScore; |
|||
@ApiModelProperty("moca得分") |
|||
private String mocaScore; |
|||
@ApiModelProperty("adl得分") |
|||
private String adlScore; |
|||
@ApiModelProperty("npi得分") |
|||
private String npiScore; |
|||
@ApiModelProperty("总分") |
|||
private String totalScore; |
|||
@ApiModelProperty("第一种药物") |
|||
private String firstMedicine; |
|||
@ApiModelProperty("第二种药物") |
|||
private String secondMedicine; |
|||
@ApiModelProperty("第三种药物") |
|||
private String thirdMedicine; |
|||
@ApiModelProperty("第四种药物") |
|||
private String forthMedicine; |
|||
@ApiModelProperty("第五种药物") |
|||
private String fifthMedicine; |
|||
@ApiModelProperty("第六种药物") |
|||
private String sixthMedicine; |
|||
@ApiModelProperty("其他药物") |
|||
private String sevName; |
|||
@ApiModelProperty("其他药物服用情况") |
|||
private String sevMedicine; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("修改药物使用记录-入参") |
|||
public static class UpdateMedicineUse { |
|||
@ApiModelProperty("药物使用记录id") |
|||
private String id; |
|||
@ApiModelProperty("是否测评") |
|||
private String isTest; |
|||
@ApiModelProperty("测试时间") |
|||
private Date testAt; |
|||
@ApiModelProperty("Mmse得分") |
|||
private String mmseScore; |
|||
@ApiModelProperty("moca得分") |
|||
private String mocaScore; |
|||
@ApiModelProperty("adl得分") |
|||
private String adlScore; |
|||
@ApiModelProperty("npi得分") |
|||
private String npiScore; |
|||
@ApiModelProperty("总分") |
|||
private String totalScore; |
|||
@ApiModelProperty("第一种药物") |
|||
private String firstMedicine; |
|||
@ApiModelProperty("第二种药物") |
|||
private String secondMedicine; |
|||
@ApiModelProperty("第三种药物") |
|||
private String thirdMedicine; |
|||
@ApiModelProperty("第四种药物") |
|||
private String forthMedicine; |
|||
@ApiModelProperty("第五种药物") |
|||
private String fifthMedicine; |
|||
@ApiModelProperty("第六种药物") |
|||
private String sixthMedicine; |
|||
@ApiModelProperty("其他药物") |
|||
private String sevName; |
|||
@ApiModelProperty("其他药物服用情况") |
|||
private String sevMedicine; |
|||
} |
|||
} |
@ -0,0 +1,49 @@ |
|||
package com.ccsens.yanyuan.bean.vo; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
public class MedicineVo { |
|||
@Data |
|||
@ApiModel("药物使用记录-返参") |
|||
public static class MedicineUse { |
|||
@ApiModelProperty("药物使用记录id") |
|||
private String id; |
|||
@ApiModelProperty("是否测评") |
|||
private String isTest; |
|||
@ApiModelProperty("测试时间") |
|||
private Date testAt; |
|||
@ApiModelProperty("Mmse得分") |
|||
private String mmseScore; |
|||
@ApiModelProperty("moca得分") |
|||
private String mocaScore; |
|||
@ApiModelProperty("adl得分") |
|||
private String adlScore; |
|||
@ApiModelProperty("npi得分") |
|||
private String npiScore; |
|||
@ApiModelProperty("总分") |
|||
private String totalScore; |
|||
@ApiModelProperty("第一种药物") |
|||
private String firstMedicine; |
|||
@ApiModelProperty("第二种药物") |
|||
private String secondMedicine; |
|||
@ApiModelProperty("第三种药物") |
|||
private String thirdMedicine; |
|||
@ApiModelProperty("第四种药物") |
|||
private String forthMedicine; |
|||
@ApiModelProperty("第五种药物") |
|||
private String fifthMedicine; |
|||
@ApiModelProperty("第六种药物") |
|||
private String sixthMedicine; |
|||
@ApiModelProperty("其他药物") |
|||
private String sevName; |
|||
@ApiModelProperty("其他药物服用情况") |
|||
private String sevMedicine; |
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.ccsens.yanyuan.persist.dao; |
|||
|
|||
import com.ccsens.yanyuan.bean.vo.MedicineVo; |
|||
import com.ccsens.yanyuan.persist.mapper.FollowUpMapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
@Repository |
|||
public interface FollowUpDao extends FollowUpMapper { |
|||
|
|||
/** |
|||
* 查询使用者用药情况 |
|||
* @param uuId 使用者uuid |
|||
* @return 使用者用药情况 |
|||
*/ |
|||
MedicineVo.MedicineUse queryByUserId(@Param("userId") String uuId); |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.ccsens.yanyuan.persist.dao; |
|||
|
|||
import com.ccsens.yanyuan.persist.mapper.UserMapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
@Repository |
|||
public interface UserYDao extends UserMapper { |
|||
/** |
|||
* 查询使用者的uuid |
|||
* @param projectId 项目id(snowId) |
|||
* @return 使用者的uuid |
|||
*/ |
|||
String queryUUIdById(@Param("keyId") Long projectId); |
|||
} |
@ -0,0 +1,35 @@ |
|||
package com.ccsens.yanyuan.service; |
|||
|
|||
import com.ccsens.util.CodeError; |
|||
import com.ccsens.yanyuan.bean.dto.MedicineDto; |
|||
import com.ccsens.yanyuan.bean.vo.MedicineVo; |
|||
|
|||
/** |
|||
* @author AUSU |
|||
*/ |
|||
public interface IMedicineService { |
|||
|
|||
/** |
|||
* 查询药物使用记录 |
|||
* @param param 项目id |
|||
* @param userId 用户id |
|||
* @return 药物使用记录 |
|||
*/ |
|||
MedicineVo.MedicineUse queryMedicineUse(MedicineDto.QueryMedicineUse param, Long userId); |
|||
|
|||
/** |
|||
* 添加药物使用记录 |
|||
* @param param 药物使用情况 |
|||
* @param userId 添加者id |
|||
* @return 成功/失败 |
|||
*/ |
|||
CodeError.Code addMedicineUse(MedicineDto.AddMedicineUse param, Long userId); |
|||
|
|||
/** |
|||
* 修改药物使用记录 |
|||
* @param param 药物使用情况 |
|||
* @param userId 修改者id |
|||
* @return 成功/失败 |
|||
*/ |
|||
CodeError.Code updateMedicineUse(MedicineDto.UpdateMedicineUse param, Long userId); |
|||
} |
@ -0,0 +1,66 @@ |
|||
package com.ccsens.yanyuan.service; |
|||
|
|||
|
|||
|
|||
import cn.hutool.core.bean.BeanUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.ccsens.util.CodeError; |
|||
import com.ccsens.util.RedisUtil; |
|||
import com.ccsens.yanyuan.bean.dto.MedicineDto; |
|||
import com.ccsens.yanyuan.bean.po.FollowUp; |
|||
import com.ccsens.yanyuan.bean.vo.MedicineVo; |
|||
import com.ccsens.yanyuan.persist.dao.FollowUpDao; |
|||
import com.ccsens.yanyuan.persist.dao.UserYDao; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Propagation; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.UUID; |
|||
|
|||
@Slf4j |
|||
@Service |
|||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|||
public class MedicineService implements IMedicineService { |
|||
|
|||
@Resource |
|||
private FollowUpDao followUpDao; |
|||
@Resource |
|||
private UserYDao userYDao; |
|||
@Resource |
|||
private RedisUtil redisUtil; |
|||
|
|||
@Override |
|||
public MedicineVo.MedicineUse queryMedicineUse(MedicineDto.QueryMedicineUse param, Long userId) { |
|||
String uuId = userYDao.queryUUIdById(param.getProjectId()); |
|||
return followUpDao.queryByUserId(uuId); |
|||
} |
|||
|
|||
@Override |
|||
public CodeError.Code addMedicineUse(MedicineDto.AddMedicineUse param, Long userId) { |
|||
String uuIdById = userYDao.queryUUIdById(userId); |
|||
FollowUp followUp = new FollowUp(); |
|||
BeanUtil.copyProperties(param,followUp); |
|||
followUp.setId(UUID.randomUUID().toString()); |
|||
followUp.setUserId(uuIdById); |
|||
followUpDao.insertSelective(followUp); |
|||
return CodeError.SUCCESS; |
|||
} |
|||
|
|||
@Override |
|||
public CodeError.Code updateMedicineUse(MedicineDto.UpdateMedicineUse param, Long userId) { |
|||
Object o = redisUtil.get(param.getId()); |
|||
if (ObjectUtil.isNull(o)){ |
|||
redisUtil.set(param.getId(),"1"); |
|||
FollowUp followUp = new FollowUp(); |
|||
BeanUtil.copyProperties(param,followUp); |
|||
followUp.setId(param.getId()); |
|||
followUpDao.updateByPrimaryKeySelective(followUp); |
|||
redisUtil.del(param.getId()); |
|||
} |
|||
|
|||
return CodeError.SUCCESS; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,32 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ccsens.yanyuan.persist.dao.FollowUpDao"> |
|||
|
|||
|
|||
<select id="queryByUserId" resultType="com.ccsens.yanyuan.bean.vo.MedicineVo$MedicineUse"> |
|||
SELECT |
|||
id, |
|||
user_id, |
|||
is_test, |
|||
test_at, |
|||
mmse_score, |
|||
moca_score, |
|||
adl_score, |
|||
npi_score, |
|||
total_score, |
|||
first_medicine, |
|||
second_medicine, |
|||
third_medicine, |
|||
forth_medicine, |
|||
fifth_medicine, |
|||
sixth_medicine, |
|||
sev_name, |
|||
sev_medicine |
|||
FROM |
|||
u_follow_up |
|||
WHERE |
|||
rec_status = 0 |
|||
AND user_id = #{userId} |
|||
</select> |
|||
|
|||
</mapper> |
@ -0,0 +1,16 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ccsens.yanyuan.persist.dao.UserYDao"> |
|||
|
|||
|
|||
<select id="queryUUIdById" resultType="String"> |
|||
SELECT |
|||
id |
|||
FROM |
|||
u_user |
|||
WHERE |
|||
rec_status = 0 |
|||
AND key_id = #{keyId} |
|||
</select> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue