Commit d6a3d638 authored by luzhuang's avatar luzhuang

积分排序、字符限制、根据文件判断文件类型

parent 00e4df5e
......@@ -165,7 +165,7 @@ public class BChapterController extends PaginationController<BChapter> {
res);
}
@ApiOperation(value = "210 判断文件类型与后缀名是否相符", notes = "判断文件类型与后缀名是否相符")
@ApiOperation(value = "210 判断文件类型与后缀名是否相符(根据http路径)", notes = "判断文件类型与后缀名是否相符")
@GetMapping("/checkFileHeader")
public Result checkFileHeader(CurUser curUser, @Valid BFile file, BindingResult br) throws IOException {
String res = bChapterService.checkFileHeader(file);
......@@ -174,6 +174,14 @@ public class BChapterController extends PaginationController<BChapter> {
MessageConstant.MESSAGE_ALERT_ERROR,
res);
}
@ApiOperation(value = "211 判断文件类型与后缀名是否相符(根据文件)", notes = "判断文件类型与后缀名是否相符")
@PostMapping("/checkHeaderFromFile")
public Result checkHeaderFromFile(CurUser curUser, MultipartFile file){
return Result.builder(new PersistModel(bChapterService.checkHeaderFromFile(file)),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
file.getOriginalFilename());
}
// @ApiOperation(value = "209 查询章节带进度(外部分享)", notes = "查询章节带进度(外部分享)", response = QueryChapterListResDTO.class)
......
......@@ -9,9 +9,11 @@ import org.rcisoft.business.bfile.entity.BFile;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.sys.user.bean.CurUser;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.List;
import java.util.Map;
......@@ -118,6 +120,8 @@ public interface BChapterService{
*/
String checkFileHeader(BFile bFile);
int checkHeaderFromFile( MultipartFile file);
/**
* 打分
* @param scoreInfoDTOS
......
......@@ -43,6 +43,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.net.HttpURLConnection;
......@@ -664,7 +665,7 @@ public class BChapterServiceImpl implements BChapterService {
LogUtil.fileChangeLog("------------------判断后缀名相符-------------------------" + fileOld);
Boolean line = CheckFileHeaderUtil.toCheck(filePath + File.separator + downLoadName);
if (!line){
throw new ServiceException(ResultServiceEnums.FILE_UNREADABLE);
throw new ServiceException(ResultServiceEnums.FILE_CHECK_ERROR);
}
LogUtil.fileChangeLog("-----------------------后缀名相符-------------------------" + fileOld);
}
......@@ -672,6 +673,17 @@ public class BChapterServiceImpl implements BChapterService {
}
@Override
public int checkHeaderFromFile( MultipartFile file) {
if(file == null)
throw new ServiceException(ResultServiceEnums.NOT_FILE);
if (!CheckFileHeaderUtil.toCheckFile(file))
throw new ServiceException(ResultServiceEnums.FILE_CHECK_ERROR);
return 1;
}
public String changeFile(BFile bFile) {
LogUtil.fileChangeLog("****************request + begin***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
......
......@@ -2,6 +2,7 @@ package org.rcisoft.business.bpersonvalue.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
......@@ -18,6 +19,7 @@ public class PersonValueClientDto {
public String endTime;
@ApiModelProperty(value = "事件")
@Length(max = 30,message = "长度最大为30")
public String event;
@ApiModelProperty(value = "类型 0 + 1-")
......
......@@ -43,7 +43,7 @@ public class BReleaseValueController extends PaginationController<BReleaseValue>
@Autowired
private BReleaseValueService bReleaseValueServiceImpl;
@ApiOperation(value = "1501 分页查询积分管理", notes = "根据条件分页查询", response = BReleaseValue.class)
@ApiOperation(value = "1501 分页查询发布积分设置", notes = "根据条件分页查询", response = BReleaseValue.class)
@GetMapping(value = "/queryByPagination")
public Result queryByPagination(CurUser curUser,@Valid ReleaseValueResDto dto ,BindingResult br) {
bReleaseValueServiceImpl.setReleaseValueResDtoIds(dto);
......
......@@ -29,14 +29,14 @@ public interface BReleaseValueRepository extends BaseMapper<BReleaseValue> {
"<if test=\"ids!=null and ids.size() > 0\"> and business_id in " +
" <foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'> #{item} </foreach> " +
"</if> " +
"<if test=\"lessonValueStart!=null and lessonValueStart != ''\"> and lesson_value &gt;= #{lessonValueStart} </if> " +
"<if test=\"lessonValueEnd!=null and lessonValueEnd != ''\"> and lesson_value &lt;= #{lessonValueEnd} </if> " +
"<if test=\"trainValueStart!=null and trainValueStart != ''\"> and train_value &gt;= #{trainValueStart} </if> " +
"<if test=\"trainValueEnd!=null and trainValueEnd != ''\"> and train_value &lt;= #{trainValueEnd} </if> " +
"<if test=\"lessonValueStart!=null and lessonValueStart != ''\"> and CAST(lesson_value AS UNSIGNED) &gt;= #{lessonValueStart} </if> " +
"<if test=\"lessonValueEnd!=null and lessonValueEnd != ''\"> and CAST(lesson_value AS UNSIGNED) &lt;= #{lessonValueEnd} </if> " +
"<if test=\"trainValueStart!=null and trainValueStart != ''\"> and CAST(train_value AS UNSIGNED) &gt;= #{trainValueStart} </if> " +
"<if test=\"trainValueEnd!=null and trainValueEnd != ''\"> and CAST(train_value AS UNSIGNED) &lt;= #{trainValueEnd} </if> " +
" ORDER BY corp_id " +
"<if test=\"lessonSort!=null and lessonSort != '' and lessonSort == '1'.toString()\"> ,lesson_value asc </if> " +
"<if test=\"lessonSort!=null and lessonSort != '' and lessonSort == '0'.toString()\"> ,lesson_value desc </if> " +
"<if test=\"trainSort!=null and trainSort != '' and trainSort == '1'.toString()\"> ,train_value asc </if> " +
"<if test=\"lessonSort!=null and lessonSort != '' and lessonSort == '1'.toString()\"> ,CAST(lesson_value AS UNSIGNED) asc </if> " +
"<if test=\"lessonSort!=null and lessonSort != '' and lessonSort == '0'.toString()\"> ,CAST(lesson_value AS UNSIGNED) desc </if> " +
"<if test=\"trainSort!=null and trainSort != '' and trainSort == '1'.toString()\"> ,CAST(train_value AS UNSIGNED) asc </if> " +
"<if test=\"trainSort!=null and trainSort != '' and trainSort == '0'.toString()\"> ,train_value desc </if> " +
"<if test=\"timeSort!=null and timeSort != '' and timeSort == '1'.toString()\"> ,update_date asc </if> " +
"<if test=\"timeSort!=null and timeSort != '' and timeSort == '0'.toString()\"> ,update_date desc </if> " +
......@@ -111,10 +111,10 @@ public interface BReleaseValueRepository extends BaseMapper<BReleaseValue> {
"from b_lesson bl " +
"left join s_user su on su.business_id = bl.lecturer_id " +
"where bl.del_flag !=1 and bl.flag = 1 " +
"<if test=\"dto.valueConsumeStart!=null and dto.valueConsumeStart != ''\"> and bl.value_consume &gt;= #{dto.valueConsumeStart} </if> " +
"<if test=\"dto.valueConsumeEnd!=null and dto.valueConsumeEnd != ''\"> and bl.value_consume &lt;= #{dto.valueConsumeEnd} </if> " +
"<if test=\"dto.valueGainStart!=null and dto.valueGainStart != ''\"> and bl.value_gain &gt;= #{dto.valueGainStart} </if> " +
"<if test=\"dto.valueGainEnd!=null and dto.valueGainEnd != ''\"> and bl.value_gain &lt;= #{dto.valueGainEnd} </if> " +
"<if test=\"dto.valueConsumeStart!=null and dto.valueConsumeStart != ''\"> and CAST(bl.value_consume AS UNSIGNED) &gt;= #{dto.valueConsumeStart} </if> " +
"<if test=\"dto.valueConsumeEnd!=null and dto.valueConsumeEnd != ''\"> and CAST(bl.value_consume AS UNSIGNED) &lt;= #{dto.valueConsumeEnd} </if> " +
"<if test=\"dto.valueGainStart!=null and dto.valueGainStart != ''\"> and CAST(bl.value_gain AS UNSIGNED) &gt;= #{dto.valueGainStart} </if> " +
"<if test=\"dto.valueGainEnd!=null and dto.valueGainEnd != ''\"> and CAST(bl.value_gain AS UNSIGNED) &lt;= #{dto.valueGainEnd} </if> " +
"<if test=\"dto.lessonName!=null and dto.lessonName != ''\"> and bl.lesson_name like concat('%',#{dto.lessonName},'%') </if> " +
"<if test=\"dto.lecturerName!=null and dto.lecturerName != ''\"> and su.`name` like concat('%',#{dto.lecturerName},'%') </if> " +
"<if test=\"dto.status!=null and dto.status != ''\"> and bl.release_state in(${dto.status}) </if> " +
......@@ -122,10 +122,10 @@ public interface BReleaseValueRepository extends BaseMapper<BReleaseValue> {
"and bl.corp_id = #{curUser.corpId} " +
"and bl.lesson_type = #{dto.type} " +
"ORDER BY bl.corp_id " +
"<if test=\"dto.valueConsumeSort!=null and dto.valueConsumeSort != '' and dto.valueConsumeSort == '1'.toString()\"> ,bl.value_consume asc </if> " +
"<if test=\"dto.valueConsumeSort!=null and dto.valueConsumeSort != '' and dto.valueConsumeSort == '0'.toString()\"> ,bl.value_consume desc </if> " +
"<if test=\"dto.valueGainSort!=null and dto.valueGainSort != '' and dto.valueGainSort == '1'.toString()\"> ,bl.value_gain asc </if> " +
"<if test=\"dto.valueGainSort!=null and dto.valueGainSort != '' and dto.valueGainSort == '0'.toString()\"> ,bl.value_gain desc </if> " +
"<if test=\"dto.valueConsumeSort!=null and dto.valueConsumeSort != '' and dto.valueConsumeSort == '1'.toString()\"> ,CAST(bl.value_consume AS UNSIGNED) asc </if> " +
"<if test=\"dto.valueConsumeSort!=null and dto.valueConsumeSort != '' and dto.valueConsumeSort == '0'.toString()\"> ,CAST(bl.value_consume AS UNSIGNED) desc </if> " +
"<if test=\"dto.valueGainSort!=null and dto.valueGainSort != '' and dto.valueGainSort == '1'.toString()\"> ,CAST(bl.value_gain AS UNSIGNED) asc </if> " +
"<if test=\"dto.valueGainSort!=null and dto.valueGainSort != '' and dto.valueGainSort == '0'.toString()\"> ,CAST(bl.value_gain AS UNSIGNED) desc </if> " +
"<if test=\"dto.updateDateSort!=null and dto.updateDateSort != '' and dto.updateDateSort == '1'.toString()\"> ,bl.value_update_date asc </if> " +
"<if test=\"dto.updateDateSort!=null and dto.updateDateSort != '' and dto.updateDateSort == '0'.toString()\"> ,bl.value_update_date desc </if> " +
"<if test=\"(dto.valueConsumeSort ==null or dto.valueConsumeSort == '') and (dto.valueGainSort == null or dto.valueGainSort == '') and (dto.updateDateSort == null or dto.updateDateSort == '')\"> ,bl.create_date desc </if> " +
......
......@@ -8,16 +8,18 @@ import org.hibernate.validator.constraints.Length;
public class BReleaseValueDto {
@ApiModelProperty(value = "分组名")
@Length(min = 1,max = 20,message = "长度最小为1,最大为20")
@Length(max = 20,message = "长度最大为20")
private String title;
@ApiModelProperty(value = "主键id")
private String businessId;
@ApiModelProperty(value = "发布课程积分")
@Length(max = 10,message = "长度最大为10")
private String lessonValue;
@ApiModelProperty(value = "发布培训积分")
@Length(max = 10,message = "长度最大为10")
private String trainValue;
@ApiModelProperty(value = "用户ids(用 , 隔开)")
......
......@@ -2,26 +2,33 @@ package org.rcisoft.business.breleasevalue.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@Data
public class LessonValueSettingQueryDto {
@ApiModelProperty(value = "课程、培训名")
@Length(max = 20,message = "长度最大为20")
public String lessonName;
@ApiModelProperty(value = "讲师名")
@Length(max = 10,message = "长度最大为10")
public String lecturerName;
@ApiModelProperty(value = "积分消耗起始值")
@Length(max = 10,message = "长度最大为10")
public String valueConsumeStart;
@ApiModelProperty(value = "积分消耗最大值")
@Length(max = 10,message = "长度最大为10")
public String valueConsumeEnd;
@ApiModelProperty(value = "积分获得起始值")
@Length(max = 10,message = "长度最大为10")
public String valueGainStart;
@ApiModelProperty(value = "积分获得最大值")
@Length(max = 10,message = "长度最大为10")
public String valueGainEnd;
@ApiModelProperty(value = "状态 0未发布 2已发布 4已关闭 ")
......
......@@ -2,6 +2,7 @@ package org.rcisoft.business.breleasevalue.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import java.util.List;
......@@ -9,21 +10,27 @@ import java.util.List;
public class ReleaseValueResDto {
@ApiModelProperty(value = "分组标题")
@Length(max = 50,message = "长度最大为50")
public String title;
@ApiModelProperty(value = "人员姓名")
@Length(max = 50,message = "长度最大为50")
public String name;
@ApiModelProperty(value = "课程奖励起始")
@Length(max = 10,message = "长度最大为10")
public String lessonValueStart;
@ApiModelProperty(value = "课程奖励截止")
@Length(max = 10,message = "长度最大为10")
public String lessonValueEnd;
@ApiModelProperty(value = "培训奖励起始")
@Length(max = 10,message = "长度最大为10")
public String trainValueStart;
@ApiModelProperty(value = "培训奖励截止")
@Length(max = 10,message = "长度最大为10")
public String trainValueEnd;
@ApiModelProperty(value = "课程积分排序 0正序 1倒序")
......
......@@ -2,25 +2,31 @@ package org.rcisoft.business.breleasevalue.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
@Data
public class UserValueResDto {
@ApiModelProperty(value = "用户名")
@Length(max = 10,message = "长度最大为10")
public String name;
@ApiModelProperty(value = "部门id")
public String dept;
@ApiModelProperty(value = "当前积分起始")
@Length(max = 10,message = "长度最大为10")
public String nowValueStart;
@ApiModelProperty(value = "当前积分截止")
@Length(max = 10,message = "长度最大为10")
public String nowValueEnd;
@ApiModelProperty(value = "获取积分起始")
@Length(max = 10,message = "长度最大为10")
public String gainValueStart;
@ApiModelProperty(value = "获取积分截止")
@Length(max = 10,message = "长度最大为10")
public String gainValueEnd;
@ApiModelProperty(value = "当前积分排序 0正序 1 倒序")
......
......@@ -256,6 +256,7 @@ public enum ResultServiceEnums {
FILE_OVER_SIZE(156,"文件超过规定大小"),
FILE_OVER_PAGES(157,"文件页数超过规定个数"),
FILE_CHECK_ERROR(158,"文件格式与后缀名不符,请上传其他文件"),
NOT_FILE(159,"未选择上传文件"),
;
private Integer code;
......
package org.rcisoft.core.util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import java.io.FileInputStream;
@Slf4j
......@@ -45,6 +46,28 @@ public class CheckFileHeaderUtil {
}else {
return false;
}
} /**
* 通过文件去判断文件类型
* @param file
* @return
*/
public static boolean toCheckFile(MultipartFile file){
String result = "";
String url = file.getOriginalFilename();
try{
FileInputStream is = (FileInputStream)file.getInputStream();
byte[] b = new byte[45];
is.read(b, 0, b.length);
result = checkType(bytesToHexString(b).toUpperCase());
is.close();
}catch (Exception e){
log.error(e.getMessage());
}
if(result.toUpperCase().contains(url.substring(url.lastIndexOf(".")+1).toUpperCase())){
return true;
}else {
return false;
}
}
public static String checkType(String type) {
......
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