基于javaweb+mysql的springboot大学生健康档案管理系统(java+mybatis+springboot+vue+mysql)

基于javaweb+mysql的springboot大学生健康档案管理系统(java+mybatis+springboot+vue+mysql)

运行环境

Java≥8、MySQL≥5.7、Node.js≥10

开发工具

后端:eclipse/idea/myeclipse/sts等均可配置运行

前端:WebStorm/VSCode/HBuilderX等均可

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot大学生健康档案管理系统(java+mybatis+springboot+vue+mysql)

项目介绍

大学生健康档案管理系统,目前演示数据中主要包括三种角色:管理员、医生、学生;其中管理员包含最高权限;可对体检表,健康文档,体检数据图标展示等进行管理,以及权限管理,指定不同科室医生进行不同的操作。此项目为前后端分离项目,后端API接口为SpringBoot项目;前端为vue项目;

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 8.0版本;

软件架构说明

  • springboot - mysql 8.0及以上 - mybatis - jpa - swagger-ui

  • lombok 注:必须安装

安装教程

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中application.yml配置文件中的数据库配置改为自己的配置

  2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行后端项目;

配合前端项目

1.运行 npm install

2.在运行 npm run serve 即可 3.运行项目成功后,在浏览器中输入地址:http://localhost:8083 即可登录; 管理员账号:admin 密码:123456 外科医生账号:waike 密码:123 学生账号:631507030104 密码:123


    @PostMapping("/deleteByIds")
    public ResponseEntity deleteByIds(@RequestBody Integer[] ids){
        if (this.service.deleteInfoByIds(ids)>0){
            return ResponseEntity.ok("操作成功");
        }else {
            throw new MyException(ExceptionEnums.DELETE_ERROR);
        }
    }
}

/**
 */
@Slf4j
@Controller
public class TestController {

    @GetMapping("/api/user/login")
    @ResponseBody
    public ResponseEntity login(){
        return ResponseEntity.status(301).body("登录过期或者未登录,请退出重新登录");
    }

    @GetMapping("/login")
    public String pageLogin(){
        return "login";
    }

    @GetMapping("/success")
    @ResponseBody
    public Object success(){
        Map<String, Object> map = new HashMap<>();
        map.put("status", "200");
    @ApiOperation(value = "基础接口: 分页返回数据")
    @PostMapping(value = "page")
    public ResponseEntity<PageInfo<T>> page(@RequestBody Condition condition){
        PageInfo<T> page ;
        try {
            page = service.selectPage(condition);
        }catch (Exception e){
            log.error(e.getMessage());
            throw new MyException(ExceptionEnums.GET_LIST_ERROR);
        }
        return ResponseEntity.ok(page);
    }

    @ApiOperation(value = "基础接口: 修改数据")
    @PostMapping(value = "update")
    public ResponseEntity<T> update(@RequestBody T entity){
        try {
            if (service.update(entity)<1){
                throw new MyException(ExceptionEnums.UPDATE_ERROR);
            }
        }catch (Exception e){
            log.error(e.getMessage());
            throw new MyException(ExceptionEnums.UPDATE_ERROR);
        }
        return ResponseEntity.ok(entity);
    }

    @ApiOperation(value = "基础接口: 删除指定ID的数据")
    @GetMapping(value = "delete/{id}")
    public ResponseEntity<String> delete(@PathVariable("id")ID id){
        try {
            if ( service.deleteByKey(id)<1){
                throw new MyException(ExceptionEnums.DELETE_ERROR);
            }
        } catch (Exception e){
            log.error(e.getMessage());
            throw new MyException(ExceptionEnums.DELETE_ERROR);
        }
        return ResponseEntity.ok("删除成功");
    }

}

@Api(description = "文件上传接口")
@RestController
@RequestMapping(value = "api/uploadFile")
public class UploadController {

    @PostMapping("/upload")
    public ResponseEntity<String> uploadLocal(MultipartFile file) throws IOException {
        if (Objects.isNull(file)){
            throw new MyException(ExceptionEnums.CHOOSE_FILE);
        }else {
            String fileName = file.getOriginalFilename();
            Integer index = fileName.lastIndexOf('.');
            String suffix = fileName.substring(index,fileName.length());
            System.out.println(suffix);
            String start = "";
            if ((".png").equals(suffix)){
                start = "data:image/png;base64,";
            }
            if ((".jpg").equals(suffix) || (".jpeg").equals(suffix)){
                start = "data:image/jpeg;base64,";
            }
            InputStream inputStream = file.getInputStream();
            OutputStream outputStream = new ByteArrayOutputStream();
            new BASE64Encoder().encodeBuffer(inputStream,outputStream);
            String key = outputStream.toString();
            return ResponseEntity.ok(start+key);
        }

    }

}

    @GetMapping("/success")
    @ResponseBody
    public Object success(){
        Map<String, Object> map = new HashMap<>();
        map.put("status", "200");
        map.put("msg", "登陆成功");
        return map;
    }

    @RequestMapping("/loginUser")
    public String loginUser(String account,String password, HttpSession session, HttpServletRequest r){
        UsernamePasswordToken token = new UsernamePasswordToken(account, password);
        Subject subject = SecurityUtils.getSubject();
        try {
            log.info(token.toString());
            subject.login(token);
            User user = (User) subject.getPrincipal();
            session.setAttribute("user", user);
            return "redirect:/swagger-ui.html";
        } catch (Exception e) {
            return "登陆失败";
        }
    }

    @RequestMapping("unauthorized")
    public String unauthorized() {
        return "unauthorized";
    }

    @RequestMapping("/loginOut")
    public String loginOut(){
        Subject subject = SecurityUtils.getSubject();
        if (subject!=null){
            subject.logout();
        }
        return "login";

    }

}
        return ResponseEntity.status(301).body("登录过期或者未登录,请退出重新登录");
    }

    @GetMapping("/login")
    public String pageLogin(){
        return "login";
    }

    @GetMapping("/success")
    @ResponseBody
    public Object success(){
        Map<String, Object> map = new HashMap<>();
        map.put("status", "200");
        map.put("msg", "登陆成功");
        return map;
    }

    @RequestMapping("/loginUser")
    public String loginUser(String account,String password, HttpSession session, HttpServletRequest r){
        UsernamePasswordToken token = new UsernamePasswordToken(account, password);
        Subject subject = SecurityUtils.getSubject();
        try {
            log.info(token.toString());
            subject.login(token);
            User user = (User) subject.getPrincipal();
            session.setAttribute("user", user);
            return "redirect:/swagger-ui.html";
        } catch (Exception e) {
            return "登陆失败";
        }
    }

    @RequestMapping("unauthorized")
    public String unauthorized() {
        return "unauthorized";
    }

    @RequestMapping("/loginOut")
    public String loginOut(){
        Subject subject = SecurityUtils.getSubject();
        if (subject!=null){
    public String unauthorized() {
        return "unauthorized";
    }

    @RequestMapping("/loginOut")
    public String loginOut(){
        Subject subject = SecurityUtils.getSubject();
        if (subject!=null){
            subject.logout();
        }
        return "login";

    }

}

public class CorsFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        servletRequest.setCharacterEncoding("utf-8");
        HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
        HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
        //是否支持cookie跨域
        httpServletResponse.setHeader("Access-Control-Allow-Credentials","true");

    public ResponseEntity<CheckInfo> save(@RequestBody CheckInfo entity) {
        return super.save(entity);
    }

    @Override
    @RequiresPermissions("checkInfo:update")
    public ResponseEntity<CheckInfo> update(@RequestBody CheckInfo entity) {
        return super.update(entity);
    }

    @Override
    @RequiresPermissions("checkInfo:delete")
    @GetMapping(value = "delete/{id}")
    public ResponseEntity<String> delete(@PathVariable("id") Integer integer) {
        return super.delete(integer);
    }

    /**
     * 判断体检表是否存在
     * @param userId 用户id
     * @param checkYear 检查年份
     * @return 是否存在
     */
    @GetMapping("/judgeCheckIsExist")
    ResponseEntity judgeCheckIsExist(Integer userId,String checkYear){
        Example example = new Example(CheckInfo.class);
        example.createCriteria().andEqualTo("userId",userId).andEqualTo("checkYear",checkYear);
        List<CheckInfo> checkInfos = this.service.selectByExample(example);
        if (checkInfos==null || checkInfos.size()==0){
            return ResponseEntity.ok(true);
        }else {
            return ResponseEntity.ok(false);
        }
    }

    @GetMapping("/getBim")
    ResponseEntity judgeIsHealth(Double height,Double weight){
        String suggestion;
        if (height==null || weight ==null){
            throw new MyException(ExceptionEnums.NO_WEIGHT_HEIGHT);
        }
        Double result = weight/((height/100)*(height/100));
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setRoundingMode(RoundingMode.UP);
        result = Double.valueOf(nf.format(result));
        if (result < 19){
            suggestion = "体重偏低";
}

@Api(description = "角色资源绑定相关接口")
@Controller
@RequestMapping(value = "api/roleResourceBind")
public class RoleResourceBindController extends BaseController<RoleResourceBindService,RoleResourceBind,Integer> {

    @GetMapping("/getRoles/{resourceId}")
    @ResponseBody
    @ApiOperation(value = "获取某个资源下面所有绑定的角色")
    List<Integer> getRoleListByResourceId(@PathVariable("resourceId") Integer resourceId){
        return this.service.getRoleIds(resourceId);
    }

    @PostMapping("/saveBind")
    @ApiOperation(value = "删除原资源下面的所有角色,然后加上现在的所有角色")
    ResponseEntity<String> saveBind(@RequestBody BindInfo bindInfo){
        try {
            if (Objects.equals(bindInfo.getRoleList(),this.getRoleListByResourceId(bindInfo.getResourceId()))){
                return ResponseEntity.ok("资源信息已保存,权限信息未发生更改!");
            }else {
                this.service.deleteBindInfo(bindInfo.getResourceId());
                this.service.addBindInfo(bindInfo.getResourceId(),bindInfo.getRoleList());
            }
        }catch (Exception e){
            throw new MyException(ExceptionEnums.UPDATE_ERROR);
        }
        return ResponseEntity.ok("更新权限信息成功");
    }
}

@Api(description = "医师建议相关接口")
@Controller
@RequestMapping(value = "api/suggestion")
public class SuggestionController extends BaseController<SuggestionService,Suggestion,Integer> {

    @Override
    @RequiresPermissions("suggestion:add")
    public ResponseEntity<Suggestion> save(@RequestBody Suggestion entity) {
        return super.save(entity);
    }

    @PostMapping("/getInfoPage")
    public ResponseEntity<PageInfo<Suggestion>> getPage(@RequestBody InfoDTO infoDTO){
        return ResponseEntity.ok(this.service.getPage(infoDTO));
    }

    @GetMapping("/getUnReadInfoCount")
    public ResponseEntity getUnReadInfoCount(Integer userId){
        List<Suggestion> info = this.service.getUnReadMessageByUserId(userId);
        return ResponseEntity.ok(info.size());
    }

    @PostMapping("/setInfoRead")
    public ResponseEntity setInfoRead(@RequestBody InfoReadDTO infoReadDTO){
        if (this.service.markToRead(infoReadDTO)>0){
            return ResponseEntity.ok("操作成功");
        }else {
            throw new MyException(ExceptionEnums.UPDATE_ERROR);
        }
    }

    @PostMapping("/deleteByIds")
    public ResponseEntity deleteByIds(@RequestBody Integer[] ids){
        if (this.service.deleteInfoByIds(ids)>0){
            return ResponseEntity.ok("操作成功");
        }else {

/**
 */
@Slf4j
@Controller
public class TestController {

    @GetMapping("/api/user/login")
    @ResponseBody
    public ResponseEntity login(){
        return ResponseEntity.status(301).body("登录过期或者未登录,请退出重新登录");
    }

    @GetMapping("/login")
    public String pageLogin(){
        return "login";
    }

    @GetMapping("/success")
    @ResponseBody
    public Object success(){
        Map<String, Object> map = new HashMap<>();
        map.put("status", "200");
        map.put("msg", "登陆成功");
        return map;

}

@Slf4j
@Api(description = "资源相关接口")
@Controller
@RequestMapping(value = "api/resources")
public class ResourcesController extends BaseController<ResourcesService,Resources,Integer> {

    @Autowired
    ResourcesService resourceService;
    @Autowired
    ShiroService shiroService;
    @Autowired
    RoleResourceBindService roleResourceBindService;
    private static Integer PASS_CODE = 200;

    @GetMapping("/getMenuByRoleId")

        //指定允许其他域名访问

        httpServletResponse.setHeader("Access-Control-Allow-Origin", httpServletRequest.getHeader("Origin"));

        //响应头设置
        httpServletResponse.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept,client_id, uuid, Authorization,user-agent,X-XSRF-TOKEN");

        // 设置过期时间
        httpServletResponse.setHeader("Access-Control-Max-Age", "3600");

        //响应类型
        httpServletResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");

        // 支持HTTP1.1.
        httpServletResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");

        // 支持HTTP 1.0. 
        httpServletResponse.setHeader("Pragma", "no-cache");

        httpServletResponse.setHeader("Allow","GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH");

        if ("OPTIONS".equals(httpServletRequest.getMethod())) {
            httpServletResponse.setStatus(204);
        }

        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {

    }
}

            String key = outputStream.toString();
            return ResponseEntity.ok(start+key);
        }

    }

}

@Api(description = "角色资源绑定相关接口")
@Controller
@RequestMapping(value = "api/roleResourceBind")
public class RoleResourceBindController extends BaseController<RoleResourceBindService,RoleResourceBind,Integer> {

    @GetMapping("/getRoles/{resourceId}")
    @ResponseBody
    @ApiOperation(value = "获取某个资源下面所有绑定的角色")
    List<Integer> getRoleListByResourceId(@PathVariable("resourceId") Integer resourceId){
        return this.service.getRoleIds(resourceId);
    }

    @PostMapping("/saveBind")
    @ApiOperation(value = "删除原资源下面的所有角色,然后加上现在的所有角色")
    ResponseEntity<String> saveBind(@RequestBody BindInfo bindInfo){
        try {
            if (Objects.equals(bindInfo.getRoleList(),this.getRoleListByResourceId(bindInfo.getResourceId()))){
                return ResponseEntity.ok("资源信息已保存,权限信息未发生更改!");
            }else {
                this.service.deleteBindInfo(bindInfo.getResourceId());
                this.service.addBindInfo(bindInfo.getResourceId(),bindInfo.getRoleList());
            }
        }catch (Exception e){
    }

    @PostMapping("/saveBind")
    @ApiOperation(value = "删除原资源下面的所有角色,然后加上现在的所有角色")
    ResponseEntity<String> saveBind(@RequestBody BindInfo bindInfo){
        try {
            if (Objects.equals(bindInfo.getRoleList(),this.getRoleListByResourceId(bindInfo.getResourceId()))){
                return ResponseEntity.ok("资源信息已保存,权限信息未发生更改!");
            }else {
                this.service.deleteBindInfo(bindInfo.getResourceId());
                this.service.addBindInfo(bindInfo.getResourceId(),bindInfo.getRoleList());
            }
        }catch (Exception e){
            throw new MyException(ExceptionEnums.UPDATE_ERROR);
        }
        return ResponseEntity.ok("更新权限信息成功");
    }
}

@Api(description = "健康文档相关接口")
@Controller
@RequestMapping(value = "api/healthDocument")
public class HealthDocumentController extends BaseController<HealthDocumentService,HealthDocument,Integer> {

    @Override
    @RequiresPermissions("healthDocument:add")
    public ResponseEntity<HealthDocument> save(@RequestBody HealthDocument entity) {
        if (entity.getIsPublished()==1){
            entity.setPublishData(new Date());
        }
        return super.save(entity);
    }

    @Override
    @RequiresPermissions("healthDocument:update")
    public ResponseEntity<HealthDocument> update(@RequestBody HealthDocument entity) {
    @ExceptionHandler(AuthorizationException.class)
    public ResponseEntity<ExceptionResult> handleException(AuthorizationException e){
        return ResponseEntity.status(403)
                .body(new ExceptionResult(ExceptionEnums.NOT_AUTHORIZED));
    }

    @ExceptionHandler(UnknownAccountException.class)
    public ResponseEntity<ExceptionResult> handleException(UnknownAccountException e){
        return ResponseEntity.status(403)
                .body(new ExceptionResult(ExceptionEnums.NOT_AUTHORIZED));
    }

    @ExceptionHandler(IncorrectCredentialsException.class)
    public ResponseEntity<ExceptionResult> handleException(IncorrectCredentialsException e){
        return ResponseEntity.status(400)
                .body(new ExceptionResult(ExceptionEnums.PASSWORD_WRONG));
    }

}

@Api(description = "角色相关接口")
@Controller
@RequestMapping(value = "api/role")
public class RoleController extends BaseController<RoleService,Role,Integer> {

    @Override
    @RequiresPermissions("role:add")
    public ResponseEntity<Role> save(@RequestBody Role entity) {
    public ResponseEntity<String> delete(@PathVariable("id") Integer integer) {
        return super.delete(integer);
    }

    /**
     * 判断体检表是否存在
     * @param userId 用户id
     * @param checkYear 检查年份
     * @return 是否存在
     */
    @GetMapping("/judgeCheckIsExist")
    ResponseEntity judgeCheckIsExist(Integer userId,String checkYear){
        Example example = new Example(CheckInfo.class);
        example.createCriteria().andEqualTo("userId",userId).andEqualTo("checkYear",checkYear);
        List<CheckInfo> checkInfos = this.service.selectByExample(example);
        if (checkInfos==null || checkInfos.size()==0){
            return ResponseEntity.ok(true);
        }else {
            return ResponseEntity.ok(false);
        }
    }

    @GetMapping("/getBim")
    ResponseEntity judgeIsHealth(Double height,Double weight){
        String suggestion;
        if (height==null || weight ==null){
            throw new MyException(ExceptionEnums.NO_WEIGHT_HEIGHT);
        }
        Double result = weight/((height/100)*(height/100));
        NumberFormat nf = NumberFormat.getNumberInstance();
        nf.setMaximumFractionDigits(2);
        nf.setRoundingMode(RoundingMode.UP);
        result = Double.valueOf(nf.format(result));
        if (result < 19){
            suggestion = "体重偏低";
        }else if (result < 25){
            suggestion = "健康体重";
        }else if (result < 30){
            suggestion = "超重";
        }else if (result < 39){
            suggestion = "严重超重";
        }else {
            suggestion = "极度超重";
        }
        return ResponseEntity.ok(new HealthDTO().setBim(result).setSuggestion(suggestion));
    }

    @GetMapping("/getDataAnalysis/{userId}")
    }
}

@Slf4j
@Api(description = "文件上传接口")
@RestController
@RequestMapping(value = "api/uploadFile")
public class UploadController {

    @PostMapping("/upload")
    public ResponseEntity<String> uploadLocal(MultipartFile file) throws IOException {
        if (Objects.isNull(file)){
            throw new MyException(ExceptionEnums.CHOOSE_FILE);
        }else {
            String fileName = file.getOriginalFilename();
            Integer index = fileName.lastIndexOf('.');
            String suffix = fileName.substring(index,fileName.length());
            System.out.println(suffix);
            String start = "";
            if ((".png").equals(suffix)){
                start = "data:image/png;base64,";
            }
            if ((".jpg").equals(suffix) || (".jpeg").equals(suffix)){
                start = "data:image/jpeg;base64,";

@Api(description = "医师建议相关接口")
@Controller
@RequestMapping(value = "api/suggestion")
public class SuggestionController extends BaseController<SuggestionService,Suggestion,Integer> {

    @Override
    @RequiresPermissions("suggestion:add")
    public ResponseEntity<Suggestion> save(@RequestBody Suggestion entity) {
        return super.save(entity);
    }

    @PostMapping("/getInfoPage")
    public ResponseEntity<PageInfo<Suggestion>> getPage(@RequestBody InfoDTO infoDTO){
        return ResponseEntity.ok(this.service.getPage(infoDTO));
    }

    @GetMapping("/getUnReadInfoCount")
    public ResponseEntity getUnReadInfoCount(Integer userId){
        List<Suggestion> info = this.service.getUnReadMessageByUserId(userId);
        return ResponseEntity.ok(info.size());
    }

    @PostMapping("/setInfoRead")
    public ResponseEntity setInfoRead(@RequestBody InfoReadDTO infoReadDTO){
        if (this.service.markToRead(infoReadDTO)>0){
            return ResponseEntity.ok("操作成功");
        }else {
            throw new MyException(ExceptionEnums.UPDATE_ERROR);
        }
    }

    @PostMapping("/deleteByIds")
    public ResponseEntity deleteByIds(@RequestBody Integer[] ids){
        if (this.service.deleteInfoByIds(ids)>0){
            return ResponseEntity.ok("操作成功");
        }else {
            throw new MyException(ExceptionEnums.DELETE_ERROR);
        }
    }
}

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值