基于javaweb+mysql的springboot医院管理系统(java+springboot+maven+mybatis+vue+mysql)

基于javaweb+mysql的springboot医院管理系统(java+springboot+maven+mybatis+vue+mysql)

运行环境

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

开发工具

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

前端:WebStorm/VSCode/HBuilderX等均可

适用

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

功能说明

基于javaweb+mysql的SpringBoot医院管理系统(java+springboot+maven+mybatis+vue+mysql)

一、项目简述本系统功能包括:医院挂号,退号,缴费,退费,检查申请单开立,科室管理,医生开单,挂号级别,检验项目开立,检查项目开立,医生接诊等等功能。

二、项目运行 环境配置:

Jdk1.8 + Tomcat8.5 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。

项目技术:

Springboot + Maven + Mybatis + Vue 等等组成,B/S模式 + Maven管理等等。


    @PutMapping("/{id}")
    @UserLoginToken
    public Result update(@RequestBody ConstantType constantType, @PathVariable int id) {
        constantType.setId(id);
        // System.out.println(constantType);
        if (constantTypeService.updateById(constantType))
            return ResultGenerator.getSuccessResult("", "更新成功");
        return ResultGenerator.getFailResult("", "更新失败");
    }

    @PutMapping("/{id}/state/{active}")
    @UserLoginToken
    public Result changeActive(@PathVariable int id, @PathVariable int active) {
        ConstantType constantType = new ConstantType();
        constantType.setActive(active);
        constantType.setId(id);
        if (constantTypeService.updateById(constantType))
            return ResultGenerator.getSuccessResult("", "激活状态修改成功");
        return ResultGenerator.getFailResult("", "激活状态修改失败");
    }

    @DeleteMapping("/{id}")
    @UserLoginToken
    public Result del(@PathVariable int id) {
        if (constantTypeService.removeById(id))
            return ResultGenerator.getSuccessResult("", "删除成功");
        return ResultGenerator.getFailResult("", "删除失败");
    }

    @DeleteMapping("/batchdel")
    @UserLoginToken
    public Result batchDel(@RequestParam String ids) {
        String[] idList = ids.split(",");
        List<Integer> list = new ArrayList<>(idList.length);
        for (String id : idList) {
            list.add(Integer.parseInt(id));
        }
        if (constantTypeService.removeByIds(list))
            return ResultGenerator.getSuccessResult("", "删除成功");
        return ResultGenerator.getFailResult("", "删除失败");
    }
}

public class DepartmentController {
    @Resource
    private IDepartmentService departmentService;

    @GetMapping
    public Result getlist(@RequestParam Map<String, Object> param) {
        InitUtil.initPage(param);
        int num = Integer.parseInt(param.get("page").toString());
        int limit = Integer.parseInt(param.get("limit").toString());
        QueryWrapper<Department> wrapper = new QueryWrapper<>();
        InitUtil.initLike(param, wrapper, "name");
        InitUtil.initEq(param, wrapper, "active");
        IPage<Department> page = new Page<>(num, limit);
        return ResultGenerator.getSuccessResult(departmentService.page(page, wrapper));
    }

    @GetMapping("/{id}")
    public Result getDepartment(@PathVariable int id) {
        Department department = departmentService.getById(id);
        if (department == null)
            return ResultGenerator.getFailResult("", "无科室记录");
        return ResultGenerator.getSuccessResult(department);
    }

    @GetMapping("/check")
    public Result checkName(@RequestParam String name) {
        QueryWrapper<Department> wrapper = new QueryWrapper<>();
        wrapper.eq("name", name);
        if (departmentService.getOne(wrapper) != null)
            return ResultGenerator.getFailResult("", "科室名称已存在");
        return ResultGenerator.getSuccessResult();
    }

    @GetMapping("/all")
    public Result getAll() {
      QueryWrapper<Department> wrapper = new QueryWrapper<>();
      wrapper.eq("active", 1);
      JSONObject jsonObject = new JSONObject();
      List<Department> list = departmentService.list(wrapper);
      for (Department i : list) {
          Map<String,Object> params = new HashMap<>();
          params.put("name",i.getName());

        jsonObject.put(i.getId().toString(), params);
      }
      return ResultGenerator.getSuccessResult(jsonObject);
    }

    @PostMapping()
    @UserLoginToken
    public Result save(@RequestBody Department department) {
        // System.out.println(department);
        if (departmentService.save(department))
    inspectApply.setId(id);
    if(!inspectApplyService.updateById(inspectApply)){
      return ResultGenerator.getFailResult("", "检查失败,该检验项不存在");
    }
    return ResultGenerator.getSuccessResult("", "检查成功");
  }

  @DeleteMapping("/{id}")
  @UserLoginToken
  public Result del(@PathVariable int id) {
    if (inspectApplyService.removeById(id))
      return ResultGenerator.getSuccessResult("", "删除成功");
    return ResultGenerator.getFailResult("", "删除失败");
  }

  @DeleteMapping("/batchdel")
  @UserLoginToken
  public Result batchDel(@RequestParam String ids) {
    String[] idList = ids.split(",");
    List<Integer> list = new ArrayList<>(idList.length);
    for (String id : idList) {
      list.add(Integer.parseInt(id));
    }
    if (inspectApplyService.removeByIds(list))
      return ResultGenerator.getSuccessResult("", "删除成功");
    return ResultGenerator.getFailResult("", "删除失败");
  }
}

@RestController
@RequestMapping("/checkApplys")
public class CheckApplyController {
  @Resource
  private ICheckApplyService checkApplyService;

  @GetMapping
  public Result getlist(@RequestParam Map<String, Object> param) {
    InitUtil.initPage(param);
    int num = Integer.parseInt(param.get("page").toString());
    int limit = Integer.parseInt(param.get("limit").toString());
    QueryWrapper<CheckApply> wrapper = new QueryWrapper<>();
    InitUtil.initLike(param, wrapper, "itemName");
    InitUtil.initEq(param, wrapper, "active");
    IPage<CheckApply> page = new Page<>(num, limit);
    return ResultGenerator.getSuccessResult(checkApplyService.page(page, wrapper));
  }

  @GetMapping("/list/{id}")
  public Result getCaselist(@RequestParam Map<String, Object> param,@PathVariable int id) {
    QueryWrapper<CheckApply> wrapper = new QueryWrapper<>();
    wrapper.eq("active", 1).eq("register_Id", id);
    InitUtil.initEq(param, wrapper, "status");
    return ResultGenerator.getSuccessResult(checkApplyService.list(wrapper));
  }

  @GetMapping("/all")
  public Result getAll() {
    QueryWrapper<CheckApply> wrapper = new QueryWrapper<>();
    wrapper.eq("active", 1);
    JSONObject jsonObject = new JSONObject();
    List<CheckApply> list = checkApplyService.list(wrapper);
    for (CheckApply i : list) {
      Map<String,Object> params = new HashMap<>();
      params.put("name",i.getItemName());

      jsonObject.put(i.getId().toString(), params);
    }
    return ResultGenerator.getSuccessResult(jsonObject);
  }

  @GetMapping("/{id}")
  public Result getCheckApply(@PathVariable int id) {
    CheckApply checkApply = checkApplyService.getById(id);
    if (checkApply == null)
      return ResultGenerator.getFailResult("", "无检查申请记录");
    return ResultGenerator.getSuccessResult(checkApply);
  }

  @PostMapping()
  @UserLoginToken
  public Result save(@RequestBody CheckApply CheckApply) {
    // System.out.println(CheckApply);
    if (checkItemService.removeById(id))
      return ResultGenerator.getSuccessResult("", "删除成功");
    return ResultGenerator.getFailResult("", "删除失败");
  }

  @DeleteMapping("/batchdel")
  @UserLoginToken
  public Result batchDel(@RequestParam String ids) {
    String[] idList = ids.split(",");
    List<Integer> list = new ArrayList<>(idList.length);
    for (String id : idList) {
      list.add(Integer.parseInt(id));
    }
    if (checkItemService.removeByIds(list))
      return ResultGenerator.getSuccessResult("", "删除成功");
    return ResultGenerator.getFailResult("", "删除失败");
  }
}

/**
 * @description :拦截器去获取token并验证token
 */
public class AuthenticationInterceptor implements HandlerInterceptor {

  @Override
  public boolean preHandle(HttpServletRequest request, HttpServletResponse response,Object object) throws Exception {
    /** 地址过滤 */
    String uri = request.getRequestURI();
    if (uri.endsWith("/login")) {
      return true;
    }
    // System.out.println(request);
    String token = request.getHeader("Authorization");// 从 http 请求头中取出 token
    // 如果不是映射到方法直接通过
    if (!(object instanceof HandlerMethod)) {
      return true;
    }
    HandlerMethod handlerMethod = (HandlerMethod) object;
    Method method = handlerMethod.getMethod();
      jsonObject.put(i.getId().toString(), params);
    }
    return ResultGenerator.getSuccessResult(jsonObject);
  }

  @GetMapping("/{id}")
  public Result getCheckItem(@PathVariable int id) {
    CheckItem checkItem = checkItemService.getById(id);
    if (checkItem == null)
      return ResultGenerator.getFailResult("", "无挂号级别记录");
    return ResultGenerator.getSuccessResult(checkItem);
  }

  @PostMapping()
  @UserLoginToken
  public Result save(@RequestBody CheckItem checkItem) {
    // System.out.println(checkItem);
    if (checkItemService.save(checkItem))
      return ResultGenerator.getSuccessResult("", "添加成功");
    return ResultGenerator.getFailResult("", "添加失败");
  }

  @PutMapping("/{id}")
  @UserLoginToken
  public Result update(@RequestBody CheckItem checkItem, @PathVariable int id) {
    checkItem.setId(id);
    // System.out.println(checkItem);
    if (checkItemService.updateById(checkItem))
      return ResultGenerator.getSuccessResult("", "更新成功");
    return ResultGenerator.getFailResult("", "更新失败");
  }

  @PutMapping("/{id}/state/{active}")
  @UserLoginToken
  public Result changeActive(@PathVariable int id, @PathVariable int active) {
    CheckItem checkItem = new CheckItem();
    checkItem.setActive(active);
    checkItem.setId(id);
    if (checkItemService.updateById(checkItem))
      return ResultGenerator.getSuccessResult("", "激活状态修改成功");
    return ResultGenerator.getFailResult("", "激活状态修改失败");
  }

  @DeleteMapping("/{id}")
  @UserLoginToken
  public Result del(@PathVariable int id) {
    if (checkItemService.removeById(id))
      return ResultGenerator.getSuccessResult("", "删除成功");

/**
 * <p>
 * 挂号级别 前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/registLevels")
public class RegistLevelController {
  @Resource
  private IRegistLevelService registLevelService;

  @GetMapping
  public Result getlist(@RequestParam Map<String, Object> param) {
    InitUtil.initPage(param);
    int num = Integer.parseInt(param.get("page").toString());
    int limit = Integer.parseInt(param.get("limit").toString());
    QueryWrapper<RegistLevel> wrapper = new QueryWrapper<>();
    InitUtil.initLike(param, wrapper, "name");
    InitUtil.initEq(param, wrapper, "active");
    IPage<RegistLevel> page = new Page<>(num, limit);
    return ResultGenerator.getSuccessResult(registLevelService.page(page, wrapper));
  }

  @GetMapping("/all")
  public Result getAll() {
    QueryWrapper<RegistLevel> wrapper = new QueryWrapper<>();
    wrapper.eq("active", 1);
    JSONObject jsonObject = new JSONObject();

/**
 * <p>
 * 检查项目 前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/checkItems")
public class CheckItemController {
  @Resource
  private ICheckItemService checkItemService;

  @GetMapping
  public Result getlist(@RequestParam Map<String, Object> param) {
    InitUtil.initPage(param);
    int num = Integer.parseInt(param.get("page").toString());
    int limit = Integer.parseInt(param.get("limit").toString());
    QueryWrapper<CheckItem> wrapper = new QueryWrapper<>();
    InitUtil.initLike(param, wrapper, "name");
    InitUtil.initEq(param, wrapper, "active");
    IPage<CheckItem> page = new Page<>(num, limit);
    return ResultGenerator.getSuccessResult(checkItemService.page(page, wrapper));
  }

  @GetMapping("/all")
  public Result getAll() {
    QueryWrapper<CheckItem> wrapper = new QueryWrapper<>();
    wrapper.eq("active", 1);
    JSONObject jsonObject = new JSONObject();
    List<CheckItem> list = checkItemService.list(wrapper);
    for (CheckItem i : list) {
      Map<String,Object> params = new HashMap<>();
      params.put("name",i.getName());

      jsonObject.put(i.getId().toString(), params);
    }
    return ResultGenerator.getSuccessResult(jsonObject);
  }

  @GetMapping("/{id}")
  public Result getCheckItem(@PathVariable int id) {
    CheckItem checkItem = checkItemService.getById(id);

/**
 * <p>
 * 常数项表 前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/constantItems")
public class ConstantItemController {

  @Resource
  private IConstantItemService constantItemService;

  @GetMapping
  public Result getlist(@RequestParam Map<String, Object> param) {
    InitUtil.initPage(param);
    int num = Integer.parseInt(param.get("page").toString());
    int limit = Integer.parseInt(param.get("limit").toString());
    QueryWrapper<ConstantItem> wrapper = new QueryWrapper<>();
    InitUtil.initLike(param, wrapper, "name");
    InitUtil.initEq(param, wrapper, "active");
    wrapper.orderByAsc("type_id","sort");
    IPage<ConstantItem> page = new Page<>(num, limit);
    return ResultGenerator.getSuccessResult(constantItemService.page(page, wrapper));
  }

  @GetMapping("/all")
  public Result getAll(){
      QueryWrapper<ConstantItem> wrapper = new QueryWrapper<>();
      wrapper.eq("active", 1);
      return ResultGenerator.getSuccessResult(constantItemService.list(wrapper));
  }

  @GetMapping("/{id}")
  public Result getConstantItem(@PathVariable int id) {
    ConstantItem constantItem = constantItemService.getById(id);
    if (constantItem == null)
      return ResultGenerator.getFailResult("", "无常数选项记录");
    return ResultGenerator.getSuccessResult(constantItem);
  }

    @GetMapping
    public Result getlist(@RequestParam Map<String, Object> param) {
        InitUtil.initPage(param);
        int num = Integer.parseInt(param.get("page").toString());
        int limit = Integer.parseInt(param.get("limit").toString());
        QueryWrapper<Department> wrapper = new QueryWrapper<>();
        InitUtil.initLike(param, wrapper, "name");
        InitUtil.initEq(param, wrapper, "active");
        IPage<Department> page = new Page<>(num, limit);
        return ResultGenerator.getSuccessResult(departmentService.page(page, wrapper));
    }

    @GetMapping("/{id}")
    public Result getDepartment(@PathVariable int id) {
        Department department = departmentService.getById(id);
        if (department == null)
            return ResultGenerator.getFailResult("", "无科室记录");
        return ResultGenerator.getSuccessResult(department);
    }

    @GetMapping("/check")
    public Result checkName(@RequestParam String name) {
        QueryWrapper<Department> wrapper = new QueryWrapper<>();
        wrapper.eq("name", name);
        if (departmentService.getOne(wrapper) != null)
            return ResultGenerator.getFailResult("", "科室名称已存在");
        return ResultGenerator.getSuccessResult();
    }

    @GetMapping("/all")
    public Result getAll() {
      QueryWrapper<Department> wrapper = new QueryWrapper<>();
      wrapper.eq("active", 1);
      JSONObject jsonObject = new JSONObject();
      List<Department> list = departmentService.list(wrapper);
      for (Department i : list) {
          Map<String,Object> params = new HashMap<>();
          params.put("name",i.getName());

        jsonObject.put(i.getId().toString(), params);
      }
      return ResultGenerator.getSuccessResult(jsonObject);
    }


  @GetMapping("/{id}")
  public Result getInspectApply(@PathVariable int id) {
    InspectApply inspectApply = inspectApplyService.getById(id);
    if (inspectApply == null)
      return ResultGenerator.getFailResult("", "无检查申请记录");
    return ResultGenerator.getSuccessResult(inspectApply);
  }

  @PostMapping()
  @UserLoginToken
  public Result save(@RequestBody InspectApply InspectApply) {
    // System.out.println(InspectApply);
    if (inspectApplyService.save(InspectApply))
      return ResultGenerator.getSuccessResult("", "添加成功");
    return ResultGenerator.getFailResult("", "添加失败");
  }

  @PutMapping("/{id}")
  @UserLoginToken
  public Result update(@RequestBody InspectApply inspectApply, @PathVariable int id) {
    inspectApply.setId(id);
    // System.out.println(InspectApply);
    if (inspectApplyService.updateById(inspectApply))
      return ResultGenerator.getSuccessResult("", "更新成功");
    return ResultGenerator.getFailResult("", "更新失败");
  }

  @PutMapping("/{id}/state/{active}")
  @UserLoginToken
  public Result changeActive(@PathVariable int id, @PathVariable int active) {
    InspectApply inspectApply = new InspectApply();
    inspectApply.setActive(active);
    inspectApply.setId(id);
    if (inspectApplyService.updateById(inspectApply))
      return ResultGenerator.getSuccessResult("", "激活状态修改成功");
    return ResultGenerator.getFailResult("", "激活状态修改失败");
  }

    /**
   * 收费
   */
  @PutMapping("/fee")
  @UserLoginToken
  public Result recevieFee(@RequestBody Map<String, Object> param) {
    String[] idList = param.get("ids").toString().split(",");
    InspectApply inspectApply = new InspectApply();
    inspectApply.setStatus(Constants.CHECK_APPLY_STATUS_2);
    for (String id : idList) {
      inspectApply.setId(Integer.parseInt(id));
      if(!inspectApplyService.updateById(inspectApply)){
        return ResultGenerator.getFailResult("", "收费失败,该检验项不存在");
      }
    public Result checkCode(@RequestParam String name) {
        QueryWrapper<ConstantType> wrapper = new QueryWrapper<>();
        wrapper.eq("code", name);
        ConstantType constantType = constantTypeService.getOne(wrapper);
        if (constantType != null)
            return ResultGenerator.getFailResult("", "该常数代码已存在");
        return ResultGenerator.getSuccessResult();
    }

    @PostMapping()
    @UserLoginToken
    public Result save(@RequestBody ConstantType constantType) {
        // System.out.println(constantType);
        if (constantTypeService.save(constantType))
            return ResultGenerator.getSuccessResult("", "添加成功");
        return ResultGenerator.getFailResult("", "添加失败");
    }

    @PutMapping("/{id}")
    @UserLoginToken
    public Result update(@RequestBody ConstantType constantType, @PathVariable int id) {
        constantType.setId(id);
        // System.out.println(constantType);
        if (constantTypeService.updateById(constantType))
            return ResultGenerator.getSuccessResult("", "更新成功");
        return ResultGenerator.getFailResult("", "更新失败");
    }

    @PutMapping("/{id}/state/{active}")
    @UserLoginToken
    public Result changeActive(@PathVariable int id, @PathVariable int active) {
        ConstantType constantType = new ConstantType();
        constantType.setActive(active);
        constantType.setId(id);
        if (constantTypeService.updateById(constantType))
            return ResultGenerator.getSuccessResult("", "激活状态修改成功");
        return ResultGenerator.getFailResult("", "激活状态修改失败");
    }

    @DeleteMapping("/{id}")
    @UserLoginToken
    public Result del(@PathVariable int id) {
        if (constantTypeService.removeById(id))
            return ResultGenerator.getSuccessResult("", "删除成功");
        return ResultGenerator.getFailResult("", "删除失败");
/**
 * <p>
 * 角色权限 前端控制器
 * </p>
 *
 */
@RestController
@RequestMapping("/role-permission")
public class RolePermissionController {

  @Resource
  private IRolePermissionService roles;

  @GetMapping("/{id}")
  public Result getRightsById(@PathVariable int id) {
    QueryWrapper<RolePermission> wrapper = new QueryWrapper<>();
    wrapper.eq("role_id", id);
    RolePermission role = roles.getOne(wrapper);
    if (role == null) {
      return ResultGenerator.getFailResult("该角色尚未分配权限");
    }
    return ResultGenerator.getSuccessResult(role);
  }

  @PostMapping()
  public Result add(@RequestBody RolePermission entity) {
    if (roles.save(entity))
      return ResultGenerator.getSuccessResult("", "分配权限成功!");
    return ResultGenerator.getFailResult("", "分配权限失败");
  }

  @PutMapping("/{id}")
  public Result add(@RequestBody RolePermission entity,@PathVariable int id) {
    entity.setId(id);
    if (roles.updateById(entity))
      return ResultGenerator.getSuccessResult("", "修改分配权限成功!");
    return ResultGenerator.getFailResult("", "修改分配权限失败");
  }

}

  @PostMapping()
  public Result add(@RequestBody RolePermission entity) {
    if (roles.save(entity))
      return ResultGenerator.getSuccessResult("", "分配权限成功!");
    return ResultGenerator.getFailResult("", "分配权限失败");
  }

  @PutMapping("/{id}")
  public Result add(@RequestBody RolePermission entity,@PathVariable int id) {
    entity.setId(id);
    if (roles.updateById(entity))
      return ResultGenerator.getSuccessResult("", "修改分配权限成功!");
    return ResultGenerator.getFailResult("", "修改分配权限失败");
  }

}

@RestControllerAdvice
public class GlobalExceptionHandle {
  private static Logger log = LoggerFactory.getLogger(GlobalExceptionHandle.class);

  // 捕获全局异常,处理所有不可知的异常 这个注解是捕获所有异常
  @ExceptionHandler(value = MyException.class)
  public Result handleMyException(MyException e, HttpServletRequest request) {
    log.error("msg:{}, url:{}", e.getMessage(), request.getRequestURL());
    e.printStackTrace();
    return ResultGenerator.getFailResult("", e.getMessage(), e.getCode());
  }
}

/**
 * <p>
  public Result update(@RequestBody CheckItem checkItem, @PathVariable int id) {
    checkItem.setId(id);
    // System.out.println(checkItem);
    if (checkItemService.updateById(checkItem))
      return ResultGenerator.getSuccessResult("", "更新成功");
    return ResultGenerator.getFailResult("", "更新失败");
  }

  @PutMapping("/{id}/state/{active}")
  @UserLoginToken
  public Result changeActive(@PathVariable int id, @PathVariable int active) {
    CheckItem checkItem = new CheckItem();
    checkItem.setActive(active);
    checkItem.setId(id);
    if (checkItemService.updateById(checkItem))
      return ResultGenerator.getSuccessResult("", "激活状态修改成功");
    return ResultGenerator.getFailResult("", "激活状态修改失败");
  }

  @DeleteMapping("/{id}")
  @UserLoginToken
  public Result del(@PathVariable int id) {
    if (checkItemService.removeById(id))
      return ResultGenerator.getSuccessResult("", "删除成功");
    return ResultGenerator.getFailResult("", "删除失败");
  }

  @DeleteMapping("/batchdel")
  @UserLoginToken
  public Result batchDel(@RequestParam String ids) {
    String[] idList = ids.split(",");
    List<Integer> list = new ArrayList<>(idList.length);
    for (String id : idList) {
      list.add(Integer.parseInt(id));
    }
    if (checkItemService.removeByIds(list))
      return ResultGenerator.getSuccessResult("", "删除成功");
    return ResultGenerator.getFailResult("", "删除失败");
  }
}
    return ResultGenerator.getFailResult("", "激活状态修改失败");
  }

  @DeleteMapping("/{id}")
  @UserLoginToken
  public Result del(@PathVariable int id) {
    if (inspectItemService.removeById(id))
      return ResultGenerator.getSuccessResult("", "删除成功");
    return ResultGenerator.getFailResult("", "删除失败");
  }

  @DeleteMapping("/batchdel")
  @UserLoginToken
  public Result batchDel(@RequestParam String ids) {
    String[] idList = ids.split(",");
    List<Integer> list = new ArrayList<>(idList.length);
    for (String id : idList) {
      list.add(Integer.parseInt(id));
    }
    if (inspectItemService.removeByIds(list))
      return ResultGenerator.getSuccessResult("", "删除成功");
    return ResultGenerator.getFailResult("", "删除失败");
  }
}

  public Result getlist(@RequestParam Map<String, Object> param) {
    InitUtil.initPage(param);
    int num = Integer.parseInt(param.get("page").toString());
    int limit = Integer.parseInt(param.get("limit").toString());
    QueryWrapper<InspectItem> wrapper = new QueryWrapper<>();
    InitUtil.initLike(param, wrapper, "name");
    InitUtil.initEq(param, wrapper, "active");
    IPage<InspectItem> page = new Page<>(num, limit);
    return ResultGenerator.getSuccessResult(inspectItemService.page(page, wrapper));
  }

  
  @GetMapping("/all")
  public Result getAll() {
    QueryWrapper<InspectItem> wrapper = new QueryWrapper<>();
    wrapper.eq("active", 1);
    JSONObject jsonObject = new JSONObject();
    List<InspectItem> list = inspectItemService.list(wrapper);
    for (InspectItem i : list) {

      Map<String,Object> params = new HashMap<>();
      params.put("name",i.getName());

      jsonObject.put(i.getId().toString(),params);
    }
    return ResultGenerator.getSuccessResult(jsonObject);
  }

  @GetMapping("/{id}")
  public Result getInspectItem(@PathVariable int id) {
    InspectItem inspectItem = inspectItemService.getById(id);
    if (inspectItem == null)
      return ResultGenerator.getFailResult("", "无挂号级别记录");
    return ResultGenerator.getSuccessResult(inspectItem);
  }

  @PostMapping()
  @UserLoginToken
  public Result save(@RequestBody InspectItem inspectItem) {
    // System.out.println(inspectItem);
    if (inspectItemService.save(inspectItem))
      return ResultGenerator.getSuccessResult("", "添加成功");
    return ResultGenerator.getFailResult("", "添加失败");
  }

  @PutMapping("/{id}")
  @UserLoginToken
  public Result update(@RequestBody InspectItem inspectItem, @PathVariable int id) {
    inspectItem.setId(id);

请添加图片描述

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值