|
|
|
@ -1,8 +1,11 @@
@@ -1,8 +1,11 @@
|
|
|
|
|
package com.cloud.kicc.system.controller; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ArrayUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.cloud.kicc.common.core.api.R; |
|
|
|
|
import com.cloud.kicc.common.core.constant.AppConstants; |
|
|
|
@ -20,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
@@ -20,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @Author: TangSheng |
|
|
|
@ -49,9 +53,8 @@ public class HospitalController {
@@ -49,9 +53,8 @@ public class HospitalController {
|
|
|
|
|
public R add(@RequestBody Hospital hospital){ |
|
|
|
|
//新增医院
|
|
|
|
|
hospitalService.save(hospital); |
|
|
|
|
|
|
|
|
|
//医院机构关联
|
|
|
|
|
List<InstitutionRelation> institutionRelations = new ArrayList<>(hospital.getInstitutionIds().size()); |
|
|
|
|
List<InstitutionRelation> institutionRelations = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String institutionId : hospital.getInstitutionIds()) { |
|
|
|
@ -64,26 +67,46 @@ public class HospitalController {
@@ -64,26 +67,46 @@ public class HospitalController {
|
|
|
|
|
|
|
|
|
|
return R.ok(hospital); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// @GetMapping("/{id}")
|
|
|
|
|
// public R queryById(@PathVariable String id){
|
|
|
|
|
// hospitalService.getById(id);
|
|
|
|
|
// return R.ok(hospitalService.getById(id));
|
|
|
|
|
// }
|
|
|
|
|
@GetMapping("/{id:\\w+}") |
|
|
|
|
public R queryById(@PathVariable("id") String id){ |
|
|
|
|
Hospital hospital = hospitalService.getById(id); |
|
|
|
|
List<String> institutionIds; |
|
|
|
|
if(hospital!=null){ |
|
|
|
|
institutionIds = institutionRelationService.list(new LambdaQueryWrapper<InstitutionRelation>().eq(InstitutionRelation::getHospitalId,hospital.getId())) |
|
|
|
|
.stream().map(institutionRelation -> institutionRelation.getInstitutionId()).collect(Collectors.toList()); |
|
|
|
|
hospital.setInstitutionIds(ArrayUtil.toArray(institutionIds,String.class)); |
|
|
|
|
} |
|
|
|
|
return R.ok(hospital); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 修改 |
|
|
|
|
* @param hospital 修改对象 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
// @PutMapping("/update")
|
|
|
|
|
// public R update(@RequestBody Hospital hospital){
|
|
|
|
|
// hospitalService.updateById(hospital);
|
|
|
|
|
// return R.ok(hospital);
|
|
|
|
|
// }
|
|
|
|
|
@PutMapping("/update") |
|
|
|
|
public R update(@RequestBody Hospital hospital){ |
|
|
|
|
hospitalService.updateById(hospital); |
|
|
|
|
return R.ok(hospital); |
|
|
|
|
hospitalService.updateHospital(hospital); |
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 删除 |
|
|
|
|
* @param ids 节点id |
|
|
|
|
* @param id 节点id |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@DeleteMapping("/remove/{ids}") |
|
|
|
|
public R remove(@PathVariable("ids") String[] ids){ |
|
|
|
|
hospitalService.removeBatchByIds(Arrays.asList(ids)); |
|
|
|
|
@DeleteMapping("/remove/{id:[\\w,]+}") |
|
|
|
|
public R remove(@PathVariable("id") String[] id){ |
|
|
|
|
hospitalService.removeByIds(Arrays.asList(id)); |
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -99,16 +122,20 @@ public class HospitalController {
@@ -99,16 +122,20 @@ public class HospitalController {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询根据条件 |
|
|
|
|
* @param page |
|
|
|
|
* @param |
|
|
|
|
* @param hospital |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
// @GetMapping("/list")
|
|
|
|
|
// public R list(Page page, Hospital hospital) {
|
|
|
|
|
// IPage<Hospital> iPage = hospitalService.page(page, getQueryWrapper(hospital));
|
|
|
|
|
// return R.ok(iPage.getRecords(), iPage.getTotal());
|
|
|
|
|
// }
|
|
|
|
|
@GetMapping("/list") |
|
|
|
|
public R list(Page page, Hospital hospital) { |
|
|
|
|
IPage<Hospital> iPage = hospitalService.queryList(page, hospital); |
|
|
|
|
return R.ok(iPage.getRecords(), iPage.getTotal()); |
|
|
|
|
public R list(Hospital hospital){ |
|
|
|
|
List<Hospital> hospitalList = hospitalService.list(getQueryWrapper(hospital)); |
|
|
|
|
return R.ok(hospitalList,hospitalList.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 查询医院关联的机构 |
|
|
|
|
* @param id 医院id |
|
|
|
@ -121,17 +148,13 @@ public class HospitalController {
@@ -121,17 +148,13 @@ public class HospitalController {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private QueryWrapper<Hospital> getQueryWrapper(Hospital hospital) { |
|
|
|
|
return new QueryWrapper<Hospital>() |
|
|
|
|
.like(StrUtil.isNotBlank(hospital.getName()), "name", hospital.getName()) |
|
|
|
|
.like(StrUtil.isNotBlank(hospital.getContactsName()), "contacts_name", hospital.getContactsName()) |
|
|
|
|
.like(StrUtil.isNotBlank(hospital.getContactsTel()), "contacts_tel", hospital.getContactsTel()) |
|
|
|
|
.like(StrUtil.isNotBlank(hospital.getContactsTitle()), "contacts_title", hospital.getContactsTitle()) |
|
|
|
|
.like(StrUtil.isNotBlank(hospital.getDetailAddress()), "detail_address", hospital.getDetailAddress()) |
|
|
|
|
.between(!StrUtil.hasBlank(hospital.getBeginTime(),hospital.getEndTime()),"create_time", |
|
|
|
|
hospital.getBeginTime(), |
|
|
|
|
hospital.getEndTime()) |
|
|
|
|
.orderByAsc("create_time"); |
|
|
|
|
private LambdaQueryWrapper<Hospital> getQueryWrapper(Hospital hospital) { |
|
|
|
|
return new LambdaQueryWrapper<Hospital>() |
|
|
|
|
.like(StrUtil.isNotBlank(hospital.getName()),Hospital::getName,hospital.getName()) |
|
|
|
|
.eq(StrUtil.isNotBlank(hospital.getType()),Hospital::getType,hospital.getType()) |
|
|
|
|
.between(StrUtil.isNotBlank(hospital.getBeginTime()) && StrUtil.isNotBlank(hospital.getEndTime()),Hospital::getCreateTime,hospital.getBeginTime(),hospital.getEndTime()) |
|
|
|
|
.orderByAsc(Hospital::getCreateTime); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|