Skip to content
Snippets Groups Projects
Commit dd7df5b4 authored by Mingyuan Chen's avatar Mingyuan Chen
Browse files

Delete CommonAdminHospitalMapper.java

parent cc4ce96f
No related branches found
No related tags found
No related merge requests found
package com.cardiff.client_project.mapper;
import com.cardiff.client_project.pojo.dto.HospitalDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class CommonAdminHospitalMapper {
@Autowired
JdbcTemplate jdbcTemplate;
// 查询所有医院信息
public List<HospitalDTO> findAll() {
String sql = "SELECT * FROM hospital";
return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(HospitalDTO.class));
}
// 添加医院信息
public int save(HospitalDTO hospital) {
String sql = "INSERT INTO hospital (name, location, phone, totalBeds, availableBeds, occupancyRate) VALUES (?, ?, ?, ?, ?, ?)";
return jdbcTemplate.update(sql, hospital.getName(), hospital.getLocation(), hospital.getPhone(), hospital.getTotalBeds(), hospital.getAvailableBeds(), hospital.getOccupancyRate());
}
// 更新医院信息
public int update(HospitalDTO hospital) {
String sql = "UPDATE hospital SET name=?, location=?, phone=?, totalBeds=?, availableBeds=?, occupancyRate=? WHERE id=?";
return jdbcTemplate.update(sql, hospital.getName(), hospital.getLocation(), hospital.getPhone(), hospital.getTotalBeds(), hospital.getAvailableBeds(), hospital.getOccupancyRate(), hospital.getId());
}
// 根据 ID 删除医院信息
public int deleteById(int id) {
String sql = "DELETE FROM hospital WHERE id=?";
return jdbcTemplate.update(sql, id);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment