修复mysql迁移语法问题,同时兼容sqlite3
This commit is contained in:
parent
e8aa9be93d
commit
18df3147c0
@ -31,7 +31,8 @@ public class CourseController {
|
||||
if (pageSize == null || pageSize < 0) {
|
||||
pageSize = 10;
|
||||
}
|
||||
return courseService.getCourse(course, page, pageSize);
|
||||
int offset = Math.max(0, (page - 1)) * pageSize;
|
||||
return courseService.getCourse(course, offset, pageSize);
|
||||
}
|
||||
|
||||
@RequestMapping("/edit")
|
||||
|
||||
@ -24,7 +24,8 @@ public class studentController {
|
||||
if (page == null) {
|
||||
page = 1;
|
||||
}
|
||||
return studentService.getStudent(student, page, pageSize);
|
||||
int offset = Math.max(0, (page - 1)) * pageSize;
|
||||
return studentService.getStudent(student, offset, pageSize);
|
||||
}
|
||||
|
||||
@RequestMapping("/add")
|
||||
|
||||
@ -12,7 +12,7 @@ public interface CourseMapper {
|
||||
* @param course 作为查询条件,该对象中的默认值表示不对该项筛选。
|
||||
* @return 查询结果集
|
||||
*/
|
||||
List<Course> selectCourse(Course course, int page, int pageSize);
|
||||
List<Course> selectCourse(Course course, int offset, int pageSize);
|
||||
|
||||
/**
|
||||
* 插入课程
|
||||
|
||||
@ -7,7 +7,7 @@ import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface StudentMapper {
|
||||
List<Student> selectStudent(Student student, int page, int pageSize);
|
||||
List<Student> selectStudent(Student student, int offset, int pageSize);
|
||||
int selectStudentCount(Student student);
|
||||
int insertStudent(Student student);
|
||||
int updateStudent(Student student);
|
||||
|
||||
@ -7,7 +7,7 @@ import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
List<User> selectUser(User user, int page, int pageSize);
|
||||
List<User> selectUser(User user, int offset, int pageSize);
|
||||
User selectUserByName(String username);
|
||||
int insertUser(User user);
|
||||
int deleteUser(User user);
|
||||
|
||||
@ -78,7 +78,8 @@ public class CourseServiceImpl implements CourseService {
|
||||
|
||||
@Override
|
||||
public Result getCourse(Course course, int page, int pageSize) {
|
||||
List<Course> courseList = courseMapper.selectCourse(course, page, pageSize);
|
||||
int offset = Math.max(0, (page - 1)) * pageSize;
|
||||
List<Course> courseList = courseMapper.selectCourse(course, offset, pageSize);
|
||||
int total = courseMapper.selectCourseCount(course);
|
||||
return Result.success(courseList, total);
|
||||
}
|
||||
|
||||
@ -21,7 +21,8 @@ public class StudentServiceImpl implements StudentService {
|
||||
@Override
|
||||
public Result getStudent(Student student, int page, int pageSize) {
|
||||
try{
|
||||
List<Student> list = studentMapper.selectStudent(student, page, pageSize);
|
||||
int offset = Math.max(0, (page - 1)) * pageSize;
|
||||
List<Student> list = studentMapper.selectStudent(student, offset, pageSize);
|
||||
int total = studentMapper.selectStudentCount(student);
|
||||
return Result.success(list, total);
|
||||
}catch (Exception e){
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
AND #{course.major} in (N_MAJOR, -1)
|
||||
AND UPPER(VC_COURSE_NAME) LIKE CONCAT('%', UPPER(#{course.name}), '%')
|
||||
ORDER BY N_COURSE_ID DESC
|
||||
LIMIT (#{page}-1)*#{pageSize},#{pageSize}
|
||||
LIMIT #{offset},#{pageSize}
|
||||
</select>
|
||||
<select id="selectCourseCount" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
|
||||
@ -19,9 +19,10 @@
|
||||
AND #{student.sex} in (N_SEX, -1)
|
||||
AND #{student.grade} in (N_GRADE, -1)
|
||||
AND #{student.major} in (N_MAJOR, -1)
|
||||
AND VC_DETAIL LIKE CONCAT('%', #{student.detail}, '%')
|
||||
AND (VC_DETAIL LIKE CONCAT('%', #{student.detail}, '%')
|
||||
OR (#{student.detail} = '' AND VC_DETAIL IS NULL))
|
||||
ORDER BY N_STUDENT_ID DESC
|
||||
LIMIT (#{page}-1)*#{pageSize},#{pageSize}
|
||||
LIMIT #{offset},#{pageSize}
|
||||
</select>
|
||||
<select id="selectStudentCount" resultType="int">
|
||||
SELECT COUNT(*)
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
AND VC_LOGIN_NAME LIKE CONCAT('%',#{user.name},'%')
|
||||
AND VC_PASSWORD LIKE CONCAT('%',#{user.password},'%')
|
||||
ORDER BY N_USER_ID DESC
|
||||
LIMIT (#{page}-1)*#{pageSize},#{pageSize}
|
||||
LIMIT #{offset},#{pageSize}
|
||||
</select>
|
||||
<insert id="insertUser" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO t_user
|
||||
|
||||
Loading…
Reference in New Issue
Block a user