Files
nursing-home/backend/src/main/java/com/nursinghome/mapper/BillMapper.java
王子琦 cc7d8f30ff add
2026-01-20 11:32:46 +08:00

29 lines
1.1 KiB
Java

package com.nursinghome.mapper;
import com.nursinghome.entity.Bill;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface BillMapper {
@Insert("INSERT INTO bill(elder_id, month, bed_fee, care_fee, meal_fee, other_fee, total, status, created_at) VALUES(#{elderId}, #{month}, #{bedFee}, #{careFee}, #{mealFee}, #{otherFee}, #{total}, #{status}, NOW())")
@Options(useGeneratedKeys = true, keyProperty = "id")
int insert(Bill bill);
@Select("SELECT * FROM bill ORDER BY month DESC")
List<Bill> listAll();
@Select("SELECT * FROM bill WHERE id = #{id}")
Bill findById(Long id);
@Select("SELECT * FROM bill WHERE elder_id = #{elderId} ORDER BY month DESC")
List<Bill> listByElderId(Long elderId);
@Select("<script>SELECT * FROM bill WHERE elder_id IN <foreach collection='elderIds' item='id' open='(' separator=',' close=')'>#{id}</foreach> ORDER BY month DESC</script>")
List<Bill> listByElderIds(@Param("elderIds") List<Long> elderIds);
@Update("UPDATE bill SET status=#{status}, paid_at=#{paidAt} WHERE id=#{id}")
int updateStatus(Bill bill);
}