diff --git a/src/main/java/com/yipin/liuwanr/controller/CourseController.java b/src/main/java/com/yipin/liuwanr/controller/CourseController.java index 9c77007..314803d 100644 --- a/src/main/java/com/yipin/liuwanr/controller/CourseController.java +++ b/src/main/java/com/yipin/liuwanr/controller/CourseController.java @@ -41,33 +41,52 @@ public class CourseController { Response resp = new Response(); Course course = vo.getCourse(); List serviceConfigList = vo.getServiceConfigList(); - if (course.getCourseName()==null||course.getCourseName().length()<=0) { + //课程名称 + String courseName = course.getCourseName(); + //课程类型 + Integer courseType = course.getCourseType(); + //学科类型id + Integer disciplineId = course.getDisciplineId(); + //专业类id + Integer professionalClassId = course.getProfessionalClassId(); + //专业id + Integer professionalId = course.getProfessionalId(); + //市场价格 + double marketPrice = course.getMarketPrice(); + Double price =new Double(marketPrice); + //课程简介 + String CourseIntroduction = course.getCourseIntroduction(); + //教学目标 + String TeachingGoal = course.getTeachingGoal(); + //绑定系统id + String SystemId = course.getSystemId(); + if (courseName==null||courseName=="") { resp.setStatus(300); - resp.setErrmessage("Course Name Is Null!"); - }else if(course.getCourseType()==null){ + resp.setErrmessage("课程名称为空!"); + }else if(courseType==null){ resp.setStatus(300); - resp.setErrmessage("Course Type Is Null!"); + resp.setErrmessage("课程类型为空!"); }else if(course.getDisciplineId()==null){ resp.setStatus(300); - resp.setErrmessage("DisciplineId Type Is Null!"); - }else if(course.getProfessionalClassId()==null){ + resp.setErrmessage("学科类别为空!"); + }else if(professionalClassId==null){ resp.setStatus(300); - resp.setErrmessage("ProfessionalId Class Is Null!"); - }else if(course.getProfessionalId()==null){ + resp.setErrmessage("专业类为空!"); + }else if(professionalId==null){ resp.setStatus(300); - resp.setErrmessage("ProfessionalId Is Null!"); - }else if(course.getMarketPrice()==null||course.getMarketPrice().length()<=0){ + resp.setErrmessage("专业为空!"); + }else if(price==null){ resp.setStatus(300); - resp.setErrmessage("Market Price Is Null!"); - }else if(course.getCourseIntroduction()==null||course.getCourseIntroduction().length()<=0){ + resp.setErrmessage("市场价格为空!"); + }else if(CourseIntroduction==null||CourseIntroduction==""){ resp.setStatus(300); - resp.setErrmessage("Course Introduction Is Null!"); - }else if(course.getTeachingGoal()==null||course.getTeachingGoal().length()<=0){ + resp.setErrmessage("课程简介为空!"); + }else if(TeachingGoal==null||TeachingGoal==""){ resp.setStatus(300); - resp.setErrmessage("Teaching Goal Is Null!"); - }else if(course.getSystemId()==null||course.getSystemId()==""){ + resp.setErrmessage("教学目标为空!"); + }else if(SystemId==null||SystemId==""){ resp.setStatus(300); - resp.setErrmessage("SystemId Is Null!"); + resp.setErrmessage("绑定系统id为空!"); }else { HashMap ret = courseService.addCourse(course); Integer courseId = (Integer) ret.get("retvalue"); @@ -81,8 +100,11 @@ public class CourseController { HashMap retPC = courseService.addCoursePC(serviceConfigList); int statusPC = (int) retPC.get("retcode"); if (statusPC == 200) { - resp.setStatus(status); - resp.setMessage(ret.get("retvalue")); + resp.setStatus(statusPC); + resp.setMessage(retPC.get("retvalue")); + }else{ + resp.setStatus(statusPC); + resp.setErrmessage(retPC.get("retvalue").toString()); } } else { resp.setStatus(status); @@ -91,7 +113,30 @@ public class CourseController { } return resp; } - + + /** + * 查询课程名称是否存在 + */ + @GetMapping("/queryCourseNameIsExists") + Response queryCourseNameIsExists(@RequestParam String courseName) { + Response resp = new Response(); + if (courseName==null||courseName=="") { + resp.setStatus(300); + resp.setErrmessage("课程名称为空!"); + }else { + HashMap ret = courseService.queryCourseNameIsExists(courseName); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + } + return resp; + } + /** * 查询课程 */ diff --git a/src/main/java/com/yipin/liuwanr/controller/CustomerController.java b/src/main/java/com/yipin/liuwanr/controller/CustomerController.java index fa09a7f..7509eeb 100644 --- a/src/main/java/com/yipin/liuwanr/controller/CustomerController.java +++ b/src/main/java/com/yipin/liuwanr/controller/CustomerController.java @@ -194,11 +194,7 @@ public class CustomerController { resp.setErrmessage("学校不能为空!"); }else { HashMap ret = customerService.queryCustomerIsExists(schoolId); - if (ret.isEmpty()) { - resp.setStatus(300); - resp.setErrmessage("该客户已存在!"); - }else { - int status = (int) ret.get("retcode"); + int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); @@ -207,7 +203,6 @@ public class CustomerController { resp.setErrmessage(ret.get("retvalue").toString()); } } - } return resp; } /** diff --git a/src/main/java/com/yipin/liuwanr/controller/StaffController.java b/src/main/java/com/yipin/liuwanr/controller/StaffController.java index 3ed175e..90bcd16 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StaffController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StaffController.java @@ -3,7 +3,9 @@ package com.yipin.liuwanr.controller; import java.util.HashMap; import java.util.List; +import com.yipin.liuwanr.vo.UserVO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -58,36 +60,48 @@ public class StaffController { /** * 添加员工 */ + @Transactional @PostMapping("/addStaff") - Response addCustomer(@RequestBody Staff staff) { + Response addCustomer(@RequestBody UserVO vo) { Response resp = new Response(); - UserM user = new UserM(); - user.setPassword("huoran123"); - user.setWorkNumber(staff.getStaffWorkNumber()); - user.setUserAccount(staff.getStaffWorkNumber()); - user.setAccountRole(3); - user.setName(staff.getStaffName()); - user.setPhone(staff.getPhone()); - user.setEmail(staff.getEmail()); - user.setSchoolId(staff.getSchoolId()); - Long startTs = System.currentTimeMillis(); // 当前时间戳 - String uniqueIdentificationAccount = startTs+""; - user.setUniqueIdentificationAccount(uniqueIdentificationAccount); - staff.setUniqueIdentificationAccount(uniqueIdentificationAccount); - user.setUniqueIdentificationAccount(staff.getUniqueIdentificationAccount()); + Staff staff = vo.getStaff(); + UserM user = vo.getUser(); +// user.setPassword("huoran123"); +// user.setWorkNumber(staff.getStaffWorkNumber()); +// user.setUserAccount(staff.getStaffWorkNumber()); +// user.setAccountRole(3); +// user.setName(staff.getStaffName()); +// user.setPhone(staff.getPhone()); +// user.setEmail(staff.getEmail()); +// user.setSchoolId(staff.getSchoolId()); +// Long startTs = System.currentTimeMillis(); // 当前时间戳 +// String uniqueIdentificationAccount = startTs+""; +// user.setUniqueIdentificationAccount(uniqueIdentificationAccount); +// staff.setUniqueIdentificationAccount(uniqueIdentificationAccount); +// user.setUniqueIdentificationAccount(staff.getUniqueIdentificationAccount()); if (staff.getPhone()==null) { resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); + resp.setErrmessage("电话为空添加失败!"); } else { HashMap ret = staffService.addStaff(staff); - HashMap ret1 = userService.addUser(user); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); + HashMap ret1 = userService.addUser(user); + int status1 = (int) ret1.get("retcode"); + if (status1 == 200){ + resp.setStatus(status1); + resp.setMessage(ret1.get("retvalue")); + }else{ + resp.setStatus(status1); + resp.setErrmessage(ret1.get("retvalue").toString()); + throw new RuntimeException(); + } } else { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); + throw new RuntimeException(); } } return resp; diff --git a/src/main/java/com/yipin/liuwanr/controller/StudentController.java b/src/main/java/com/yipin/liuwanr/controller/StudentController.java index c49dc89..573adbf 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StudentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StudentController.java @@ -3,7 +3,9 @@ package com.yipin.liuwanr.controller; import java.util.HashMap; import java.util.List; +import com.yipin.liuwanr.vo.UserVO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -65,35 +67,47 @@ public class StudentController { /** * 添加学生 */ + @Transactional @PostMapping("/addStudent") - Response addStudent(@RequestBody Student student) { + Response addStudent(@RequestBody UserVO vo) { Response resp = new Response(); - UserM user = new UserM(); - user.setPassword("huoran123"); - user.setPassword(student.getStudentPassword()); - user.setUserAccount(student.getStudentNumber()); - user.setAccountRole(4); - user.setName(student.getStudentName()); - user.setPhone(student.getPhone()); - user.setEmail(student.getEmail()); - user.setWorkNumber(student.getStudentNumber()); - Long startTs = System.currentTimeMillis(); // 当前时间戳 - String uniqueIdentificationAccount = startTs+""; - user.setUniqueIdentificationAccount(uniqueIdentificationAccount); - student.setUniqueIdentificationAccount(uniqueIdentificationAccount); + Student student = vo.getStudent(); + UserM user = vo.getUser(); +// user.setPassword("huoran123"); +// user.setPassword(student.getStudentPassword()); +// user.setUserAccount(student.getStudentNumber()); +// user.setAccountRole(4); +// user.setName(student.getStudentName()); +// user.setPhone(student.getPhone()); +// user.setEmail(student.getEmail()); +// user.setWorkNumber(student.getStudentNumber()); +// Long startTs = System.currentTimeMillis(); // 当前时间戳 +// String uniqueIdentificationAccount = startTs+""; +// user.setUniqueIdentificationAccount(uniqueIdentificationAccount); +// student.setUniqueIdentificationAccount(uniqueIdentificationAccount); if (student.getPhone()==null) { resp.setStatus(300); resp.setErrmessage("Parameter Invalid"); } else { HashMap ret = studentService.addStudent(student); - HashMap ret1 = userService.addUser(user); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); + HashMap ret1 = userService.addUser(user); + int status1 = (int)ret.get("retcode"); + if (status1 == 200){ + resp.setStatus(status1); + resp.setMessage(ret1.get("retvalue")); + }else { + resp.setStatus(status1); + resp.setErrmessage(ret1.get("retvalue").toString()); + throw new RuntimeException(); + } } else { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); + throw new RuntimeException(); } } return resp; diff --git a/src/main/java/com/yipin/liuwanr/controller/UserController.java b/src/main/java/com/yipin/liuwanr/controller/UserController.java index 7e7e610..ca1c389 100644 --- a/src/main/java/com/yipin/liuwanr/controller/UserController.java +++ b/src/main/java/com/yipin/liuwanr/controller/UserController.java @@ -1,27 +1,22 @@ package com.yipin.liuwanr.controller; -import java.util.HashMap; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - +import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.entity.Response; -import com.yipin.liuwanr.entity.User; -import com.yipin.liuwanr.entity.UserM; import com.yipin.liuwanr.helper.PushHelper; import com.yipin.liuwanr.helper.RandomUtil; import com.yipin.liuwanr.helper.RedisHelper; +import com.yipin.liuwanr.service.StaffService; +import com.yipin.liuwanr.service.StudentService; import com.yipin.liuwanr.service.UserService; +import com.yipin.liuwanr.vo.UserVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; @RestController @RequestMapping("/user") @@ -30,6 +25,12 @@ public class UserController { @Autowired private UserService userService; + @Autowired + private StudentService studentService; + + @Autowired + private StaffService staffService; + @Autowired RedisHelper redisHelper; @@ -95,13 +96,43 @@ public class UserController { } return resp; } - + + /** + * 查询电话 + */ + @GetMapping("/queryPhone") + Response queryPhone(@RequestParam String phone) { + Response resp = new Response(); + if (phone==null||phone=="") {//前台传来的值是否为空 + resp.setStatus(300); + resp.setErrmessage("手机号为空!查询失败!"); + }else { + HashMap ret = userService.queryPhone(phone); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + } + return resp; + } + /** * 添加用户 */ + @Transactional @PostMapping("/addUser") - Response addUser(@RequestBody UserM user) { + Response addUser(@RequestBody UserVO vo) { Response resp = new Response(); + //用户实体 + UserM user = vo.getUser(); + //学生实体 + Student student = vo.getStudent(); + //员工实体 + Staff staff = vo.getStaff(); //用户手机号 String phone = user.getPhone(); //用户名称 @@ -133,21 +164,39 @@ public class UserController { resp.setStatus(300); resp.setErrmessage("学校不能为空!"); }else { - HashMap ret1 = userService.queryPhone(phone); - int status1 = (int) ret1.get("retcode"); - if (status1==200){ - HashMap ret = userService.addUser(user); - int status = (int) ret.get("retcode"); - if (200 == status) { + if (accountRole == 4){ + HashMap stu = studentService.addStudent(student); + int status = (int) stu.get("retcode"); + if (status == 200){ resp.setStatus(status); - resp.setMessage(ret.get("retvalue")); - } else { + resp.setMessage(stu.get("retvalue")); + }else { resp.setStatus(status); - resp.setErrmessage(ret.get("retvalue").toString()); + resp.setErrmessage(stu.get("retvalue").toString()); + throw new RuntimeException(); } - }else{ - resp.setStatus(status1); - resp.setErrmessage(ret1.get("retvalue").toString()); + } + if(accountRole == 3){ + HashMap sta = staffService.addStaff(staff); + int status = (int) sta.get("retcode"); + if (status == 200){ + resp.setStatus(status); + resp.setMessage(sta.get("retvalue")); + }else { + resp.setStatus(status); + resp.setErrmessage(sta.get("retvalue").toString()); + throw new RuntimeException(); + } + } + HashMap ret = userService.addUser(user); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + throw new RuntimeException(); } } return resp; @@ -358,4 +407,31 @@ public class UserController { } return resp; } + /** + * 用户模块查询客户 + */ + @GetMapping("/queryCustomer") + Response queryCustomer(@RequestParam Integer cityId,Integer provinceId) { + Response resp = new Response(); + if(provinceId == null){ + resp.setStatus(300); + resp.setErrmessage("省份id为空!查询失败!"); + }else if (cityId==null) { + resp.setStatus(300); + resp.setErrmessage("城市id为空!查询失败!"); + }else { + HashMap ret = userService.queryCustomer(cityId,provinceId); + resp.setStatus(200); + resp.setErrmessage("查询成功!"); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + } + return resp; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/Course.java b/src/main/java/com/yipin/liuwanr/entity/Course.java index dba90f1..53efdd1 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Course.java +++ b/src/main/java/com/yipin/liuwanr/entity/Course.java @@ -16,7 +16,7 @@ public class Course { //预计课时 private Integer courseHours; //市场价格 - private String marketPrice; + private double marketPrice; //课程简介 private String courseIntroduction; //教学目标 @@ -98,12 +98,6 @@ public class Course { public void setCourseHours(Integer courseHours) { this.courseHours = courseHours; } - public String getMarketPrice() { - return marketPrice; - } - public void setMarketPrice(String marketPrice) { - this.marketPrice = marketPrice; - } public String getCourseIntroduction() { return courseIntroduction; } @@ -122,4 +116,10 @@ public class Course { public void setSearchContent(String searchContent) { this.searchContent = searchContent; } + public double getMarketPrice() { + return marketPrice; + } + public void setMarketPrice(double marketPrice) { + this.marketPrice = marketPrice; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/CoursePermissions.java b/src/main/java/com/yipin/liuwanr/entity/CoursePermissions.java index 569a39c..63454e7 100644 --- a/src/main/java/com/yipin/liuwanr/entity/CoursePermissions.java +++ b/src/main/java/com/yipin/liuwanr/entity/CoursePermissions.java @@ -8,9 +8,9 @@ public class CoursePermissions { //使用期限 private Integer usePeriod; //市场价 - private String marketPrice; + private double marketPrice; //交易价格 - private Integer transactionPrice; + private double transactionPrice; //折扣率 private Integer discount; //绑定端口地址id @@ -25,7 +25,13 @@ public class CoursePermissions { private String courseName; //到期时间 private String expirationTime; - + + public double getTransactionPrice() { + return transactionPrice; + } + public void setTransactionPrice(double transactionPrice) { + this.transactionPrice = transactionPrice; + } public String getExpirationTime() { return expirationTime; } @@ -50,18 +56,12 @@ public class CoursePermissions { public void setUsePeriod(Integer usePeriod) { this.usePeriod = usePeriod; } - public String getMarketPrice() { + public double getMarketPrice() { return marketPrice; } - public void setMarketPrice(String marketPrice) { + public void setMarketPrice(double marketPrice) { this.marketPrice = marketPrice; } - public Integer getTransactionPrice() { - return transactionPrice; - } - public void setTransactionPrice(Integer transactionPrice) { - this.transactionPrice = transactionPrice; - } public Integer getDiscount() { return discount; } diff --git a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index 034c27e..ce567eb 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java @@ -93,7 +93,7 @@ public interface AssesmentMapper { * * @param assesment */ - @Update("update assessment set assesmentName=#{assesmentName},releaseType=#{releaseType},creationTime=#{creationTime},endTime=#{endTime},timesum=#{timesum},assessmentSize=#{assessmentSize},assessmentNumber=#{assessmentNumber}" + @Update("update assessment set assesmentName=#{assesmentName},releaseType=#{releaseType},creationTime=#{creationTime},endTime=#{endTime},timesum=#{timesum},assessmentSize=#{assessmentSize},assessmentNumber=#{assessmentNumber}," + "experimentId=#{experimentId},assesmentState=#{assesmentState},classId=#{classId},experimentalClassId=#{experimentalClassId} where id=#{id}") void updateAssesment(Assesment assesment); @@ -197,7 +197,7 @@ public interface AssesmentMapper { * @param creationTime * @return */ - @Select("select experimentalClassId,experimentalClassName from experimental_class_ning where isdel=0 and creationTime like concat('%',#{creationTime},'%') and founder=(select staffName from staff where staffId=#{staffId}) and schoolId={schoolId} ") + @Select("select experimentalClassId,experimentalClassName from experimental_class_ning where isdel=0 and creationTime like concat('%',#{creationTime},'%') and founder=(select staffName from staff where staffId=#{staffId}) and schoolId=#{schoolId} ") @Results({ @Result(id = true, column = "experimentalClassId", property = "experimentalClassId"), @Result(column = "experimentalClassName", property = "experimentalClassName"), diff --git a/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java b/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java index a4d2577..1526013 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java @@ -70,7 +70,12 @@ public interface CourseMapper { @Result(property = "serviceConfigList", column = "courseId",many = @Many(select = "com.yipin.liuwanr.mapper.CourseMapper.queryCourseDetailsTC")), }) List queryCourseDetails(Integer courseId); - + + @Select({" "}) + List queryCourseNameIsExists(String courseName); + @Select({" "}) @@ -85,7 +90,8 @@ public interface CourseMapper { "SELECT o.orderId,o.orderNumber,o.orderName,o.orderAmount,o.orderDate,o.orderType,o.orderStatus,o.orderNature,o.provinceId,o.cityId,o.orderContact,o.phone,o.email,o.customerId,(SELECT c.customerName from customer c WHERE c.customerId = o.customerId) as customerName from orders o where o.isdel=0 and o.orderId = #{orderId} ", " "}) Order queryOrderDetailsO(Integer orderId); - + + //删除课程 @Update({" "}) void deleteCourse(@Param("courseId")List courseId); - + + //修改课程 @Update("UPDATE course SET courseName = #{courseName},courseType = #{courseType},disciplineId = #{disciplineId},professionalClassId = #{professionalClassId},professionalId = #{professionalId}," + "courseHours = #{courseHours},marketPrice = #{marketPrice},courseIntroduction = #{courseIntroduction},teachingGoal = #{teachingGoal},systemId = #{systemId} where courseId = #{courseId}") void updateCourse(Course course); + //修改课程实训配置 @Update("UPDATE hr_course_tc SET systemId = #{systemId},projectId = #{projectId},isShow = #{isShow} where courseId = #{courseId} and systemId = #{systemId} and projectId = #{projectId}") void updateCoursePC(ServiceConfig serviceConfig); - + + //删除课程实训配置 @Delete("Delete FROM hr_course_tc where courseId = #{courseId}") void deleteCoursePC(Integer courseId); - + + //查询课程学科 @Select({" "}) List queryCourseDiscipline(); - + + //查询课程专业类 @Select({" "}) List queryCourseProfessionalClass(Integer disciplineId); - + + //查询课程专业 @Select({" "}) @@ -174,7 +186,7 @@ public interface CourseMapper { //查询配置 @Select({" "}) List queryConfig(String systemId); diff --git a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java index 69c6113..1ce3e13 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java @@ -13,10 +13,12 @@ import io.lettuce.core.dynamic.annotation.Param; public interface StudentMapper { + //添加学生 @Insert("INSERT INTO student(studentName,studentNumber,phone,email,roleId,schoolId,professionalId,gradeId,classId,isdel,uniqueIdentificationAccount)" + "VALUES(#{studentName},#{studentNumber},#{phone},#{email},#{roleId},#{schoolId},#{professionalId},#{gradeId},#{classId},0,#{uniqueIdentificationAccount})") void addStudent(Student student); + //查询学生 @Select({ " " }) void deleteStudent(@Param("studentId") List studentId); + //查询学生详情 @Select({ " " }) List queryStudentDetails(Integer studentId); + //修改学生 @Update("UPDATE student SET studentName = #{studentName},studentWorkNumber = #{studentWorkNumber},phone = #{phone},email = #{email},roleId = #{roleId}" + ",schoolId = #{schoolId},professionalId = #{professionalId},gradeId = #{gradeId},classId = #{classId} where studentId = #{studentId}") void updateStudent(Student student); diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java index 40879b7..38abb54 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java @@ -1,21 +1,10 @@ package com.yipin.liuwanr.mapper; -import java.util.List; - -import org.apache.ibatis.annotations.Delete; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Many; -import org.apache.ibatis.annotations.Result; -import org.apache.ibatis.annotations.Results; -import org.apache.ibatis.annotations.Select; -import org.apache.ibatis.annotations.Update; +import com.yipin.liuwanr.entity.*; +import org.apache.ibatis.annotations.*; import org.apache.ibatis.mapping.FetchType; -import com.yipin.liuwanr.entity.Config; -import com.yipin.liuwanr.entity.Demo; -import com.yipin.liuwanr.entity.User; -import com.yipin.liuwanr.entity.UserM; -import org.apache.ibatis.annotations.Param; +import java.util.List; public interface UserMapper { @@ -108,10 +97,20 @@ public interface UserMapper { + "#{settlement},#{open},#{high},#{low},#{volume},#{amount},#{ticktime},#{per},#{pb},#{mktcap},#{nmc},#{turnoverratio}) ") void insertDemo(Demo demo); - @Insert("INSERT INTO user(name,password,sex,documentType,countries,educationDegree,IDNumber,accountRole,provinceId,subjectsTaught,cityId,phone,teachingProfessional,WeChatID,dateBirth,email,creationTime,isdel,schoolId,uniqueIdentificationAccount,disciplineId,professionalClassId,professionalId)" - + " VALUES(#{name},#{password},#{sex},#{documentType},#{countries},#{educationDegree},#{IDNumber},#{accountRole},#{provinceId},#{subjectsTaught},#{cityId},#{phone},#{teachingProfessional},#{WeChatID},#{dateBirth},#{email},now(),0,#{schoolId},#{uniqueIdentificationAccount},#{disciplineId},#{professionalClassId},#{professionalId})") + @Insert("INSERT INTO user(name,password,sex,documentType,countries,educationDegree,IDNumber,accountRole,provinceId,subjectsTaught,cityId,phone,teachingProfessional,WeChatID,dateBirth,email,creationTime,isdel,schoolId,uniqueIdentificationAccount,disciplineId,professionalClassId,professionalId,userAccount,workNumber)" + + " VALUES(#{name},#{password},#{sex},#{documentType},#{countries},#{educationDegree},#{IDNumber},#{accountRole},#{provinceId},#{subjectsTaught},#{cityId},#{phone},#{teachingProfessional},#{WeChatID},#{dateBirth},#{email},now(),0,#{schoolId},#{uniqueIdentificationAccount},#{disciplineId},#{professionalClassId},#{professionalId},#{userAccount},#{workNumber})") void addUser(UserM user); - + +// //添加学生 +// @Insert("INSERT INTO student(name,password,sex,documentType,countries,educationDegree,IDNumber,accountRole,provinceId,subjectsTaught,cityId,phone,teachingProfessional,WeChatID,dateBirth,email,creationTime,isdel,schoolId,uniqueIdentificationAccount,disciplineId,professionalClassId,professionalId)" +// + " VALUES(#{name},#{password},#{sex},#{documentType},#{countries},#{educationDegree},#{IDNumber},#{accountRole},#{provinceId},#{subjectsTaught},#{cityId},#{phone},#{teachingProfessional},#{WeChatID},#{dateBirth},#{email},now(),0,#{schoolId},#{uniqueIdentificationAccount},#{disciplineId},#{professionalClassId},#{professionalId})") +// void addStudent(Student student); +// +// //添加员工 +// @Insert("INSERT INTO staff(name,password,sex,documentType,countries,educationDegree,IDNumber,accountRole,provinceId,subjectsTaught,cityId,phone,teachingProfessional,WeChatID,dateBirth,email,creationTime,isdel,schoolId,uniqueIdentificationAccount,disciplineId,professionalClassId,professionalId)" +// + " VALUES(#{name},#{password},#{sex},#{documentType},#{countries},#{educationDegree},#{IDNumber},#{accountRole},#{provinceId},#{subjectsTaught},#{cityId},#{phone},#{teachingProfessional},#{WeChatID},#{dateBirth},#{email},now(),0,#{schoolId},#{uniqueIdentificationAccount},#{disciplineId},#{professionalClassId},#{professionalId})") +// void addStaff(Staff staff); + // @Select("SELECT * from user where isdel = 1 and countries = #{countries} and provinces = #{provinces} and city = #{city}") @Select({" "}) List queryUserDetails(Integer userId); - + + @Select({" "}) + List queryCustomer(Integer cityId,Integer provinceId); + /** * 批量插入用户 * @param user diff --git a/src/main/java/com/yipin/liuwanr/service/CourseService.java b/src/main/java/com/yipin/liuwanr/service/CourseService.java index 627b9cd..6634553 100644 --- a/src/main/java/com/yipin/liuwanr/service/CourseService.java +++ b/src/main/java/com/yipin/liuwanr/service/CourseService.java @@ -114,12 +114,27 @@ public class CourseService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "查询课程详情失败!"); return resp; } return resp; } - + + //查询课程名称是否存在 + public HashMap queryCourseNameIsExists(String courseName){ + HashMap resp = new HashMap(); + try { + resp.put("retvalue", courseMapper.queryCourseNameIsExists(courseName)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询课程名称失败!"); + return resp; + } + return resp; + } + //查询课程详情课程权限 public HashMap queryCourseDetailsTC(Integer courseId,Integer pageNo,Integer pageSize){ HashMap resp = new HashMap(); @@ -145,12 +160,13 @@ public class CourseService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "查询课程详情课程权限失败!"); return resp; } return resp; } - + + //删除课程 public HashMap deleteCourse(List courseId){ HashMap resp = new HashMap(); try { @@ -159,12 +175,12 @@ public class CourseService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "删除课程失败!"); return resp; } return resp; } - + //更新课程 public HashMap updateCourse(Course course){ HashMap resp = new HashMap(); try { @@ -173,12 +189,12 @@ public class CourseService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "更新课程失败!"); return resp; } return resp; } - + //修改课程实训配置 public HashMap updateCoursePC(ServiceConfig serviceConfig){ HashMap resp = new HashMap(); try { @@ -187,7 +203,7 @@ public class CourseService { } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "更新失败"); return resp; } return resp; diff --git a/src/main/java/com/yipin/liuwanr/service/UserService.java b/src/main/java/com/yipin/liuwanr/service/UserService.java index 4a028eb..7b0ebe5 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserService.java @@ -9,6 +9,7 @@ import java.util.List; import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.mapper.StaffMapper; import com.yipin.liuwanr.mapper.StudentMapper; +import com.yipin.liuwanr.entity.*; import org.jboss.logging.Logger; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -37,7 +38,7 @@ public class UserService { private StaffMapper staffMapper; @Autowired private StudentMapper studentMapper; - + @Autowired private JedisCluster jedis; @@ -91,7 +92,7 @@ public class UserService { } return result; } - + public HashMap insert(Demo demo) { HashMap result = new HashMap(); try { @@ -106,25 +107,22 @@ public class UserService { return result; } - public HashMap queryPhone(String phone) { + //查询手机号 + public HashMapqueryPhone(String phone) { HashMap resp = new HashMap(); try { resp.put("retvalue", userMapper.queryPhone(phone)); - if (resp.get("retvalue")==null) { - resp.put("retcode", 200); - }else { - resp.put("retcode", 300); - resp.put("retvalue", "新增失败,账号已存在!"); - } + resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "查询手机号失败!"); return resp; } return resp; } + //添加用户 public HashMap addUser(UserM user){ HashMap resp = new HashMap(); try { @@ -141,7 +139,8 @@ public class UserService { } return resp; } - + + //查询用户 public HashMap queryUser(UserM user,Integer pageNo,Integer pageSize){ HashMap resp = new HashMap(); try { @@ -171,7 +170,8 @@ public class UserService { } return resp; } - + + //删除用户 public HashMap deleteUser(UserM user){ HashMap resp = new HashMap(); try { @@ -185,7 +185,8 @@ public class UserService { } return resp; } - + + //更新用户 public HashMap updateUser(UserM user){ HashMap resp = new HashMap(); try { @@ -199,37 +200,15 @@ public class UserService { } return resp; } - -// public HashMap logins(UserM user){ -//// -//// HashMap resp = new HashMap(); -//// try { -//// resp.put("retvalue", userMapper.logins(user)); -//// if (resp.get("retvalue")==null) { -//// resp.put("retcode", 300); -//// resp.put("retvalue", "登录失败,账号密码有误或不存在!"); -//// }else { -//// resp.put("retcode", 200); -//// } -//// } catch (RuntimeException e) { -//// logger.error(e.getMessage()); -//// resp.put("retcode", 500); -//// resp.put("retvalue", "登录异常,请稍后再试!"); -//// return resp; -//// } -//// return resp; -//// } - + //登陆 public HashMap logins(UserM userM){ HashMap resp = new HashMap(); - List obj=new ArrayList<>(); - String param=userM.getPhone(); - String password=userM.getPassword(); - Student student; - Staff staff; + HashMap obj = new HashMap(); + Student student; + Staff staff; try { - UserM user=userMapper.loginsQ(param,password); + UserM user=userMapper.logins(userM); if(user!=null) { int loginNumber=user.getLogInNumber()+1; Integer userId=user.getUserId(); @@ -238,39 +217,39 @@ public class UserService { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String lastTime=sd.format(date); if(user.getAccountRole().equals(4)) { - student=studentMapper.queryStudentQ(user); + student=studentMapper.queryStudentQ(user); if(student!=null) { Integer studentId=student.getStudentId(); studentMapper.updateStudentQ(lastTime,loginNumber, studentId); - obj.add(student); + obj.put("student",student); } }else if(user.getAccountRole().equals(3)) { - staff=staffMapper.queryStaffQ(user); + staff =staffMapper.queryStaffQ(user); if(staff!=null) { Integer staffId=staff.getStaffId(); staffMapper.updateStaffQ(lastTime,loginNumber, staffId); - obj.add(staff); + obj.put("staff",staff); } } user.setPassword(null); - obj.add(user); + obj.put("user",user); userMapper.updateUserQ(lastTime,loginNumber, userId); - resp.put("retcode", 200); resp.put("retvalue", obj); }else { resp.put("retcode", 300); - resp.put("retvalue", "Login failed"); + resp.put("retvalue", "登录失败,账号密码有误或不存在!"); } } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "登录异常,请稍后再试!"); return resp; } return resp; } + //查询用户详情 public HashMap queryUserDetails(Integer userId){ HashMap resp = new HashMap(); try { @@ -285,6 +264,20 @@ public class UserService { return resp; } + //查询客户 + public HashMap queryCustomer(Integer cityId,Integer provinceId){ + HashMap resp = new HashMap(); + try { + resp.put("retvalue", userMapper.queryCustomer(cityId,provinceId)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询客户失败!"); + return resp; + } + return resp; + } //修改用户头像 public HashMap uploadUserAvatars(MultipartFile file,Integer userId){ diff --git a/src/main/java/com/yipin/liuwanr/vo/UserVO.java b/src/main/java/com/yipin/liuwanr/vo/UserVO.java new file mode 100644 index 0000000..6bf37bb --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/vo/UserVO.java @@ -0,0 +1,61 @@ +package com.yipin.liuwanr.vo; + +import com.yipin.liuwanr.entity.Staff; +import com.yipin.liuwanr.entity.Student; +import com.yipin.liuwanr.entity.UserM; + +import java.util.List; + +/** + * 用户信息实体 + * @author Ning + * + */ +public class UserVO { + //用户 + private UserM user; + //学生 + private Student student; + //员工 + private Staff staff; + private List userList; + private List studentList; + private List staffList; + + public UserM getUser() { + return user; + } + public void setUser(UserM user) { + this.user = user; + } + public Student getStudent() { + return student; + } + public void setStudent(Student student) { + this.student = student; + } + public Staff getStaff() { + return staff; + } + public void setStaff(Staff staff) { + this.staff = staff; + } + public List getUserList() { + return userList; + } + public void setUserList(List userList) { + this.userList = userList; + } + public List getStudentList() { + return studentList; + } + public void setStudentList(List studentList) { + this.studentList = studentList; + } + public List getStaffList() { + return staffList; + } + public void setStaffList(List staffList) { + this.staffList = staffList; + } +}