功能调整

sale
tianea 3 years ago
parent 21430485c1
commit f6c867a0c0

@ -43,13 +43,20 @@ public class ZhiYunApi {
}
public String findCourceBySchool(Integer schoolId){
String content = HttpUtil.get(baseUrl+"/api/course/findAllBySchoolId?schoolId="+schoolId,headers);
return content;
}
public String findAllQuestion(){
String content = HttpUtil.get(baseUrl+"/api/question/findAll",headers);
/**
*
* @param pageIndex 1
* @param pageSize 10
* @return
*/
public String findAllQuestion(int pageIndex,int pageSize){
String content = HttpUtil.get(baseUrl+"/api/question/findAll?pageSize="+pageSize+"&pageIndex="+pageIndex,headers);
return content;
}

@ -0,0 +1,17 @@
package com.tz.platform.feign.exam;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.feign.exam.vo.CourseVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@FeignClient(value = "tz-exam-service")
public interface IFeignCourse {
@PostMapping(value = "/feign/exam/course/addAll")
Result<String> addAll(@RequestBody List<CourseVO> qo);
@PostMapping(value = "/feign/exam/course/getByOuterId")
CourseVO getByOuterId(@RequestBody Integer outerId);
}

@ -16,4 +16,6 @@ public interface IFeignExam {
@PostMapping(value = "/feign/exam/question/list")
List<QuestionVo> listQusetion(@RequestBody CacheQuestionQO qo);
}

@ -0,0 +1,21 @@
package com.tz.platform.feign.exam.vo;
import lombok.Data;
import java.util.Date;
@Data
public class CourseVO {
private Long id;
private Long userNo;
private String name;
private String creator;
private Long createId;
private Date createTime;
private Integer learningCount;
private String thumbnail;
private String content;
private Integer tagId;
private Integer catId;
private Integer schoolId;
private Integer outerId;
}

@ -26,4 +26,5 @@ public class QuestionVo {
private String analysis;
private List<Integer> answerId;
private List<SubQuestionVO> children;
private Integer outerId;
}

@ -8,7 +8,7 @@ import java.util.Date;
@Entity
@Data
@Table(name = "course_sale",indexes = {@Index(columnList = "name")})
@Table(name = "course_sale",indexes = {@Index(columnList = "name"),@Index(columnList = "outerId")})
public class Course implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@ -23,4 +23,6 @@ public class Course implements Serializable {
private String content;
private Integer tagId;
private Integer catId;
private Integer schoolId;
private Integer outerId;
}

@ -0,0 +1,19 @@
package com.tz.platform.entity;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
@Data
@Entity
@Table(indexes = {@Index(columnList = "schoolId")})
public class CourseSchoolMap {
@Id
private String id;
private Integer courseId;
private Integer schoolId;
}

@ -0,0 +1,18 @@
package com.tz.platform.entity;
import lombok.Data;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;
@Data
@Entity
@Table(indexes = {@Index(columnList = "schoolId")})
public class QuestionSchoolMap {
@Id
private String id;
private Integer schoolId;
private Integer questionId;
}

@ -0,0 +1,29 @@
package com.tz.platform.exam.feign;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.tools.BeanUtils;
import com.tz.platform.feign.exam.IFeignCourse;
import com.tz.platform.feign.exam.vo.CourseVO;
import com.tz.platform.pc.biz.PCCourseBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class FeignCourseController implements IFeignCourse {
@Autowired
private PCCourseBiz courseBiz;
@Override
public Result<String> addAll(List<CourseVO> qo) {
List<com.tz.platform.pc.vo.CourseVO> voList = BeanUtils.copyProperties(qo,com.tz.platform.pc.vo.CourseVO.class);
return courseBiz.addForJob(voList);
}
@Override
public CourseVO getByOuterId(Integer outerId) {
return courseBiz.getByOuterId(outerId);
}
}

@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class FeignExamController extends BaseController implements IFeignExam {
public class FeignExamController implements IFeignExam {
@Autowired
private FeignExamBiz feignExamBiz;
@ -26,4 +26,5 @@ public class FeignExamController extends BaseController implements IFeignExam {
return feignExamBiz.list(qo.getIds());
}
}

@ -1,6 +1,7 @@
package com.tz.platform.pc.biz;
import com.tz.platform.common.core.base.Result;
import com.tz.platform.common.core.tools.BeanUtils;
import com.tz.platform.entity.Course;
import com.tz.platform.feign.user.IFeignUser;
import com.tz.platform.feign.user.vo.UserVo;
@ -9,7 +10,6 @@ import com.tz.platform.pc.dto.PageCourseDTO;
import com.tz.platform.pc.vo.CourseVO;
import com.tz.platform.pc.vo.PageCourseVO;
import com.tz.platform.repository.CourseDao;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
@Component
public class PCCourseBiz {
@ -33,15 +34,31 @@ public class PCCourseBiz {
return v;
}
UserVo userVo = feignUser.getByUserNo(courseVO.getUserNo());
Course course = new Course();
BeanUtils.copyProperties(courseVO,course);
Course course = BeanUtils.copyProperties(courseVO,Course.class);
course.setCreateId(userVo.getId());
course.setCreator(userVo.getName());
course.setCreateTime(new Date());
course.setSchoolId(userVo.getSchoolId());
courseDao.save(course);
return Result.success("成功");
}
public com.tz.platform.feign.exam.vo.CourseVO getByOuterId(Integer outerId){
Course course = courseDao.getByOuterId(outerId);
return BeanUtils.copyProperties(course,com.tz.platform.feign.exam.vo.CourseVO.class);
}
public Result<String> addForJob(List<CourseVO> courseVOList){
List<Course> courseList = BeanUtils.copyProperties(courseVOList,Course.class);
courseList.forEach(course -> {
course.setCreateId(1L);
course.setCreator("管理员");
course.setCreateTime(new Date());
});
courseDao.saveAll(courseList);
return Result.success("成功");
}
private Result<String> valid(CourseVO courseVO){
if(StringUtils.isEmpty(courseVO.getName())){
return Result.error("课程名不能为空");
@ -60,8 +77,8 @@ public class PCCourseBiz {
if(v.getCode()!=200){
return v;
}
Course course = new Course();
BeanUtils.copyProperties(courseVO,course);
Course course = BeanUtils.copyProperties(courseVO,Course.class);
courseDao.save(course);
return Result.success("success");
}
@ -87,8 +104,7 @@ public class PCCourseBiz {
public Result<CourseDTO> get(Long id){
Course course = courseDao.getById(id);
CourseDTO courseDTO = new CourseDTO();
BeanUtils.copyProperties(course,courseDTO);
CourseDTO courseDTO = BeanUtils.copyProperties(course,CourseDTO.class);
return Result.success(courseDTO);
}
}

@ -17,4 +17,5 @@ public class CourseDTO implements Serializable {
private String content;
private Integer tagId;
private Integer catId;
private Integer schoolId;
}

@ -16,4 +16,6 @@ public class CourseVO {
private String content;
private Integer tagId;
private Integer catId;
private Integer schoolId;
private Integer outerId;
}

@ -11,4 +11,5 @@ import org.springframework.stereotype.Repository;
public interface CourseDao extends JpaRepository<Course,Long> {
Page<Course> findAll(Pageable pageable);
Course getById(Long id);
Course getByOuterId(Integer outerId);
}

@ -34,6 +34,10 @@
<groupId>com.tz</groupId>
<artifactId>user-feign</artifactId>
</dependency>
<dependency>
<groupId>com.tz</groupId>
<artifactId>exam-feign</artifactId>
</dependency>
<dependency>
<groupId>com.monitorjbl</groupId>
<artifactId>xlsx-streamer</artifactId>

Loading…
Cancel
Save