| | |
| | | package com.ruoyi.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.domain.ZHealthNote; |
| | | import com.ruoyi.mapper.ZHealthNoteMapper; |
| | | import com.ruoyi.service.ZHealthNoteService; |
| | |
| | | **/ |
| | | @Service |
| | | public class ZHealthNoteServiceImpl extends ServiceImpl<ZHealthNoteMapper, ZHealthNote> implements ZHealthNoteService { |
| | | @Override |
| | | public AjaxResult listAll() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | LambdaQueryWrapper<ZHealthNote> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZHealthNote::getUid,userId); |
| | | ZHealthNote result = getOne(lqw); |
| | | if(result == null){ |
| | | throw new RuntimeException("请先填写好数据"); |
| | | } |
| | | |
| | | return AjaxResult.success(result); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult saveData(ZHealthNote zHealthNote) { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | LambdaQueryWrapper<ZHealthNote> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZHealthNote::getUid,userId); |
| | | ZHealthNote result = getOne(lqw); |
| | | |
| | | if(result == null){ |
| | | zHealthNote.setUid(userId); |
| | | save(zHealthNote); |
| | | }else { |
| | | zHealthNote.setId(result.getId()); |
| | | zHealthNote.setUid(userId); |
| | | updateById(zHealthNote); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | } |