ExperimentalClassService单元测试

master
shijie 4 years ago
parent a5f90b7b18
commit 96be942be1
  1. 61
      src/main/java/com/yipin/liuwanr/controller/CustomerController.java
  2. 19
      src/main/java/com/yipin/liuwanr/entity/ExperimentalClass.java
  3. 2
      src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java
  4. 23
      src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java
  5. 5
      src/main/java/com/yipin/liuwanr/mapper/ServiceConfigMapper.java
  6. 27
      src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java
  7. 91
      src/main/java/com/yipin/liuwanr/service/OrderService.java
  8. 35
      src/main/java/com/yipin/liuwanr/service/ServiceConfigService.java
  9. 42
      src/test/java/com/yipin/liuwanr/ExperimentalClassServiceTest.java
  10. 217
      src/test/java/com/yipin/liuwanr/OrderServiceTest.java
  11. 83
      src/test/java/com/yipin/liuwanr/ServiceConfigServiceTest.java

@ -1,22 +1,15 @@
package com.yipin.liuwanr.controller;
import java.util.HashMap;
import com.yipin.liuwanr.entity.School;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yipin.liuwanr.entity.Customer;
import com.yipin.liuwanr.entity.Response;
import com.yipin.liuwanr.entity.School;
import com.yipin.liuwanr.entity.UserM;
import com.yipin.liuwanr.helper.RedisHelper;
import com.yipin.liuwanr.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
@RestController
@RequestMapping("/customer")
@ -51,22 +44,23 @@ public class CustomerController {
userm.setEmail(email);
userm.setName(name);
userm.setPassword("huoran123");
if (email==null||email==""){
if (email == null || email == "") {
resp.setStatus(300);
resp.setErrmessage("邮箱不能为空!");
}if (phone==null||phone==""){
}
if (phone == null || phone == "") {
resp.setStatus(300);
resp.setErrmessage("电话不能为空!");
}else if (name==null||name==""){
} else if (name == null || name == "") {
resp.setStatus(300);
resp.setErrmessage("姓名不能为空!");
}else if (schoolId==null){
} else if (schoolId == null) {
resp.setStatus(300);
resp.setErrmessage("学校不能为空!");
}else if (provinceId==null){
} else if (provinceId == null) {
resp.setStatus(300);
resp.setErrmessage("省份不能为空!");
}else if (cityId==null) {
} else if (cityId == null) {
resp.setStatus(300);
resp.setErrmessage("城市不能为空!");
} else {
@ -88,22 +82,22 @@ public class CustomerController {
* 查询客户
*/
@GetMapping("/queryCustomer")
Response queryCustomer(@RequestParam String countries,Integer provinceId,Integer cityId,Integer pageNo,Integer pageSize,String searchContent) {
Response queryCustomer(@RequestParam String countries, Integer provinceId, Integer cityId, Integer pageNo, Integer pageSize, String searchContent) {
Response resp = new Response();
Customer customer = new Customer();
if (searchContent!=null&&searchContent!="") {
if (searchContent != null && searchContent != "") {
customer.setSearchContent(searchContent);
}
if (countries!=null&&countries!="") {
if (countries != null && countries != "") {
customer.setCountries(countries);
}
if (provinceId!=null) {
if (provinceId != null) {
customer.setProvinceId(provinceId);
}
if (cityId!=null) {
if (cityId != null) {
customer.setCityId(cityId);
}
HashMap<String, Object> ret = customerService.queryCustomer(customer,pageNo,pageSize);
HashMap<String, Object> ret = customerService.queryCustomer(customer, pageNo, pageSize);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
@ -113,7 +107,7 @@ public class CustomerController {
resp.setErrmessage(ret.get("retvalue").toString());
}
return resp;
}
}
/**
* 查询客户详情
@ -121,10 +115,10 @@ public class CustomerController {
@GetMapping("/queryCustomerDetails")
Response queryCustomerDetails(@RequestParam Integer customerId) {
Response resp = new Response();
if (customerId==null) {
if (customerId == null) {
resp.setStatus(300);
resp.setErrmessage("Parameter Invalid");
}else {
} else {
HashMap<String, Object> ret = customerService.queryCustomerDetails(customerId);
int status = (int) ret.get("retcode");
if (200 == status) {
@ -136,7 +130,7 @@ public class CustomerController {
}
}
return resp;
}
}
/**
* 删除客户
@ -167,7 +161,7 @@ public class CustomerController {
@PostMapping("/updateCustomer")
Response updateCustomer(@RequestBody Customer customer) {
Response resp = new Response();
if (customer.getCustomerId()==null) {
if (customer.getCustomerId() == null) {
resp.setStatus(300);
resp.setErrmessage("客户不能为空!");
} else {
@ -190,10 +184,10 @@ public class CustomerController {
@GetMapping("/queryCustomerIsExists")
Response queryCustomerIsExists(@RequestParam Integer schoolId) {
Response resp = new Response();
if (schoolId==null) {
if (schoolId == null) {
resp.setStatus(300);
resp.setErrmessage("学校不能为空!");
}else {
} else {
HashMap<String, Object> ret = customerService.queryCustomerIsExists(schoolId);
int status = (int) ret.get("retcode");
if (200 == status) {
@ -205,7 +199,8 @@ public class CustomerController {
}
}
return resp;
}
}
/**
* 查询行业类
*/
@ -249,7 +244,7 @@ public class CustomerController {
Response querySchool(@RequestParam String schoolName) {
Response resp = new Response();
School school = new School();
if (schoolName!=null||schoolName!=""){
if (schoolName != null || schoolName != "") {
school.setSchoolName(schoolName);
}
HashMap<String, Object> ret = customerService.querySchool(school);

@ -6,7 +6,6 @@ import java.util.List;
* 实验班级信息
*
* @author 全承珠
*
*/
public class ExperimentalClass {
@ -130,4 +129,22 @@ public class ExperimentalClass {
public void setCourseId(Integer courseId) {
this.courseId = courseId;
}
@Override
public String toString() {
return "ExperimentalClass{" +
"experimentalClassId=" + experimentalClassId +
", experimentalClassName='" + experimentalClassName + '\'' +
", classSize=" + classSize +
", practiceNumber=" + practiceNumber +
", inspectionNumber=" + inspectionNumber +
", courseSchedule='" + courseSchedule + '\'' +
", creationTime='" + creationTime + '\'' +
", founder='" + founder + '\'' +
", courseId=" + courseId +
", schoolId=" + schoolId +
", userId=" + userId +
", students=" + students +
'}';
}
}

@ -13,7 +13,9 @@ import com.yipin.liuwanr.entity.ExperimentalClass;
import com.yipin.liuwanr.entity.Professional;
import com.yipin.liuwanr.entity.StuProfessionalArchitecture;
import com.yipin.liuwanr.entity.Student;
import org.apache.ibatis.annotations.*;
import java.util.List;
public interface ExperimentalClassMapper {
@Insert("INSERT INTO experimental_class_student(studentId,experimentalClassId)"

@ -1,7 +1,6 @@
package com.yipin.liuwanr.mapper;
import java.util.List;
import com.yipin.liuwanr.entity.*;
import org.apache.ibatis.annotations.*;
import com.yipin.liuwanr.entity.ApplicationPermissions;
@ -38,7 +37,7 @@ public interface OrderMapper {
+ " (#{c.courseId},#{c.usePeriod},#{c.marketPrice},#{c.transactionPrice},#{c.discount},#{c.portAddressId},#{c.isDeliverGoods},0,#{c.orderId})"
+ "</foreach>",
"</script> "})
void addCoursePermissionss(@Param("coursePermissionss")List<CoursePermissions> coursePermissionss);
void addCoursePermissionss(@Param("coursePermissionss") List<CoursePermissions> coursePermissionss);
@Insert("INSERT INTO hr_application_permissions(systemId,isdel,orderId"
+ ") VALUES(#{systemId},0,#{orderId})")
@ -61,10 +60,10 @@ public interface OrderMapper {
@Select(
"SELECT o.* from orders o where o.isdel = 0 and o.orderId = #{orderId} ")
@Results({
@Result(property = "orders", column = "orderId",one = @One(select = "com.yipin.liuwanr.mapper.OrderMapper.queryOrderDetailsO")),
@Result(property = "contractInformations", column = "orderId",one = @One(select = "com.yipin.liuwanr.mapper.OrderMapper.queryOrderDetailsCI")),
@Result(property = "coursePermissionss", column = "orderId",many = @Many(select = "com.yipin.liuwanr.mapper.OrderMapper.queryOrderDetailsCP"))
})
@Result(property = "orders", column = "orderId", one = @One(select = "com.yipin.liuwanr.mapper.OrderMapper.queryOrderDetailsO")),
@Result(property = "contractInformations", column = "orderId", one = @One(select = "com.yipin.liuwanr.mapper.OrderMapper.queryOrderDetailsCI")),
@Result(property = "coursePermissionss", column = "orderId", many = @Many(select = "com.yipin.liuwanr.mapper.OrderMapper.queryOrderDetailsCP"))
})
List<OrderVo> queryOrderDetails(Integer orderId);
@Select({"<script>",
@ -75,7 +74,7 @@ public interface OrderMapper {
@Select({"<script>",
"SELECT cp.*,c.courseName FROM hr_course_permissions cp,course c where cp.courseId = c.courseId and cp.orderId = #{orderId}",
"</script> "})
List<CoursePermissions>queryOrderDetailsCP(Integer orderId);
List<CoursePermissions> queryOrderDetailsCP(Integer orderId);
@Select({"<script>",
"SELECT ci.* from hr_contract_information ci where ci.orderId = #{orderId}",
@ -88,7 +87,7 @@ public interface OrderMapper {
+ " #{c}"
+ "</foreach>",
"</script> "})
void deleteOrder(@Param("orderId")List<Integer> orderId);
void deleteOrder(@Param("orderId") List<Integer> orderId);
@Update("UPDATE orders SET customerName = #{customerName},orderName = #{orderName},orderAmount = #{orderAmount},orderType = #{orderType},provinceId = #{provinceId},cityId = #{cityId},orderContact = #{orderContact},phone = #{phone},email = #{email},customerId = #{customerId} where orderId = #{orderId}")
void updateOrder(Order order);
@ -116,7 +115,7 @@ public interface OrderMapper {
" <if test='provinceId !=null'>and provinceId = #{provinceId} </if>",
" <if test='cityId !=null'>and cityId = #{cityId} </if>",
"</script> "})
List<Customer> queryOrderCustomer(Integer cityId,Integer provinceId);
List<Customer> queryOrderCustomer(Integer cityId, Integer provinceId);
@Select({"<script>",
"SELECT customerId,adminName,adminPhone,email FROM customer where isdel = 0 and customerId = #{customerId}",
@ -129,9 +128,9 @@ public interface OrderMapper {
" <if test='searchContent !=null and searchContent!=\"\" '> and c.courseName like CONCAT('%',#{searchContent},'%')</if>",
" <if test='courseId!=null'>"
+ "<foreach collection='courseId' item='id' open='and c.courseId not in (' separator=',' close=')'> #{id}"
+"</foreach>"
+ "</foreach>"
+ "</if>",
"</script> "})
List<Course> queryCourseList(String searchContent,@Param("courseId")List<Integer> courseId);
List<Course> queryCourseList(String searchContent, @Param("courseId") List<Integer> courseId);
}

@ -1,12 +1,11 @@
package com.yipin.liuwanr.mapper;
import java.util.List;
import com.yipin.liuwanr.entity.ServiceConfig;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.yipin.liuwanr.entity.ServiceConfig;
import java.util.List;
public interface ServiceConfigMapper {

@ -1,23 +1,16 @@
package com.yipin.liuwanr.service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.mapper.ExperimentalClassMapper;
import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yipin.liuwanr.entity.ExperimentalClass;
import com.yipin.liuwanr.entity.Professional;
import com.yipin.liuwanr.entity.Project_Management;
import com.yipin.liuwanr.entity.StuProfessionalArchitecture;
import com.yipin.liuwanr.entity.Student;
import com.yipin.liuwanr.mapper.ExperimentalClassMapper;
import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper;
import com.yipin.liuwanr.vo.ExperimentalClassVo;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
@Service
public class ExperimentalClassService {
@ -86,7 +79,7 @@ public class ExperimentalClassService {
Integer experimentalClassId = experimentalClass.getExperimentalClassId();
Integer courseId = experimentalClass.getCourseId();
List<Integer> projectIds = projectAndCourseMapper.queryProject(courseId);
projectAndCourseMapper.addBatchTeachProject(experimentalClassId,courseId,projectIds);
projectAndCourseMapper.addBatchTeachProject(experimentalClassId, courseId, projectIds);
resp.put("retcode", 200);
} catch (RuntimeException e) {
@ -98,11 +91,11 @@ public class ExperimentalClassService {
return resp;
}
public HashMap<String, Object> queryExperimentalClass(Integer schoolId,Integer courseId) {
public HashMap<String, Object> queryExperimentalClass(Integer schoolId, Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(!StringUtils.isEmpty(courseId)){
resp.put("retvalue", experimentalClassMapper.queryExperimentalClass(schoolId,courseId));
if (!StringUtils.isEmpty(courseId)) {
resp.put("retvalue", experimentalClassMapper.queryExperimentalClass(schoolId, courseId));
resp.put("retcode", 200);
}
} catch (RuntimeException e) {

@ -1,25 +1,19 @@
package com.yipin.liuwanr.service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.mapper.OrderMapper;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yipin.liuwanr.entity.ApplicationPermissions;
import com.yipin.liuwanr.entity.ContractInformation;
import com.yipin.liuwanr.entity.Course;
import com.yipin.liuwanr.entity.CoursePermissions;
import com.yipin.liuwanr.entity.Order;
import com.yipin.liuwanr.entity.PageResult;
import com.yipin.liuwanr.mapper.OrderMapper;
@Service
public class OrderService {
@ -29,7 +23,7 @@ public class OrderService {
private OrderMapper orderMapper;
//添加合同信息
public HashMap<String, Object> addOrder(Order order){
public HashMap<String, Object> addOrder(Order order) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
long timeStamp = new Date().getTime();//获取时间戳
@ -47,7 +41,8 @@ public class OrderService {
}
return resp;
}
public HashMap<String, Object> addContractInformation(ContractInformation contractInformation){
public HashMap<String, Object> addContractInformation(ContractInformation contractInformation) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
orderMapper.addContractInformation(contractInformation);
@ -62,14 +57,14 @@ public class OrderService {
}
//添加课程权限
public HashMap<String, Object> addCoursePermissionss(List<CoursePermissions> coursePermissionss) throws ParseException{
public HashMap<String, Object> addCoursePermissionss(List<CoursePermissions> coursePermissionss) throws ParseException {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
Integer size = coursePermissionss.size();
for (int i = 0; i < size; i++) {
CoursePermissions coursePermissionssList = coursePermissionss.get(i);
Integer usePeriod = coursePermissionssList.getUsePeriod();
Integer usePeriod1 = usePeriod*1000*(60*60*24);
Integer usePeriod1 = usePeriod * 1000 * (60 * 60 * 24);
long DQSJC = System.currentTimeMillis();
long expireSJC = usePeriod1 + DQSJC;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -90,7 +85,7 @@ public class OrderService {
}
//绑定应用权限
public HashMap<String, Object> bindingApplicationPermissions(ApplicationPermissions applicationPermissions){
public HashMap<String, Object> bindingApplicationPermissions(ApplicationPermissions applicationPermissions) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
orderMapper.bindingApplicationPermissions(applicationPermissions);
@ -104,7 +99,7 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> queryCoursePermissions(String courseId){
public HashMap<String, Object> queryCoursePermissions(String courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
List<Course> list = orderMapper.queryCoursePermissions(courseId);
@ -119,24 +114,23 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> queryOrder(Order order,Integer pageNo,Integer pageSize){
public HashMap<String, Object> queryOrder(Order order, Integer pageNo, Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(pageNo!=null&&pageSize!=null) {
if (pageNo != null && pageSize != null) {
PageHelper.startPage(pageNo, pageSize);
List<Order> list = orderMapper.queryOrder(order);
PageInfo<Order> info=new PageInfo<Order>(list);
PageInfo<Order> info = new PageInfo<Order>(list);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / pageSize;
if (total1 % pageSize != 0){
totalPages ++;
if (total1 % pageSize != 0) {
totalPages++;
}
long total = total1;
resp.put("retvalue", new PageResult(total, list,totalPages));
resp.put("retvalue", new PageResult(total, list, totalPages));
resp.put("retcode", 200);
}else {
} else {
List<Order> list = orderMapper.queryOrder(order);
resp.put("retvalue", list);
resp.put("retcode", 200);
@ -150,7 +144,7 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> queryOrderDetails(Integer orderId){
public HashMap<String, Object> queryOrderDetails(Integer orderId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
resp.put("retvalue", orderMapper.queryOrderDetails(orderId));
@ -164,7 +158,7 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> deleteOrder(List<Integer> orderId){
public HashMap<String, Object> deleteOrder(List<Integer> orderId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
orderMapper.deleteOrder(orderId);
@ -178,7 +172,7 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> updateOrder(Order order){
public HashMap<String, Object> updateOrder(Order order) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
orderMapper.updateOrder(order);
@ -192,7 +186,7 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> deleteCoursePermissions(Integer orderId){
public HashMap<String, Object> deleteCoursePermissions(Integer orderId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
orderMapper.deleteCoursePermissions(orderId);
@ -206,12 +200,12 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> updateCoursePermissions(List<CoursePermissions> coursePermissionss){
public HashMap<String, Object> updateCoursePermissions(List<CoursePermissions> coursePermissionss) {
HashMap<String, Object> resp = new HashMap<String, Object>();
int size = coursePermissionss.size();
if (coursePermissionss.isEmpty()) {
resp.put("retcode", 200);
}else {
} else {
try {
for (int i = 0; i < size; i++) {
CoursePermissions coursePermissions = coursePermissionss.get(i);
@ -228,7 +222,7 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> updateContractInformation(ContractInformation contractInformation){
public HashMap<String, Object> updateContractInformation(ContractInformation contractInformation) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
orderMapper.updateContractInformation(contractInformation);
@ -243,7 +237,7 @@ public class OrderService {
}
//绑定应用权限
public HashMap<String, Object> isDeliverGoods(CoursePermissions coursePermissions){
public HashMap<String, Object> isDeliverGoods(CoursePermissions coursePermissions) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
orderMapper.isDeliverGoods(coursePermissions);
@ -257,10 +251,10 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> queryOrderCustomer(Integer cityId,Integer provinceId){
public HashMap<String, Object> queryOrderCustomer(Integer cityId, Integer provinceId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
resp.put("retvalue", orderMapper.queryOrderCustomer(cityId,provinceId));
resp.put("retvalue", orderMapper.queryOrderCustomer(cityId, provinceId));
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());
@ -271,8 +265,7 @@ public class OrderService {
return resp;
}
public HashMap<String, Object> queryOrderCustomerContact(Integer customerId){
public HashMap<String, Object> queryOrderCustomerContact(Integer customerId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
resp.put("retvalue", orderMapper.queryOrderCustomerContact(customerId));
@ -287,24 +280,24 @@ public class OrderService {
}
//查询订单课程列表
public HashMap<String, Object> queryCourseList(String searchContent,List<Integer> courseId,Integer pageNo,Integer pageSize){
public HashMap<String, Object> queryCourseList(String searchContent, List<Integer> courseId, Integer pageNo, Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(pageNo!=null&&pageSize!=null) {
if (pageNo != null && pageSize != null) {
PageHelper.startPage(pageNo, pageSize);
List<Course> list = orderMapper.queryCourseList(searchContent,courseId);
PageInfo<Course> info=new PageInfo<Course>(list);
List<Course> list = orderMapper.queryCourseList(searchContent, courseId);
PageInfo<Course> info = new PageInfo<Course>(list);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / pageSize;
if (total1 % pageSize != 0){
totalPages ++;
if (total1 % pageSize != 0) {
totalPages++;
}
long total = total1;
resp.put("retvalue", new PageResult(total, list,totalPages));
resp.put("retvalue", new PageResult(total, list, totalPages));
resp.put("retcode", 200);
}else {
List<Course> list = orderMapper.queryCourseList(searchContent,courseId);
} else {
List<Course> list = orderMapper.queryCourseList(searchContent, courseId);
resp.put("retvalue", list);
resp.put("retcode", 200);
}

@ -1,17 +1,16 @@
package com.yipin.liuwanr.service;
import java.util.HashMap;
import java.util.List;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yipin.liuwanr.entity.PageResult;
import com.yipin.liuwanr.entity.ServiceConfig;
import com.yipin.liuwanr.mapper.ServiceConfigMapper;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
@Service
public class ServiceConfigService {
@ -21,7 +20,7 @@ public class ServiceConfigService {
@Autowired
private ServiceConfigMapper serviceConfigMapper;
public HashMap<String, Object> addServiceConfig(ServiceConfig serviceConfig){
public HashMap<String, Object> addServiceConfig(ServiceConfig serviceConfig) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
serviceConfigMapper.addServiceConfig(serviceConfig);
@ -35,23 +34,23 @@ public class ServiceConfigService {
return resp;
}
public HashMap<String, Object> queryServiceConfig(ServiceConfig serviceConfig,Integer pageNo,Integer pageSize){
public HashMap<String, Object> queryServiceConfig(ServiceConfig serviceConfig, Integer pageNo, Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(pageNo!=null&&pageSize!=null) {
if (pageNo != null && pageSize != null) {
PageHelper.startPage(pageNo, pageSize);
List<ServiceConfig> list = serviceConfigMapper.queryServiceConfig(serviceConfig);
PageInfo<ServiceConfig> info=new PageInfo<ServiceConfig>(list);
PageInfo<ServiceConfig> info = new PageInfo<ServiceConfig>(list);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / pageSize;
if (total1 % pageSize != 0){
totalPages ++;
if (total1 % pageSize != 0) {
totalPages++;
}
long total = total1;
resp.put("retvalue", new PageResult(total, list,totalPages));
resp.put("retvalue", new PageResult(total, list, totalPages));
resp.put("retcode", 200);
}else {
} else {
List<ServiceConfig> list = serviceConfigMapper.queryServiceConfig(serviceConfig);
resp.put("retvalue", list);
resp.put("retcode", 200);
@ -65,7 +64,7 @@ public class ServiceConfigService {
return resp;
}
public HashMap<String, Object> queryServiceConfigDetails(Integer systemId){
public HashMap<String, Object> queryServiceConfigDetails(Integer systemId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
resp.put("retvalue", serviceConfigMapper.queryServiceConfigDetails(systemId));
@ -79,7 +78,7 @@ public class ServiceConfigService {
return resp;
}
public HashMap<String, Object> deleteServiceConfig(ServiceConfig serviceConfig){
public HashMap<String, Object> deleteServiceConfig(ServiceConfig serviceConfig) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
serviceConfigMapper.deleteServiceConfig(serviceConfig);
@ -93,7 +92,7 @@ public class ServiceConfigService {
return resp;
}
public HashMap<String, Object> updateServiceConfig(ServiceConfig serviceConfig){
public HashMap<String, Object> updateServiceConfig(ServiceConfig serviceConfig) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
serviceConfigMapper.updateServiceConfig(serviceConfig);

@ -52,19 +52,19 @@ public class ExperimentalClassServiceTest {
public void addExperimentalClass() {
ExperimentalClass experimentalClass = new ExperimentalClass();
experimentalClass.setExperimentalClassName("测试");
experimentalClass.setClassSize(12);
experimentalClass.setClassSize(120);
experimentalClass.setFounder("测试");
experimentalClass.setCourseId(2);
experimentalClass.setUserId(2);
experimentalClass.setSchoolId(2);
experimentalClass.setCourseId(77);
experimentalClass.setUserId(452);
experimentalClass.setSchoolId(2043);
HashMap<String, Object> map = experimentalClassService.addExperimentalClass(experimentalClass);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
public void queryExperimentalClass() {
Integer schoolId = 1;
Integer courseId = 2;
Integer schoolId = 2043;
Integer courseId = 77;
HashMap<String, Object> map = experimentalClassService.queryExperimentalClass(schoolId, courseId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -72,7 +72,7 @@ public class ExperimentalClassServiceTest {
//查询实验班级专业
@Test
public void queryExperimentalClassSP() {
Integer experimentalClassId = 1;
Integer experimentalClassId = 56;
HashMap<String, Object> map = experimentalClassService.queryExperimentalClassSP(experimentalClassId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -80,7 +80,7 @@ public class ExperimentalClassServiceTest {
//查询学生行政班级
@Test
public void queryStudentClass() {
Integer experimentalClassId = 1;
Integer experimentalClassId = 56;
HashMap<String, Object> map = experimentalClassService.queryStudentClass(experimentalClassId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -91,7 +91,7 @@ public class ExperimentalClassServiceTest {
@Test
public void queryExperimentalClassDetails() {
Student student = new Student();
Integer courseId = 1;
Integer courseId = 56;
HashMap<String, Object> map = experimentalClassService.queryExperimentalClassDetails(student, courseId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -99,7 +99,7 @@ public class ExperimentalClassServiceTest {
//新增学生显示数据
@Test
public void queryexperimentalClass() {
Integer experimentalClassId = 1;
Integer experimentalClassId = 56;
HashMap<String, Object> map = experimentalClassService.queryexperimentalClass(experimentalClassId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -107,7 +107,7 @@ public class ExperimentalClassServiceTest {
//专业下拉框
@Test
public void getProfessionals() {
Integer experimentalClassId = 1;
Integer experimentalClassId = 56;
HashMap<String, Object> map = experimentalClassService.getProfessionals(experimentalClassId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -115,7 +115,7 @@ public class ExperimentalClassServiceTest {
//班级下拉框
@Test
public void getStudentClass() {
Integer experimentalClassId = 1;
Integer experimentalClassId = 56;
HashMap<String, Object> map = experimentalClassService.getStudentClass(experimentalClassId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -123,7 +123,7 @@ public class ExperimentalClassServiceTest {
@Test
@Transactional
public void deleteExperimentalClass() {
Integer experimentalClassId = 1;
Integer experimentalClassId = 56;
HashMap<String, Object> map = experimentalClassService.deleteExperimentalClass(experimentalClassId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -132,6 +132,13 @@ public class ExperimentalClassServiceTest {
@Transactional
public void updateExperimentalClass() {
ExperimentalClass experimentalClass = new ExperimentalClass();
experimentalClass.setExperimentalClassName("测试");
experimentalClass.setClassSize(120);
experimentalClass.setFounder("测试");
experimentalClass.setCourseId(77);
experimentalClass.setUserId(452);
experimentalClass.setSchoolId(2043);
experimentalClass.setExperimentalClassId(56);
HashMap<String, Object> map = experimentalClassService.updateExperimentalClass(experimentalClass);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -141,6 +148,13 @@ public class ExperimentalClassServiceTest {
@Transactional
public void updateExperimentClassName() {
ExperimentalClass experimentalClass = new ExperimentalClass();
experimentalClass.setExperimentalClassName("测试");
experimentalClass.setClassSize(120);
experimentalClass.setFounder("测试");
experimentalClass.setCourseId(77);
experimentalClass.setUserId(452);
experimentalClass.setSchoolId(2043);
experimentalClass.setExperimentalClassId(56);
HashMap<String, Object> map = experimentalClassService.updateExperimentalClass(experimentalClass);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@ -148,7 +162,7 @@ public class ExperimentalClassServiceTest {
//——————————————————————————————全承珠
@Test
public void queryGetByExperimentalClassName() {
String experimentalClassName = "";
String experimentalClassName = "测试";
HashMap<String, Object> map = experimentalClassService.queryGetByExperimentalClassName(experimentalClassName);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}

@ -0,0 +1,217 @@
package com.yipin.liuwanr;
import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.service.OrderService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class OrderServiceTest {
@Autowired
private OrderService orderService;
//添加合同信息
@Test
@Transactional
public void addOrder() {
Order order = new Order();
order.setOrderNumber("1596424017647");
order.setCustomerName("测试");
order.setOrderName("测试");
order.setOrderAmount("120");
order.setOrderType(1);
order.setProvinceId(1);
order.setCityId(1);
order.setOrderContact("张三");
order.setPhone("15267668899");
order.setEmail("123@qq.com");
order.setCustomerId(126);
HashMap<String, Object> map = orderService.addOrder(order);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void addContractInformation() {
ContractInformation contractInformation = new ContractInformation();
contractInformation.setContractInformationName("1");
contractInformation.setContractInformationNumber("1");
contractInformation.setContractInformationSum("1");
contractInformation.setContractInformationLink("1");
contractInformation.setOrderId(20);
HashMap<String, Object> map = orderService.addContractInformation(contractInformation);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
//添加课程权限
@Test
@Transactional
public void addCoursePermissionss() throws ParseException {
List<CoursePermissions> coursePermissionss = new ArrayList<>();
CoursePermissions coursePermissions = new CoursePermissions();
coursePermissions.setCourseId(77);
coursePermissions.setUsePeriod(30);
coursePermissions.setMarketPrice(12.8);
coursePermissions.setTransactionPrice(1);
coursePermissions.setDiscount(7);
coursePermissions.setPortAddressId(1);
coursePermissions.setIsDeliverGoods(1);
coursePermissions.setOrderId(118);
coursePermissionss.add(coursePermissions);
HashMap<String, Object> map = orderService.addCoursePermissionss(coursePermissionss);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
//绑定应用权限
@Test
@Transactional
public void bindingApplicationPermissions() {
ApplicationPermissions applicationPermissions = new ApplicationPermissions();
applicationPermissions.setSystemId("2");
applicationPermissions.setOrderId(2);
HashMap<String, Object> map = orderService.bindingApplicationPermissions(applicationPermissions);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void queryCoursePermissions() {
String courseId = "1";
HashMap<String, Object> map = orderService.queryCoursePermissions(courseId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void queryOrder() {
Order order = new Order();
Integer pageNo = 1;
Integer pageSize = 10;
HashMap<String, Object> map = orderService.queryOrder(order, pageNo, pageSize);
Integer retcode = (Integer) map.get("retcode");
System.out.println(retcode);
if (retcode == 200) {
PageResult pageResult = (PageResult) map.get("retvalue");
Long total = pageResult.getTotal();
System.out.println("total = " + total);
List<Order> rows = (List<Order>) pageResult.getRows();
rows.forEach(item -> System.out.println(item.toString()));
} else {
String msg = (String) map.get("retvalue");
System.out.println(msg);
}
}
@Test
@Transactional
public void queryOrderDetails() {
Integer orderId = 1;
HashMap<String, Object> map = orderService.queryOrderDetails(orderId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void deleteOrder() {
List<Integer> orderId = new ArrayList<>();
orderId.add(1);
orderId.add(2);
orderId.add(3);
HashMap<String, Object> map = orderService.deleteOrder(orderId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void updateOrder() {
Order order = new Order();
HashMap<String, Object> map = orderService.updateOrder(order);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void deleteCoursePermissions() {
Integer orderId = 1;
HashMap<String, Object> map = orderService.deleteCoursePermissions(orderId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void updateCoursePermissions() {
List<CoursePermissions> coursePermissionss = new ArrayList<>();
CoursePermissions coursePermissions = new CoursePermissions();
coursePermissionss.add(coursePermissions);
HashMap<String, Object> map = orderService.updateCoursePermissions(coursePermissionss);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void updateContractInformation() {
ContractInformation contractInformation = new ContractInformation();
HashMap<String, Object> map = orderService.updateContractInformation(contractInformation);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
//绑定应用权限
@Test
@Transactional
public void isDeliverGoods() {
CoursePermissions coursePermissions = new CoursePermissions();
HashMap<String, Object> map = orderService.isDeliverGoods(coursePermissions);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void queryOrderCustomer() {
Integer cityId = 1;
Integer provinceId = 1;
HashMap<String, Object> map = orderService.queryOrderCustomer(cityId, provinceId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void queryOrderCustomerContact() {
Integer customerId = 1;
HashMap<String, Object> map = orderService.queryOrderCustomerContact(customerId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
//查询订单课程列表
@Test
@Transactional
public void queryCourseList() {
String searchContent = "";
List<Integer> courseId = new ArrayList<>();
Integer pageNo = 1;
Integer pageSize = 10;
HashMap<String, Object> map = orderService.queryCourseList(searchContent, courseId, pageNo, pageSize);
Integer retcode = (Integer) map.get("retcode");
System.out.println(retcode);
if (retcode == 200) {
PageResult pageResult = (PageResult) map.get("retvalue");
Long total = pageResult.getTotal();
System.out.println("total = " + total);
List<Course> rows = (List<Course>) pageResult.getRows();
rows.forEach(item -> System.out.println(item.toString()));
} else {
String msg = (String) map.get("retvalue");
System.out.println(msg);
}
}
}

@ -0,0 +1,83 @@
package com.yipin.liuwanr;
import com.yipin.liuwanr.entity.PageResult;
import com.yipin.liuwanr.entity.ServiceConfig;
import com.yipin.liuwanr.service.ServiceConfigService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ServiceConfigServiceTest {
@Autowired
private ServiceConfigService serviceConfigService;
@Test
@Transactional
public void addServiceConfig() {
ServiceConfig serviceConfig = new ServiceConfig();
serviceConfig.setSystemName("测试");
serviceConfig.setSystemType(2);
serviceConfig.setSystemAttribution(2);
serviceConfig.setSystemStatus(1);
HashMap<String, Object> map = serviceConfigService.addServiceConfig(serviceConfig);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
public void queryServiceConfig() {
ServiceConfig serviceConfig = new ServiceConfig();
Integer pageNo = 1;
Integer pageSize = 10;
HashMap<String, Object> map = serviceConfigService.queryServiceConfig(serviceConfig, pageNo, pageSize);
Integer retcode = (Integer) map.get("retcode");
System.out.println(retcode);
if (retcode == 200) {
PageResult pageResult = (PageResult) map.get("retvalue");
Long total = pageResult.getTotal();
System.out.println("total = " + total);
List<ServiceConfig> rows = (List<ServiceConfig>) pageResult.getRows();
rows.forEach(item -> System.out.println(item.toString()));
} else {
String msg = (String) map.get("retvalue");
System.out.println(msg);
}
}
@Test
public void queryServiceConfigDetails() {
Integer systemId = 1;
HashMap<String, Object> map = serviceConfigService.queryServiceConfigDetails(systemId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void deleteServiceConfig() {
ServiceConfig serviceConfig = new ServiceConfig();
serviceConfig.setSystemId(1);
HashMap<String, Object> map = serviceConfigService.deleteServiceConfig(serviceConfig);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
@Test
@Transactional
public void updateServiceConfig() {
ServiceConfig serviceConfig = new ServiceConfig();
serviceConfig.setSystemName("测试");
serviceConfig.setSystemType(2);
serviceConfig.setSystemAttribution(2);
serviceConfig.setSystemStatus(1);
serviceConfig.setSystemId(1);
HashMap<String, Object> map = serviceConfigService.updateServiceConfig(serviceConfig);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
}
Loading…
Cancel
Save