package com.example.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.example.common.Result;
import com.example.common.ResultCode;
import com.example.entity.JiankangziceInfo;
import com.example.dao.JiankangziceInfoDao;
import com.example.service.JiankangziceInfoService;
import com.example.exception.CustomException;
import com.example.common.ResultCode;
import com.example.vo.EchartsData;
import com.example.vo.JiankangziceInfoVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.example.service.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Value;
import cn.hutool.core.util.StrUtil;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(value = "/jiankangziceInfo")
public class JiankangziceInfoController {
@Resource
private JiankangziceInfoService jiankangziceInfoService;
@Resource
private JiankangziceInfoDao jiankangziceInfoDao;
@PostMapping
public Result<JiankangziceInfo> add(@RequestBody JiankangziceInfoVo jiankangziceInfo) {
//mixmajixami
jiankangziceInfoService.add(jiankangziceInfo);
return Result.success(jiankangziceInfo);
}
//youtixing1
//youtixing2
@GetMapping("/getByDiqu")
public Result<List<Map<String,String>>> qidu() {
return Result.success(jiankangziceInfoService.findByDiqu());
}
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
jiankangziceInfoService.delete(id);
return Result.success();
}
@GetMapping("/getByzhuceyonghuZhanghao/{zhanghao}")
public Result<List<JiankangziceInfo>> getByzhuceyonghuZhanghao(@PathVariable String zhanghao) {
List<JiankangziceInfo> jiankangziceInfo = jiankangziceInfoService.getByzhuceyonghuZhanghao(zhanghao);
return Result.success(jiankangziceInfo);
}
@PutMapping
public Result update(@RequestBody JiankangziceInfoVo jiankangziceInfo) {
jiankangziceInfoService.update(jiankangziceInfo);
return Result.success();
}
//@PutMapping("/update2")
// public Result update2(@RequestBody JiankangziceInfoVo jiankangziceInfo) {
// jiankangziceInfoService.update2(jiankangziceInfo);
// return Result.success();
// }
@GetMapping("/{id}")
public Result<JiankangziceInfo> detail(@PathVariable Long id) {
JiankangziceInfo jiankangziceInfo = jiankangziceInfoService.findById(id);
return Result.success(jiankangziceInfo);
}
@GetMapping("/changeStatus/{id}")
public Result<JiankangziceInfo> changeStatus(@PathVariable Long id) {
jiankangziceInfoService.changeStatus(id);
return Result.success();
}
@GetMapping
public Result<List<JiankangziceInfoVo>> all() {
return Result.success(jiankangziceInfoService.findAll());
}
@GetMapping("/page/{name}")
public Result<PageInfo<JiankangziceInfoVo>> page(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
HttpServletRequest request) {
return Result.success(jiankangziceInfoService.findPage(name, pageNum, pageSize, request));
}
@GetMapping("/pageqt/{name}")
public Result<PageInfo<JiankangziceInfoVo>> pageqt(@PathVariable String name,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "8") Integer pageSize,
HttpServletRequest request) {
return Result.success(jiankangziceInfoService.findPageqt(name, pageNum, pageSize, request));
}
// @PostMapping("/register")
// public Result<JiankangziceInfo> register(@RequestBody JiankangziceInfo jiankangziceInfo) {
// if (StrUtil.isBlank(jiankangziceInfo.getName()) || StrUtil.isBlank(jiankangziceInfo.getPassword())) {
// throw new CustomException(ResultCode.PARAM_ERROR);
// }
// return Result.success(jiankangziceInfoService.add(jiankangziceInfo));
// }
/**
* 批量通过excel添加信息
* @param file excel文件
* @throws IOException
*/
@PostMapping("/upload")
public Result upload(MultipartFile file) throws IOException {
List<JiankangziceInfo> infoList = ExcelUtil.getReader(file.getInputStream()).readAll(JiankangziceInfo.class);
if (!CollectionUtil.isEmpty(infoList)) {
// 处理一下空数据
List<JiankangziceInfo> resultList = infoList.stream().filter(x -> ObjectUtil.isNotEmpty(x.getRiqi())).collect(Collectors.toList());
for (JiankangziceInfo info : resultList) {
jiankangziceInfoService.add(info);
}
}
return Result.success();
}
//yoxutonxgjitu
@GetMapping("/getExcelModel")
public void getExcelModel(HttpServletResponse response) throws IOException {
// 1. 生成excel
Map<String, Object> row = new LinkedHashMap<>();
row.put("riqi", "A日期");
row.put("xueya", "A血压");
row.put("xuetang", "A血糖");
row.put("shuimianshijian", "A睡眠时间");
row.put("tizhong", "A体重");
row.put("shengao", "A身高");
row.put("zhanghao", "A账号");
row.put("xingming", "A姓名");
row.put("huifu", "A回复");
row.put("status", "是");
row.put("level", "jiankangzice");
List<Map<String, Object>> list = CollUtil.newArrayList(row);
// 2. 写excel
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.write(list, true);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
response.setHeader("Content-Disposition","attachment;filename=jiankangziceInfoModel.xlsx");
ServletOutputStream out = response.getOutputStream();
writer.flush(out, true);
writer.close();
IoUtil.close(System.out);
}
@GetMapping("/getExcel")
public void getExcel(HttpServletResponse response) throws IOException {
// 1. 生成excel
Map<String, Object> row = new LinkedHashMap<>();
row.put("riqi", "A日期");
row.put("xueya", "A血压");
row.put("xuetang", "A血糖");
row.put("shuimianshijian", "A睡眠时间");
row.put("tizhong", "A体重");
row.put("shengao", "A身高");
row.put("zhanghao", "A账号");
row.put("xingming", "A姓名");
row.put("huifu", "A回复");
row.put("status", "是");
row.put("level", "权限");
List<Map<String, Object>> list = CollUtil.newArrayList(row);
List<Map<String, Object>> daochuexcellist = jiankangziceInfoDao.daochuexcel();
Map<String, Double> typeMap = new HashMap<>();
for (Map<String, Object> map : daochuexcellist) {
list.add(map);
}
// 2. 写excel
ExcelWriter writer = ExcelUtil.getWriter(true);
writer.write(list, true);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
response.setHeader("Content-
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于微信小程序开发的老年人健康管理平台(后端java+mysql).zip 采用小程序+后台服务端 java,jsp技术开发, mysql数据库 小程序端 A5 后台服务端:ZDA+ZDB 老年人健康小程序 小程序端: 用户登录 健康科普知识 健康食谱查看 健康情况自测管理(日期,血压,血糖,睡眠时间,体重,身高,提交后,后台根据测试可以进行回复) 健康问卷,填写后,可以查看问卷结果 在线留言 管理员 用户管理 健康科普知识管理 食谱管理 健康自测管理 问卷管理 在线留言管理
资源推荐
资源详情
资源评论
收起资源包目录
基于微信小程序开发的老年人健康管理平台(后端java+mysql).zip (785个子文件)
ZhuceyonghuInfoController.class 13KB
JiankangziceInfoController.class 13KB
XinwentongzhiInfoController.class 13KB
JiankangshipuInfoController.class 13KB
LiuyanbanInfoController.class 12KB
NxTestpaperInfoService.class 11KB
AccountController.class 11KB
AdminInfoController.class 9KB
NxSystemFileController.class 8KB
UserTextInfoController.class 8KB
NxQuestionInfoController.class 8KB
UserTextInfoService.class 7KB
YonghuService.class 7KB
NxTestpaperInfoController.class 7KB
ZhuceyonghuInfoService.class 6KB
YonghuController.class 5KB
EchartsController.class 5KB
XinwentongzhiInfoService.class 5KB
JiankangziceInfoService.class 5KB
AdminInfoService.class 5KB
NxScoreInfoService.class 5KB
AdminInfo.class 4KB
UserTextInfo.class 4KB
JiankangshipuInfoService.class 4KB
CommentInfoService.class 4KB
NxScoreInfoController.class 4KB
NxUserPaperInfoService.class 4KB
XinwentongzhiInfo.class 4KB
ZhuceyonghuInfo.class 4KB
PaperCommentInfoController.class 4KB
LiuyanbanInfoService.class 4KB
CommentInfoController.class 4KB
CollectInfoController.class 4KB
NxUserPaperInfoController.class 4KB
JiankangshipuInfo.class 3KB
RichtextInfoController.class 3KB
UserTextInfoDao.class 3KB
JiankangziceInfo.class 3KB
PaperCommentInfoService.class 3KB
CollectInfoService.class 3KB
NxQuestionInfoService.class 3KB
RichtextInfoService.class 3KB
NxScoreInfo.class 3KB
NxSystemFileInfoService.class 3KB
LiuyanbanInfo.class 3KB
CollectInfo.class 3KB
PaperCommentInfo.class 3KB
CommentInfo.class 3KB
Account.class 3KB
Yonghu.class 3KB
NxUserPaperInfo.class 2KB
Result.class 2KB
NxUserPaperInfoVo.class 2KB
EchartsData.class 2KB
ResultCode.class 2KB
JiankangziceInfoDao.class 2KB
MyInterceptor.class 2KB
ZhuceyonghuInfoDao.class 2KB
NxUserPaperInfoDao.class 2KB
NxTestpaperInfoDao.class 2KB
GlobalExceptionHandler.class 2KB
XinwentongzhiInfoDao.class 2KB
PaperCommentInfoDao.class 2KB
EchartsData$Data.class 2KB
NxQuestionInfo.class 2KB
WebMvcConfig.class 2KB
NxTestpaperInfo.class 2KB
CommentInfoDao.class 1KB
NxUserPaperQuestionInfo.class 1KB
JiankangshipuInfoDao.class 1KB
YonghuDao.class 1KB
EchartsData$Series.class 1KB
MyInterceptorConfig.class 1KB
AuthorityInfo.class 1KB
NxSystemFileInfo.class 1KB
CollectInfoDao.class 1KB
RichtextInfo.class 1KB
LiuyanbanInfoDao.class 1KB
NxPaperQuestionInfo.class 1KB
YonghuVo.class 1KB
NxScoreInfoDao.class 1KB
AuthorityInfo$Model.class 1KB
CustomException.class 1KB
NxQuestionInfoDao.class 993B
AdminInfoDao.class 928B
Application.class 793B
NxSystemFileInfoDao.class 773B
RichtextInfoDao.class 641B
NxTestpaperInfoVo.class 631B
NxUserPaperQuestionInfoDao.class 394B
NxPaperQuestionInfoDao.class 382B
JiankangshipuInfoVo.class 332B
XinwentongzhiInfoVo.class 332B
JiankangziceInfoVo.class 328B
ZhuceyonghuInfoVo.class 324B
NxQuestionInfoVo.class 320B
LiuyanbanInfoVo.class 316B
UserTextInfoVo.class 312B
RichtextInfoVo.class 312B
CollectInfoVo.class 308B
共 785 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
程序猿阿存
- 粉丝: 1245
- 资源: 1804
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功