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