1.22

今天实现接触数据库的Mapper类
package com.example.mapper;

import com.example.pojo.Application;
import com.example.pojo.Baoxiao;
import com.example.pojo.Staff;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from finaltest.staff where UserID=#{username} and Password=#{password}")
    Staff getByUser(String username, String password);

    @Select("select * from finaltest.staff where UserID=#{username}")
    Staff getName(String username);

    @Select("select COUNT(*) from finaltest.application where id like Concat(#{id},'%')")
    int count(String id);

    @Insert("insert into finaltest.application(id, name, department, destination, departuredate, returndate, type, typecontent, reason, state) VALUES (#{id},#{name},#{department},#{destination},#{departureDate},#{returnDate},#{type},#{typeContent},#{reason},#{state})")
    void add1(String id, String name, String department, String destination, LocalDateTime departureDate, LocalDateTime returnDate, String type, String typeContent, String reason, String state);

    @Update("UPDATE finaltest.application SET destination=#{destination}, " +
            "departureDate=#{departureDate}, returnDate=#{returnDate}, " +
            "type=#{type}, typecontent=#{typeContent}, reason=#{reason},state=#{state} " +
            "WHERE id=#{id} AND name=#{name} AND department=#{department}")
    void update1(String id, String name, String department, String destination,
                 LocalDateTime departureDate, LocalDateTime returnDate,
                 String type, String typeContent, String reason, String state);

    @Select("select * from finaltest.application where id=#{id} and state=#{state} ")
    Application reasonable(String id, String state);

    @Delete("delete from finaltest.application where id=#{id}")
    void delete(String id);

    @Insert("insert into finaltest.baoxiao (ID, Name, Department, Destination, Departuredate, Returndate, Reason, Startfare, Returnfare, Foodallowance, Localtrans, Accommodation, Totalamount, Schedule) VALUES(#{ID},#{name},#{department},#{destination},#{departureDate},#{returnDate},#{reason},#{startFare},#{returnFare},#{foodAllowance},#{localTrans},#{accommodation},#{totalAmount},#{schedule}) ")
    void add2(String ID, String name, String department, String destination, LocalDateTime departureDate, LocalDateTime returnDate, String reason, int startFare, int returnFare, int foodAllowance, int localTrans, int accommodation, int totalAmount, String schedule);

    @Select("select COUNT(*) from finaltest.baoxiao where ID like concat(#{id},'%')")
    int pay1(String id);

    @Select("select * from finaltest.baoxiao where ID=#{id} and Schedule=#{state} ")
    Baoxiao examine(String id, String state);

    @Update("UPDATE finaltest.baoxiao SET destination=#{destination}, " +
            "departureDate=#{departureDate}, returnDate=#{returnDate}, " +
            "Startfare=#{startFare}, Returnfare=#{returnFare}, reason=#{reason},Foodallowance=#{foodAllowance}, Accommodation=#{accommodation},Totalamount=#{totalAmount},Schedule=#{schedule} " +
            "WHERE id=#{id} AND name=#{name} AND department=#{department}")
    void update2(String id, String name, String department, String destination, LocalDateTime departureDate, LocalDateTime returnDate, String reason, int startFare, int returnFare, int foodAllowance, int localTrans, int accommodation, int totalAmount, String schedule);

    @Select("select * from finaltest.application where name=#{name}")
    List<Application> selectApp(String name);

    @Select("select * from finaltest.baoxiao where name=#{name}")
    List<Baoxiao> selectBao(String name);

    @Select("select * from finaltest.application where department=#{id}")
    List<Application> select1(String id);

    @Update("update finaltest.application set state=#{state} where id=#{id}")
    void updateById(String id, String state);

    @Update("update finaltest.baoxiao set Schedule=#{state} where id=#{id}")
    void updateById2(String id, String state);
}

 

posted @ 2024-01-26 18:11  七安。  阅读(15)  评论(0编辑  收藏  举报