This commit is contained in:
wanghu
2026-02-28 19:31:18 +08:00
commit 9e06e21b9d
173 changed files with 17839 additions and 0 deletions
@@ -0,0 +1,21 @@
package com.bestsch.classicalchinese;
import com.bestsch.bschapistd.config.EnableBschApiStd;
import com.bestsch.bschsso.EnableBschSso;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableTransactionManagement
@EnableAsync
@EnableBschSso //用户中心接口
@EnableBschApiStd
public class ClassicalchineseApplication {
public static void main(String[] args) {
SpringApplication.run(ClassicalchineseApplication.class, args);
}
}
@@ -0,0 +1,44 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.BschKnowledge;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
/**
* @ Description : java类作用描述
* @ Author : cls
* @ CreateDate : 2020/2/21 10:21
* @ Company : bestsch
*/
@Repository
public interface BschKnowledgeRepository extends JpaRepository<BschKnowledge,Integer> {
@Query("from BschKnowledge where id = :id")
BschKnowledge getById(int id);
List<BschKnowledge> getAllByParentIdOrderByOrderCodeAsc(int parentId);
List<BschKnowledge> getAllByPathLikeOrderByOrderCodeAsc(String path);
/**
* 获取同层级 某个排序区间内的知识节点
* @param parentId
* @param begin
* @param end
* @return
*/
@Query("from BschKnowledge k where k.parentId = :parentId and k.orderCode >= :begin and k.orderCode <= :end order by k.orderCode asc")
List<BschKnowledge> getSection(Integer parentId, int begin, int end);
@Query("from BschKnowledge where path like :pathKey order by orderCode asc")
List<BschKnowledge> getChildByPath(String pathKey);
@Query("from BschKnowledge k where k.parentId = :parentId order by k.orderCode asc")
List<BschKnowledge> getSectionList(Integer parentId);
List<BschKnowledge> getAllByIdInOrderByLevelAsc(List<Integer> ids);
}
@@ -0,0 +1,13 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.BschLeadlearning;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface BschLeadlearningRepository extends JpaRepository<BschLeadlearning, Integer>, JpaSpecificationExecutor<BschLeadlearning> {
}
@@ -0,0 +1,11 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.BschQuestion;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface BschQuestionRepository extends JpaRepository<BschQuestion, Integer>, JpaSpecificationExecutor<BschQuestion> {
}
@@ -0,0 +1,45 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.BschTextbook;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @ Description : java类作用描述
* @ Author : cls
* @ CreateDate : 2020/2/21 10:22
* @ Company : bestsch
*/
@Repository
public interface BschTextbookRepository extends JpaRepository<BschTextbook,Integer> {
/**
* 统计当前查询条件下总数据量
* @param specification
* @return
*/
Long count(Specification<BschTextbook> specification);
/**
* 条件查询,支持分页
* @param specification
* @param pageable
* @return
*/
Page<BschTextbook> findAll(Specification<BschTextbook> specification, Pageable pageable);
/**
* 条件查询,不支持分页
* @param specification
* @return
*/
List<BschTextbook> findAll(Specification<BschTextbook> specification);
BschTextbook getById(int id);
BschTextbook getFirstByTreeId(int treeId);
}
@@ -0,0 +1,44 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.BschVideoExplanation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import javax.transaction.Transactional;
public interface BschVideoExplanationRepository extends JpaRepository<BschVideoExplanation, Integer>, JpaSpecificationExecutor<BschVideoExplanation> {
// @Query(value = "select * from bsch_video_explanation where textbook_id=:textbook_id and node_id=:nodeId ;", nativeQuery = true)
// List<BschVideoExplanation> getAllBySchIdAndNodeId(Integer textbookId, Integer nodeId);
@Query(value = "SELECT * from bsch_video_explanation where textbook_id=?1 and (node_id=?2 or path like CONCAT('%,',?2,',%')) ",
countQuery = "select count(id) from bsch_video_explanation where textbook_id=?1 and (node_id=?2 or path like CONCAT('%,',?2,',%')) ", nativeQuery = true)
Page<BschVideoExplanation> findPageBySchIdAndNodeId(Integer textbookId, Integer nodeId, Pageable pageable);
@Query(value = "SELECT * from bsch_video_explanation where textbook_id=?1 and subject_id=?2 and if(?3 is null,1=1, node_id=?3 or path like CONCAT('%,',?3,',%')) and if(?4 is null,1=1,name like CONCAT('%',?4,'%')) ",
countQuery = "select count(id) from bsch_video_explanation where textbook_id=?1 and subject_id=?2 and if(?3 is null,1=1, node_id=?3 or path like CONCAT('%,',?3,',%')) and if(?4 is null,1=1,name like CONCAT('%',?4,'%')) ", nativeQuery = true)
Page<BschVideoExplanation> findPageBySchIdAndSubjectIdAndNodeIdAndName(Integer textbookId, String subjectId, Integer nodeId, String keyword, Pageable pageable);
@Query(value = "select id from bsch_video_explanation where id=?1 and create_user=?2 ;", nativeQuery = true)
Integer getIdByIdAndUserId(Integer id, Integer userId);
@Query(value = "select * from bsch_video_explanation where id=?1 ;", nativeQuery = true)
BschVideoExplanation getAllById(Integer id);
@Transactional
@Modifying
@Query(nativeQuery = true, value = "delete from bsch_video_explanation where id=?1 ")
void deleteAllById(Integer id);
@Transactional
@Modifying
@Query(nativeQuery = true, value = "update bsch_video_explanation set clicks=clicks+1 where id=?1 ")
void updateClickById(Integer id);
}
@@ -0,0 +1,13 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.FeedBack;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
@Repository
public interface FeedBackRepository extends JpaRepository<FeedBack, Integer>, JpaSpecificationExecutor<FeedBack> {
}
@@ -0,0 +1,16 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.enums.OcrDataCache;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface OcrDataCacheRepository extends JpaRepository<OcrDataCache, Integer>, JpaSpecificationExecutor<OcrDataCache> {
@Query(value = "SELECT data FROM ocr_data_cache WHERE img_url = ?1", nativeQuery = true)
Optional<String> findDataByImgUrl(String imgUrl);
}
@@ -0,0 +1,10 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.PunitCommunication;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface PunitCommunicationRepository extends JpaRepository<PunitCommunication, Integer>, JpaSpecificationExecutor<PunitCommunication> {
}
@@ -0,0 +1,42 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.PunitLeadlearning;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
import java.util.Map;
public interface PunitLeadlearningRepository extends JpaRepository<PunitLeadlearning, Integer>, JpaSpecificationExecutor<PunitLeadlearning> {
@Query(value = "select * from (SELECT *," +
"(select count(id) from punit_stu_answer b where a.sch_id=b.sch_id and b.node_id=a.node_id and b.stu_id=?3) as stucount," +
"(select count(id) from punit_stu_answer b where a.sch_id=b.sch_id and b.node_id=a.node_id and b.stu_id=?3 and status=1) as duicount," +
"(select count(id) from punit_stu_answer b where a.sch_id=b.sch_id and b.node_id=a.node_id and b.stu_id=?3 and status=2) as cuocount," +
"(select count(id) from punit_stu_answer b where a.sch_id=b.sch_id and b.node_id=a.node_id and b.stu_id=?3 and status not in(1,2)) as elecount," +
"(select count(id) from punit_question b where a.sch_id=b.sch_id and b.node_id=a.node_id) as qcount," +
"IFNULL((select is_review from punit_stu_answer b where a.sch_id=b.sch_id and b.node_id=a.node_id and b.stu_id=?3 LIMIT 1),0) is_review from punit_leadlearning a where sch_id=?1 and if(?2 is null,1=1,node_id=?2 or path like CONCAT('%,',?2,',%')) )c where is_review in (?4)",
countQuery = "select count(id) from (" +
" SELECT *,IFNULL((select is_review from punit_stu_answer b where a.sch_id=b.sch_id and b.node_id=a.node_id and b.stu_id=?3 LIMIT 1),0) is_review from punit_leadlearning a where sch_id=?1 and if(?2 is null,1=1,node_id=?2 or path like CONCAT('%,',?2,',%')) ) c where is_review in (?4)", nativeQuery = true)
Page<Map<String,Object>> findPageBySchId(Integer schId, Integer nodeId, Integer stuId, List<Integer> is_review, Pageable pageable);
@Query(value = "select * from (SELECT *," +
"(select count(DISTINCT stu_id) from punit_stu_answer b where a.sch_id=b.sch_id and b.node_id=a.node_id and b.class_id=?3) as stucount," +
"(select count(id) from punit_communication b where a.sch_id=b.sch_id and b.node_id=a.node_id and b.c_id=0) as askcount," +
"(select count(id) from punit_question b where a.sch_id=b.sch_id and b.node_id=a.node_id) as qcount " +
" from punit_leadlearning a where sch_id=?1 and if(?4 is null,1=1,node_id=?2 or path like CONCAT('%,',?2,',%')) ) c " ,
countQuery = "select count(id) from (" +
" SELECT * from punit_leadlearning a where sch_id=?1 and if(?2 is null,1=1,node_id=?2 or path like CONCAT('%,',?2,',%') ) )c where ?3=?3", nativeQuery = true)
Page<Map<String,Object>> findTeaPageBySchId(Integer schId, Integer nodeId, Integer classId, Pageable pageable);
}
@@ -0,0 +1,18 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.PunitQuestion;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
import java.util.Map;
public interface PunitQuestionRepository extends JpaRepository<PunitQuestion, Integer>, JpaSpecificationExecutor<PunitQuestion> {
@Query(value = "select node_id,Count(id) qcount from punit_question where sch_id=?1 group by node_id",nativeQuery = true)
List<Map> findByNodeQcount(Integer schId);
}
@@ -0,0 +1,17 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.PunitStuAnswer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
import java.util.Map;
public interface PunitStuAnswerRepository extends JpaRepository<PunitStuAnswer, Integer>, JpaSpecificationExecutor<PunitStuAnswer> {
@Query(value = "select node_id,Count(id) qcount from punit_question where sch_id=?1 and grade_id=?2 and subject_id=?3 group by node_id",nativeQuery = true)
List<Map> findByNodeQcount(Integer schId, Integer gradeId, String subjectId);
}
@@ -0,0 +1,10 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.PunitZiYuanTreeTea;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface PunitZiYuanTreeTeaRepository extends JpaRepository<PunitZiYuanTreeTea, Integer>, JpaSpecificationExecutor<PunitZiYuanTreeTea> {
}
@@ -0,0 +1,11 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.UploadFile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
@Repository
public interface UploadFileRepository extends JpaRepository<UploadFile, Integer>, JpaSpecificationExecutor<UploadFile> {
}
@@ -0,0 +1,47 @@
package com.bestsch.classicalchinese.Repository;
import com.bestsch.classicalchinese.entity.VideoExplanation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import javax.transaction.Transactional;
import java.util.List;
public interface VideoExplanationRepository extends JpaRepository<VideoExplanation, Integer>, JpaSpecificationExecutor<VideoExplanation> {
@Query(value = "select * from video_explanation where sch_id=:schId and node_id=:nodeId ;", nativeQuery = true)
List<VideoExplanation> getAllBySchIdAndNodeId(Integer schId, Integer nodeId);
@Query(value = "SELECT * from video_explanation where sch_id=?1 and (node_id=?2 or path like CONCAT('%,',?2,',%')) ",
countQuery = "select count(id) from video_explanation where sch_id=?1 and (node_id=?2 or path like CONCAT('%,',?2,',%')) ", nativeQuery = true)
Page<VideoExplanation> findPageBySchIdAndNodeId(Integer schId, Integer nodeId, Pageable pageable);
@Query(value = "SELECT * from video_explanation where sch_id=?1 and subject_id=?2 and if(?3 is null,1=1, node_id=?3 or path like CONCAT('%,',?3,',%')) and if(?4 is null,1=1,name like CONCAT('%',?4,'%')) ",
countQuery = "select count(id) from video_explanation where sch_id=?1 and subject_id=?2 and if(?3 is null,1=1, node_id=?3 or path like CONCAT('%,',?3,',%')) and if(?4 is null,1=1,name like CONCAT('%',?4,'%')) ", nativeQuery = true)
Page<VideoExplanation> findPageBySchIdAndSubjectIdAndNodeIdAndName(Integer schId, String subjectId, Integer nodeId, String keyword, Pageable pageable);
@Query(value = "select id from video_explanation where id=?1 and create_user=?2 ;", nativeQuery = true)
Integer getIdByIdAndUserId(Integer id, Integer userId);
@Query(value = "select * from video_explanation where id=?1 ;", nativeQuery = true)
VideoExplanation getAllById(Integer id);
@Transactional
@Modifying
@Query(nativeQuery = true, value = "delete from video_explanation where id=?1 ")
void deleteAllById(Integer id);
@Transactional
@Modifying
@Query(nativeQuery = true, value = "update video_explanation set clicks=clicks+1 where id=?1 ")
void updateClickById(Integer id);
}
@@ -0,0 +1,76 @@
package com.bestsch.classicalchinese.baidu;
import com.bestsch.classicalchinese.enums.OcrDataCache;
import com.bestsch.classicalchinese.service.IOcrDataCacheService;
import com.bestsch.classicalchinese.utils.FileUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.baidu.aip.ocr.AipOcr;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
/**
* @author CHY
* @date 2024/5/31 16:51
*/
@Component
@Slf4j
public class AipOcrComponent {
@Autowired
private AipOcr aipOcr;
@Autowired
private IOcrDataCacheService iOcrDataCacheService;
/**
* 手写文字识别
*/
private String handwriting(byte[] image) {
JSONObject handwriting = aipOcr.handwriting(image, new HashMap<>());
List<String> list = new ArrayList<>();
try {
JSONArray wordsResult = handwriting.getJSONArray("words_result");
for (int i = 0; i < wordsResult.length(); i++) {
String words = wordsResult.getJSONObject(i).getString("words");
list.add(words);
}
} catch (JSONException e) {
log.error("手写文字识别handwriting方法报错:", e);
}
if (!list.isEmpty()) {
String data = String.join("", list);
log.info("手写识别结果:{}", data);
return data;
}
return "";
}
/**
* 手写文字识别url
*/
public String handwriting(String imageUrl) {
// 先从db中拿
Optional<String> optional = iOcrDataCacheService.findDataByImgUrl(imageUrl);
if (optional.isPresent()) {
return optional.get();
}
byte[] imageBytes = FileUtil.getBytes(imageUrl);
String data = imageBytes.length == 0 ? "" : handwriting(imageBytes);
// 存db
if (StringUtils.isNotBlank(data)) {
OcrDataCache ocrDataCache = new OcrDataCache(null, imageUrl, data);
iOcrDataCacheService.save(ocrDataCache);
}
return data;
}
}
@@ -0,0 +1,27 @@
package com.bestsch.classicalchinese.baidu;
import com.baidu.aip.ocr.AipOcr;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author CHY
* @date 2024/5/31 16:51
*/
@Configuration
public class AipOcrConfig {
@Autowired
private BaiDuConfigProperties baiDuConfigProperties;
@Bean
public AipOcr createClient() {
// 初始化一个AipOcr
AipOcr client = new AipOcr(baiDuConfigProperties.getAppId(), baiDuConfigProperties.getAppKey(), baiDuConfigProperties.getAppSecret());
// 可选:设置网络连接参数
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(60000);
return client;
}
}
@@ -0,0 +1,23 @@
package com.bestsch.classicalchinese.baidu;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
* @author CHY
* @date 2023/10/12 17:28
*/
@Component
@Data
public class BaiDuConfigProperties {
@Value("${baidu.api.app_id}")
private String appId;
@Value("${baidu.api.app_secret}")
private String appSecret;
@Value("${baidu.api.app_key}")
private String appKey;
}
@@ -0,0 +1,40 @@
package com.bestsch.classicalchinese.config;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import java.util.ResourceBundle;
public enum Config {
Inst;
public static final String API_PATH = "/api/";
public static final String MOBILEAPI_PATH = "/mobiapi/";
public static final String OAPI = "/oapi/";
@Value("${FILE_WEB_PATH}")
public String FILE_WEB_PATH;
@Value("${FILE_PATH}")
public String FILE_PATH;
public String getString(String key)
{
ResourceBundle resource = ResourceBundle.getBundle("config");
return resource.getString(key);
}
public int getInt(String key)
{
String value = getString(key);
return Integer.parseInt(value);
}
}
@@ -0,0 +1,21 @@
package com.bestsch.classicalchinese.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* 解决跨域
*/
@Configuration
public class DWebMvcConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
.allowedHeaders("*")
.maxAge(3600).allowCredentials(true);
}
}
@@ -0,0 +1,24 @@
package com.bestsch.classicalchinese.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
/**
* @author luona
* @date 2021-02-22 10:31
**/
@Configuration
@Getter
@Setter
public class FileConfig {
@Value("${FILE_PATH}")
private String path;
@Value("${FILE_WEB_PATH}")
private String webPath;
}
@@ -0,0 +1,87 @@
package com.bestsch.classicalchinese.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.support.spring.FastJsonRedisSerializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheConfiguration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import java.time.Duration;
/**
* @author min
* @description
* @date 2019-07-06
*/
@Slf4j
@Configuration
@EnableCaching
// 自动配置
@ConditionalOnClass(RedisOperations.class)
@EnableConfigurationProperties(RedisProperties.class)
public class RedisConfig extends CachingConfigurerSupport {
/**
* 设置 redis 数据默认过期时间,默认1天
* 设置@cacheable 序列化方式
* @return
*/
@Bean
public RedisCacheConfiguration redisCacheConfiguration(){
FastJsonRedisSerializer<Object> fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class);
RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig();
configuration = configuration.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer)).entryTtl(Duration.ofDays(1));
return configuration;
}
@Bean(name = "redisTemplate")
@ConditionalOnMissingBean(name = "redisTemplate")
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
template.setValueSerializer(jackson2JsonRedisSerializer);
template.setHashValueSerializer(jackson2JsonRedisSerializer);
ParserConfig.getGlobalInstance().addAccept("com.bestsch.modules.system.service.dto");
// key的序列化采用StringRedisSerializer
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setConnectionFactory(redisConnectionFactory);
return template;
}
/**
* 自定义缓存key生成策略
* 使用方法 @Cacheable(keyGenerator="keyGenerator")
* @return
*/
@Bean
@Override
public KeyGenerator keyGenerator() {
return (target, method, params) -> {
StringBuilder sb = new StringBuilder();
sb.append(target.getClass().getName());
sb.append(method.getName());
for (Object obj : params) {
sb.append(JSON.toJSONString(obj).hashCode());
}
return sb.toString();
};
}
}
@@ -0,0 +1,37 @@
package com.bestsch.classicalchinese.controller;
import com.bestsch.classicalchinese.entity.BschTextbook;
import com.bestsch.classicalchinese.model.Page;
import com.bestsch.classicalchinese.service.IBschTextbookService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@Slf4j
public class BaseController {
protected Page getPageVO(String page, String pageCount) {
Page pageVO = new Page();
if (StringUtils.isNumeric(pageCount)) {
int num = Integer.valueOf(pageCount);
/*if (num>50) {
pageVO.setPageSize(50);
}*/
pageVO.setPageSize(Double.valueOf(pageCount).intValue());
}
if (StringUtils.isNumeric(page)) {
pageVO.setCurrent(page);
}
return pageVO;
}
public static Integer getIntByString(String str){
Integer id = null;
if (str != null && StringUtils.isNotBlank(str) && !str.equals("null"))
id = Integer.valueOf(str);
return id;
}
}
@@ -0,0 +1,27 @@
package com.bestsch.classicalchinese.controller.Handler;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.HashMap;
import java.util.Map;
@RestControllerAdvice
public class ValidationExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<Map<String, String>> handleValidationExceptions(MethodArgumentNotValidException ex) {
Map<String, String> errors = new HashMap<>();
ex.getBindingResult().getAllErrors().forEach(error -> {
String fieldName = ((FieldError) error).getField();
String errorMessage = error.getDefaultMessage();
errors.put(fieldName, errorMessage);
});
return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);
}
}
@@ -0,0 +1,374 @@
package com.bestsch.classicalchinese.controller.api;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.alibaba.fastjson.JSON;
import com.bestsch.classicalchinese.service.IBschKnowledgeService;
import com.bestsch.classicalchinese.service.IBschTextbookService;
import com.bestsch.classicalchinese.service.com.ZiyuankuService;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.controller.BaseController;
import com.bestsch.classicalchinese.entity.*;
import com.bestsch.classicalchinese.model.ExcelBschLeadlearning;
import com.bestsch.classicalchinese.model.Page;
import com.bestsch.classicalchinese.model.SystemGrade;
import com.bestsch.classicalchinese.model.vo.BschFormQuestionVo;
import com.bestsch.classicalchinese.service.impl.*;
import com.bestsch.classicalchinese.utils.EasyPoiUtils;
import com.bestsch.classicalchinese.utils.ModelMapperUtil;
import com.bestsch.classicalchinese.utils.ValidationUtil;
import com.bestsch.utils.DException;
import com.bestsch.utils.ErrorCode;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotBlank;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.API_PATH+"/bschset/")
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class BschSettingsController extends BaseController {
@Autowired
private BschLeadlearningService bschLeadlearningService;
@Autowired
private BschExplanationService bschExplanationService;
@Autowired
private BschQuestionService bschQuestionService;
@Autowired
private IBschKnowledgeService bschKnowledgeService;
@Autowired
private IBschTextbookService bschTextbookService;
/************************************************* 知识树节点相关接口 ************************************************/
@RequestMapping("addKnowledge")
public BschKnowledge addKnowledge(Integer parentId, String name){
if(StringUtils.isBlank(name)
|| parentId == null){
throw new DException(ErrorCode.WRONG_REQUEST_PARAMS);
}
return bschKnowledgeService.addKnowledge(parentId,name);
}
@PostMapping("delKnowledge")
public void delKnowledge(Integer id){
if(id == null){
throw new DException(ErrorCode.WRONG_REQUEST_PARAMS);
}
bschKnowledgeService.delKnowledge(id);
}
@PostMapping("setKnowledge")
public BschKnowledge setKnowledge(Integer id, String name){
if(id == null){
throw new DException(ErrorCode.WRONG_REQUEST_PARAMS);
}
BschKnowledge knowledge = new BschKnowledge();
knowledge.setName(name);
return bschKnowledgeService.setKnowledge(id,knowledge);
}
@PostMapping("setKnowledgeOrder")
public void setKnowledgeOrder(Integer id, Integer replaceId){
if(id == null
|| replaceId == null){
throw new DException(ErrorCode.WRONG_REQUEST_PARAMS);
}
bschKnowledgeService.setOrder(id,replaceId);
}
/** 功能描述: 获取指定教材知识树结构
* @param
* @return:
* @Author: cls
* @Date: 2021/3/17 17:04
*/
@GetMapping("getKnowledgeTree")
public Map<String,Object> getKnowledgeTree(HttpServletRequest reques){
Integer textbookId=this.getTextbookId(reques);
Map<String,Object> result = new HashMap<>();
result.put("tree",bschKnowledgeService.getTreeOfSystemForApi(textbookId));
//getTreeOfSystemForApi(textbookId)
return result;
}
@GetMapping("getTextbookId")
public Integer getTextbookId(HttpServletRequest reques){
String apptype= reques.getHeader("apptype");
String xdCode= reques.getHeader("xdCode");
Optional<BschTextbook> textbookOptional= bschTextbookService.getAllList().stream().filter(s->s.getApptype().toString().equals(apptype)&&s.getSchParagraph().toString().equals(xdCode)).findFirst();
if(textbookOptional.isPresent())
return textbookOptional.get().getId();
else
throw new DException("");
}
@GetMapping("getTextbookName")
public String getTextbookName(HttpServletRequest reques){
String apptype= reques.getHeader("apptype");
String xdCode= reques.getHeader("xdCode");
Optional<BschTextbook> textbookOptional= bschTextbookService.getAllList().stream().filter(s->s.getApptype().toString().equals(apptype)&&s.getSchParagraph().toString().equals(xdCode)).findFirst();
if(textbookOptional.isPresent())
return textbookOptional.get().getName();
else
return "";
}
// /** 功能描述: 设置知识树的维护人员
// * @param knowledgeId 知识节点id
// * @param users 维护人信息集合 [{id:xxx,name:"xxx"}] 以替换的形式更新
// * @return:
// * @Author: cls
// * @Date: 2021/3/22 15:58
// */
// @PostMapping("knowledge/maintainer/set")
// public List setKnowledgeMaintainer(Integer knowledgeId, Integer schoolSid, String users){
// if(knowledgeId == null || schoolSid == null){
// throw new DException(ErrorCode.WRONG_REQUEST_PARAMS);
// }
// return bschKnowledgeService.set(knowledgeId,schoolSid,users);
// }
/*************************************************/
// @GetMapping("getAllGrade")
// public List<Map<String, Object>> getAllGrade() {
// List<Map<String,Object>> list = new ArrayList<>();
// for (SystemGrade grade : SystemGrade.values()) {
// Map<String,Object> map = new HashMap<>();
// map.put("id",grade.getGradeId());
// map.put("name",grade.getGradeName());
// list.add(map);
// }
// return list;
// }
// @GetMapping("getKnowledgeTree")
// public Object getKnowledgeTree(BoaUser authUserWithDept,@RequestParam(required = true) Integer textbookId){
// List<Integer> textbookIds=new ArrayList<>(Arrays.asList(textbookId));
// return ziyuankuService.getKnowledgeTree_cache(textbookIds);
// }
@GetMapping("getSubdirectoryList")
public Object getSubdirectoryList(HttpServletRequest reques,BoaUser authUserWithDept){
int textbookId=getTextbookId(reques);
return bschKnowledgeService.getSubdirectoryList(textbookId);
}
@GetMapping("getEndNodeList")
public Object getEndNodeList(HttpServletRequest reques){
int textbookId=getTextbookId(reques);
return bschKnowledgeService.getEndNodeList(textbookId);
}
@GetMapping("getLeadlearning")
public Optional<BschLeadlearning> getLeadlearning(HttpServletRequest reques,BoaUser authUserWithDept, @RequestParam(required = true) Integer nodeId
) {
int textbookId=getTextbookId(reques);
return bschLeadlearningService.findOne(textbookId,nodeId);
}
@PostMapping("saveLeadlearning")
public void saveLeadlearning(HttpServletRequest reques,BoaUser authUserWithDept,
@RequestParam(required = true) Integer nodeId,
@RequestParam(required = true) String content,
@RequestParam(required = true) String path
) {
int textbookId=getTextbookId(reques);
if(authUserWithDept.getType()!=1) throw new DException("无权限!");
BschLeadlearning model=new BschLeadlearning();
Optional<BschLeadlearning> modelOpt = bschLeadlearningService.findOne(textbookId,nodeId);
model.setId(modelOpt.map(BschLeadlearning::getId).orElse(0));
model.setTextbookId(textbookId);
model.setContent(content);
model.setNodeId(nodeId);
model.setPath(path);
model.setCDate(new Date());
model.setCUserId(authUserWithDept.getId());
bschLeadlearningService.save(model);
}
// @GetMapping("DownBschLeadlearningTemp")
// public void DownBschLeadlearningTemp(HttpServletResponse response,
// @RequestParam(value = "textbookId", required = false) Integer textbookId) {
// List<ExcelBschLeadlearning> list= bschLeadlearningService.getExcelBschLeadlearning(textbookId);
// String fileName="导入模板";
// String titleName ="内容导入" ;
// ExportParams exportParams = new ExportParams(titleName, "");
// Workbook workbook2 = ExcelExportUtil.exportExcel(exportParams, ExcelBschLeadlearning.class, list);
// EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook2);
// }
// @PostMapping("ImportBschLeadlearningTemp")
// public void ImportPunitTeaTemp(UserSysRole curRole,
// @RequestPart("file") MultipartFile file,
// @RequestParam(value = "textbookId", required = false) Integer textbookId
// ) throws Exception
// {
// List<String> errorMsgArr=new ArrayList<>();
// List<BschLeadlearning> baseList=new ArrayList<BschLeadlearning>();
// ImportParams params = new ImportParams();
// params.setTitleRows(1);
// params.setHeadRows(1);
//
// try {
// List<Map> treenodelist= bschZiYuanTreeService.getTreeNodeList(textbookId);
//
// List<ExcelBschLeadlearning> list = ExcelImportUtil.importExcel(file.getInputStream(), ExcelBschLeadlearning.class, params);
// int rows=0;
// Date date=new Date();
// for (ExcelBschLeadlearning item:list) {
//
// rows+=1;
// if(item.getCname()==null){
// errorMsgArr.add("第"+(rows+2)+"行,章节不能为空!");
// continue;
// }
// Optional<Map> treenodeFirst=treenodelist.stream().filter(s->s.get("cname").toString().equals(item.getCname())).findFirst();
//
// if(!treenodeFirst.isPresent())
// {
// errorMsgArr.add("第"+(rows+2)+"行,“"+item.getCname()+"”章节不存在!");
// continue;
// }
//
// Integer nodeId=Integer.parseInt(treenodeFirst.get().get("id").toString());
// String path=treenodeFirst.get().get("path").toString();
// {
// BschLeadlearning model = new BschLeadlearning();
// model.setCDate(date);
// model.setCUserId(curRole.getUserId());
// model.setPath(path);
// model.setNodeId(nodeId);
// model.setContent(item.getBschLeadlearning());
// model.setTextbookId(textbookId);
// baseList.add(model);
// }
// }
// if(errorMsgArr.size()>0) throw new DException(String.join("</br>",errorMsgArr));
//
// bschLeadlearningService.saveAll(baseList);
// } catch (Exception e) {
// System.out.println(e);
// throw new Exception("导入失败,请联系管理员! </br> 错误详情: </br>" + e.getMessage().toString());
// }
// }
@GetMapping("getExplanationList")
public Object getExplanationList(BoaUser authUserWithDept,
@RequestParam(required = true) Integer textbookId,
@RequestParam(required = true) Integer nodeId,@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer count
) {
Page pageVO = getPageVO(page.toString(), count.toString());
Sort sort = Sort.by(Sort.Order.desc("create_time"));
Pageable pageable = PageRequest.of(pageVO.getCurrent() - 1, pageVO.getPageSize(),sort);
return bschExplanationService.getExplanationList(textbookId,authUserWithDept.getId(),nodeId,pageable);
}
@PostMapping("saveExplanation")
public void saveExplanation(BoaUser authUserWithDept,
@RequestBody List<BschVideoExplanation> list
) {
if (authUserWithDept.getType() !=1 )
throw new NullPointerException("您没有该权限!");
bschExplanationService.saveExplanation(authUserWithDept.getId(),list);
}
@PostMapping("saveExplanation1")
public void saveExplanation1(BoaUser authUserWithDept, @RequestBody Map<String,Object> map) {
bschExplanationService.saveExplanation1(authUserWithDept.getId(), map);
}
@GetMapping("findNodeQuestion")
public List<Map> findNodeQuestion(HttpServletRequest reques,
@RequestParam(value = "nodeId", required = true) Integer nodeId)
{
int textbookId=getTextbookId(reques);
return bschQuestionService.findGradeMapAll(nodeId,textbookId);
}
@PostMapping("saveNodeQuestion")
public void findNodeQuestion(BoaUser authUserWithDept,@RequestBody @NotBlank String jsonData)
{
Date date=new Date();
BschFormQuestionVo form = JSON.parseObject(jsonData, BschFormQuestionVo.class);
List<BschQuestion> questions=form.getQuestionList();
long questionCount=questions.stream().map(BschQuestion::getName).distinct().count();
if(questionCount!=questions.stream().count()) throw new DException("题目存在重复!");
for (BschQuestion qtem:questions) {
ValidationUtil.validate(qtem);
if(qtem.getId()==null) qtem.setId(0);
qtem.setNodeId(qtem.getNodeId());
qtem.setTextbookId(qtem.getTextbookId());
}
List<BschQuestion> questionList=bschQuestionService.findNoteAll(form.getNodeId(),form.getTextbookId());
List<Integer> dbquestionIds=questionList.stream().filter(s->s.getId() != null &&s.getId()>0).map(BschQuestion::getId).collect(Collectors.toList());
List<Integer> jsonQuestionIds=questions.stream().filter(s->s.getId() != null &&s.getId()>0).map(BschQuestion::getId).collect(Collectors.toList());
for (BschQuestion qtem:questions) {
Optional<BschQuestion> bschQuestionOpt=questionList.stream().filter(s->s.getId().equals(qtem.getId())).findFirst();
BschQuestion eniity=new BschQuestion();
//数据库赋值(用户,时间,学校)
if(bschQuestionOpt.isPresent()) eniity=bschQuestionOpt.get();
eniity= ModelMapperUtil.map(qtem,BschQuestion.class);//编辑或添加赋值
eniity.setCUserId(authUserWithDept.getId());
eniity.setCDate(date);
bschQuestionService.save(eniity);
}
List<Integer> delquestionIds= ListUtils.subtract(dbquestionIds,jsonQuestionIds);
if(delquestionIds.stream().count()>0)
{
List<BschQuestion> delQuestionList=questionList.stream().filter(s->delquestionIds.contains(s.getId())).collect(Collectors.toList());
bschQuestionService.deleteAll(delQuestionList);
}
}
}
@@ -0,0 +1,106 @@
package com.bestsch.classicalchinese.controller.api;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.service.ICommonService;
import com.bestsch.classicalchinese.service.com.*;
import com.bestsch.utils.DException;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(Config.API_PATH+"/com/")
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class CommonController {
@Value("${FILE_PATH}")
private String FILE_PATH;
@Autowired
private ICommonService commonService;
@Autowired
private UserGradeClassSubService userGradeClassSubService;
/**
* 获取学科年级学期
* 教师端,不用传gradeId
*/
// @GetMapping("getSubjectGradeTerm")
// public Object getSubjectGradeTerm(UserSysRole curRole,@RequestParam(required = false) Integer gradeId){
// return commonService.getSubjectGradeTerm(curRole.getSchId(),curRole.getRoleId(),curRole.getUserId(),gradeId);
// }
//
// @GetMapping("getTeaSubGradeTrem")
// public Object getTeaSubGradeTrem(UserSysRole curRole){
// return commonService.getTeaSubGradeTrem(curRole.getRoleId(),curRole.getSchId(),curRole.getUserId());
// }
/**
* 知识树节点
*/
// @GetMapping("getChapterWrongQuestNumTree")
// public Object getChapterWrongQuestNumTree(UserSysRole curRole,
// String subjectId, Integer gradeId, Integer year, Integer term,
// @RequestParam(required = false) String checkedIds) {
// if (StringUtils.isEmpty(subjectId) || gradeId == null)
// throw new DException("年级或学科不能为空!");
//
// return commonService.getChapterWrongQuestNumTree(curRole.getSchId(), subjectId, gradeId, year, term, checkedIds);
// }
// @GetMapping("getChapterWrongQuestNumTree")
// public Object getChapterWrongQuestNumTree(UserSysRole curRole,
// String subjectId,
// @RequestParam(required = false) String checkedIds) {
// if (StringUtils.isEmpty(subjectId))
// throw new DException("学科不能为空!");
//
// return commonService.getChapterWrongQuestNumTree(curRole.getSchId(), curRole.getUserId(), subjectId,checkedIds);
// }
/**
* 知识树节点--年级学期(墨水瓶)
*/
// @GetMapping("getGradeTerm")
// public Object getGradeTerm(UserSysRole curRole,Integer gradeId){
// return commonService.getGradeTerm(curRole.getSchId(),curRole.getUserId(),gradeId);
// }
/**
* 获取年级班级
*/
@GetMapping("getGradeClass")
public List<Map> getGradeClass(UserSysRole curRole){
return commonService.getGradeClass(curRole.getSchId(),curRole.getRoleId(),curRole.getUserId());
}
/**
* 获取班级学生
*/
@GetMapping("getClassStuList")
public List<Map> getClassStuList(UserSysRole curRole,Integer classId){
return commonService.getClassStuList(curRole.getSchId(),classId);
}
@GetMapping("getSchTeaTree")
public Object getSchTeaTree(UserSysRole curRole){
return commonService.getSchTeaTree(curRole.getSchId());
}
@GetMapping("geTeaGradeSubClass")
public Object geTeaGradeSubClass(UserSysRole curRole)
{
return userGradeClassSubService.GetList(curRole.getRoleId(),curRole.getUserId(),curRole.getSchId());
}
}
@@ -0,0 +1,127 @@
package com.bestsch.classicalchinese.controller.api;
import com.bestsch.classicalchinese.entity.BschTextbook;
import com.bestsch.classicalchinese.service.impl.BschTextbookService;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.service.IExplanationService;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.controller.BaseController;
import com.bestsch.classicalchinese.entity.VideoExplanation;
import com.bestsch.classicalchinese.model.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@RestController
@RequestMapping(Config.API_PATH+"explanation/")
@CrossOrigin(origins = {"*"}, allowCredentials = "true")
public class ExplanationController extends BaseController {
@Autowired
private IExplanationService explanationService;
@Autowired
private BschTextbookService bschTextbookService;
@GetMapping("getTextbookId")
public Integer getTextbookId(HttpServletRequest reques){
String apptype= reques.getHeader("apptype");
String xdCode= reques.getHeader("xdCode");
Optional<BschTextbook> textbookOptional= bschTextbookService.getAllList().stream().filter(s->s.getApptype().toString().equals(apptype)&&s.getSchParagraph().toString().equals(xdCode)).findFirst();
if(textbookOptional.isPresent())
return textbookOptional.get().getId();
else
return null;
}
/**
* 讲解--列表
*/
@GetMapping("getExplanationList")
public Object getExplanationList(UserSysRole curRole,Integer nodeId,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer count){
if (curRole.getRoleId() !=1 && curRole.getRoleId()!=2 && curRole.getRoleId() !=7)
throw new NullPointerException("您没有该权限!");
Page pageVO = getPageVO(page.toString(), count.toString());
Sort sort = Sort.by(Sort.Order.desc("create_time"));
Pageable pageable = PageRequest.of(pageVO.getCurrent() - 1, pageVO.getPageSize(),sort);
return explanationService.getExplanationList(curRole.getSchId(),curRole.getUserId(),nodeId,pageable);
}
/**
* 讲解--添加
*/
@PostMapping("saveExplanation")
public void saveExplanation(HttpServletRequest reques,UserSysRole curRole, @RequestBody List<VideoExplanation> list) {
if (curRole.getRoleId() !=1 && curRole.getRoleId()!=2 && curRole.getRoleId() !=7)
throw new NullPointerException("您没有该权限!");
Integer textbookId=getTextbookId(reques);
for (VideoExplanation vmodel:list)
{
vmodel.setTextbookId(textbookId);
}
explanationService.saveExplanation(curRole.getSchId(), curRole.getUserId(), list);
}
@PostMapping("saveExplanation1")
public void saveExplanation1(UserSysRole curRole, @RequestBody Map<String,Object> map) {
explanationService.saveExplanation1(curRole.getSchId(), curRole.getUserId(), map);
}
/**
* 讲解--删除
*/
@PostMapping("deleteExplanation")
public void deleteExplanation(UserSysRole curRole,Integer id){
if (curRole.getRoleId() !=1 && curRole.getRoleId()!=2 && curRole.getRoleId() !=7)
throw new NullPointerException("您没有该权限!");
if(curRole.getRoleId()==7||curRole.getRoleId()==2)
explanationService.deleteExplanation(id);
else
explanationService.deleteExplanation(curRole.getUserId(),id);
}
/**
* 从资源库选择--知识树
*/
@GetMapping("getZYKSubjectTree")
public Object getZYKSubjectTree(UserSysRole curRole,
@RequestParam(required = false) Integer nodeId){
return explanationService.getZYKSubjectTree(curRole.getSchId(),curRole.getUserId(),nodeId);
}
/**
* 从资源库选择--视频列表
*/
@GetMapping("getZYKVideoList")
public Object getZYKVideoList(UserSysRole curRole,Integer nodeId,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer count){
return explanationService.getZYKVideoList(curRole.getSchId(),curRole.getUserId(),curRole.getRoleId(),nodeId,page,count);
}
@GetMapping("pdfPreview")
public Object pdfPreview(UserSysRole curRole,Integer id){
return explanationService.pdfPreview(curRole.getSchId(),id);
}
}
@@ -0,0 +1,51 @@
package com.bestsch.classicalchinese.controller.api;
import com.bestsch.openapi.BoaModule;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.BschBaseOpenApi;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Enumeration;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH)
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class LoginUserController {
@Autowired
private BschBaseOpenApi bschBaseOpenApi;
@GetMapping("GetUserMod")
public List<BoaModule> getUserMod(BoaUser authUserWithDept, UserSysRole curRole) {
return bschBaseOpenApi.getUserModule(curRole.getUserId(),curRole.getSchId());
}
@GetMapping("GetUserInfo")
public BoaUser getUserInfo(BoaUser authUserWithDept) {
return authUserWithDept;
}
@GetMapping("Logout")
protected void logout(HttpServletRequest request) {
HttpSession session = request.getSession();
Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements()) {
System.out.print(names.nextElement() + ",");
}
session.invalidate();
System.out.println("logout over");
}
}
@@ -0,0 +1,288 @@
package com.bestsch.classicalchinese.controller.api;
import com.bestsch.classicalchinese.model.YearSemester;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.BschBaseOpenApi;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.controller.BaseController;
import com.bestsch.classicalchinese.entity.*;
import com.bestsch.classicalchinese.model.Grade;
import com.bestsch.classicalchinese.model.vo.PunitFormVo;
import com.bestsch.classicalchinese.service.com.ClassService;
import com.bestsch.classicalchinese.service.impl.*;
import com.bestsch.classicalchinese.utils.ModelMapperUtil;
import com.bestsch.classicalchinese.utils.OtherUtil;
import com.bestsch.classicalchinese.utils.ValidationUtil;
import com.bestsch.utils.DException;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSON;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotBlank;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.API_PATH+"/punitnode/")
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class PunitNodeController extends BaseController {
@Autowired
private PunitLeadlearningService punitLeadlearningService;
@Autowired
private PunitQuestionService punitQuestionService;
@Autowired
private ClassService classService;
@Autowired
private PunitCommunicationService punitCommunicationService;
@Autowired
public BschLeadlearningService bschLeadlearningService;
@Autowired
private BschBaseOpenApi bschBaseOpenApi;
@Autowired
private BschTextbookService bschTextbookService;
@GetMapping("getTextbookId")
public Integer getTextbookId(HttpServletRequest reques){
String apptype= reques.getHeader("apptype");
String xdCode= reques.getHeader("xdCode");
Optional<BschTextbook> textbookOptional= bschTextbookService.getAllList().stream().filter(s->s.getApptype().toString().equals(apptype)&&s.getSchParagraph().toString().equals(xdCode)).findFirst();
if(textbookOptional.isPresent())
return textbookOptional.get().getId();
else
throw new DException("");
}
@GetMapping("getPunitForm")
public Map getPunitForm(HttpServletRequest reques,UserSysRole curRole,@RequestParam(value = "nodeId", required = true) Integer nodeId
) {
Integer textBookId= getTextbookId(reques);
Optional<PunitLeadlearning> modelOpt = punitLeadlearningService.findOne(textBookId,nodeId, curRole.getSchId());
String content = modelOpt.map(PunitLeadlearning::getContent).orElse("");
Integer id=modelOpt.map(PunitLeadlearning::getId).orElse(0);
if(StringUtils.isEmpty(content))
{
Optional<BschLeadlearning> bschLeadlearningOpt= bschLeadlearningService.findOne(textBookId,nodeId);
content= bschLeadlearningOpt.map(BschLeadlearning::getContent).orElse("");
}
Map map=new HashMap();
{
map.put("id", id);
map.put("nodeId", nodeId);
map.put("content",content);
map.put("type",1);
map.put("questionList",punitQuestionService.findMapAll(nodeId,curRole.getSchId()));
}
//map.put("subjectName",getSubjectName(curRole.getSchId(),subjectId));
//map.put("gradeName",getNameBySystemGrade(curRole.getSchId(),gradeId));
return map;
}
@PostMapping("savePunitForm")
public void savePunitForm(HttpServletRequest reques,UserSysRole curRole, @RequestBody @NotBlank String jsonData) {
PunitFormVo punit = JSON.parseObject(jsonData, PunitFormVo.class);
Integer textbookId=getTextbookId(reques);
List<PunitQuestion> questions=punit.getQuestionList();
long questionCount=questions.stream().map(PunitQuestion::getName).distinct().count();
if(questionCount!=questions.stream().count()) throw new DException("题目存在重复!");
//Integer textBookId= punitZiYuanTreeService.findTextBookId(punit.getYear(),punit.getTerm(),punit.getGradeId(),punit.getSubjectId(),curRole.getSchId());
//添加修改删除
for (PunitQuestion qtem:questions) {
ValidationUtil.validate(qtem);
if(qtem.getId()==null) qtem.setId(0);
qtem.setNodeId(punit.getNodeId());
qtem.setTextbookId(textbookId);
}
Optional<PunitLeadlearning> modelOpt = punitLeadlearningService.findOne(punit.getId(), curRole.getSchId());
int id = modelOpt.map(PunitLeadlearning::getId).orElse(0);
PunitLeadlearning model=ModelMapperUtil.map(punit,PunitLeadlearning.class);
OtherUtil.setBaseEntityValue(curRole, model, id);
model.setTextbookId(textbookId);
punitLeadlearningService.save(model);
List<PunitQuestion> questionList=punitQuestionService.findSchAll(punit.getNodeId(),curRole.getSchId());
List<Integer> dbquestionIds=questionList.stream().filter(s->s.getId() != null &&s.getId()>0).map(PunitQuestion::getId).collect(Collectors.toList());
List<Integer> jsonQuestionIds=questions.stream().filter(s->s.getId() != null &&s.getId()>0).map(PunitQuestion::getId).collect(Collectors.toList());
for (PunitQuestion qtem:questions) {
Optional<PunitQuestion> punitQuestionOpt=questionList.stream().filter(s->s.getId().equals(qtem.getId())).findFirst();
PunitQuestion eniity=new PunitQuestion();
//数据库赋值(用户,时间,学校)
if(punitQuestionOpt.isPresent()) eniity=punitQuestionOpt.get();
eniity.setTextbookId(textbookId);
eniity= ModelMapperUtil.map(qtem,PunitQuestion.class);//编辑或添加赋值
OtherUtil.setBaseEntityValue(curRole, eniity, eniity.getId());////编辑或添加赋值(用户,时间,学校)
punitQuestionService.save(eniity);
}
List<Integer> delquestionIds= ListUtils.subtract(dbquestionIds,jsonQuestionIds);
if(delquestionIds.stream().count()>0)
{
List<PunitQuestion> delQuestionList=questionList.stream().filter(s->delquestionIds.contains(s.getId())).collect(Collectors.toList());
punitQuestionService.deleteAll(delQuestionList);
}
}
// private String getSubjectName(Integer schId,String subjectId){
// List<Map> list = (List<Map>)classService.getSchoolSubject(schId);
// String subjectName = list.stream().filter(x -> Objects.equals(x.get("subId").toString(), subjectId)).map(x -> x.get("name").toString()).findFirst().orElse(null);
// return subjectName;
// }
@PostMapping("saveLeadlearning")
public void saveLeadlearning(HttpServletRequest reques,UserSysRole curRole,
@RequestBody @NotBlank String jsonData) {
PunitFormVo punit = JSON.parseObject(jsonData, PunitFormVo.class);
Integer textBookId= getTextbookId(reques);
Optional<PunitLeadlearning> modelOpt = punitLeadlearningService.findOne(punit.getId(),curRole.getSchId());
Integer id = modelOpt.map(PunitLeadlearning::getId).orElse(0);
PunitLeadlearning model=ModelMapperUtil.map(punit,PunitLeadlearning.class);
model.setTextbookId(textBookId);
OtherUtil.setBaseEntityValue(curRole, model, id);
punitLeadlearningService.save(model);
}
@PostMapping("saveQuestions")
public void saveQuestions(HttpServletRequest reques,UserSysRole curRole, @RequestBody @NotBlank String jsonData) {
PunitFormVo punit = JSON.parseObject(jsonData, PunitFormVo.class);
List<PunitQuestion> questions=punit.getQuestionList();
long questionCount=questions.stream().map(PunitQuestion::getName).distinct().count();
if(questionCount!=questions.stream().count()) throw new DException("题目存在重复!");
Integer textbookId=getTextbookId(reques);
//添加修改删除
for (PunitQuestion qtem:questions) {
ValidationUtil.validate(qtem);
if(qtem.getId()==null) qtem.setId(0);
qtem.setNodeId(punit.getNodeId());
qtem.setTextbookId(textbookId);
}
List<PunitQuestion> questionList=punitQuestionService.findSchAll(punit.getNodeId(),curRole.getSchId());
List<Integer> dbquestionIds=questionList.stream().filter(s->s.getId() != null &&s.getId()>0).map(PunitQuestion::getId).collect(Collectors.toList());
List<Integer> jsonQuestionIds=questions.stream().filter(s->s.getId() != null &&s.getId()>0).map(PunitQuestion::getId).collect(Collectors.toList());
for (PunitQuestion qtem:questions) {
Optional<PunitQuestion> punitQuestionOpt=questionList.stream().filter(s->s.getId().equals(qtem.getId())).findFirst();
PunitQuestion eniity=new PunitQuestion();
//数据库赋值(用户,时间,学校)
if(punitQuestionOpt.isPresent()) eniity=punitQuestionOpt.get();
eniity.setTextbookId(textbookId);
eniity= ModelMapperUtil.map(qtem,PunitQuestion.class);//编辑或添加赋值
OtherUtil.setBaseEntityValue(curRole, eniity, eniity.getId());////编辑或添加赋值(用户,时间,学校)
punitQuestionService.save(eniity);
}
List<Integer> delquestionIds= ListUtils.subtract(dbquestionIds,jsonQuestionIds);
if(delquestionIds.stream().count()>0)
{
List<PunitQuestion> delQuestionList=questionList.stream().filter(s->delquestionIds.contains(s.getId())).collect(Collectors.toList());
punitQuestionService.deleteAll(delQuestionList);
}
}
@GetMapping("getCommunicationClassStu")
public List<Map> getClassStuList(UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "classId", required = false) Integer classId){
return punitCommunicationService.getCommunicationClassStu(curRole.getSchId(),classId,nodeId);
}
@GetMapping("getCommunicationList")
public Object getCommunicationList(UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "stuId", required = false) Integer stuId)
{
if(curRole.getRoleId()==3)stuId=curRole.getUserId();
return punitCommunicationService.getCommunicationList(nodeId,stuId,curRole.getSchId());
}
@PostMapping("saveCommunication")
public void saveCommunication(HttpServletRequest reques,BoaUser authUser, UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "classId", required = true) Integer classId,
@RequestParam(value = "id", required = true) Integer id,
@RequestParam(value = "cId", required = true) Integer cId,
@RequestParam(value = "content", required = true) String content
)
{
if(StringUtils.isEmpty(content)) throw new DException("内容为空!");
if(content.length()>500) throw new DException("字符串超出限定长度(500)!");
if (!Objects.equals(authUser.getId(),curRole.getUserId())) {
authUser = bschBaseOpenApi.getUserInfo(curRole.getUserId());
}
if(id>0)
{
Optional<PunitCommunication> punitCommunicationOptional= punitCommunicationService.findOne(id,curRole.getUserId(),curRole.getSchId());
if(!punitCommunicationOptional.isPresent()) throw new DException("无权限!");
}
Integer textBookId=getTextbookId(reques);
YearSemester years= classService.getCurYearSemesterDate();
PunitCommunication pction=new PunitCommunication();
pction.setId(id);
pction.setYear(years.getYear());
pction.setTerm(years.getSemester());
pction.setCId(cId);
pction.setTextbookId(textBookId);
pction.setNodeId(nodeId);
pction.setClassId(classId);
pction.setContent(content);
pction.setCUserId(curRole.getUserId());
pction.setUserName(authUser.getName());
pction.setUserPhoto(authUser.getProfilePicture());
pction.setSchId(curRole.getSchId());
pction.setRole(curRole.getRoleId()==3?3:1);
pction.setCDate(new java.util.Date());
punitCommunicationService.save(pction);
}
@PostMapping("delCommunication")
public void saveCommunication(BoaUser authUser, UserSysRole curRole,Integer id)
{
Optional<PunitCommunication> punitCommunicationOptional= punitCommunicationService.findOne(id,curRole.getUserId(),curRole.getSchId());
if(!punitCommunicationOptional.isPresent()) throw new DException("无权限!");
punitCommunicationService.delete(punitCommunicationOptional.get());
}
// @GetMapping("getPunitList")
// private List<Map> getPunitList(UserSysRole curRole) {
// List<Map> nodeList = bschKnowledgeService.getEndNodeList(textbookId);
// return punitLeadlearningService.getPunitList(curRole.getRoleId(), curRole.getUserId(),year,term,curRole.getSchId());
// }
private String getNameBySystemGrade(Integer schId,Integer systemGrade){
List<Grade> list = classService.getGradeListBySchoolId(schId);
String name = list.stream().filter(x -> Objects.equals(x.getGradeId(), systemGrade)).map(x -> x.getName()).findFirst().orElse(null);
return name;
}
}
@@ -0,0 +1,282 @@
package com.bestsch.classicalchinese.controller.api;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.bestsch.classicalchinese.entity.BschTextbook;
import com.bestsch.classicalchinese.service.IBschTextbookService;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.controller.BaseController;
import com.bestsch.classicalchinese.entity.PunitZiYuanTreeTea;
import com.bestsch.classicalchinese.model.ExcelPunitTreeTea;
import com.bestsch.classicalchinese.service.com.ClassService;
import com.bestsch.classicalchinese.service.impl.*;
import com.bestsch.classicalchinese.utils.*;
import com.bestsch.utils.DException;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
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.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.API_PATH+"/settings/")
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class PunitSettingsController extends BaseController {
@Autowired
private PunitLeadlearningService punitLeadlearningService;
@Autowired
private ClassService classService;
@Autowired
private BschKnowledgeService bschKnowledgeService;
@Autowired
private PunitZiYuanTreeTeaService punitZiYuanTreeTeaService;
@Autowired
private IBschTextbookService bschTextbookService;
@GetMapping("getTextbookId")
public Integer getTextbookId(HttpServletRequest reques){
String apptype= reques.getHeader("apptype");
String xdCode= reques.getHeader("xdCode");
Optional<BschTextbook> textbookOptional= bschTextbookService.getAllList().stream().filter(s->s.getApptype().toString().equals(apptype)&&s.getSchParagraph().toString().equals(xdCode)).findFirst();
if(textbookOptional.isPresent())
return textbookOptional.get().getId();
else
return null;
}
//
// @GetMapping("getTreeNodeList")
// private List<Map> getTreeNodeList(UserSysRole curRole,
// @RequestParam(value = "year", required = true) Integer year,
// @RequestParam(value = "term", required = true) Integer term,
// @RequestParam(value = "gradeId", required = true) Integer gradeId,
// @RequestParam(value = "subjectId", required = true) String subjectId
// ) {
// return punitZiYuanTreeService.findTeaTreeNodeAll(year,term,gradeId,subjectId,curRole.getSchId());
// }
//
//
// @PostMapping("saveTreeNodeId")
// private void saveTreeNodeId(UserSysRole curRole, @RequestParam(value = "year", required = true) Integer year,
// @RequestParam(value = "term", required = true) Integer term,
// @RequestParam(value = "gradeId", required = true) Integer gradeId,
// @RequestParam(value = "subId", required = true) String subId,
// @RequestParam(value = "nodeIds", required = true) String nodeIds
// )
// {
//
// List<Integer> nodeIdInt=new ArrayList<>();
// if(!StringUtils.isEmpty(nodeIds)){
// nodeIdInt=Arrays.stream(nodeIds.split(","))
// .mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
// }
// punitZiYuanTreeService.savePunitZiYuanNodeId(curRole.getUserId(),year,term,gradeId,subId,curRole.getSchId(),nodeIdInt);
//
// }
@PostMapping("saveTreeNodeTea")
private void saveTreeNodeTea(UserSysRole curRole, @RequestParam(value = "year", required = true) Integer year,
@RequestParam(value = "term", required = true) Integer term,
@RequestParam(value = "gradeId", required = true) Integer gradeId,
@RequestParam(value = "subId", required = true) String subId,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "teaIds", required = true) String teaIds
)
{
List<Integer> teaIdsInt=new ArrayList<>();
if(!StringUtils.isEmpty(teaIds)){
teaIdsInt=Arrays.stream(teaIds.split(","))
.mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
}
punitZiYuanTreeTeaService.saveTreeNodeTea(curRole.getUserId(),year,term,gradeId,subId,nodeId,teaIdsInt,curRole.getSchId());
}
//导出研学基地模板
// @GetMapping("DownPunitTeaTemp")
// public void DownPunitTeaTemp(HttpServletResponse response, BoaUser authUser,
// @RequestParam(value = "year", required = true) Integer year,
// @RequestParam(value = "term", required = true) Integer term,
// @RequestParam(value = "gradeId", required = true) Integer gradeId,
// @RequestParam(value = "subjectId", required = true) String subjectId,
// @RequestParam(value = "schId", required = true) Integer schId) {
// List<ExcelPunitTreeTea> list= punitLeadlearningService.getExcelPunitTreeTea(authUser.getId(),year,term,gradeId,subjectId,schId);
// String fileName="预习教师导入模板";
// String titleName ="预习教师导入";
// ExportParams exportParams = new ExportParams(titleName, "");
// Workbook workbook2 = ExcelExportUtil.exportExcel(exportParams, ExcelPunitTreeTea.class, list);
// EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook2);
// }
// @PostMapping("ImportPunitTeaTemp")
// public void ImportPunitTeaTemp(UserSysRole curRole,
// @RequestPart("file") MultipartFile file,
// @RequestParam(value = "year", required = true) Integer year,
// @RequestParam(value = "term", required = true) Integer term,
// @RequestParam(value = "gradeId", required = true) Integer gradeId,
// @RequestParam(value = "subjectId", required = true) String subjectId
// ) throws Exception
// {
// List<String> errorMsgArr=new ArrayList<>();
// List<PunitZiYuanTreeTea> baseList=new ArrayList<PunitZiYuanTreeTea>();
// ImportParams params = new ImportParams();
// params.setTitleRows(1);
// params.setHeadRows(1);
// try {
// List<Map> treenodelist= punitLeadlearningService.getPunitAllList(year,term,gradeId,subjectId,curRole.getSchId());
//
// List<Map> tealist=classService.getSchteaList(curRole.getSchId());
//
// List<ExcelPunitTreeTea> list = ExcelImportUtil.importExcel(file.getInputStream(), ExcelPunitTreeTea.class, params);
// int rows=0;
// Date date=new Date();
// for (ExcelPunitTreeTea item:list) {
//
// rows+=1;
// if(item.getCname()==null){
// errorMsgArr.add("第"+(rows+2)+"行,章节不能为空!");
// continue;
// }
// Optional<Map> treenodeFirst=treenodelist.stream().filter(s->s.get("cname").toString().equals(item.getCname())).findFirst();
//
// if(!treenodeFirst.isPresent())
// {
// errorMsgArr.add("第"+(rows+2)+"行,“"+item.getCname()+"”章节不存在!");
// continue;
// }
//
// if(item.getTeaNames()==null){
// continue;
// }
//
// List<String> cNames=Arrays.asList(item.getTeaNames().split(","));
//
// List<String> notExistsTeaNames=new ArrayList<>();
// List<Integer> teaIds=new ArrayList<>();
// for (String name:cNames)
// {
// Optional<Map> teaOptional=tealist.stream().filter(s->s.get("TeaName").toString().equals(name)).findFirst();
// if(!teaOptional.isPresent())
// {
// notExistsTeaNames.add(name);
// }else {
// teaIds.add(Integer.parseInt(teaOptional.get().get("UserTeaSerID").toString()));
// }
// }
// if(notExistsTeaNames.stream().count()>0)
// {
// errorMsgArr.add("第"+(rows+2)+"行,教师“"+String.join(",",notExistsTeaNames)+"”不存在!");
// continue;
// }
// Integer nodeId=Integer.parseInt(treenodeFirst.get().get("id").toString());
// for (Integer teaId:teaIds)
// {
// PunitZiYuanTreeTea model = new PunitZiYuanTreeTea();
// model.setCDate(date);
// model.setCUserId(curRole.getUserId());
// model.setTeaId(teaId);
// model.setNodeId(nodeId);
// model.setSchId(curRole.getSchId());
// baseList.add(model);
// }
// }
// if(errorMsgArr.size()>0) throw new DException(String.join("</br>",errorMsgArr));
//
// punitZiYuanTreeTeaService.saveAll(baseList);
// } catch (Exception e) {
// System.out.println(e);
// throw new Exception("导入失败,请联系管理员! </br> 错误详情: </br>" + e.getMessage().toString());
// }
// }
// @GetMapping("getGradeSubTextBookInfo")
// public List<Map> getGradeSubTextBookInfo(UserSysRole curRole,
// @RequestParam(value = "year", required = true) Integer year,
// @RequestParam(value = "term", required = true) Integer term,
// @RequestParam(value = "gradeId", required = true) Integer gradeId,
// @RequestParam(value = "subjectId", required = true) String subjectId
// )
// {
// List<Map> listMap=new ArrayList<>();
//
// List<PunitZiYuanTree> nodelist= punitZiYuanTreeService.findGradeSubAll(year,term,gradeId,subjectId,curRole.getSchId());
//
// for (PunitZiYuanTree node:nodelist) {
// Map map=new HashMap();
// map.put("textbookld",node.getTextbookId());
// map.put("textbookName",ziyuankuService.getTextbookInfo(node.getTextbookId()));
// listMap.add(map);
// }
// return listMap;
// }
// @GetMapping("getTextBookInfo")
// public List<Map> getTextBookInfo(UserSysRole curRole,
// @RequestParam(value = "textbooklds", required = true) String textbooklds
// )
// {
// List<Integer> tlds= Arrays.stream(textbooklds.split(",")).map(s->Integer.parseInt(s)).collect(Collectors.toList());
//
// List<Map> listMap=new ArrayList<>();
// for (Integer tid:tlds) {
// listMap.add(ziyuankuService.getTextbookInfo(tid));
// }
// return listMap;
// }
// @GetMapping("getGradeSubTextBookId")
// public List<Integer> getGradeSubTextBookId(UserSysRole curRole,
// @RequestParam(value = "year", required = true) Integer year,
// @RequestParam(value = "term", required = true) Integer term,
// @RequestParam(value = "gradeId", required = true) Integer gradeId,
// @RequestParam(value = "subId", required = true) String subId
// )
// {
// return punitZiYuanTreeService.findTextBookIds(year,term,gradeId,subId,curRole.getSchId());
// }
// @PostMapping("setGradeSubTextBookId")
// public void setGradeSubTextBookId(UserSysRole curRole,
// @RequestParam(value = "year", required = true) Integer year,
// @RequestParam(value = "term", required = true) Integer term,
// @RequestParam(value = "gradeId", required = true) Integer gradeId,
// @RequestParam(value = "subId", required = true) String subId,
// @RequestParam(value = "textbookIds", required = true) String textbookIds
// )
// {
// List<Integer> tIds= Arrays.stream(textbookIds.split(",")).map(s->Integer.parseInt(s)).collect(Collectors.toList());
// punitZiYuanTreeService.setGradeSubTextBookId(year,term,gradeId,subId,tIds,curRole.getUserId(),curRole.getSchId());
// }
@GetMapping("initialization")
public void initialization(){
}
}
@@ -0,0 +1,179 @@
package com.bestsch.classicalchinese.controller.api;
import com.alibaba.fastjson.JSONObject;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.utils.DException;
import com.bestsch.utils.DHttp;
import com.bestsch.utils.JsonResp;
import com.google.common.base.Joiner;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
/**
* @program: QualityEvaluate
* @description: 转发第三发接口请求
* @author: chenx
* @create: 2023-08-30 14:43
**/
@RestController
@RequestMapping(Config.API_PATH+"/relay/")
public class RelayController {
//, Map paramsMap
@GetMapping(value = "doGet", produces = "application/json")
public Object doGet(BoaUser authUserWithDept, UserSysRole curRole, @RequestHeader("RelayUrl") String apiUrl,
@RequestParam HashMap<String, String> map ) {
// System.out.println("curRole============"+ JSON.toJSONString(curRole));
apiUrl += apiUrlInit(apiUrl);
apiUrl += "&" + asUrlParams(map);
apiUrl +="&"+ asRoleParams(curRole);
// System.out.println("apiUrl============"+apiUrl);
String resultStr = DHttp.get(apiUrl, getRoleMap(curRole));
return formatRespStr(resultStr);
}
@PostMapping(value = "doPost", produces = "application/json")
public Object doPost(BoaUser authUserWithDept, UserSysRole curRole,
@RequestHeader("RelayUrl") String apiUrl,
@RequestBody HashMap<String, Object> map ) {
apiUrl += apiUrlInit(apiUrl);
apiUrl += "&" + asRoleParams(curRole);
String jsonString = JSONObject.toJSONString(map);
// String resultStr= DHttp.post(apiUrl,jsonString.getBytes(),getRoleMap(currentRole));
Map header = getRoleMap(curRole);
header.put("Content-Type", "application/json");
String resultStr = DHttp.post(apiUrl, jsonString.getBytes(), header);
return formatRespStr(resultStr);
}
@PostMapping(value = "doPost2", produces = "application/json")
public Object doPost2(BoaUser authUserWithDept,UserSysRole curRole,
@RequestHeader("RelayUrl") String apiUrl,
@RequestParam HashMap<String, String> map ) {
String postData = asRoleParams(curRole);
apiUrl += apiUrlInit(apiUrl);
apiUrl += "&"+asUrlParams(map);
String resultStr = DHttp.post(apiUrl, postData.getBytes(), getRoleMap(curRole));
return formatRespStr(resultStr);
}
@PostMapping(value = "doUpload", produces = "application/json")
public Object doUpload(UserSysRole curRole,
@RequestHeader("RelayUrl") String apiUrl,
@RequestParam HashMap<String, String> map,
@RequestPart("file") MultipartFile file)throws Exception {
apiUrl += apiUrlInit(apiUrl);
apiUrl +="&"+ asRoleParams(curRole);
Map header = getRoleMap(curRole);
Map<String, File> fileMap = new HashMap<>();
fileMap.put("file", multipartFile2File(file));
String resultStr = DHttp.formUpload(apiUrl, map, fileMap, header);
if(StringUtils.isEmpty(resultStr))return Optional.empty();
else return formatRespStr(resultStr);
}
private Map<String,String> getRoleMap(UserSysRole curRole){
Map<String, String> header=new HashMap<>();
header.put("schId",String.valueOf(curRole.getSchId()));
header.put("userId",String.valueOf(curRole.getUserId()));
header.put("roleId",String.valueOf(curRole.getRoleId()));
header.put("currentRole", JSONObject.toJSONString(curRole));
// System.out.println("header============"+ JSONObject.toJSONString(header));
return header;
}
private String setRoleParams(String apiUrl,UserSysRole curRole){
// if(apiUrl==null)apiUrl="1=1";
// else if(apiUrl.indexOf("?")==-1) apiUrl+="?1=1";
apiUrl+="schId=" + curRole.getSchId();
apiUrl+="&userId="+ curRole.getUserId();
apiUrl+="&roleId="+ curRole.getRoleId();
return apiUrl;
}
private String asRoleParams(UserSysRole curRole) {
String paramsStr="";
paramsStr+="schId=" + curRole.getSchId();
paramsStr+="&userId="+ curRole.getUserId();
paramsStr+="&roleId="+ curRole.getRoleId();
return paramsStr;
}
private static File multipartFile2File(MultipartFile multipartFile) throws IOException {
InputStream inputStream = multipartFile.getInputStream();
String fileName=multipartFile.getOriginalFilename(),extension= "tmp";
int lastIndex = fileName.lastIndexOf(".");
if (lastIndex != -1 && lastIndex < fileName.length() - 1) {
extension = fileName.substring(lastIndex + 1);
}
File file = File.createTempFile(multipartFile.getOriginalFilename(),"."+ extension);
FileOutputStream outputStream = new FileOutputStream(file);
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.close();
file.deleteOnExit();
return file;
}
private Object formatRespStr(String resultStr){
JSONObject json = JSONObject.parseObject(resultStr);
if(json.containsKey("State") && json.getBoolean("State")== false){
if(json.get("Message")!=null)throw new DException(json.getString("Message"));
else throw new DException(JSONObject.toJSON(json.get("Data")).toString());
}
JsonResp resp= JSONObject.parseObject(resultStr, JsonResp.class);
if(resp.getCode()==0){
if( resp.getData()!=null) return resp.getData();
else return Optional.empty();
}
else{
if(resp.getMsg()!=null) throw new DException(resp.getMsg());
else throw new DException(JSONObject.toJSONString(resp.getData()));
}
}
public String asUrlParams( Map<String, String> source){
Map<String, String> tmp = Maps.newHashMap();
// java8 语法
source.forEach((k, v) -> {
if (k != null){
try {
tmp.put(k, URLEncoder.encode(v, "utf-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
});
return Joiner.on("&").useForNull("").withKeyValueSeparator("=").join(tmp);
}
private String apiUrlInit(String apiUrl) {
return apiUrl.indexOf("?") == -1 ? "?1=1" : "";
}
private static String hexToString(String hex) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hex.length(); i += 2) {
String hexSubstring = hex.substring(i, i + 2);
int decimalValue = Integer.parseInt(hexSubstring, 16);
sb.append((char) decimalValue);
}
return sb.toString();
}
}
@@ -0,0 +1,55 @@
package com.bestsch.classicalchinese.controller.api;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.service.impl.PunitStuAnswerService;
import com.bestsch.classicalchinese.service.impl.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@RestController
@RequestMapping(Config.API_PATH+"/statistics/")
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class StatisticsController {
@Autowired
private StatisticsService statisticsService;
@Autowired
private PunitStuAnswerService punitStuAnswerService;
//1 根据章节 班级 统计 完成度 学生名单 year term nodeId classId
@GetMapping("getClassWcqk")
public Map getClassWcqk(UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "classId", required = true) Integer classId
) {
return statisticsService.getClassWcqk(curRole.getSchId(),nodeId,classId);
}
@GetMapping("getStuPunitList")
public Map<String,Object> getStuPunitList(UserSysRole curRole,
@RequestParam(value = "stuId", required = true) Integer stuId,
Pageable pageable
) {
List<Integer> status= Arrays.asList(0,1);
return statisticsService.getStuPunitList(curRole.getSchId(),stuId,status,pageable);
}
@GetMapping("getStuSeeQuestion")
public Map getStuSeeQuestion(UserSysRole curRole,Integer nodeId)
{
return punitStuAnswerService.getStuSeeQuestion(nodeId,curRole.getUserId(),curRole.getSchId());
}
@GetMapping("findStuAnswerRecordAll")
public List<Map> findStuAnswerRecordAll(UserSysRole curRole,Integer stuId,Integer nodeId)
{
return punitStuAnswerService.findStuAnswerRecordAll(nodeId,stuId,curRole.getSchId());
}
}
@@ -0,0 +1,48 @@
package com.bestsch.classicalchinese.controller.api;
import com.bestsch.openapi.BoaModule;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.BschBaseOpenApi;
import com.bestsch.classicalchinese.config.Config;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Enumeration;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH +"/base/")
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class UserController {
@Autowired
private BschBaseOpenApi bschBaseOpenApi;
@GetMapping("getUserMod")
public List<BoaModule> getUserMod(BoaUser authUserWithDept) {
return bschBaseOpenApi.getUserModule(authUserWithDept.getId());
}
@GetMapping("getUserInfo")
public BoaUser getUserInfo(BoaUser authUserWithDept) {
return authUserWithDept;
}
@GetMapping("logout")
protected void logout(HttpServletRequest request) {
HttpSession session = request.getSession();
Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements()) {
System.out.print(names.nextElement() + ",");
}
session.invalidate();
System.out.println("logout over");
}
}
@@ -0,0 +1,328 @@
package com.bestsch.classicalchinese.controller.mobiapi;
import com.alibaba.fastjson.JSON;
import com.bestsch.classicalchinese.entity.BschKnowledge;
import com.bestsch.classicalchinese.entity.BschTextbook;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.BschBaseOpenApi;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.entity.FeedBack;
import com.bestsch.classicalchinese.entity.PunitCommunication;
import com.bestsch.classicalchinese.enums.GradeEnum;
import com.bestsch.classicalchinese.enums.SchoolSection;
import com.bestsch.classicalchinese.enums.Subject;
import com.bestsch.classicalchinese.model.ClassInfo;
import com.bestsch.classicalchinese.model.YearSemester;
import com.bestsch.classicalchinese.model.vo.SubmitStuQuestionVo;
import com.bestsch.classicalchinese.service.ICommonService;
import com.bestsch.classicalchinese.service.com.ClassService;
import com.bestsch.classicalchinese.service.impl.*;
import com.bestsch.utils.BschUtils;
import com.bestsch.utils.DException;
import com.bestsch.utils.ErrorCode;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.sql.Date;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.MOBILEAPI_PATH+"com/")
@CrossOrigin(origins = {"*"}, allowCredentials = "true")
public class MobiCommonController {
@Autowired
private ICommonService commonService;
@Autowired
private ClassService classService;
@Autowired
private BschBaseOpenApi bschBaseOpenApi;
@Autowired
private PunitStuAnswerService punitStuAnswerService;
@Autowired
private ExplanationService explanationService;
@Autowired
private FeedBackService feedBackService;
@Autowired
private PunitCommunicationService punitCommunicationService;
@Autowired
private BschTextbookService bschTextbookService;
@Autowired
private BschKnowledgeService bschKnowledgeService;
@GetMapping("getTextbookId")
public Integer getTextbookId(HttpServletRequest reques){
String apptype= reques.getHeader("apptype");
String xdCode= reques.getHeader("xdCode");
Optional<BschTextbook> textbookOptional= bschTextbookService.getAllList().stream().filter(s->s.getApptype().toString().equals(apptype)&&s.getSchParagraph().toString().equals(xdCode)).findFirst();
if(textbookOptional.isPresent())
return textbookOptional.get().getId();
else
throw new DException("");
}
// /**
// * 知识树节点--年级学期
// */
// @GetMapping("getGradeTerm")
// public Object getGradeTerm(UserSysRole curRole,Integer gradeId){
// return commonService.getGradeTerm(curRole.getSchId(),curRole.getUserId(),gradeId);
// }
// /**
// * 知识树节点
// */
// @GetMapping("getChapterWrongQuestNumTree")
// public Object getChapterWrongQuestNumTree(UserSysRole curRole,
// String subjectId, Integer gradeId, Integer year, Integer term,
// @RequestParam(required = false) String checkedIds) {
// if (StringUtils.isEmpty(subjectId) || gradeId == null)
// throw new DException(String.valueOf(ErrorCode.WRONG_REQUEST_PARAMS));
// return commonService.getChapterWrongQuestNumTree(curRole.getSchId(), year, term, checkedIds);
// }
// @GetMapping("getChapterWrongQuestNumTree")
// public Object getChapterWrongQuestNumTree(UserSysRole curRole,
// String subjectId,
// @RequestParam(required = false) String checkedIds) {
// if (StringUtils.isEmpty(subjectId))
// throw new DException(String.valueOf(ErrorCode.WRONG_REQUEST_PARAMS));
//
// return commonService.getChapterWrongQuestNumTree(curRole.getSchId(), curRole.getUserId(), subjectId, checkedIds);
// }
/**
* 获取学生的班级、年级、学段信息
*/
@GetMapping("getStuInfo")
public Object getStuInfo(BoaUser authUser, UserSysRole curRole) {
if (curRole.getRoleId() != 3) {
throw new DException("只支持学生用户");
}
if (!Objects.equals(authUser.getId(),curRole.getUserId())) {
authUser = bschBaseOpenApi.getUserInfo(curRole.getUserId());
}
ClassInfo classInfo = classService.getClassInfo(authUser.getGroupId());
if (classInfo == null) {
throw new DException("未获取到班级信息");
}
Optional<Integer> sectionIdOptional = GradeEnum.getSectionIdBySystemGrade(classInfo.getGradeId());
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(classInfo));
jsonObject.put("sectionId", sectionIdOptional.orElse(null));
jsonObject.put("stuId", authUser.getId());
jsonObject.put("stuName", authUser.getName());
jsonObject.put("classId", classInfo.getClassId());
jsonObject.put("gradeId", classInfo.getGradeId());
jsonObject.put("year",classService.getCurYearSemesterDate().getYear());
jsonObject.put("term",classService.getCurYearSemesterDate().getSemester());
return jsonObject;
}
//获取学生的科目
@GetMapping("GetStuSubject")
public List<Subject.Dto> getStuSubject(UserSysRole curRole)
{
Set<Integer> schoolSectionSet = classService.getSchoolSection(curRole.getSchId());
if (BschUtils.isEmpty(schoolSectionSet)) return new ArrayList<>();
List<Subject.Dto> dtoList = new ArrayList<>();
for (SchoolSection.Dto dto: SchoolSection.dtoList())
{
if (!schoolSectionSet.contains(dto.getId())) continue;
dtoList.addAll(dto.getSubjects());
}
return dtoList.stream().distinct().collect(Collectors.toList());
}
@GetMapping("getKnowledgeTree")
public Map<String,Object> getKnowledgeTree(HttpServletRequest reques){
Integer textbookId=this.getTextbookId(reques);
Map<String,Object> result = new HashMap<>();
result.put("tree",bschKnowledgeService.getTreeOfSystemForApi(textbookId));
//getTreeOfSystemForApi(textbookId)
return result;
}
@GetMapping("getSubdirectoryList")
public Object getSubdirectoryList(HttpServletRequest reques,BoaUser authUserWithDept){
int textbookId=getTextbookId(reques);
return bschKnowledgeService.getSubdirectoryList(textbookId);
}
// @GetMapping("getPunitList")
// public Object getPunitList(UserSysRole curRole, String subjectId, Integer gradeId, Integer nodeId,String statusStr, Pageable pageable)
// {
// if(StringUtils.isEmpty(statusStr)) throw new DException("status is null");
// List<Integer> status= Arrays.stream(statusStr.split(","))
// .mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
// return punitStuAnswerService.getPageBySchId(curRole.getSchId(),gradeId,subjectId,nodeId,curRole.getUserId(),status,pageable);
// }
// @GetMapping("getPunitList")
// public Object getPunitList(UserSysRole curRole, String subjectId, Integer gradeId, Integer nodeId,String statusStr, Pageable pageable)
// {
// if(StringUtils.isEmpty(statusStr)) throw new DException("status is null");
// List<Integer> status= Arrays.stream(statusStr.split(","))
// .mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
// return punitStuAnswerService.getPageBySchId(curRole.getSchId(),gradeId,subjectId,nodeId,curRole.getUserId(),status,pageable);
// }
@GetMapping("getStuPunitList")
public Object getStuPunitList(HttpServletRequest reques,UserSysRole curRole, Integer nodeId, String statusStr,String name,Date startDate, Pageable pageable)
{
if(StringUtils.isEmpty(statusStr)) throw new DException("status is null");
List<Integer> status= Arrays.stream(statusStr.split(","))
.mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
int textbookId=getTextbookId(reques);
return punitStuAnswerService.getStuPageByList(textbookId,curRole.getSchId(),nodeId,curRole.getUserId(),startDate,status,pageable);
}
@GetMapping("getPunitNodeInfo")
public Object getPunitNodeInfo(HttpServletRequest reques,UserSysRole curRole,Integer nodeId)
{
int textbookId=getTextbookId(reques);
return punitStuAnswerService.getPunitNodeInfo(textbookId,curRole.getSchId(),curRole.getUserId(),nodeId);
}
@GetMapping("getExplanationList")
public Object getExplanationList(UserSysRole curRole,Integer nodeId,Pageable pageable){
Sort sort = Sort.by(Sort.Order.desc("create_time"));
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(),sort);
return explanationService.getExplanationList(curRole.getSchId(),curRole.getUserId(),nodeId,pageable);
}
// @GetMapping("getQuestionList")
// public Object getQuestionList(UserSysRole curRole,Integer nodeId,Pageable pageable){
// Sort sort = Sort.by(Sort.Order.desc("create_time"));
// pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(),sort);
// return punitStuAnswerService.getQuestionList(curRole.getSchId(),curRole.getUserId(),nodeId,pageable);
// }
@GetMapping("getStuSeeQuestion")
public Map getStuSeeQuestion(UserSysRole curRole,Integer nodeId)
{
return punitStuAnswerService.getStuSeeQuestion(nodeId,curRole.getUserId(),curRole.getSchId());
}
@GetMapping("findStuAnswerRecordAll")
public List<Map> findStuAnswerRecordAll(UserSysRole curRole,Integer nodeId)
{
return punitStuAnswerService.findStuAnswerRecordAll(nodeId,curRole.getUserId(),curRole.getSchId());
}
@PostMapping("saveStuAnswerRecord")
public void saveStuAnswerRecord(HttpServletRequest reques,BoaUser authUser,UserSysRole curRole,SubmitStuQuestionVo model)
{
int textbookId=getTextbookId(reques);
if (curRole.getRoleId() != 3) {
throw new DException("只支持学生用户");
}
if (!Objects.equals(authUser.getId(),curRole.getUserId())) {
authUser = bschBaseOpenApi.getUserInfo(curRole.getUserId());
}
ClassInfo classInfo = classService.getClassInfo(authUser.getGroupId());
if (classInfo == null) {
throw new DException("未获取到班级信息");
}
model.setTextbookId(textbookId);
YearSemester curYear = classService.getCurYearSemesterDate();
punitStuAnswerService.saveStuAnswerRecord(model,authUser.getId(),authUser.getName(),authUser.getGroupId(),curYear.getYear(),curYear.getSemester(),curRole.getSchId());
}
@PostMapping("correctStuAnswer")
public void correctStuAnswer(BoaUser authUser,UserSysRole curRole,Integer nodeId)
{
punitStuAnswerService.correctStuAnswer(authUser.getId(),curRole.getSchId(),nodeId);
}
@GetMapping("getCommunicationList")
public Object getCommunicationList(UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "classId", required = true) Integer classId)
{
return punitCommunicationService.getClassCommunicationList(nodeId,classId,curRole.getSchId());
}
@PostMapping("saveCommunication")
public void saveCommunication(HttpServletRequest reques,BoaUser authUser, UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "classId", required = true) Integer classId,
@RequestParam(value = "id", required = true) Integer id,
@RequestParam(value = "cId", required = true) Integer cId,
@RequestParam(value = "content", required = true) String content
)
{
if(StringUtils.isEmpty(content)) throw new DException("内容为空!");
if(content.length()>500) throw new DException("字符串超出限定长度(500)!");
if (!Objects.equals(authUser.getId(),curRole.getUserId())) {
authUser = bschBaseOpenApi.getUserInfo(curRole.getUserId());
}
if(id>0)
{
Optional<PunitCommunication> punitCommunicationOptional= punitCommunicationService.findOne(id,curRole.getUserId(),curRole.getSchId());
if(!punitCommunicationOptional.isPresent()) throw new DException("无权限!");
}
YearSemester years= classService.getCurYearSemesterDate();
int textbookId=getTextbookId(reques);
PunitCommunication pction=new PunitCommunication();
pction.setId(id);
pction.setYear(years.getYear());
pction.setTerm(years.getSemester());
pction.setCId(cId);
pction.setTextbookId(textbookId);
pction.setNodeId(nodeId);
pction.setClassId(classId);
pction.setContent(content);
pction.setCUserId(curRole.getUserId());
pction.setUserName(authUser.getName());
pction.setUserPhoto(authUser.getProfilePicture());
pction.setSchId(curRole.getSchId());
pction.setRole(curRole.getRoleId()==3?3:1);
pction.setCDate(new java.util.Date());
punitCommunicationService.save(pction);
}
/**
* 学生创建问题反馈
*/
@PostMapping("addFeedBack")
public void addFeedBack(@RequestBody @Validated FeedBack feedBack, BoaUser authUser, @ModelAttribute UserSysRole curRole) {
int userId = curRole.getUserId();
feedBack.setUserId(userId);
feedBackService.addFeedBack(feedBack);
}
}
@@ -0,0 +1,231 @@
package com.bestsch.classicalchinese.controller.mobiapi;
import com.alibaba.fastjson.JSONArray;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.config.FileConfig;
import com.bestsch.classicalchinese.entity.UploadFile;
import com.bestsch.classicalchinese.enums.FileType;
import com.bestsch.classicalchinese.model.FileMessage;
import com.bestsch.classicalchinese.service.IExplanationService;
import com.bestsch.classicalchinese.service.com.UploadFileService;
import com.bestsch.classicalchinese.utils.FileUtil;
import com.bestsch.classicalchinese.utils.VideoTransCodeUtil;
import com.bestsch.utils.BschUtils;
import com.bestsch.utils.DException;
import com.bestsch.utils.ErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;
//文件管理
@RestController
@RequestMapping(Config.MOBILEAPI_PATH+"file/")
@CrossOrigin(origins = {"*"}, allowCredentials = "true")
@Slf4j
public class MobiFileController
{
@Autowired
private IExplanationService explanationService;
@Autowired
private UploadFileService uploadFileService;
@Autowired
private FileConfig fileConfig;
@PostMapping(value = "uploadFile")
public Object save(@RequestParam(value = "file", required = false) MultipartFile[] files)
{
String pathName = "optionFile/";
List<UploadFile> uploadFiles = uploadFile(files, pathName);
if (BschUtils.isEmpty(uploadFiles)) return new ArrayList<>();
List<UploadFile> res = uploadFileService.save(uploadFiles);
getWebFileName(res, pathName);
return res;
}
//base64数据图片上传
@PostMapping(value = "uploadFileByBase64")
public Object save(String base64, @PathVariable String platform)
{
JSONArray jsonArray = JSONArray.parseArray(base64);
List<UploadFile> fileList = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++)
{
String base64Str = jsonArray.getString(i);
int inx = base64Str.indexOf(",");
base64Str = base64Str.substring(inx + 1);
byte[] bytes = Base64.getDecoder().decode(base64Str);
UploadFile uploadFile = new UploadFile();
//todo 这里要用字符串头里的信息来确定文件类型
uploadFile.setRealName(".jpg");
uploadFile.setBytes(bytes);
fileList.add(uploadFile);
}
if (BschUtils.isEmpty(fileList)) return new ArrayList<>();
String pathName = "optionFile/";
saveUploadFile(fileList, pathName);
for (UploadFile uploadFile: fileList)
uploadFile.setFileUrl(fileConfig.getWebPath() + pathName + uploadFile.getRealName());
return fileList;
}
@PostMapping("deleteById")
public void findById(@RequestParam("id") String id)
{
if (StringUtils.isEmpty(id) || !StringUtils.isNumeric(id))
throw new DException(String.valueOf(ErrorCode.WRONG_REQUEST_PARAMS));
uploadFileService.delete(Integer.parseInt(id));
}
/**
* 上传文件
*/
@PostMapping("uploadFile1")
public Map<String, String> uploadFile1(MultipartFile file) throws IOException {
if (file == null || file.isEmpty()) {
throw new DException("上传文件不能为空");
}
String originalFilename = file.getOriginalFilename();
String fileType = originalFilename.substring(originalFilename.lastIndexOf("."));
String fileName = UUID.randomUUID().toString() + fileType;
String filePath = fileConfig.getPath() + fileName;
String webPath = fileConfig.getWebPath() + fileName;
Files.copy(file.getInputStream(), Paths.get(filePath), StandardCopyOption.REPLACE_EXISTING);
Map<String, String> map = new HashMap<>();
map.put("fileName", fileName);
map.put("webPath", webPath);
return map;
}
@GetMapping("mkdir")
public void mkdir(String dirName) {
String filePath = fileConfig.getPath() + dirName;
File file = new File(filePath);
file.mkdirs();
}
public List<UploadFile> getWebFileName(List<UploadFile> uploadFiles, String path) {
if (uploadFiles!=null) {
for (UploadFile file : uploadFiles) {
String videoPicture = file.getVideoPicture();
String fileUrl = file.getFileUrl();
if (StringUtils.isNotEmpty(videoPicture))
file.setVideoPicture(fileConfig.getWebPath() + path + videoPicture);
if (StringUtils.isNotEmpty(fileUrl)) file.setFileUrl(fileConfig.getWebPath() + path + fileUrl);
}
}
return uploadFiles;
}
//按数据列表存储
protected void saveUploadFile(List<UploadFile> files, String pathName)
{
if (BschUtils.isEmpty(files)) return;
String path = fileConfig.getPath() + pathName;
for (UploadFile uploadFile: files)
{
String ext = "." + FileUtil.getExtensionName(uploadFile.getRealName());
String name = FileUtil.randName(path, ext);
String filePath = path + name;
FileUtil.save( new ByteArrayInputStream(uploadFile.getBytes()), filePath);
uploadFile.setRealName(name);
}
}
protected List<UploadFile> uploadFile(MultipartFile[] files, String pathName)
{
List<UploadFile> uploadFiles = new ArrayList<>();
try
{
if (files != null && files.length > 0)
{
synchronized (this)
{
for (MultipartFile file : files)
{
if (!file.isEmpty())
{
String realName = file.getOriginalFilename();
Integer fileTypeId = FileUtil.getFileType(file);
String path = fileConfig.getPath() + pathName;
UploadFile uploadFile = new UploadFile();
String fileName = "";
String fileSize = "";
if (fileTypeId.equals(FileType.VIDEO_TYPE.getId()) || fileTypeId.equals(FileType.AUDIO_TYPE.getId()))
{
FileMessage message = null;
try
{
message = VideoTransCodeUtil.VideoTransCode(path, file);
}
catch (Exception e)
{
log.error(e.getMessage());
}
fileName = message.getFileName();
fileSize = message.getSize();
uploadFile.setVideoPicture(message.getPictureName());
uploadFile.setVideoTime(message.getVideoSize());
}
else
{
fileName = FileUtil.uploadImg(file, path);
fileSize = FileUtil.getSize((int) file.getSize());
}
uploadFile.setFileUrl(fileName);
uploadFile.setRealName(realName);
uploadFile.setFileType(fileTypeId);
uploadFile.setFileSize(fileSize);
uploadFiles.add(uploadFile);
}
}
}
}
}
catch (Exception e)
{
log.error(e.getMessage());
}
return uploadFiles;
}
@GetMapping("pdfPreview")
public Object pdfPreview(UserSysRole curRole, Integer id){
return explanationService.pdfPreview(curRole.getSchId(),id);
}
}
@@ -0,0 +1,250 @@
package com.bestsch.classicalchinese.controller.mobiapi;
import com.bestsch.classicalchinese.entity.BschTextbook;
import com.bestsch.classicalchinese.model.YearSemester;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.BschBaseOpenApi;
import com.bestsch.openapi.UserSysRole;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.entity.PunitCommunication;
import com.bestsch.classicalchinese.service.ICommonService;
import com.bestsch.classicalchinese.service.com.ClassService;
import com.bestsch.classicalchinese.service.impl.*;
import com.bestsch.utils.DException;
import com.bestsch.utils.ErrorCode;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
@RestController
@RequestMapping(Config.MOBILEAPI_PATH+"tea/")
@CrossOrigin(origins = {"*"}, allowCredentials = "true")
public class MobiTeaAreaController {
@Autowired
private ICommonService commonService;
@Autowired
private ClassService classService;
@Autowired
private BschBaseOpenApi bschBaseOpenApi;
@Autowired
private PunitStuAnswerService punitStuAnswerService;
@Autowired
private ExplanationService explanationService;
@Autowired
private FeedBackService feedBackService;
@Autowired
private PunitCommunicationService punitCommunicationService;
@Autowired
private PunitLeadlearningService punitLeadlearningService;
@Autowired
private StatisticsService statisticsService;
@Autowired
private BschTextbookService bschTextbookService;
@Autowired
private BschKnowledgeService bschKnowledgeService;
@GetMapping("getTextbookId")
public Integer getTextbookId(HttpServletRequest reques){
String apptype= reques.getHeader("apptype");
String xdCode= reques.getHeader("xdCode");
Optional<BschTextbook> textbookOptional= bschTextbookService.getAllList().stream().filter(s->s.getApptype().toString().equals(apptype)&&s.getSchParagraph().toString().equals(xdCode)).findFirst();
if(textbookOptional.isPresent())
return textbookOptional.get().getId();
else
throw new DException("");
}
@GetMapping("getKnowledgeTree")
public Map<String,Object> getKnowledgeTree(HttpServletRequest reques){
Integer textbookId=this.getTextbookId(reques);
Map<String,Object> result = new HashMap<>();
result.put("tree",bschKnowledgeService.getTreeOfSystemForApi(textbookId));
//getTreeOfSystemForApi(textbookId)
return result;
}
@GetMapping("getSubdirectoryList")
public Object getSubdirectoryList(HttpServletRequest reques,BoaUser authUserWithDept){
int textbookId=getTextbookId(reques);
return bschKnowledgeService.getSubdirectoryList(textbookId);
}
/**
* 知识树节点--年级学期
*/
// @GetMapping("getGradeTerm")
// public Object getGradeTerm(UserSysRole curRole,Integer gradeId){
// return commonService.getGradeTerm(curRole.getSchId(),curRole.getUserId(),gradeId);
// }
//
// /**
// * 知识树节点
// */
// @GetMapping("getChapterWrongQuestNumTree")
// public Object getChapterWrongQuestNumTree(UserSysRole curRole,
// String subjectId, Integer gradeId, Integer year, Integer term,
// @RequestParam(required = false) String checkedIds) {
// if (StringUtils.isEmpty(subjectId) || gradeId == null)
// throw new DException(String.valueOf(ErrorCode.WRONG_REQUEST_PARAMS));
//
// return commonService.getChapterWrongQuestNumTree(curRole.getSchId(), year, term, checkedIds);
// }
@GetMapping("GetTeaSubject")
public Object GetTeaSubject(UserSysRole curRole)
{
if (curRole.getRoleId() == 3) {
throw new DException("只支持教师用户");
}
return classService.getTeaSubject(curRole.getSchId(),curRole.getRoleId(),curRole.getUserId());
}
@GetMapping("GetTeaGrade")
public Object GetTeaGrade(UserSysRole curRole,String subjectId)
{
if (curRole.getRoleId() == 3) {
throw new DException("只支持教师用户");
}
return classService.getTeaGrade(curRole.getSchId(),curRole.getRoleId(),curRole.getUserId(),subjectId);
}
@GetMapping("GetTeaClasses")
public Object getTeaClassesWithStu(UserSysRole curRole, BoaUser authUserWithDept)
{
if (curRole.getRoleId() == 3) {
throw new DException("只支持教师用户");
}
Integer schId = curRole.getSchId();
List<Map<String, Object>> teaClasses = classService.getTeaClasses(curRole.getRoleId(), curRole.getUserId(), schId);
return teaClasses;
}
@GetMapping("getTeaPunitList")
public Object getTeaPunitList(HttpServletRequest reques,UserSysRole curRole,Integer classId, Integer nodeId, Pageable pageable)
{
Integer textbookId=this.getTextbookId(reques);
return punitLeadlearningService.getTeaPunitList(textbookId,curRole.getRoleId(), curRole.getUserId(),nodeId,classId,curRole.getSchId(),pageable);
}
@GetMapping("getPunitNodeInfo")
public Object getPunitNodeInfo(HttpServletRequest reques,UserSysRole curRole,Integer nodeId)
{
int textbookId=getTextbookId(reques);
return punitStuAnswerService.getPunitNodeInfo(textbookId,curRole.getSchId(),curRole.getUserId(),nodeId);
}
@GetMapping("getExplanationList")
public Object getExplanationList(UserSysRole curRole,Integer nodeId,Pageable pageable){
Sort sort = Sort.by(Sort.Order.desc("create_time"));
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(),sort);
return explanationService.getExplanationList(curRole.getSchId(),curRole.getUserId(),nodeId,pageable);
}
@PostMapping("saveCommunication")
public void saveCommunication(HttpServletRequest reques,BoaUser authUser, UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "gradeId", required = true) Integer gradeId,
@RequestParam(value = "classId", required = true) Integer classId,
@RequestParam(value = "subjectId", required = true) String subjectId,
@RequestParam(value = "id", required = true) Integer id,
@RequestParam(value = "cId", required = true) Integer cId,
@RequestParam(value = "content", required = true) String content
)
{
if(StringUtils.isEmpty(content)) throw new DException("内容为空!");
if(content.length()>500) throw new DException("字符串超出限定长度(500)!");
if (!Objects.equals(authUser.getId(),curRole.getUserId())) {
authUser = bschBaseOpenApi.getUserInfo(curRole.getUserId());
}
if(id>0)
{
Optional<PunitCommunication> punitCommunicationOptional= punitCommunicationService.findOne(id,curRole.getUserId(),curRole.getSchId());
if(!punitCommunicationOptional.isPresent()) throw new DException("无权限!");
}
YearSemester yreas= classService.getCurYearSemesterDate();
int textbookId=getTextbookId(reques);
PunitCommunication pction=new PunitCommunication();
pction.setId(id);
pction.setYear(yreas.getYear());
pction.setTerm(yreas.getSemester());
pction.setCId(cId);
pction.setTextbookId(textbookId);
pction.setNodeId(nodeId);
pction.setClassId(classId);
pction.setContent(content);
pction.setCUserId(curRole.getUserId());
pction.setUserName(authUser.getName());
pction.setUserPhoto(authUser.getProfilePicture());
pction.setSchId(curRole.getSchId());
pction.setRole(curRole.getRoleId()==3?3:1);
pction.setCDate(new java.util.Date());
punitCommunicationService.save(pction);
}
@GetMapping("getCommunicationList")
public Object getCommunicationList(UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "classId", required = true) Integer classId)
{
return punitCommunicationService.getClassCommunicationList(nodeId,classId,curRole.getSchId());
}
@GetMapping("getCommunicationClassStu")
public List<Map> getClassStuList(UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "gradeId", required = true) Integer gradeId,
@RequestParam(value = "subjectId", required = true) String subjectId,
@RequestParam(value = "classId", required = true) Integer classId){
return punitCommunicationService.getCommunicationClassStu(curRole.getSchId(),classId,nodeId);
}
@GetMapping("getStuCommunicationList")
public Object getStuCommunicationList(UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "stuId", required = true) Integer stuId)
{
return punitCommunicationService.getCommunicationList(nodeId,stuId,curRole.getSchId());
}
@GetMapping("getClassWcqk")
public Map getClassWcqk(UserSysRole curRole,
@RequestParam(value = "nodeId", required = true) Integer nodeId,
@RequestParam(value = "classId", required = true) Integer classId
) {
return statisticsService.getClassWcqk(curRole.getSchId(),nodeId,classId);
}
}
@@ -0,0 +1,78 @@
package com.bestsch.classicalchinese.controller.oapi;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.model.AiAsk;
import com.bestsch.classicalchinese.service.com.HyAIService;
import com.bestsch.classicalchinese.utils.OtherUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(Config.OAPI+"/hyai/")
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class HyAIController {
@Autowired
private HyAIService hyaiService;
@PostMapping("askQuestion")
public Map askQuestion(@Valid @RequestBody AiAsk aiAsk) {
if (StringUtils.isEmpty(aiAsk.getPrompt())) throw new NullPointerException("请输入你的问题");
long startTime = System.currentTimeMillis();
Map map = new HashMap();
String json = hyaiService.send(aiAsk);
map.put("body", OtherUtil.convertJsonToMapList(json));
long endTime = System.currentTimeMillis();
map.put("time", (endTime - startTime) / 1000 + "s");
return map;
}
@PostMapping("askQuestions")
public Map askQuestions(@Valid @RequestBody AiAsk aiAsk) {
//aiAsk.setModel("deepseek-r1:14b");
//qwen2.5:latest
if (StringUtils.isEmpty(aiAsk.getPrompt())) throw new NullPointerException("请输入你的问题");
long startTime = System.currentTimeMillis();
Map map = new HashMap();
String json = hyaiService.send(aiAsk);
List<Map<String, Object>> list = OtherUtil.convertJsonToMapList(json);
map.put("body", hyaiService.getQuestionList(list));
long endTime = System.currentTimeMillis();
map.put("time", (endTime - startTime) / 1000 + "s");
return map;
}
@PostMapping("askLeadlearning")
public Map askLeadlearning(@Valid @RequestBody AiAsk aiAsk) {
if (StringUtils.isEmpty(aiAsk.getPrompt())) throw new NullPointerException("请输入你的问题");
long startTime = System.currentTimeMillis();
Map map = new HashMap();
map.put("body", hyaiService.send(aiAsk));
long endTime = System.currentTimeMillis();
map.put("time", (endTime - startTime) / 1000 + "s");
return map;
}
@PostMapping("askCommunication")
public Map askCommunication(@Valid @RequestBody AiAsk aiAsk) {
if (StringUtils.isEmpty(aiAsk.getPrompt())) throw new NullPointerException("请输入你的问题");
long startTime = System.currentTimeMillis();
Map map = new HashMap();
map.put("body", hyaiService.send(aiAsk));
long endTime = System.currentTimeMillis();
map.put("time", (endTime - startTime) / 1000 + "s");
return map;
}
}
@@ -0,0 +1,133 @@
package com.bestsch.classicalchinese.controller.oapi;
import com.alibaba.fastjson.JSON;
import com.bestsch.openapi.BoaUser;
import com.bestsch.openapi.BschBaseOpenApi;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.entity.PunitLeadlearning;
import com.bestsch.classicalchinese.entity.PunitQuestion;
import com.bestsch.classicalchinese.entity.PunitStuAnswer;
import com.bestsch.classicalchinese.entity.VideoExplanation;
import com.bestsch.classicalchinese.model.YearSemester;
import com.bestsch.classicalchinese.model.vo.PunitFormVo;
import com.bestsch.classicalchinese.service.IExplanationService;
import com.bestsch.classicalchinese.service.com.ClassService;
import com.bestsch.classicalchinese.service.impl.PunitLeadlearningService;
import com.bestsch.classicalchinese.service.impl.PunitQuestionService;
import com.bestsch.classicalchinese.service.impl.PunitStuAnswerService;
import com.bestsch.classicalchinese.utils.ModelMapperUtil;
import com.bestsch.classicalchinese.utils.ValidationUtil;
import org.apache.commons.collections.ListUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotBlank;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.OAPI)
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class OapiController {
@Autowired
private PunitLeadlearningService punitLeadlearningService;
@Autowired
private IExplanationService explanationService;
@Autowired
private PunitQuestionService punitQuestionService;
@Autowired
private PunitStuAnswerService punitStuAnswerService;
@Autowired
private ClassService classService;
@Autowired
private BschBaseOpenApi bschBaseOpenApi;
@PostMapping("batchPunitLeadlearning")
public void batchPunitLeadlearning(@RequestParam(value = "schId", required = true) Integer schId,
@RequestBody @NotBlank String jsonData) {
List<PunitFormVo> punitList = JSON.parseArray(jsonData, PunitFormVo.class);
List<PunitLeadlearning> punitLSchList = punitLeadlearningService.findSchAll(schId);
List<PunitQuestion> questionSchList= punitQuestionService.findSchAll(schId);
Date date=new Date();
List<PunitLeadlearning> saveLeadlearningEntitys=new ArrayList<>();
List<PunitQuestion> saveQuestionEntitys=new ArrayList<>();
List<PunitQuestion> delQuestionAllList=new ArrayList<>();
for (PunitFormVo punit:punitList)
{
Optional<PunitLeadlearning> punitOpt=punitLSchList.stream().filter(s->s.getNodeId().equals(punit.getNodeId())).findFirst();
ValidationUtil.validate(punit);
PunitLeadlearning model=ModelMapperUtil.map(punit,PunitLeadlearning.class);
if(punitOpt.isPresent()) model.setId(punitOpt.get().getId());
model.setCDate(date);
model.setSchId(schId);
model.setCUserId(10000);
saveLeadlearningEntitys.add(model);
List<PunitQuestion> questions=punit.getQuestionList();
if(questions!=null){
//添加修改删除
for (PunitQuestion qtem:questions) {
ValidationUtil.validate(qtem);
if(qtem.getId()==null) qtem.setId(0);
qtem.setNodeId(punit.getNodeId());
}
//当前节点的题目
List<PunitQuestion> questionList=questionSchList.stream().filter(s->s.getNodeId().equals(punit.getNodeId())).collect(Collectors.toList());
List<Integer> dbquestionIds=questionList.stream().filter(s->s.getId() != null &&s.getId()>0).map(PunitQuestion::getId).collect(Collectors.toList());
List<Integer> jsonQuestionIds=questions.stream().filter(s->s.getId() != null &&s.getId()>0).map(PunitQuestion::getId).collect(Collectors.toList());
for (PunitQuestion qtem:questions) {
Optional<PunitQuestion> punitQuestionOpt=questionList.stream().filter(s->s.getId().equals(qtem.getId())).findFirst();
PunitQuestion eniity=new PunitQuestion();
//数据库赋值(用户,时间,学校)
if(punitQuestionOpt.isPresent()) eniity=punitQuestionOpt.get();
eniity= ModelMapperUtil.map(qtem,PunitQuestion.class);//编辑或添加赋值
eniity.setCDate(date);
eniity.setSchId(schId);
eniity.setCUserId(10000);
saveQuestionEntitys.add(eniity);
}
List<Integer> delquestionIds= ListUtils.subtract(dbquestionIds,jsonQuestionIds);
if(delquestionIds.stream().count()>0)
{
List<PunitQuestion> delQuestionList=questionList.stream().filter(s->delquestionIds.contains(s.getId())).collect(Collectors.toList());
delQuestionAllList.addAll(delQuestionList);
}
}
}
if(saveLeadlearningEntitys.stream().count()>0)
punitLeadlearningService.saveAll(saveLeadlearningEntitys);
if(delQuestionAllList.stream().count()>0)
punitQuestionService.deleteAll(delQuestionAllList);
if(saveQuestionEntitys.stream().count()>0)
punitQuestionService.saveAll(saveQuestionEntitys);
}
@PostMapping("batchPunitFiles")
public void batchPunitFiles(@RequestParam(value = "schId", required = true) Integer schId,
@RequestBody @NotBlank String jsonData)
{
List<VideoExplanation> list=JSON.parseArray(jsonData, VideoExplanation.class);
explanationService.saveExplanation(schId,10000, list);
}
}
@@ -0,0 +1,32 @@
package com.bestsch.classicalchinese.controller.oapi;
import com.bestsch.classicalchinese.config.Config;
import com.bestsch.classicalchinese.service.com.UploadFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(Config.OAPI)
@CrossOrigin(origins = {"*", "*"}, allowCredentials = "true")
public class UploadFileController {
@Autowired
private UploadFileService uploadFileService;
@PostMapping("addFile")
public List<Map> addFile(MultipartFile[] file, HttpServletRequest request) {
return uploadFileService.addFile(file, request);
}
}
@@ -0,0 +1,29 @@
package com.bestsch.classicalchinese.entity;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Data
@MappedSuperclass
public abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = Update.class)
private Integer id;
@Column(name = "sch_id")
private Integer schId;
@Column(name = "c_date")
private Date cDate;
@Column(name = "c_user_id")
private Integer cUserId;
public @interface Update {}
}
@@ -0,0 +1,57 @@
package com.bestsch.classicalchinese.entity;
import lombok.Data;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@Data
@Entity
@Table(name = "bsch_knowledge")
public class BschKnowledge {
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = BaseEntity.Update.class)
private Integer id;
/**
* 节点名称
*/
@Column(name = "name", nullable = false)
private String name;
/**
* 父节点
*/
@Column(name = "parent_id", nullable = false)
private Integer parentId = 0;
/**
* 顶层节点为空,由父节点path+父id+逗号组成
*/
@Column(name = "path")
private String path = "";
/**
* 层级 从1开始
*/
@Column(name = "level", nullable = false)
private Integer level = 1;
/**
* 排序码
*/
@Column(name = "order_code")
private Integer orderCode = 0;
@Transient
private List<BschKnowledge> child;
}
@@ -0,0 +1,47 @@
package com.bestsch.classicalchinese.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "bsch_leadlearning")
public class BschLeadlearning {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = BaseEntity.Update.class)
private Integer id;
@Column(name = "c_date")
private Date cDate;
@Column(name = "c_user_id")
private Integer cUserId;
@Column(name = "textbook_id")
private Integer textbookId;
@Column(name = "node_id")
private Integer nodeId;
@Column(name = "content",length = 8000)
private String content;
@Column(name = "path")
private String path;
public @interface Update {
}
}
@@ -0,0 +1,90 @@
package com.bestsch.classicalchinese.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
/**
* @program: UserProfile
* @description: 系统应用
* @author: chenx
* @create: 2024-05-27 15:23
**/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "bsch_question")
public class BschQuestion {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = Update.class)
private Integer id;
@Column(name = "textbook_id")
private Integer textbookId;
@Column(name = "node_id")
private Integer nodeId;
//0AI 1我的 2校本 3题库
@Column(name = "bank_type")
private Integer bankType;
@Column(name = "question_type_id")
private Integer questionTypeId;
/**
* 困难程度
*/
@Column(name = "difficult_level_id", columnDefinition = "tinyint default 4 comment '难度'")
private Integer difficultLevelId;
@Column(name = "name", columnDefinition = "text comment '' ")
private String name;
/**
* 选项
*/
@Size(max = 2000, message = "题目选项长度超出限制(2000字符)!")
@Column(name = "config", columnDefinition = "text comment '' ")
private String config;
@Size(max = 4000, message = "题目选答案长度超出限制(4000字符)!")
@Column(name = "answer",length = 4000)
private String answer;
@Size(max = 6000, message = "题目解析长度超出限制(6000字符)!")
@Column(name = "solve",length = 6000)
private String solve;
@Size(max = 200)
@Column(name = "solve_question_files",columnDefinition = "text comment '' ")
private String solveQuestionFiles;
@Column(name = "score")
private Double score;
@Column(name = "p_id")
private Integer pId;//综合题需要
private Integer sort=999;
@Column(name = "c_date")
private Date cDate;
@Column(name = "c_user_id")
private Integer cUserId;
public @interface Update {
}
}
@@ -0,0 +1,88 @@
package com.bestsch.classicalchinese.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import static javax.persistence.GenerationType.IDENTITY;
/**
* @ Description : java类作用描述
* @ Author : cls
* @ CreateDate : 2020/2/21 10:13
* @ Company : bestsch
*/
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bsch_textbook")
@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
public class BschTextbook implements Serializable {
/**
* id
*/
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
/**
* name
*/
@Column(name = "name")
private String name;
/**
* apptype
*/
@Column(name = "apptype")
private Integer apptype;
/**
* grade
*/
@Column(name = "sch_paragraph")
private Integer SchParagraph;
/**
* 学科名称
*/
@Column(name = "subject_name")
private String subjectName;
/**
* out_time
*/
@Column(name = "out_time")
private String outTime;
/**
* tree_id
*/
@Column(name = "tree_id")
private Integer treeId;
/**
* 学期 0上学期 1下学期
*/
@Column(name = "semester")
private Integer semester;
/**
* 封面图
*/
//@Column(name = "cover_image")
//private String coverImage;
// @Column(name = "c_date")
// private Date cDate;
//
// @Column(name = "c_user_id")
// private Integer cUserId;
}
@@ -0,0 +1,95 @@
package com.bestsch.classicalchinese.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
import static javax.persistence.GenerationType.IDENTITY;
/**
* 视频讲解
*/
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bsch_video_explanation")
public class BschVideoExplanation {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
@Column(name = "textbook_id")
private Integer textbookId;
@Column(name = "node_id", nullable = false)
private Integer nodeId;
@Column(name = "path")
private String path;
/**
* 资源名称
*/
@Column(name = "name", nullable = false)
private String name;
/**
* 资源大小,单位byte
*/
@Column(name = "size", nullable = false)
private String size = "0";
/**
* 时长,单位毫秒。对视频/音频资源有效
*/
@Column(name = "duration")
private Long duration;
/**
* 资源后缀名
*/
@Column(name = "suffix_name", nullable = false)
private String suffixName;
/**
* 文件路径
*/
@Column(name = "file_url", nullable = false)
private String fileUrl;
/**
* 类型
* 1:本地上传;2:从资源库选择;
*/
@Column(name = "type", nullable = false)
private Integer type;
/**
* 是否同步到资源
* 0:否;1:是;
*/
@Column(name = "is_sync_resource", nullable = false)
private Integer isSyncResource = 0;
/**
* 创建人
*/
@Column(name = "create_user", nullable = false)
private Integer createUser;
/**
* 创建时间
*/
@Column(name = "create_time", nullable = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
public @interface Update {}
}
@@ -0,0 +1,65 @@
package com.bestsch.classicalchinese.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
/**
* @author CHY
* @date 2022/9/2 10:03
* @description 考生反馈
*/
@Data
@Entity
@Table(name = "feed_back")
public class FeedBack {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "textbook_id")
private Integer textbookId;
/**
* 测验id
*/
@NotNull
@Column(name = "node_id")
private Integer nodeId;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_date_time")
private LocalDateTime createDateTime;
/**
* 返回内容
*/
@NotBlank
@Length(max = 500)
@Column(name = "content", length = 500)
private String content;
/**
* 学生作业
*/
@Column(name = "stu_punit_id")
private Integer stuPunitId;
/**
* 反馈的题目
*/
@Column(name = "question_id")
private Integer questionId;
@Transient
private Integer userId;
}
@@ -0,0 +1,63 @@
package com.bestsch.classicalchinese.entity;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author CHY
* @date 2022/9/2 10:03
* @description 考生反馈
*/
@Data
@Entity
@Table(name = "punit_communication")
public class PunitCommunication extends BaseEntity {
@Column(name = "year")
private Integer year;
@Column(name = "term")
private Integer term;
/**
* 交流id
*/
@Column(name = "c_id")
private Integer cId;
@NotBlank
@Length(max = 50)
@Column(name = "user_name", length = 50)
private String userName;
@NotBlank
@Length(max = 200)
@Column(name = "user_photo", length = 200)
private String userPhoto;
@Column(name = "textbook_id")
private Integer textbookId;
/**
* 测验id
*/
@NotNull
@Column(name = "node_id")
private Integer nodeId;
@NotNull
@Column(name = "class_id")
private Integer classId;
/**
* 内容
*/
@NotBlank
@Length(max = 500)
@Column(name = "content", length = 500)
private String content;
private Integer role;
}
@@ -0,0 +1,46 @@
package com.bestsch.classicalchinese.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "punit_leadlearning")
public class PunitLeadlearning extends BaseEntity {
@Column(name = "textbook_id")
private Integer textbookId;
@Column(name = "node_id")
private Integer nodeId;
@Column(name = "name",length = 200)
private String name;
//PunitHistoryLeadlearning历史导学content内容8000
@Column(name = "content",length = 8000)
private String content;
@Column(name = "path")
private String path;
/**
* 显示答案解析
* 0:不显示;1:显示;
*/
@Column(name = "is_show_answer", nullable = false)
private Integer isShowAnswer=0;
public @interface Update {
}
}
@@ -0,0 +1,39 @@
package com.bestsch.classicalchinese.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* @program: UserProfile
* @description: 系统应用
* @author: chenx
* @create: 2024-05-27 15:23
**/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "punit_question")
public class PunitQuestion extends Question {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = Update.class)
private Integer id;
@Column(name = "c_date")
private Date cDate;
@Column(name = "c_user_id")
private Integer cUserId;
public @interface Update {
}
}
@@ -0,0 +1,78 @@
package com.bestsch.classicalchinese.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "punit_stu_answer")
public class PunitStuAnswer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = Update.class)
private Integer id;
//根据学年学期查询预习单(备份版本号)
private Integer year;
private Integer term;
@Column(name = "textbook_id")
private Integer textbookId;
@Column(name = "node_id")
private Integer nodeId;
@Column(name = "question_id")
private Integer questionId;
@Size(max=6000,message = "答案内容超出限制(6000字符)!")
@Column(name = "stu_analysis",length = 6000)
private String stuAnalysis;
@Column(name = "stu_id")
private Integer stuId;
@Column(name = "stu_name",length = 50)
private String stuName;
@Column(name = "stu_grade_id")
private Integer stuGradeId;
@Column(name = "class_id")
private Integer classId;
@Column(name = "gclass_name",length = 50)
private String gClassName;
@Column(name = "score")
private Double score;
@Column(name = "status")
private Integer status;////题目正确 1正确 2错误 3半对
@Column(name = "tk_status", columnDefinition = "text comment '' ")
private String tkStatus;//填空题每个填空的答案是否正确
@Column(name = "is_review", length = 8, columnDefinition = "tinyint default 0 comment ' 0-未批 1-已批 2-订正'")
private Integer isReview;//题目是否批阅 ' 0-未批 1-已批 2-订正'
@Column(name = "c_date")
private Date cDate;
@Column(name = "sch_id")
private Integer schId;
public @interface Update {
}
}
@@ -0,0 +1,28 @@
package com.bestsch.classicalchinese.entity;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
@Entity
@Table(name = "punit_ziyuantreetea")
public class PunitZiYuanTreeTea extends BaseEntity {
@Column(name = "textbook_id")
private Integer textbookId;
@NotNull
@Column(name = "node_id")
private Integer nodeId;
@Column(name = "tea_id")
private Integer teaId;
}
@@ -0,0 +1,69 @@
package com.bestsch.classicalchinese.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.Size;
@AllArgsConstructor
@NoArgsConstructor
@Data
@MappedSuperclass
public abstract class Question extends BaseEntity {
@Column(name = "textbook_id")
private Integer textbookId;
@Column(name = "node_id")
private Integer nodeId;
//0AI 1我的 2校本 3题库
@Column(name = "bank_type")
private Integer bankType;
@Column(name = "question_type_id")
private Integer questionTypeId;
/**
* 困难程度
*/
@Column(name = "difficult_level_id", columnDefinition = "tinyint default 4 comment '难度'")
private Integer difficultLevelId;
@Column(name = "name", columnDefinition = "text comment '' ")
private String name;
/**
* 选项
*/
@Size(max = 2000, message = "题目选项长度超出限制(2000字符)!")
@Column(name = "config", columnDefinition = "text comment '' ")
private String config;
@Size(max = 4000, message = "题目选答案长度超出限制(4000字符)!")
@Column(name = "answer",length = 4000)
private String answer;
@Size(max = 6000, message = "题目解析长度超出限制(6000字符)!")
@Column(name = "solve",length = 6000)
private String solve;
@Size(max = 200)
@Column(name = "solve_question_files",columnDefinition = "text comment '' ")
private String solveQuestionFiles;
@Column(name = "score")
private Double score;
@Column(name = "p_id")
private Integer pId;//综合题需要
private Integer sort=999;
}
@@ -0,0 +1,74 @@
package com.bestsch.classicalchinese.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
/**
*文件
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "upload_file")
public class UploadFile {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@NotNull(groups = UploadFile.Update.class)
private Integer id;
// @Column(name="fileName")
// private String fileName;
// @Column(name = "file_type_id",columnDefinition = "tinyint default 1 comment ' 1-图片 2-视频 3-音频'")
// private Integer fileTypeId;
@Column(name = "real_name")
private String realName;//文件真实名
@Column(name = "file_url")
private String fileUrl;
@Column(name = "file_size")
private String fileSize;
@Column(name = "file_type")
private Integer fileType;
// 视屏中中间截图,包含时间戳后缀
@Column(name = "video_Picture")
private String videoPicture;
//视频时长
@Column(name = "video_time")
private Long videoTime;
@Column(name="screen_file_name")
private String screenFileName;//视频截图文件
@Column(name="imgWidth")
private Integer imgWidth;
@Column(name="imgHeight")
private Integer imgHeight;
@Transient
private byte[] bytes;
public UploadFile(Integer id, String fileUrl, Integer fileType) {
this.id = id;
this.fileUrl = fileUrl;
this.fileType=fileType;
}
public @interface Update{};
}
@@ -0,0 +1,114 @@
package com.bestsch.classicalchinese.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Date;
import static javax.persistence.GenerationType.IDENTITY;
/**
* 视频讲解
*/
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "video_explanation")
public class VideoExplanation {
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Integer id;
/**
* 所属学校id
*/
@Column(name = "sch_id", nullable = false)
private Integer schId;
@Column(name = "textbook_id")
private Integer textbookId;
/**
* 节点id
*/
@Column(name = "node_id", nullable = false)
private Integer nodeId;
@Column(name = "path")
private String path;
/**
* 资源名称
*/
@Column(name = "name", nullable = false)
private String name;
/**
* 资源大小,单位byte
*/
@Column(name = "size", nullable = false)
private String size = "0";
/**
* 时长,单位毫秒。对视频/音频资源有效
*/
@Column(name = "duration")
private Long duration;
/**
* 资源后缀名
*/
@Column(name = "suffix_name", nullable = false)
private String suffixName;
/**
* 文件路径
*/
@Column(name = "file_url", nullable = false)
private String fileUrl;
/**
* 类型
* 1:本地上传;2:从资源库选择;
*/
@Column(name = "type", nullable = false)
private Integer type;
/**
* 是否同步到资源
* 0:否;1:是;
*/
@Column(name = "is_sync_resource", nullable = false)
private Integer isSyncResource = 0;
/**
* 被点击次数
*/
@Column(name = "clicks", nullable = false)
private Integer clicks = 0;
/**
* 下载次数
*/
@Column(name = "down_num", nullable = false)
private Integer downNum = 0;
/**
* 创建人
*/
@Column(name = "create_user", nullable = false)
private Integer createUser;
/**
* 创建时间
*/
@Column(name = "create_time", nullable = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}
@@ -0,0 +1,36 @@
package com.bestsch.classicalchinese.enums;
public enum AnswerStatus {
//1-正确 2-错误 0-默认 3-半对
// I(1,"错误");
O(0,"默认"),
I(1,"正确"),
II(2,"错误"),
III(3,"半对");
private int id;
private String name;
AnswerStatus(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,33 @@
package com.bestsch.classicalchinese.enums;
public enum AppType {
O(1001,"古诗文"),
I(1002,"文言文"),
II(1003,"记叙文"),
III(1004,"散文");
private int id;
private String name;
AppType(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,88 @@
package com.bestsch.classicalchinese.enums;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
public enum DifficultLevel
{
I(1, "容易"),
II(2, "中等"),
III(3, "困难"),
IV(4, "不限制难度"),
;
private int id;
private String name;
DifficultLevel(int id, String name)
{
this.id = id;
this.name = name;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public static String nameById(int id) {
for (DifficultLevel type : list()) {
if (type.getId() == id) return type.getName();
}
return null;
}
public static Integer getIdByName(String name) {
for (DifficultLevel type : list()) {
if (type.getName().equals(name)) return type.getId();
}
return null;
}
private static List<DifficultLevel> list;
public static List<DifficultLevel> list()
{
if (list != null)
return list;
list = new ArrayList<>();
EnumSet<DifficultLevel> statusSet = EnumSet.allOf(DifficultLevel.class);
for (DifficultLevel status : statusSet)
list.add(status);
return list;
}
public static DifficultLevel getById(int id)
{
if (list == null)
list();
for (DifficultLevel na : list)
{
if (na.getId() == id)
{
return na;
}
}
return null;
}
}
@@ -0,0 +1,37 @@
package com.bestsch.classicalchinese.enums;
public enum FileType {
IMG_TYPE(1,"图片"),
VIDEO_TYPE(2,"视频"),
AUDIO_TYPE(3,"音频"),
OTHER_TYPE(4,"其他");
private int id;
private String name;
FileType(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,127 @@
package com.bestsch.classicalchinese.enums;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Optional;
public enum GradeEnum {
/* GRADE100("幼托",100),
GRADE101("幼小",101),
GRADE102("幼中",102),
GRADE103("幼大",103),*/
GRADE1("一年级上", 1, 1, SchoolSection.XX.getId()),
GRADE2("一年级下", 1, 2, SchoolSection.XX.getId()),
GRADE3("二年级上", 2, 1, SchoolSection.XX.getId()),
GRADE4("二年级下", 2, 2, SchoolSection.XX.getId()),
GRADE5("三年级上", 3, 1, SchoolSection.XX.getId()),
GRADE6("三年级下", 3, 2, SchoolSection.XX.getId()),
GRADE7("四年级上", 4, 1, SchoolSection.XX.getId()),
GRADE8("四年级下", 4, 2, SchoolSection.XX.getId()),
GRADE9("五年级上", 5, 1, SchoolSection.XX.getId()),
GRADE10("五年级下", 5, 2, SchoolSection.XX.getId()),
GRADE11("六年级上", 6, 1, SchoolSection.XX.getId()),
GRADE12("六年级下", 6, 2, SchoolSection.XX.getId()),
GRADE13("七年级上", 7, 1, SchoolSection.CZ.getId()),
GRADE14("七年级下", 7, 2, SchoolSection.CZ.getId()),
GRADE15("八年级上", 8, 1, SchoolSection.CZ.getId()),
GRADE16("八年级下", 8, 2, SchoolSection.CZ.getId()),
GRADE17("九年级上", 9, 1, SchoolSection.CZ.getId()),
GRADE18("九年级下", 9, 2, SchoolSection.CZ.getId()),
GRADE19("高一年级上", 10, 1, SchoolSection.GZ.getId()),
GRADE20("高一年级下", 10, 2, SchoolSection.GZ.getId()),
GRADE21("高二年级上", 11, 1, SchoolSection.GZ.getId()),
GRADE22("高二年级下", 11, 2, SchoolSection.GZ.getId()),
GRADE23("高三年级上", 12, 1, SchoolSection.GZ.getId()),
GRADE24("高三年级下", 12, 2, SchoolSection.GZ.getId()),
;
private String name;
private Integer system_garde;
private Integer term;
private Integer sectionId;
GradeEnum(String name, Integer system_garde, Integer term, Integer sectionId) {
this.name = name;
this.system_garde = system_garde;
this.term = term;
this.sectionId = sectionId;
}
private static List<GradeEnum> list;
public static List<GradeEnum> list() {
if (list != null)
return list;
list = new ArrayList<>();
EnumSet<GradeEnum> statusSet = EnumSet.allOf(GradeEnum.class);
for (GradeEnum status : statusSet)
list.add(status);
return list;
}
public static String getName(Integer id) {
if (list == null) {
list = list();
}
for (GradeEnum status : list) {
if (status.getSystem_garde().equals(id))
return status.getName();
}
return "";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSystem_garde() {
return system_garde;
}
public Integer getTerm() {
return term;
}
public void setTerm(Integer term) {
this.term = term;
}
public Integer getSectionId() {
return sectionId;
}
public void setSectionId(Integer sectionId) {
this.sectionId = sectionId;
}
public void setSystem_garde(Integer system_garde) {
this.system_garde = system_garde;
}
/**
* 根据systemGrade获取学段
*/
public static Optional<Integer> getSectionIdBySystemGrade(Integer systemGrade) {
for (GradeEnum gradeEnum : GradeEnum.values()) {
if (gradeEnum.getSystem_garde().equals(systemGrade)) {
return Optional.of(gradeEnum.getSectionId());
}
}
return Optional.empty();
}
}
@@ -0,0 +1,29 @@
package com.bestsch.classicalchinese.enums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.*;
/**
* 调用OCR接口,识别到的数据,缓存在这
* 在现有逻辑下,会对同一个url的图片多次调用ocr接口,因此将这个url图片识别到的数据存储起来
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "ocr_data_cache", uniqueConstraints = {
@UniqueConstraint(name = "unique_img_url", columnNames = {"img_url"})
})
public class OcrDataCache {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "img_url")
private String imgUrl;
private String data;
}
@@ -0,0 +1,23 @@
package com.bestsch.classicalchinese.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum QuestionDifficultyEnum
{
//容易
Easily (1,"容易"),
//中等
Medium (2,"中等"),
//困难
Difficulty (3,"困难"),
//随机
Random (4,"随机");
private Integer key;
private String value;
}
@@ -0,0 +1,82 @@
package com.bestsch.classicalchinese.enums;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public enum QuestionType
{
I(1, "单选题"),
II(2, "多选题"),
III(3, "判断题"),
IV(4, "解答题"),
V(6, "组合题"),
VI(5, "填空题"),
VII(7, "英语题");
private int id;
private String name;
QuestionType(int id, String name)
{
this.id = id;
this.name = name;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public static List<QuestionType> list()
{
return new ArrayList<>(EnumSet.allOf(QuestionType.class));
}
public static Map<Integer, QuestionType> map()
{
return list().stream().collect(Collectors.toMap(QuestionType::getId, QuestionType->QuestionType));
}
public static String nameById(int id) {
for (QuestionType type : list()) {
if (type.getId() == id) return type.getName();
}
return null;
}
public static Integer getIdByName(String name) {
for (QuestionType type : list()) {
if (type.getName().equals(name)) return type.getId();
}
return null;
}
public static QuestionType getById(int id)
{
for (QuestionType na : list())
{
if (na.getId() == id)
{
return na;
}
}
return null;
}
}
@@ -0,0 +1,22 @@
package com.bestsch.classicalchinese.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
//oneSelect单选题,manySelect多选题,judge判断题,answer解答题,fillBlanks填空题
@Getter
@NoArgsConstructor
@AllArgsConstructor
public enum QuestionTypeEnum
{
oneSelect (1,"单选题"),
manySelect (2,"多选题"),
judge (3,"判断题"),
answer (4,"解答题"),
fillBlanks (5,"填空题");
private Integer key;
private String value;
}
@@ -0,0 +1,33 @@
package com.bestsch.classicalchinese.enums;
public enum ReviewStatus {
UNREVIEW(0,"未批"),
REVIEW(1,"已批"),
DINGZHENG(2,"订正");
private int id;
private String name;
ReviewStatus(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,102 @@
package com.bestsch.classicalchinese.enums;
import lombok.Data;
import java.util.*;
import java.util.stream.Collectors;
//学段,要跟班级管理一致
public enum SchoolSection
{
XX(2, "小学", "XX", Arrays.asList(Subject.YW, Subject.SX, Subject.YY, Subject.PD, Subject.KX)),
/* CZ(3, "初中", "CZ",
Arrays.asList(Subject.YW, Subject.SX, Subject.YY, Subject.WL, Subject.HX, Subject.SW, Subject.LS, Subject.DL, Subject.KX, Subject.XX, Subject.PD)),*/
CZ(3, "初中", "CZ",
Arrays.asList(Subject.YW, Subject.SX, Subject.YY)),
GZ(4, "高中", "GZ",
Arrays.asList(Subject.YW, Subject.SX, Subject.YY, Subject.WL, Subject.HX, Subject.SW, Subject.ZZ, Subject.LS, Subject.DL, Subject.XX));
private int id;
private String name;
private String code;
private List<Subject> subjects = new ArrayList<>();
SchoolSection(int id, String name, String code, List<Subject> subjects)
{
this.id = id;
this.name = name;
this.code = code;
this.subjects.addAll(subjects);
}
public int getId()
{
return id;
}
public String getName()
{
return name;
}
public String getCode()
{
return code;
}
public static SchoolSection getById(int id)
{
return map.get(id);
}
private static List<SchoolSection> list;
private static Map<Integer, SchoolSection> map;
public static List<SchoolSection> list()
{
if (list != null) return list;
EnumSet<SchoolSection> statusSet = EnumSet.allOf(SchoolSection.class);
list = new ArrayList<>(statusSet);
map = list.stream().collect(Collectors.toMap(SchoolSection::getId, SchoolSection -> SchoolSection));
return list;
}
static
{
list();
}
@Data
public static class Dto
{
private int id;
private String name;
private String code;
private List<Subject.Dto> subjects = new ArrayList<>();
}
public Dto toDto()
{
Dto dto = new Dto();
dto.setId(id);
dto.setName(name);
dto.setCode(code);
for (Subject subject: subjects)
dto.getSubjects().add(subject.toDto());
return dto;
}
private static List<Dto> dtoList;
public static List<Dto> dtoList()
{
if (dtoList != null) return dtoList;
List<Dto> dtoList = new ArrayList<>();
for (SchoolSection section: list())
dtoList.add(section.toDto());
return dtoList;
}
}
@@ -0,0 +1,100 @@
package com.bestsch.classicalchinese.enums;
import lombok.Data;
import java.util.*;
import java.util.stream.Collectors;
//学段,要跟班级管理一致
public enum SchoolSection_
{
XX(2, "小学", "XX", Arrays.asList(Subject.YW, Subject.SX, Subject.YY, Subject.PD, Subject.KX)),
CZ(3, "初中", "CZ",
Arrays.asList(Subject.YW, Subject.SX, Subject.YY, Subject.WL, Subject.HX, Subject.SW, Subject.LS, Subject.DL, Subject.KX, Subject.XX, Subject.PD, Subject.LJ)),
GZ(4, "高中", "GZ",
Arrays.asList(Subject.YW, Subject.SX, Subject.YY, Subject.WL, Subject.HX, Subject.SW, Subject.ZZ, Subject.LS, Subject.DL, Subject.XX));
private int id;
private String name;
private String code;
private List<Subject> subjects = new ArrayList<>();
SchoolSection_(int id, String name, String code, List<Subject> subjects)
{
this.id = id;
this.name = name;
this.code = code;
this.subjects.addAll(subjects);
}
public int getId()
{
return id;
}
public String getName()
{
return name;
}
public String getCode()
{
return code;
}
public static SchoolSection_ getById(int id)
{
return map.get(id);
}
private static List<SchoolSection_> list;
private static Map<Integer, SchoolSection_> map;
public static List<SchoolSection_> list()
{
if (list != null) return list;
EnumSet<SchoolSection_> statusSet = EnumSet.allOf(SchoolSection_.class);
list = new ArrayList<>(statusSet);
map = list.stream().collect(Collectors.toMap(SchoolSection_::getId, SchoolSection -> SchoolSection));
return list;
}
static
{
list();
}
@Data
public static class Dto
{
private int id;
private String name;
private String code;
private List<Subject.Dto> subjects = new ArrayList<>();
}
public Dto toDto()
{
Dto dto = new Dto();
dto.setId(id);
dto.setName(name);
dto.setCode(code);
for (Subject subject: subjects)
dto.getSubjects().add(subject.toDto());
return dto;
}
private static List<Dto> dtoList;
public static List<Dto> dtoList()
{
if (dtoList != null) return dtoList;
List<Dto> dtoList = new ArrayList<>();
for (SchoolSection_ section: list())
dtoList.add(section.toDto());
return dtoList;
}
}
@@ -0,0 +1,37 @@
package com.bestsch.classicalchinese.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import java.util.Arrays;
import java.util.Optional;
/**
* @Description 教材来源
* @Author cls
* @Date 2021/3/17 14:59
* @Version V1.0
**/
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum SourceEnum {
UNKNOWN("UNKNOWN","未知"),
SYSTEM("SYSTEM","系统级"),SCHOOL("SCHOOL","校级")
;
private String enKey;
private String cnKey;
public static SourceEnum getByEnKey(String enKey) {
String enKey0 = enKey.toUpperCase();
SourceEnum[] enums = SourceEnum.values();
Optional<SourceEnum> opt = Arrays.stream(enums).filter(item -> item.getEnKey().equals(enKey0.toUpperCase())).findAny();
if(opt.isPresent()){
return opt.get();
}
return UNKNOWN;
}
}
@@ -0,0 +1,105 @@
package com.bestsch.classicalchinese.enums;
import lombok.Data;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public enum Subject
{
YW(40,"语文","SUB01"),
SX(41,"数学","SUB02"),
YY(42,"英语","SUB03"),
WL(74,"物理","SUB04"),
HX(75,"化学","SUB05"),
SW(76,"生物","SUB06"),
XX(111,"信息","SUB7"),
PD(112,"道法","SUB8"),
TY(113,"体育","SUB9"),
MS(114,"美术","SUB10"),
KX(115,"科学","SUB11"),
LJ(116,"劳技","SUB12"),
LS(117,"历史","SUB13"),
DL(118,"地理","SUB14"),
ZZ(119,"政治","SUB15");
private int id;
private String name;
private String code;
Subject(int id, String name, String code)
{
this.id = id;
this.name = name;
this.code = code;
}
public int getId()
{
return id;
}
public String getName()
{
return name;
}
public String getCode()
{
return code;
}
public static Subject getByCode(String code)
{
return codeMap.get(code);
}
private static List<Subject> list;
private static Map<String, Subject> codeMap;
public static List<Subject> list()
{
if (list != null) return list;
EnumSet<Subject> statusSet = EnumSet.allOf(Subject.class);
list = new ArrayList<>(statusSet);
codeMap = list.stream().collect(Collectors.toMap(Subject::getCode, Subject -> Subject));
return list;
}
static
{
list();
}
@Data
public static class Dto
{
private int id;
private String name;
private String code;
}
public Dto toDto()
{
Dto dto = new Dto();
dto.setId(id);
dto.setName(name);
dto.setCode(code);
return dto;
}
private static List<Dto> dtoList;
public static List<Dto> dtoList()
{
if (dtoList != null) return dtoList;
List<Dto> dtoList = new ArrayList<>();
for (Subject subject: list())
dtoList.add(subject.toDto());
return dtoList;
}
}
@@ -0,0 +1,72 @@
package com.bestsch.classicalchinese.enums;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
public enum TimeTypeEnum
{
CURRENT_TERM(1, "本学期"), CURRENT_MONTH(2, "本月"), CURRENT_WEEK(3, "本周"),
TODAY(4, "今日"),TOTAL(5,"累计"),CUSTOM(6,"自定义");
private int id;
private String name;
private TimeTypeEnum(int id, String name)
{
setId(id);
setName(name);
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public static String nameById(int id)
{
for(TimeTypeEnum type : list())
{
if(type.getId()==id) return type.getName();
}
return null;
}
public static Integer IdByName(String name)
{
for(TimeTypeEnum type : list())
{
if(type.getName().equals(name)) return type.getId();
}
return null;
}
private static List<TimeTypeEnum> list;
public static List<TimeTypeEnum> list()
{
if (list != null) return list;
list = new ArrayList<>();
EnumSet<TimeTypeEnum> typeSet = EnumSet.allOf(TimeTypeEnum.class);
for (TimeTypeEnum type : typeSet)
list.add(type);
return list;
}
}
@@ -0,0 +1,52 @@
package com.bestsch.classicalchinese.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum UserRole {
GENERAL_USER(0,"一般用户"),
TEACHER_USER(1,"教师"),
SCH_LEADER_USER(2,"校领导"),
STU_USER(3,"学生"),
PATRIARCH_USER(4,"家长"),
BUREAU_LEADER_USER(5,"局领导"),
BUSINESS(6,"工作号"),
ADMIN(7,"管理员"),
;
private Integer value;
private String name;
UserRole () {
}
UserRole ( Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
public static List<Map<String,Object>> getAll(){
UserRole[] users = UserRole.values();
List<Map<String,Object>> list = new ArrayList<>();
for(UserRole user : users){
Map<String,Object> map = new HashMap<>();
map.put("name",user.getName());
map.put("value",user.getValue());
list.add(map);
}
return list;
}
}
@@ -0,0 +1,24 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class AcademicYear {
private Integer id;
private String name;
private Date startDate;
private Date endDate;
private Date progressionDate;
private Integer year;
private Date firstSemesterStartDate;
private Date firstSemesterEndDate;
private Date secondSemesterStartDate;
private Date secondSemesterEndDate;
}
@@ -0,0 +1,21 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class AiAsk {
@NotNull(message="请选择模型!")
@Size(max = 20, message = "模型错误!")
private String model;
@NotNull(message="请输入问题内容!")
@Size(max = 8000, message = "问题长度超出限制(8000字符)!")
private String prompt;
}
@@ -0,0 +1,17 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class BaseTree {
public Integer id;
public String name;
public Integer pid ;
public List<BaseTree> children;
}
@@ -0,0 +1,26 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
import java.util.List;
@Data
public class ClassInfo
{
private Integer classId;
private Integer gradeId;
private String className;
private String gradeName;
private Integer teacherId;
private Integer schoolId;
@Data
public static class ClassInfoWithStu
{
private Integer classId;
private Integer gradeId;
private String className;
private String gradeName;
private List<StudentInfo> children;
}
}
@@ -0,0 +1,13 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
@Data
public class ClassModel {
private Integer classId;
private String className;
private String gradeName;
private String name;
private Integer gradeId;
private String classIds;
}
@@ -0,0 +1,13 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
import java.util.Date;
@Data
public class DateModel {
private int year;
private int semester;
private Date startDate;
private Date endDate;
}
@@ -0,0 +1,12 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
import java.util.Date;
@Data
public class DateTimeModel {
private int timeIndex;
private Date startDate;
private Date endDate;
}
@@ -0,0 +1,39 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
import java.util.Map;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Example {
private String name;
private String config;
private String answer;
private String solve;
private Integer difficultLevelId;
// private String difficultLevelName;
// private String questionTypeName;
private Integer questionTypeId;
private DifficultLevel difficultLevel;
private QuestionType questionType;
private List<Map> solveQuestionFiles;
@Data
static public class DifficultLevel{
private Integer id;
private String name;
}
@Data
static public class QuestionType{
private Integer id;
private String name;
private Date cdate;
}
}
@@ -0,0 +1,20 @@
package com.bestsch.classicalchinese.model;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @Author wanghu
* @Date 2025-11-7 13:26 (可以根据需要修改)
* @Description:
*/
@Data
public class ExcelBschLeadlearning {
@Excel(name = "章节名称")
private String cname;
@Excel(name = "导学内容")
private String bschLeadlearning;
}
@@ -0,0 +1,20 @@
package com.bestsch.classicalchinese.model;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
/**
* @Author wanghu
* @Date 2025-11-7 13:26 (可以根据需要修改)
* @Description:
*/
@Data
public class ExcelPunitTreeTea {
@Excel(name = "章节名称")
private String cname;
@Excel(name = "教师(“,”英文逗号隔开)")
private String teaNames;
}
@@ -0,0 +1,15 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
@Data
public class FileMessage {
private String fileName;
private String pictureName;
private Long videoSize;
private Integer imgWidth;
private Integer imgHeight;
private String size;
}
@@ -0,0 +1,26 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Grade {
private Integer gradeId;//1-12年级
private String name;
private Integer term;//学期
private Integer id;//年级ID 唯一
public Grade(Integer id, String name) {
this.gradeId = id;
this.name = name;
}
}
@@ -0,0 +1,72 @@
package com.bestsch.classicalchinese.model;
import org.apache.commons.lang.StringUtils;
public class Page<U> {
private int current;
private int pageSize;
private long count;
public Page() {
}
public int getCurrent() {
return this.current;
}
public void setCurrent(int current) {
this.current = current;
}
public int getPageSize() {
return this.pageSize == 0 ? 10 : this.pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public void setPageSize(String pageSize) {
if (!StringUtils.isEmpty(pageSize) && StringUtils.isNumeric(pageSize)) {
this.pageSize = Integer.valueOf(pageSize);
}
}
public long getCount() {
return this.count;
}
public void setCount(long count) {
this.count = count;
}
public int getPageCount() {
return this.getPageSize() != 0 ? (int)Math.ceil((double)this.count / (double)this.getPageSize()) : 0;
}
public int getStartIndex() {
return (this.getCurrent() - 1) * this.getPageSize();
}
public void setCurrent(String current) {
if (!StringUtils.isEmpty(current) && StringUtils.isNumeric(current)) {
this.current = Integer.valueOf(current);
}
}
public void setCount(String count) {
if (!StringUtils.isEmpty(count) && StringUtils.isNumeric(count)) {
this.count = Long.valueOf(count);
}
}
public int getEndIndex() {
return this.getStartIndex() + this.getPageSize();
}
}
@@ -0,0 +1,26 @@
package com.bestsch.classicalchinese.model;
/**
* @Author wanghu
* @Date 2025-11-10 14:47 (可以根据需要修改)
* @Description:
*/
public class PageInfo {
private int pageNum;
private int pageSize;
private int total;
private int totalPages;
private boolean hasNext;
private boolean hasPrev;
// 构造方法、getter、setter...
public PageInfo(int pageNum, int pageSize, int total, int totalPages,
boolean hasNext, boolean hasPrev) {
this.pageNum = pageNum;
this.pageSize = pageSize;
this.total = total;
this.totalPages = totalPages;
this.hasNext = hasNext;
this.hasPrev = hasPrev;
}
}
@@ -0,0 +1,12 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
@Data
public class SchClassModel {
public Integer classID;
public Integer gradeID;
public String gradeName;
public String className;
}
@@ -0,0 +1,9 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
@Data
public class SchSub {
private String subId;
private String subName;
}
@@ -0,0 +1,10 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
@Data
public class SchTeaSubGrade {
public Integer gradeID;
public String subID;
}
@@ -0,0 +1,14 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class StartEndDate {
private Date startDate;
private Date endDate;
}
@@ -0,0 +1,14 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
@Data
public class StudentInfo
{
private Integer id;
private String name;
private Integer claId;
private String claName;
private Integer gradeId;
private String profilePicture;
}
@@ -0,0 +1,17 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
import java.util.List;
/**
* @Author wanghu
* @Date 2025-11-18 16:18 (可以根据需要修改)
* @Description:
*/
@Data
public class SubGroupTeaIds {
public List<Integer> gradeIds;
public List<String> subIds;
public List<Integer> teaIds;
}
@@ -0,0 +1,31 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Getter
public enum SystemGrade {
one(1,"一年级"),two(2,"二年级"),
three(3,"三年级"),four(4,"四年级"),
five(5,"五年级"),six(6,"六年级"),
seven(7,"七年级"),eight(8,"八年级"),
nine(9,"九年级"),ten(10,"高一年级"),
eleven(11,"高二年级"),twelve(12,"高三年级");
private Integer gradeId;
private String gradeName;
public static String getName(Integer gradeId) {
for (SystemGrade grade : SystemGrade.values()) {
if (grade.getGradeId().equals(gradeId)) {
return grade.gradeName;
}
}
return null;
}
}
@@ -0,0 +1,15 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
@Data
public class TeaFirstClass {
public String gradeName;
public int gradeId ;
public String alias;
public String className ;
public String subName ;
public String subId ;
public String name ;
public int id ;
}
@@ -0,0 +1,16 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class TreeDept {
private int schoolId;
private String name;
private int pId;
private int id;
private Integer type;
}
@@ -0,0 +1,17 @@
package com.bestsch.classicalchinese.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class TreeUser {
private int UserID;
private String Name;
private String Photo;
private Integer type;
private int id;
private int GroupID;
}
@@ -0,0 +1,15 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
/**
* @Author wanghu
* @Date 2025-11-18 16:18 (可以根据需要修改)
* @Description:
*/
@Data
public class UserGradeClassSub {
public Integer gradeId;
public Integer classId;
public String subId;
}
@@ -0,0 +1,28 @@
package com.bestsch.classicalchinese.model;
import lombok.Data;
import java.util.Date;
@Data
public class YearSemester {
private Integer year;
private Integer semester;
private String name;
private Date startDate;
private Date endDate;
@Data
static public class AcademicYear {
private Integer id;
private String name;
private Date startDate;
private Date endDate;
private Date progressionDate;
private Integer year;
private Date firstSemesterStartDate;
private Date firstSemesterEndDate;
private Date secondSemesterStartDate;
private Date secondSemesterEndDate;
}
}
@@ -0,0 +1,24 @@
package com.bestsch.classicalchinese.model.dto;
import com.bestsch.classicalchinese.entity.PunitQuestion;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class PunitDto {
public Integer nodeId;
@NotNull(message="导学内容不允许为空!")
@Size(max = 8000, message = "导学内容超出长度限制(8000字符)!")
public String connect;
public List<PunitQuestion> questions;
}
@@ -0,0 +1,25 @@
package com.bestsch.classicalchinese.model.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class AiQuestionsVo {
private String type;
private String difficulty;
private String question;
private String[] options;
// ["",""],[""] 一级表示答案有多种解析方式 或者关系, 二级表示答案属于并且关系答案同时存在
private String answer;
private String analysis;
}
@@ -0,0 +1,27 @@
package com.bestsch.classicalchinese.model.vo;
import com.bestsch.classicalchinese.entity.BschQuestion;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BschFormQuestionVo implements Serializable {
public Integer nodeId;
public String content;
//小题
public List<BschQuestion> questionList;
public String path;
public Integer textbookId;
}
@@ -0,0 +1,26 @@
package com.bestsch.classicalchinese.model.vo;
import lombok.Data;
@Data
public class PunitFilesVo {
public Integer id;
public Integer nodeId;
public String fileName;
public String fileCode;
public String filePath;
public Integer fileSize;
public String fileType;
public Integer sort;
public boolean displayDel;
public boolean show;
}

Some files were not shown because too many files have changed in this diff Show More