Commit 2ade57d6 authored by YangZhaoJun1's avatar YangZhaoJun1

接口调整

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