Commit 875dd83c authored by 李博今's avatar 李博今

Merge branch 'V2.0.3' of http://103.249.252.28:90/lcy/education

parents fb427873 8641a120
......@@ -47,7 +47,8 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
" bf.video_url AS videoUrl,\n" +
" bf.file_url AS fileUrl,\n" +
" bf.ppt_url AS pptUrl,\n" +
" bf.pdf_url AS pdfUrl,\n" +
" bf.pdf_url AS pdfUrl," +
" bf.video_name AS fileName,\n" +
" pc.business_id AS paperUrl," +
" (SELECT count(*) FROM b_r_student_chapter brs WHERE brs.chapter_id = bc.business_id AND brs.score = - 1) AS studentNum \n" +
" FROM\n" +
......
......@@ -136,6 +136,9 @@ public class BChapter extends IdEntity<BChapter> {
@Transient
private String paperUrl;
@Transient
private String fileName;
public BChapter(String businessId) {
this.businessId = businessId;
......
......@@ -153,8 +153,8 @@ public class BClassController extends PaginationController<BClass> {
@ApiOperation(value="查询班级列表", notes="查询班级列表赋值在下拉框中")
@GetMapping(value = "/queryBClassList")
public Result queryBClassList() {
List<SelectModel> bClass = bClassService.queryBClassList();
public Result queryBClassList(String type) {
List<SelectModel> bClass = bClassService.queryBClassList(type);
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
......
package org.rcisoft.business.bclass.dao;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.bclass.entity.BClass;
......@@ -50,9 +51,10 @@ public interface BClassRepository extends BaseMapper<BClass> {
"</foreach></script>")
int insertBusinessClassList(List<BClass> bClasses);
@Select("select * from b_class where del_flag != 1 and flag = 1")
@Select("<script>select * from b_class where del_flag != 1 and flag = 1 " +
"<if test=\"type!=null and type!=''\">and type = #{type}</if></script>")
@ResultMap(value = "BaseResultMap" )
List<BClass> queryBClassList();
List<BClass> queryBClassList(@Param("type") String type);
@Select("select class_name from b_class where find_in_set(code,#{classesCode}) and del_flag != 1 and flag = 1")
List<String> queryClassNamesByIds(String classesCode);
......
......@@ -75,5 +75,5 @@ public interface BClassService{
*/
PersistModel businessImportExcel(HSSFWorkbook hwb, String token) throws IOException;
List<SelectModel> queryBClassList();
List<SelectModel> queryBClassList(String type);
}
......@@ -272,8 +272,8 @@ public class BClassServiceImpl implements BClassService {
}
@Override
public List<SelectModel> queryBClassList() {
List<BClass> bClass = bClassRepository.queryBClassList();
public List<SelectModel> queryBClassList(String type) {
List<BClass> bClass = bClassRepository.queryBClassList(type);
ArrayList<SelectModel> comBoxModel = new ArrayList<SelectModel>();
for(BClass c : bClass){
SelectModel selectModel = new SelectModel();
......
......@@ -156,48 +156,41 @@ public class BFileController extends PaginationController<BFile> {
*/
@ApiOperation(value="下载文件", notes="下载文件")
@ApiImplicitParam(name = "chapterId", value = "章节ID", required = true, dataType = "varchar")
@PostMapping(value = "/downloadFile")
public Result downloadFile(String chapterId, HttpServletResponse response){
BFile video = bFileService.queryFileUrlByChapterId(chapterId);
@GetMapping(value = "/downloadFileWithoutAuth")
public Result downloadFileWithoutAuth(String chapterId, HttpServletResponse response) throws IOException {
BFile bFile = bFileService.queryFileUrlByChapterId(chapterId);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
if(video.getVideoUrl()!=""&&video.getVideoUrl()!=null){
try {
File file=new File(global.getBASE_UPLOAD_SERVER_LOCATION()+video.getVideoUrl());
if(bFile.getFileUrl()!=""&&bFile.getFileUrl()!=null){
File file=new File(global.getBASE_UPLOAD_SERVER_LOCATION()+File.separator+bFile.getFileUrl());
if(!file.isFile()){
throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR);
}
bis = new BufferedInputStream(new FileInputStream(file));
bos = new BufferedOutputStream(response.getOutputStream());
String fileName = "";
if(bFile.getVideoName()!=null&&!bFile.getVideoName().equals("")&&bFile.getVideoName().endsWith(".zip")){
fileName = bFile.getVideoName();
}else{
fileName = file.getName();
}
response.reset();
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename="+ new String((video.getVideoName()).getBytes(), "iso-8859-1"));
response.setHeader("Content-Disposition", "attachment;filename="+ new String((fileName).getBytes(), "iso-8859-1"));
response.setHeader("Access-Control-Allow-Origin", "*");
IOUtils.copy(bis, bos);
}catch (Exception e){
e.printStackTrace();
}finally {
if (bis != null)
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
if (bos != null)
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}else {
throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR);
}
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
"");
}else{
return Result.builder(new PersistModel(0),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
"");
}
}
}
......@@ -267,7 +267,10 @@ public class BFileServiceImpl implements BFileService {
e.printStackTrace();
}
}
//上传的是文件时才存文件名,方便下载时取
if(bFile.getType().equals("1")){
bFile.setVideoName(name+ "." +uploadFileSuffix);//文件名
}
if (bFile.getType().equals("0")){
......
......@@ -197,7 +197,7 @@ public class BSlServiceImpl implements BSlService {
lessonCode.add(value[1]);
continue;
}
if ((bTermRepository.selectOne(new BTerm(value[3]))) == null) {
if ((bTermRepository.selectOne(new BTerm(value[3],null))) == null) {
if (!termCode.contains(value[3]))
termCode.add(value[3]);
continue;
......
......@@ -80,7 +80,7 @@ public class BSlApplyServiceImpl implements BSlApplyService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel persist(BSlApply model, String token){
int line = 0;
if(model.getTermCode()!=null&&bTermRepository.selectOne(new BTerm(model.getTermCode()))==null)
if(model.getTermCode()!=null&&bTermRepository.selectOne(new BTerm(model.getTermCode(),null))==null)
throw new ServiceException(ResultServiceEnums.TERM_NOT_EXISTS);
if(model.getTeacherCode()!=null&&bTeacherRepository.selectOne(new BTeacher(model.getTeacherCode()))==null)
throw new ServiceException(ResultServiceEnums.TEACHER_NOT_EXISTS);
......
......@@ -140,9 +140,9 @@ public class BStudentServiceImpl implements BStudentService {
List<String> valuesEmailExist = new ArrayList<>();
List<String> valuesGrade = new ArrayList<>();
int i = 1;
int i = 0;
for (String[] value : values) {
i++;
String stuCode = value[0];
//判断1:学号是否满足8~15位;
......@@ -225,7 +225,6 @@ public class BStudentServiceImpl implements BStudentService {
users.add(user);
userRoles.add(userRole);
}
i++;
}
......
......@@ -94,9 +94,9 @@ public class BTeacherServiceImpl implements BTeacherService {
List<String> valuesShort = new ArrayList<>();
List<String> valuesIncomplete = new ArrayList<>();
List<String> valuesAgencyExist = new ArrayList<>();
int i = 1;
int i = 0;
for (String[] value : values) {
i++;
String teaCode = value[0];
//判断1:学号是否满足8~15位;
......@@ -177,7 +177,6 @@ public class BTeacherServiceImpl implements BTeacherService {
users.add(user);
userRoles.add(userRole);
}
i++;
}
String result = "";
if (teachers.size()>0){
......
......@@ -144,15 +144,15 @@ public class BTermController extends PaginationController<BTerm> {
@ApiOperation(value="更改当前学期", notes="更改当前学期")
@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar")
@ApiImplicitParam(name = "code", value = "code", required = true, dataType = "varchar")
@PreAuthorize("hasRole('ROLE_1001')")
@PostMapping(value = "/changeCurrent")
public Result changeCurrent(@RequestParam("id") String id){
PersistModel data=bTermService.changeCurrent(id);
public Result changeCurrent(@RequestParam("code") String code){
PersistModel data=bTermService.changeCurrent(code);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
id);
code);
}
@ApiOperation(value="获取校历", notes="获取校历")
......
......@@ -46,8 +46,8 @@ public interface BTermRepository extends BaseMapper<BTerm> {
@Update("<script>update b_term set current = '0'</script>")
int changeAllTermNotCurrent();
@Update("<script>update b_term set current = '1' where business_id = #{id}</script>")
int changeCurrent(String id);
@Update("<script>update b_term set current = '1' where code = #{code} and del_flag = 0 and flag = 1</script>")
int changeCurrent(String code);
@Select("select max_sl_code from b_term where code = #{termCode}")
int queryMaxSlCodeByTermCode(String termCode);
......@@ -69,5 +69,13 @@ public interface BTermRepository extends BaseMapper<BTerm> {
@Select("select * from b_term where code = #{termCode}")
@ResultMap(value = "BaseResultMap" )
BTerm queryCurrentTerm(String termCode);
@Select("select * from b_term " +
"WHERE (#{startDate} BETWEEN start_date AND end_date) " +
"OR (#{endDate} BETWEEN start_date AND end_date) " +
"OR (start_date BETWEEN #{startDate} AND #{endDate}) " +
"OR (end_date BETWEEN #{startDate} AND #{endDate})")
@ResultMap(value = "BaseResultMap" )
List<BTerm> queryBTermsByStartDateOrEndDate(BTerm model);
}
......@@ -24,8 +24,9 @@ public class BTerm extends IdEntity<BTerm> {
private static final long serialVersionUID = 6619306545135522432L;
public BTerm(String code) {
public BTerm(String code, String name) {
this.code = code;
this.name = name;
}
......
......@@ -58,7 +58,7 @@ public interface BTermService{
List<SelectModel> queryBTermList();
PersistModel changeCurrent(String id);
PersistModel changeCurrent(String code);
Map<String,Object> getSchoolWeek(String termCode);
}
......@@ -56,13 +56,22 @@ public class BTermServiceImpl implements BTermService {
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel persist(BTerm model, String token){
//验证时间区间是否重叠
List<BTerm> bTerms = bTermRepository.queryBTermsByStartDateOrEndDate(model);
if(bTerms.size()>0){
throw new ServiceException(ResultServiceEnums.CAN_NOT_OVERLAP);
}
//验证名称是否重复
if(bTermRepository.selectOne(new BTerm(null,model.getName()))!=null)
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
int line = 0;
model.setWeek(String.valueOf(Week.buildList(model.getStartDate(),model.getEndDate()).size() + 1));
if(model.getBusinessId()!=null) {
UserUtil.setCurrentMergeOperation(model);
line = bTermRepository.updateByPrimaryKeySelective(model);
}else {
if(bTermRepository.selectOne(new BTerm(model.getCode()))!=null)
//验证编号是否重复
if(bTermRepository.selectOne(new BTerm(model.getCode(),null))!=null)
throw new ServiceException(ResultServiceEnums.TERM_EXISTS);
Map<String,Object> map = Week.buildWeek(model.getStartDate(),model.getEndDate());
model.setWeek(String.valueOf(((List<Week>) map.get("weeks")).size()));
......@@ -133,11 +142,11 @@ public class BTermServiceImpl implements BTermService {
}
@Override
public PersistModel changeCurrent(String id) {
public PersistModel changeCurrent(String code) {
//先把学期全部置为否
bTermRepository.changeAllTermNotCurrent();
//把所选的学期置为是
int result = bTermRepository.changeCurrent(id);
int result = bTermRepository.changeCurrent(code);
return new PersistModel(result);
}
......
......@@ -15,6 +15,7 @@ import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.DisabledException;
import org.springframework.security.core.AuthenticationException;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerExceptionResolver;
......@@ -80,7 +81,7 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
if(e instanceof SystemException){
/*sys*/
/*license*/
try {
throw e;
} catch (Exception e1) {
......@@ -88,14 +89,16 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
log.error(e1.getMessage());
}
}
if (e instanceof ServiceException) {//业务失败的异常,如“账号或密码错误”
result.setCode(ResultCode.FAIL).setMessage(e.getMessage());
} else if (e instanceof AuthenticationException) {
if (e instanceof BadCredentialsException)
if (e instanceof BadCredentialsException) {
//密码错误
result.setCode(ResultCode.UNAUTHORIZED).setMessage(e.getMessage());
} else if (e instanceof DisabledException){
//用户已停用
result.setCode(ResultCode.UNAUTHORIZED).setMessage("用户已停用");
}
else
result.setCode(ResultCode.UNAUTHORIZED).setMessage(e.getMessage());
} else if (e instanceof AccessDeniedException) {
......
......@@ -20,6 +20,9 @@ public class JwtUser implements UserDetails{
private final String username;
private final String password;
private boolean enable = true;
/** 权限类.*/
private final Collection<? extends GrantedAuthority> authorities;
......@@ -68,6 +71,6 @@ public class JwtUser implements UserDetails{
}
@JsonIgnore
public boolean isEnabled() {
return true;
return enable;
}
}
......@@ -187,6 +187,8 @@ public enum ResultServiceEnums {
NAME_IS_EXISTS(99,"名称重复"),
DATA_HAS_USED(100,"当前数据被使用,不可删除"),
CAN_NOT_OVERLAP(101,"时间区间不可重叠"),
;
private Integer code;
......
......@@ -52,14 +52,14 @@ public class JwtAuthenTokenFilter extends OncePerRequestFilter {
/**/
String lk = rcRedisServiceImpl.get("lk");
// if(StringUtils.isBlank(lk) || !"1".equals(lk)){
// if(permitRes==-1) {
// Result result = new Result();
// result.setCode(202);
// ResponseUtil.responseResult(response, result);
// return;
// }
// }
if(StringUtils.isBlank(lk) || !"1".equals(lk)){
if(permitRes==-1) {
Result result = new Result();
result.setCode(202);
ResponseUtil.responseResult(response, result);
return;
}
}
// 取得header
String authHeader = request.getHeader(this.tokenHeader);
//判断header头
......
package org.rcisoft.core.service.impl;
import org.apache.commons.collections4.CollectionUtils;
import org.rcisoft.core.constant.FlagStatus;
import org.rcisoft.core.model.JwtUser;
import org.rcisoft.core.util.JwtUserFactory;
import org.rcisoft.sys.role.dao.SysRoleRepository;
import org.rcisoft.sys.role.entity.SysRole;
......@@ -41,6 +43,10 @@ public class JwtUserDetailServiceImpl implements UserDetailsService {
if (CollectionUtils.isEmpty(roles))
roles = Collections.emptyList();
sysUser.setRoleList(roles);
return JwtUserFactory.create(sysUser);
JwtUser user = JwtUserFactory.create(sysUser);
/*停用*/
if(FlagStatus.ABNORMAL.getStatus().equals(sysUser.getFlag()))
user.setEnable(false);
return user;
}
}
......@@ -19,7 +19,7 @@ import java.util.List;
public interface SysUserMapper extends BaseMapper<SysUser> {
@Select("<script>select * from s_user where login_name = #{username} and del_flag = 0 and flag = 1</script>")
@Select("<script>select * from s_user where login_name = #{username} and del_flag = 0 </script>")
@ResultMap(value = "BaseResultMap")
List<SysUser> queryUserByName(String username);
......@@ -42,7 +42,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
"(#{businessId},#{userId},#{roleId})")
int insertUserRole(UserRole userRole);
@Select("SELECT u.business_id from s_user u left join ${tab} s on u.login_name = s.code where s.business_id = #{id} and u.del_flag = 0 and u.flag = 1")
@Select("SELECT u.business_id from s_user u left join ${tab} s on u.login_name = s.code where s.business_id = #{id} and u.del_flag = 0")
String selectUserIdByStuOrTeaId(@Param("id") String id, @Param("tab") String table);
@Update("update s_user set del_flag = 1 where login_name = #{code}")
......@@ -74,7 +74,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
@Update("<script>update s_user set password = #{password} where 1=1 " +
"and login_name = #{loginName} " +
"and del_flag = 0 and flag = 1</script>")
"and del_flag = 0</script>")
int resetPassword(@Param("loginName") String loginNam,@Param("password") String password);
@Select("<script>select business_id from s_user where login_name = #{studentCode} and del_flag = 0 and flag = 1</script>")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment