CourseInfo修改基本完成
Signed-off-by: Chenx221 <chenx221@yandex.com>
This commit is contained in:
parent
9c50926a51
commit
d4e571936e
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,5 +22,17 @@
|
|||||||
AND Description LIKE CONCAT('%', #{description}, '%')
|
AND Description LIKE CONCAT('%', #{description}, '%')
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
<update id="updateCourse" parameterType="cyou.chenx221.pojo.Course">
|
||||||
|
UPDATE course
|
||||||
|
SET
|
||||||
|
<trim suffixOverrides=",">
|
||||||
|
<if test="courseName != null">
|
||||||
|
CourseName = #{courseName},
|
||||||
|
</if>
|
||||||
|
<if test="description != null">
|
||||||
|
Description = #{description},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
WHERE CourseID = #{courseID}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
@ -197,7 +197,7 @@
|
|||||||
<div class="form-outline">
|
<div class="form-outline">
|
||||||
<input type="text" id="typeText2" class="form-control"
|
<input type="text" id="typeText2" class="form-control"
|
||||||
name="name"/>
|
name="name"/>
|
||||||
<label class="form-label" for="typeText2">课程名(支持部分关键词匹配)</label>
|
<label class="form-label" for="typeText2">课程名(支持部分)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -206,7 +206,7 @@
|
|||||||
<div class="form-outline">
|
<div class="form-outline">
|
||||||
<input type="text" id="typeText3" class="form-control"
|
<input type="text" id="typeText3" class="form-control"
|
||||||
name="description"/>
|
name="description"/>
|
||||||
<label class="form-label" for="typeText3">描述(支持部分关键词匹配)</label>
|
<label class="form-label" for="typeText3">描述(支持部分)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -79,34 +79,31 @@ public class CourseController {
|
|||||||
// return "redirect:/student/infomodv2";
|
// return "redirect:/student/infomodv2";
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @PostMapping(value = "/modinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")//处理学生信息修改请求
|
@PostMapping(value = "/modinfo", produces = "application/x-www-form-urlencoded;charset=UTF-8")
|
||||||
// public String UpdateModInfo(@RequestParam(value = "name", defaultValue = "null", required = false) String name,
|
public String UpdateModInfo(@RequestParam(value = "name", defaultValue = "null", required = false) String name,
|
||||||
// @RequestParam(value = "birthday", defaultValue = "null", required = false) String birthdayStr,
|
@RequestParam(value = "description", defaultValue = "null", required = false) String description,
|
||||||
// @RequestParam(value = "sex", defaultValue = "null", required = false) String sex,
|
@RequestParam(value = "id", defaultValue = "-1", required = false) int id,
|
||||||
// @RequestParam(value = "id", defaultValue = "-1", required = false) int id,
|
Model model) {
|
||||||
// @RequestParam(value = "phone", defaultValue = "null", required = false) String phone,
|
|
||||||
// @RequestParam(value = "classes", defaultValue = "", required = false) String classes,
|
Course course;
|
||||||
// Model model) {
|
if (name.equals("null")) name = null;
|
||||||
// Date birthday = null;
|
if (description.equals("null")) description = null;
|
||||||
// if (!"null".equals(birthdayStr)) {
|
if (id <= -1) {
|
||||||
// birthday = Date.valueOf(birthdayStr);
|
model.addAttribute("errorMessage", "ID非法,课程信息修改失败");
|
||||||
// }
|
} else {
|
||||||
// System.out.println(birthday);//debug
|
course = new Course(id, name, description);
|
||||||
// Student student;
|
int status_code = courseService.updateCourse(course);
|
||||||
// if (name.equals("null")) name = null;
|
if(status_code==1){
|
||||||
// if (sex.equals("null")) sex = null;
|
model.addAttribute("successMessage", "课程信息修改成功");
|
||||||
// if (phone.equals("null")) phone = null;
|
}else if(status_code==0) {
|
||||||
// if (classes.equals("")) classes = null;
|
model.addAttribute("errorMessage", "课程信息修改失败,可能是ID非法或者课程不存在");
|
||||||
//
|
}else{
|
||||||
// if (id <= -1) {
|
model.addAttribute("errorMessage", "课程信息修改异常");
|
||||||
// model.addAttribute("errorMessage", "学生信息修改失败");
|
System.out.println("DEBUG:课程信息修改异常,存在多条记录被修改的情况");
|
||||||
// } else {
|
}
|
||||||
// student = new Student(id, name, sex, birthday, phone, classes);
|
}
|
||||||
// studentService.updateStudent(student);
|
return "redirect:/course/infomodv2";
|
||||||
// model.addAttribute("successMessage", "学生信息修改成功");
|
}
|
||||||
// }
|
|
||||||
// return "redirect:/student/infomodv2";
|
|
||||||
// }
|
|
||||||
|
|
||||||
@PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8")//学生信息查询(带条件)
|
@PostMapping(value = "/query", produces = "application/x-www-form-urlencoded;charset=UTF-8")//学生信息查询(带条件)
|
||||||
public String getQueryCourses(@RequestParam(value = "name", defaultValue = "null", required = false) String name,
|
public String getQueryCourses(@RequestParam(value = "name", defaultValue = "null", required = false) String name,
|
||||||
@ -122,16 +119,7 @@ public class CourseController {
|
|||||||
List<Course> courses;
|
List<Course> courses;
|
||||||
Course course;
|
Course course;
|
||||||
course = new Course((id == -1 ? null : id), name, description);
|
course = new Course((id == -1 ? null : id), name, description);
|
||||||
System.out.println("id:" + id + " name:" + name + " description:" + description);
|
// System.out.println("id:" + id + " name:" + name + " description:" + description);
|
||||||
// if(course.getCourseID() == null){
|
|
||||||
// System.out.println("WARNNING : id is null");
|
|
||||||
// }
|
|
||||||
// if (course.getCourseName() == null) {
|
|
||||||
// System.out.println("WARNNING : courseName is null");
|
|
||||||
// }
|
|
||||||
// if (course.getDescription() == null) {
|
|
||||||
// System.out.println("WARNNING : description is null");
|
|
||||||
// }
|
|
||||||
courses = courseService.getQueryCourses(course);
|
courses = courseService.getQueryCourses(course);
|
||||||
model.addAttribute("courses", courses);
|
model.addAttribute("courses", courses);
|
||||||
return "courseQueryResult";
|
return "courseQueryResult";
|
||||||
|
@ -10,4 +10,6 @@ public interface CourseDao {
|
|||||||
List<Course> getAllCourses();
|
List<Course> getAllCourses();
|
||||||
|
|
||||||
List<Course> getQueryCourses(Course course);
|
List<Course> getQueryCourses(Course course);
|
||||||
|
|
||||||
|
int updateCourse(Course course);
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,9 @@ public class CourseDaoImpl implements CourseDao {
|
|||||||
public List<Course> getQueryCourses(Course course) {
|
public List<Course> getQueryCourses(Course course) {
|
||||||
return sqlSession.selectList("getQueryCourses", course);
|
return sqlSession.selectList("getQueryCourses", course);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateCourse(Course course) {
|
||||||
|
return sqlSession.update("updateCourse", course);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,4 +22,9 @@ public class CourseService {
|
|||||||
public List<Course> getQueryCourses(Course course) {
|
public List<Course> getQueryCourses(Course course) {
|
||||||
return courseDao.getQueryCourses(course);
|
return courseDao.getQueryCourses(course);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int updateCourse(Course course) {
|
||||||
|
return courseDao.updateCourse(course);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,5 +22,17 @@
|
|||||||
AND Description LIKE CONCAT('%', #{description}, '%')
|
AND Description LIKE CONCAT('%', #{description}, '%')
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
<update id="updateCourse" parameterType="cyou.chenx221.pojo.Course">
|
||||||
|
UPDATE course
|
||||||
|
SET
|
||||||
|
<trim suffixOverrides=",">
|
||||||
|
<if test="courseName != null">
|
||||||
|
CourseName = #{courseName},
|
||||||
|
</if>
|
||||||
|
<if test="description != null">
|
||||||
|
Description = #{description},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
WHERE CourseID = #{courseID}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
@ -197,7 +197,7 @@
|
|||||||
<div class="form-outline">
|
<div class="form-outline">
|
||||||
<input type="text" id="typeText2" class="form-control"
|
<input type="text" id="typeText2" class="form-control"
|
||||||
name="name"/>
|
name="name"/>
|
||||||
<label class="form-label" for="typeText2">课程名(支持部分关键词匹配)</label>
|
<label class="form-label" for="typeText2">课程名(支持部分)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -206,7 +206,7 @@
|
|||||||
<div class="form-outline">
|
<div class="form-outline">
|
||||||
<input type="text" id="typeText3" class="form-control"
|
<input type="text" id="typeText3" class="form-control"
|
||||||
name="description"/>
|
name="description"/>
|
||||||
<label class="form-label" for="typeText3">描述(支持部分关键词匹配)</label>
|
<label class="form-label" for="typeText3">描述(支持部分)</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user