今天实现Mapper类
LogOnMapper
package com.example.mapper;
import com.example.pojo.Department;
import com.example.pojo.Staff;
import org.apache.ibatis.annotations.*;
import java.time.LocalDate;
import java.util.List;
@Mapper
public interface LogONMapper {
@Select("select * from attendancesystem.staff where JobID=#{username} and Password=#{password}")
Staff getByUser(String username, String password);
@Select("select * from attendancesystem.department")
List<Department> selectCount();
@Select("select count(*) from attendancesystem.staff")
int count();
@Insert("insert into attendancesystem.staff (JobID, Name, Sex, Birthday, Department, Role, Password) VALUES (#{jobID},#{name},#{sex},#{birthday},#{department},#{role},#{password})")
void addStaff(String jobID, String name, String sex, LocalDate birthday, String department, String role, String password);
@Update("update attendancesystem.staff set Name=#{name},Sex=#{sex}, Birthday=#{birthday} where JobID=#{jobID}")
void updateStaff(String jobID, String name, String sex, LocalDate birthday);
@Select("select * from attendancesystem.staff where JobID like concat (#{t},'%')")
List<Staff> getStaff(String t);
@Delete("delete from attendancesystem.staff where JobID=#{id}")
void deleteStaff(String id);
@Select("select count(*) from attendancesystem.department where DepartmentID=#{id}")
int aDep(String id);
@Select("select count(*) from attendancesystem.department where DepartmentName=#{name}")
int bDep(String name);
@Insert("insert into attendancesystem.department (DepartmentID, DepartmentName) VALUES (#{departmentID},#{departmentName})")
void addDep(String departmentID, String departmentName);
@Update("update attendancesystem.department set DepartmentName=#{departmentName} where DepartmentID=#{departmentID}")
void updateDep(String departmentID, String departmentName);
@Select("select count(*) from attendancesystem.staff where Department=#{id}")
int cDep(String id);
@Delete("delete from attendancesystem.department where DepartmentID=#{id}")
void deleteDep(String id);
@Select("select count(*) from attendancesystem.staff where Role=#{name} ")
int dDep(String name);
@Update("update attendancesystem.staff set Role=#{name} where JobID=#{id}")
void updateRole(String id, String name);
@Select("select * from attendancesystem.staff where JobID=#{id}")
Staff selectById(String id);
@Update("update attendancesystem.staff set Password=#{password} where JobID=#{id}")
void update(String id, String password);
}
StaffMapper
package com.example.mapper;
import com.example.pojo.Attendance;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
@Mapper
public interface StaffMapper {
@Select("select count(*) from attendancesystem.attendance")
int count();
@Insert("insert into attendancesystem.attendance (ID,AttendanceTime,JobID,Name,Sex,Department,AttendanceType,Notes,ApprovedType) VALUES(#{id},#{attendanceTime},#{jobID},#{name}, #{sex},#{department},#{attendanceType},#{notes},#{approvedType})" )
void addStaff(int id, String attendanceTime, String jobID, String name, String sex, String department, int attendanceType, String notes, String approvedType);
@Select("select * from attendancesystem.attendance where AttendanceType IN (2, 3) and ApprovedType=#{i}")
List<Attendance> low(int i);
@Update("update attendancesystem.attendance set ApprovedType=#{i} where AttendanceType= #{type} and Name=#{name}")
void approve(String name, String type, String i);
}

浙公网安备 33010602011771号