Commit 2ade57d6 authored by YangZhaoJun1's avatar YangZhaoJun1

接口调整

parent cd7bbdf0
...@@ -124,7 +124,11 @@ public class BCarouselController extends PaginationController<BCarousel> { ...@@ -124,7 +124,11 @@ public class BCarouselController extends PaginationController<BCarousel> {
public Result upload(MultipartFile file){ public Result upload(MultipartFile file){
String path = global.getBASE_UPLOAD_SERVER_LOCATION(); String path = global.getBASE_UPLOAD_SERVER_LOCATION();
String sl_logo_path = global.getIMAGE_LOCATION()+global.getIMAGES_LOCATION(); String sl_logo_path = global.getIMAGE_LOCATION()+global.getIMAGES_LOCATION();
Map<String, Object> uploadResult = UploadUtil.picImport(path, sl_logo_path, file); boolean type = false;
if((global.getSERVER_LINUX()).equals(global.getIS_SERVER_LINUX())){
type = true;
}
Map<String, Object> uploadResult = UploadUtil.picImport(path, sl_logo_path, file, type);
if ((boolean) uploadResult.get(UploadUtil.IS_SUCCESSS)) { if ((boolean) uploadResult.get(UploadUtil.IS_SUCCESSS)) {
String url = (String) uploadResult.get(UploadUtil.URL); String url = (String) uploadResult.get(UploadUtil.URL);
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
......
...@@ -118,7 +118,11 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -118,7 +118,11 @@ public class BChapterController extends PaginationController<BChapter> {
public Map<String, Object> uploadMdFile(@RequestParam(name = "editormd-image-file") MultipartFile image) { public Map<String, Object> uploadMdFile(@RequestParam(name = "editormd-image-file") MultipartFile image) {
String path = global.getMD_FILE_LOCATION(); String path = global.getMD_FILE_LOCATION();
String basePath = global.getBASE_UPLOAD_SERVER_LOCATION(); String basePath = global.getBASE_UPLOAD_SERVER_LOCATION();
Map<String, Object> pic = UploadUtil.picImport(basePath, path, image); boolean type = false;
if((global.getSERVER_LINUX()).equals(global.getIS_SERVER_LINUX())){
type = true;
}
Map<String, Object> pic = UploadUtil.picImport(basePath, path, image, type);
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
if (!(boolean) pic.get(UploadUtil.IS_SUCCESSS)) { if (!(boolean) pic.get(UploadUtil.IS_SUCCESSS)) {
result.put("success", 0); result.put("success", 0);
......
...@@ -68,7 +68,7 @@ public class BClassController extends PaginationController<BClass> { ...@@ -68,7 +68,7 @@ public class BClassController extends PaginationController<BClass> {
public Result remove(String id) { public Result remove(String id) {
PersistModel data = bClassService.removeBClass(id); PersistModel data = bClassService.removeBClass(id);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, data.getInfluenceReason(),
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
id); id);
} }
...@@ -110,7 +110,7 @@ public class BClassController extends PaginationController<BClass> { ...@@ -110,7 +110,7 @@ public class BClassController extends PaginationController<BClass> {
return gridModel; return gridModel;
} }
@ApiOperation(value="根据条件查询班级", notes="根据URL中的参数分页查询全部班级") @ApiOperation(value="根据条件查询班级", notes="根据URL中的参数查询全部班级")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "code", value = "班级编号", required = false, dataType = "varchar"), @ApiImplicitParam(name = "code", value = "班级编号", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "className", value = "班级名称", required = false, dataType = "varchar"), @ApiImplicitParam(name = "className", value = "班级名称", required = false, dataType = "varchar"),
......
...@@ -16,7 +16,7 @@ public interface BClassRepository extends BaseMapper<BClass> { ...@@ -16,7 +16,7 @@ public interface BClassRepository extends BaseMapper<BClass> {
/** /**
* 根据条件查找 * 根据条件查找
* @param param * @param bClass
* @return * @return
*/ */
// @Select("<script>select * from b_class b where b.del_flag != 1" + // @Select("<script>select * from b_class b where b.del_flag != 1" +
...@@ -24,7 +24,7 @@ public interface BClassRepository extends BaseMapper<BClass> { ...@@ -24,7 +24,7 @@ public interface BClassRepository extends BaseMapper<BClass> {
// "<if test=\"num!=null\">and b.`student_num` = #{num}</if></script>)") // "<if test=\"num!=null\">and b.`student_num` = #{num}</if></script>)")
// @Select("select * from b_class") // @Select("select * from b_class")
// @ResultMap(value = "BaseResultMap" ) // @ResultMap(value = "BaseResultMap" )
List<BClass> queryBClasss(Map<String, Object> param); List<BClass> queryBClasss(BClass bClass);
/** /**
* 更新班级人数 * 更新班级人数
......
...@@ -7,6 +7,7 @@ import org.rcisoft.business.bclass.entity.BClass; ...@@ -7,6 +7,7 @@ import org.rcisoft.business.bclass.entity.BClass;
import org.rcisoft.business.bclass.service.BClassService; import org.rcisoft.business.bclass.service.BClassService;
import org.rcisoft.business.brclassstudent.dao.BRClassStudentRepository; import org.rcisoft.business.brclassstudent.dao.BRClassStudentRepository;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
...@@ -42,12 +43,12 @@ public class BClassServiceImpl implements BClassService { ...@@ -42,12 +43,12 @@ public class BClassServiceImpl implements BClassService {
@Override @Override
public List<BClass> queryBClasssByPagination(PageUtil pageUtil, BClass model) { public List<BClass> queryBClasssByPagination(PageUtil pageUtil, BClass model) {
return bClassRepository.queryBClasss(queryParamHandler(model)); return bClassRepository.queryBClasss(model);
} }
@Override @Override
public List<BClass> queryBClasss(BClass model) { public List<BClass> queryBClasss(BClass model) {
return bClassRepository.queryBClasss(queryParamHandler(model)); return bClassRepository.queryBClasss(model);
} }
...@@ -70,10 +71,12 @@ public class BClassServiceImpl implements BClassService { ...@@ -70,10 +71,12 @@ public class BClassServiceImpl implements BClassService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override @Override
public PersistModel removeBClass(String id) { public PersistModel removeBClass(String id) {
if(brClassStudentRepository.selectStuentNumByClassId(id)>0) if(brClassStudentRepository.selectStuentNumByClassId(id)>0) {
throw new ServiceException(ResultServiceEnums.CLASS_HAS_STUDENTS); //throw new ServiceException(ResultServiceEnums.CLASS_HAS_STUDENTS);
return new PersistModel(1, (ResultServiceEnums.CLASS_HAS_STUDENTS).getMessage());
}
int line = bClassRepository.deleteByPrimaryKey(id); int line = bClassRepository.deleteByPrimaryKey(id);
return new PersistModel(line); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
...@@ -120,7 +123,7 @@ public class BClassServiceImpl implements BClassService { ...@@ -120,7 +123,7 @@ public class BClassServiceImpl implements BClassService {
private Map<String,Object> queryParamHandler(BClass model){ private Map<String,Object> queryParamHandler(BClass model){
Map param = new HashMap<String, Object>(); Map param = new HashMap<String, Object>();
if(model.getClassName()!=null) if(!model.getClassName().equals("")&&model.getClassName()!="")
param.put("name","%"+model.getClassName()+"%"); param.put("name","%"+model.getClassName()+"%");
else else
param.put("name","%%"); param.put("name","%%");
......
...@@ -74,7 +74,7 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -74,7 +74,7 @@ public class BLessonController extends PaginationController<BLesson> {
public Result remove(String id) { public Result remove(String id) {
PersistModel data = bLessonService.removeBLesson(id); PersistModel data = bLessonService.removeBLesson(id);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, data.getInfluenceReason(),
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
id); id);
} }
...@@ -99,7 +99,11 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -99,7 +99,11 @@ public class BLessonController extends PaginationController<BLesson> {
public Result picImport(MultipartFile importFile,String code) throws Exception { public Result picImport(MultipartFile importFile,String code) throws Exception {
String path = global.getBASE_UPLOAD_SERVER_LOCATION(); String path = global.getBASE_UPLOAD_SERVER_LOCATION();
String course_logo_path =global.getIMAGE_LOCATION()+global.getCOURCE_LOGO_LOCATION(); String course_logo_path =global.getIMAGE_LOCATION()+global.getCOURCE_LOGO_LOCATION();
Map<String,Object> map= UploadUtil.picImport(path,course_logo_path,importFile); boolean type = false;
if((global.getSERVER_LINUX()).equals(global.getIS_SERVER_LINUX())){
type = true;
}
Map<String,Object> map= UploadUtil.picImport(path,course_logo_path,importFile,type);
if(map.get(UploadUtil.IS_SUCCESSS).equals(true)) if(map.get(UploadUtil.IS_SUCCESSS).equals(true))
{ {
BLesson bL=new BLesson(); BLesson bL=new BLesson();
......
...@@ -8,6 +8,7 @@ import org.rcisoft.business.blesson.service.BLessonService; ...@@ -8,6 +8,7 @@ import org.rcisoft.business.blesson.service.BLessonService;
import org.rcisoft.business.bsl.dao.BSlRepository; import org.rcisoft.business.bsl.dao.BSlRepository;
import org.rcisoft.common.component.Global; import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
...@@ -164,10 +165,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -164,10 +165,13 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override @Override
public PersistModel removeBLesson(String id) { public PersistModel removeBLesson(String id) {
if(bSlRepository.selectslNumByLesson(id)>0) if(bSlRepository.selectslNumByLesson(id)>0) {
throw new ServiceException(ResultServiceEnums.LESSON_HAS_SL); //throw new ServiceException(ResultServiceEnums.LESSON_HAS_SL);
return new PersistModel(1, (ResultServiceEnums.LESSON_HAS_SL).getMessage());
}
int line = bLessonRepository.deleteByPrimaryKey(id); int line = bLessonRepository.deleteByPrimaryKey(id);
return new PersistModel(line); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
private Map<String,Object> queryParamHandler(BLesson model){ private Map<String,Object> queryParamHandler(BLesson model){
......
...@@ -192,7 +192,11 @@ public class BSlController extends PaginationController<BSl> { ...@@ -192,7 +192,11 @@ public class BSlController extends PaginationController<BSl> {
@RequestParam("id") String id) { @RequestParam("id") String id) {
String path = global.getBASE_UPLOAD_SERVER_LOCATION(); String path = global.getBASE_UPLOAD_SERVER_LOCATION();
String sl_logo_path = global.getIMAGE_LOCATION() + global.getLANCH_LOGO_LOCATION(); String sl_logo_path = global.getIMAGE_LOCATION() + global.getLANCH_LOGO_LOCATION();
Map<String, Object> uploadResult = UploadUtil.picImport(path, sl_logo_path, cover); boolean type = false;
if((global.getSERVER_LINUX()).equals(global.getIS_SERVER_LINUX())){
type = true;
}
Map<String, Object> uploadResult = UploadUtil.picImport(path, sl_logo_path, cover,type);
if ((boolean) uploadResult.get(UploadUtil.IS_SUCCESSS)) { if ((boolean) uploadResult.get(UploadUtil.IS_SUCCESSS)) {
String url = (String) uploadResult.get(UploadUtil.URL); String url = (String) uploadResult.get(UploadUtil.URL);
BSl bSl = new BSl(); BSl bSl = new BSl();
......
...@@ -127,7 +127,7 @@ public class BStudentController extends PaginationController<BStudent> { ...@@ -127,7 +127,7 @@ public class BStudentController extends PaginationController<BStudent> {
public Result remove(String id) { public Result remove(String id) {
PersistModel data = bStudentService.removeBBStudent(id); PersistModel data = bStudentService.removeBBStudent(id);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, data.getInfluenceReason(),
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
id); id);
} }
......
...@@ -8,6 +8,7 @@ import org.rcisoft.business.bstudent.entity.BStudent; ...@@ -8,6 +8,7 @@ import org.rcisoft.business.bstudent.entity.BStudent;
import org.rcisoft.business.bstudent.service.BStudentService; import org.rcisoft.business.bstudent.service.BStudentService;
import org.rcisoft.common.component.Global; import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.entity.DataEntity; import org.rcisoft.core.entity.DataEntity;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
...@@ -243,12 +244,12 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -243,12 +244,12 @@ public class BStudentServiceImpl implements BStudentService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel removeBBStudent(String id) { public PersistModel removeBBStudent(String id) {
if(brSlStudentRepository.selectSlNumByStuId(id)>0) if(brSlStudentRepository.selectSlNumByStuId(id)>0) {
throw new ServiceException(ResultServiceEnums.STUDENT_HAS_SL); return new PersistModel(1, (ResultServiceEnums.STUDENT_HAS_SL).getMessage());
/*User user = userRepository.selectUserByStuOrTeaId(id,"b_student"); //throw new ServiceException(ResultServiceEnums.STUDENT_HAS_SL);
userService.removeUser(user);*/ }
int line = bStudentRepository.deleteByPrimaryKey(id); int line = bStudentRepository.deleteByPrimaryKey(id);
return new PersistModel(line); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
@Override @Override
......
...@@ -66,7 +66,7 @@ public class BTeacherController extends PaginationController<BTeacher> { ...@@ -66,7 +66,7 @@ public class BTeacherController extends PaginationController<BTeacher> {
public Result remove(String id) { public Result remove(String id) {
PersistModel data = bTeacherService.removeBTeacher(id); PersistModel data = bTeacherService.removeBTeacher(id);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, data.getInfluenceReason(),
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
id); id);
} }
......
...@@ -8,6 +8,7 @@ import org.rcisoft.business.bteacher.entity.BTeacher; ...@@ -8,6 +8,7 @@ import org.rcisoft.business.bteacher.entity.BTeacher;
import org.rcisoft.business.bteacher.service.BTeacherService; import org.rcisoft.business.bteacher.service.BTeacherService;
import org.rcisoft.common.component.Global; import org.rcisoft.common.component.Global;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.entity.DataEntity; import org.rcisoft.core.entity.DataEntity;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
...@@ -190,12 +191,12 @@ public class BTeacherServiceImpl implements BTeacherService { ...@@ -190,12 +191,12 @@ public class BTeacherServiceImpl implements BTeacherService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel removeBTeacher(String id) { public PersistModel removeBTeacher(String id) {
if(bSlRepository.selectSlNumByStuent(id)>0) if(bSlRepository.selectSlNumByStuent(id)>0) {
throw new ServiceException(ResultServiceEnums.TEACHER_HAS_SL); //throw new ServiceException(ResultServiceEnums.TEACHER_HAS_SL);
/*User user =userRepository.selectUserByStuOrTeaId(id,"b_teacher"); return new PersistModel(1, (ResultServiceEnums.TEACHER_HAS_SL).getMessage());
userService.removeUser(user);*/ }
int line = bTeacherRepository.deleteByPrimaryKey(id); int line = bTeacherRepository.deleteByPrimaryKey(id);
return new PersistModel(line); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
@Override @Override
......
...@@ -116,7 +116,7 @@ public class BTermController extends PaginationController<BTerm> { ...@@ -116,7 +116,7 @@ public class BTermController extends PaginationController<BTerm> {
public Result remove(String id) { public Result remove(String id) {
PersistModel data = bTermService.removeBTerm(id); PersistModel data = bTermService.removeBTerm(id);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, data.getInfluenceReason(),
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
id); id);
} }
......
...@@ -6,6 +6,7 @@ import org.rcisoft.business.bterm.entity.BTerm; ...@@ -6,6 +6,7 @@ import org.rcisoft.business.bterm.entity.BTerm;
import org.rcisoft.business.bterm.enums.BTermEnum; import org.rcisoft.business.bterm.enums.BTermEnum;
import org.rcisoft.business.bterm.service.BTermService; import org.rcisoft.business.bterm.service.BTermService;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
...@@ -69,10 +70,12 @@ public class BTermServiceImpl implements BTermService { ...@@ -69,10 +70,12 @@ public class BTermServiceImpl implements BTermService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public PersistModel removeBTerm(String id) { public PersistModel removeBTerm(String id) {
if(bSlRepository.selectslNumByTermId(id)>0) if(bSlRepository.selectslNumByTermId(id)>0) {
throw new ServiceException(ResultServiceEnums.TERM_HAS_SL); return new PersistModel(1, (ResultServiceEnums.TERM_HAS_SL).getMessage());
//throw new ServiceException(ResultServiceEnums.TERM_HAS_SL);
}
int line = bTermRepository.deleteByPrimaryKey(id); int line = bTermRepository.deleteByPrimaryKey(id);
return new PersistModel(line); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
......
...@@ -90,8 +90,8 @@ public class MvcConfig extends WebMvcConfigurerAdapter { ...@@ -90,8 +90,8 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
else else
result.setCode(ResultCode.UNAUTHORIZED).setMessage(e.getMessage()); result.setCode(ResultCode.UNAUTHORIZED).setMessage(e.getMessage());
} else if (e instanceof AccessDeniedException) { } else if (e instanceof AccessDeniedException) {
log.info(e.getMessage()); //无权限 @PreAuthorize("hasRole('ROLE_1001')")
result.setCode(ResultCode.UNAUTHORIZED).setMessage(""); result.setCode(ResultCode.UNAUTHORIZED).setMessage("无访问权限");
} else { } else {
result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage("接口 [" + request.getRequestURI() + "] 内部错误,请联系管理员"); result.setCode(ResultCode.INTERNAL_SERVER_ERROR).setMessage("接口 [" + request.getRequestURI() + "] 内部错误,请联系管理员");
String message = String.format("接口 [%s] 出现异常,方法:%s.%s,异常摘要:%s", String message = String.format("接口 [%s] 出现异常,方法:%s.%s,异常摘要:%s",
......
...@@ -78,6 +78,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -78,6 +78,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/api-docs/**").permitAll() .antMatchers("/api-docs/**").permitAll()
.antMatchers("/auth/**").permitAll() //登录注册等请求过滤 .antMatchers("/auth/**").permitAll() //登录注册等请求过滤
.antMatchers("/code/**").permitAll() //登录注册等请求过滤 .antMatchers("/code/**").permitAll() //登录注册等请求过滤
.antMatchers("/excelUtil/**").permitAll()//excel类
.antMatchers( .antMatchers(
"/", "/",
"/*.html", "/*.html",
......
...@@ -61,14 +61,14 @@ public abstract class DataEntity<T> implements Serializable { ...@@ -61,14 +61,14 @@ public abstract class DataEntity<T> implements Serializable {
* 设置启用 * 设置启用
*/ */
public void setStart(){ public void setStart(){
this.setDelFlag(FlagStatus.NORMAL.getStatus()); this.setFlag(FlagStatus.NORMAL.getStatus());
} }
/** /**
* 设置停用 * 设置停用
*/ */
public void setStop(){ public void setStop(){
this.setDelFlag(FlagStatus.ABNORMAL.getStatus()); this.setFlag(FlagStatus.ABNORMAL.getStatus());
} }
} }
...@@ -10,6 +10,7 @@ public enum ResultCode { ...@@ -10,6 +10,7 @@ public enum ResultCode {
NOT_FOUND(404),//接口不存在 NOT_FOUND(404),//接口不存在
INTERNAL_SERVER_ERROR(500);//服务器内部错误 INTERNAL_SERVER_ERROR(500);//服务器内部错误
public int code; public int code;
ResultCode(int code) { ResultCode(int code) {
......
...@@ -27,9 +27,8 @@ public class UploadUtil { ...@@ -27,9 +27,8 @@ public class UploadUtil {
* @param multipartFile 上传的文件 * @param multipartFile 上传的文件
* @return * @return
*/ */
public static Map<String,Object> picImport(String basePath, String uploadPath, MultipartFile multipartFile) { public static Map<String,Object> picImport(String basePath, String uploadPath, MultipartFile multipartFile, boolean type) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
Global global = new Global();
try { try {
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
...@@ -56,10 +55,9 @@ public class UploadUtil { ...@@ -56,10 +55,9 @@ public class UploadUtil {
String fileurl = realPath + filename; String fileurl = realPath + filename;
multipartFile.transferTo(new File(fileurl));//上传到服务器,在服务器上新建一个文件夹,放图片, multipartFile.transferTo(new File(fileurl));//上传到服务器,在服务器上新建一个文件夹,放图片,
// 图片是multipartFile中包含的,也就是说,实际上传给我的参数中,multipartFile就是图片的代表。 // 图片是multipartFile中包含的,也就是说,实际上传给我的参数中,multipartFile就是图片的代表。
System.out.println(global.getSERVER_LINUX()); if(type) {
System.out.println(global.getIS_SERVER_LINUX()); Runtime.getRuntime().exec("chmod -R 755 " + basePath);
if((global.getSERVER_LINUX()).equals(global.getIS_SERVER_LINUX())) }
Runtime.getRuntime().exec("chmod -R 755 "+basePath);
map.put(IS_SUCCESSS, true); map.put(IS_SUCCESSS, true);
map.put(URL, userPath.substring(1, userPath.length()) + filename);//url中是图片的路径,应该是服务器上图片 map.put(URL, userPath.substring(1, userPath.length()) + filename);//url中是图片的路径,应该是服务器上图片
//的路径,我在controller中调用这个方法时间,直接看返回值,如果isSuccess是true,则取出url,然后将其存入数据库,如果 //的路径,我在controller中调用这个方法时间,直接看返回值,如果isSuccess是true,则取出url,然后将其存入数据库,如果
......
...@@ -51,7 +51,6 @@ public class UserUtil { ...@@ -51,7 +51,6 @@ public class UserUtil {
/** /**
* 增加实体 * 增加实体
* @param entity * @param entity
* @param token
*/ */
public static void setCurrentPersistOperation(IdEntity entity) { public static void setCurrentPersistOperation(IdEntity entity) {
entity.setCreateBy(UserUtil.getAuthenBusinessId()); entity.setCreateBy(UserUtil.getAuthenBusinessId());
...@@ -66,7 +65,6 @@ public class UserUtil { ...@@ -66,7 +65,6 @@ public class UserUtil {
/** /**
* 修改实体 * 修改实体
* @param entity * @param entity
* @param token
*/ */
public static void setCurrentMergeOperation(IdEntity entity) { public static void setCurrentMergeOperation(IdEntity entity) {
entity.setUpdateBy(UserUtil.getAuthenBusinessId()); entity.setUpdateBy(UserUtil.getAuthenBusinessId());
......
...@@ -6,6 +6,8 @@ import org.rcisoft.common.component.Global; ...@@ -6,6 +6,8 @@ import org.rcisoft.common.component.Global;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -16,7 +18,9 @@ import java.net.URLEncoder; ...@@ -16,7 +18,9 @@ import java.net.URLEncoder;
/** /**
* Created by gaowenfeng on 2017/8/2. * Created by gaowenfeng on 2017/8/2.
*/ */
@RestController @RestController
@RequestMapping("/excelUtil")
public class ExcelDownloadController { public class ExcelDownloadController {
private static final String STUDNET_FILE_NAME = "student.xls"; private static final String STUDNET_FILE_NAME = "student.xls";
private static final String TEACHER_FILE_NAME = "teacher.xls"; private static final String TEACHER_FILE_NAME = "teacher.xls";
...@@ -31,15 +35,14 @@ public class ExcelDownloadController { ...@@ -31,15 +35,14 @@ public class ExcelDownloadController {
@ApiOperation(value="下载excel模板", notes="下载excel模板") @ApiOperation(value="下载excel模板", notes="下载excel模板")
@ApiImplicitParam(name = "type", value = "模板类型", required = false, dataType = "varchar") @ApiImplicitParam(name = "type", value = "模板类型", required = false, dataType = "varchar")
@PostMapping("excelWithoutAuth") @GetMapping("excelWithoutAuth")
public void excelDownLoad(HttpServletRequest request, public void excelDownLoad(HttpServletRequest request,
HttpServletResponse response, HttpServletResponse response,
@RequestParam("type") String type) @RequestParam("type") String type)
throws Exception { throws Exception {
String path = request.getServletContext().getRealPath(global.getEXCEL_TEMPLATE_LOCATION());
InputStream in = null; InputStream in = null;
OutputStream out = null; OutputStream out = null;
File file = getDownLoadFile(type,path); File file = getDownLoadFile(type);
if (file == null) if (file == null)
throw new ServiceException(ResultServiceEnums.TEMPLAGE_NOT_EXISTS); throw new ServiceException(ResultServiceEnums.TEMPLAGE_NOT_EXISTS);
in = new BufferedInputStream(new FileInputStream(file)); in = new BufferedInputStream(new FileInputStream(file));
...@@ -60,29 +63,29 @@ public class ExcelDownloadController { ...@@ -60,29 +63,29 @@ public class ExcelDownloadController {
excelDownLoad(request,response,type); excelDownLoad(request,response,type);
} }
private File getDownLoadFile(String type, String path){ private File getDownLoadFile(String type) throws Exception {
File file = null; File file = null;
switch (type) { switch (type) {
case "1": case "1":
file = new File(path + STUDNET_FILE_NAME); file = ResourceUtils.getFile("classpath:"+global.getEXCEL_TEMPLATE_LOCATION()+STUDNET_FILE_NAME);
break; break;
case "2": case "2":
file = new File(path + TEACHER_FILE_NAME); file = ResourceUtils.getFile("classpath:"+global.getEXCEL_TEMPLATE_LOCATION()+TEACHER_FILE_NAME);
break; break;
case "3": case "3":
file = new File(path + CLASS_FILE_NAME); file = ResourceUtils.getFile("classpath:"+global.getEXCEL_TEMPLATE_LOCATION()+CLASS_FILE_NAME);
break; break;
case "4": case "4":
file = new File(path + STUDENT_CLASS_FILE_NAME); file = ResourceUtils.getFile("classpath:"+global.getEXCEL_TEMPLATE_LOCATION()+STUDENT_CLASS_FILE_NAME);
break; break;
case "5": case "5":
file = new File(path + STUDNET_SL_FILE_NAME); file = ResourceUtils.getFile("classpath:"+global.getEXCEL_TEMPLATE_LOCATION()+STUDNET_SL_FILE_NAME);
break; break;
case "6": case "6":
file = new File(path + LESSON_FILE_NAME); file = ResourceUtils.getFile("classpath:"+global.getEXCEL_TEMPLATE_LOCATION()+LESSON_FILE_NAME);
break; break;
case "7": case "7":
file = new File(path + SL_FILE_NAME); file = ResourceUtils.getFile("classpath:"+global.getEXCEL_TEMPLATE_LOCATION()+SL_FILE_NAME);
break; break;
} }
return file; return file;
......
#没有此配置文件查询方法会报相同实体类无法转换问题 ----- entity cannot be cast to entity
restart.include.companycommonlibs=tk/mybatis.*
\ No newline at end of file
...@@ -106,7 +106,7 @@ global: ...@@ -106,7 +106,7 @@ global:
video_location: /video video_location: /video
temp_location: /temp temp_location: /temp
file_location: /file file_location: /file
excel_template_location: /WEB-INF/classes/excel-template/ excel_template_location: excel-template/
cource_logo_location: /course/logo cource_logo_location: /course/logo
images_location: /images images_location: /images
lanch_logo_location: /lanch/logo lanch_logo_location: /lanch/logo
...@@ -117,7 +117,7 @@ global: ...@@ -117,7 +117,7 @@ global:
server_url: http://gwf.natapp.cc/eduServer server_url: http://gwf.natapp.cc/eduServer
server_linux: 1 server_linux: 1
login_secert_key: "base64EncodedSecretKey" login_secert_key: "base64EncodedSecretKey"
is_server_linux: 1 is_server_linux: 5
max_code_length: 15 max_code_length: 15
session_admin_header_value: pYez25-y7nqPfm9seY2S session_admin_header_value: pYez25-y7nqPfm9seY2S
code: code:
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
<select id="queryBClasss" resultMap="BaseResultMap"> <select id="queryBClasss" resultMap="BaseResultMap">
SELECT * FROM b_class b SELECT * FROM b_class b
WHERE b.del_flag = 1 WHERE b.del_flag != '1'
<if test="name!=null"> <if test="className!=null and className != ''">
AND b.class_name LIKE #{name} OR b.code LIKE #{name} AND b.class_name LIKE CONCAT('%',#{className},'%') OR b.code LIKE CONCAT('%',#{className},'%')
</if> </if>
<if test="num!=null"> <if test="studentNum!=null and studentNum != ''">
AND b.student_num = #{num} AND b.student_num = #{studentNum}
</if> </if>
</select> </select>
......
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