Commit 17d3c94c authored by YangZhaoJun1's avatar YangZhaoJun1

完善接口

parent 15d0c4cb
...@@ -27,6 +27,8 @@ import org.rcisoft.core.result.ResultCode; ...@@ -27,6 +27,8 @@ import org.rcisoft.core.result.ResultCode;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UploadUtil; import org.rcisoft.core.util.UploadUtil;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.role.dao.SysRoleRepository;
import org.rcisoft.sys.role.entity.SysRole;
import org.rcisoft.sys.user.entity.SysUser; import org.rcisoft.sys.user.entity.SysUser;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
...@@ -53,10 +55,9 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -53,10 +55,9 @@ public class BChapterController extends PaginationController<BChapter> {
private BChapterService bChapterService; private BChapterService bChapterService;
@Autowired @Autowired
private BSlService bSlService; private BSlService bSlService;
/*@Autowired
private IAction action;*/
@Autowired @Autowired
private BRSlStudentService brSlStudentService; private SysRoleRepository sysRoleRepository;
@Autowired @Autowired
private Global global; private Global global;
...@@ -143,7 +144,7 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -143,7 +144,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation(value="分页查询章节", notes="根据条件分页查询章节") @ApiOperation(value="分页查询章节", notes="根据条件分页查询章节")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课id", required = false, dataType = "varchar"), @ApiImplicitParam(name = "slId", value = "开课id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapterName", value = "章节名称", required = false, dataType = "varchar"), @ApiImplicitParam(name = "chapterName", value = "章节名称", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "chapterLevel", value = "等级,1:章 2:节", required = false, dataType = "Byte"), @ApiImplicitParam(name = "chapterLevel", value = "等级,1:章 2:节", required = false, dataType = "Byte"),
@ApiImplicitParam(name = "pid", value = "上一级", required = false, dataType = "varchar"), @ApiImplicitParam(name = "pid", value = "上一级", required = false, dataType = "varchar"),
...@@ -164,7 +165,7 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -164,7 +165,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation(value="根据条件查询章节", notes="根据条件查询章节") @ApiOperation(value="根据条件查询章节", notes="根据条件查询章节")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"), @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课id", required = false, dataType = "varchar"), @ApiImplicitParam(name = "slId", value = "开课id", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "chapterName", value = "章节名称", required = false, dataType = "varchar"), @ApiImplicitParam(name = "chapterName", value = "章节名称", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "chapterLevel", value = "等级,1:章 2:节", required = false, dataType = "Byte"), @ApiImplicitParam(name = "chapterLevel", value = "等级,1:章 2:节", required = false, dataType = "Byte"),
@ApiImplicitParam(name = "pid", value = "上一级", required = false, dataType = "varchar"), @ApiImplicitParam(name = "pid", value = "上一级", required = false, dataType = "varchar"),
...@@ -176,22 +177,17 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -176,22 +177,17 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")}) @ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")})
@GetMapping(value = "/queryBChaptersWithoutAuth") @GetMapping(value = "/queryBChaptersWithoutAuth")
public Result queryBChapters(BChapter param) { public Result queryBChapters(BChapter param) {
/*if (StringUtils.isEmpty(param.getSlId())) if (StringUtils.isEmpty(param.getSlId()))
throw new ServiceException(ResultServiceEnums.PARAMER_ERROR); throw new ServiceException(ResultServiceEnums.PARAMER_ERROR);
Map<String, Object> map = new HashedMap(); Map<String, Object> map = new HashedMap();
boolean islogin = UserUtil.isLogin(); String userId = UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID);
if (!islogin) List<SysRole> role = sysRoleRepository.queryCodeByBusinessId(userId);
map.put("RoleFlag", RoleFlagEnum.TOURIST.getFlag()); if (role.get(0).getCode().equals(RoleEnum.TEACHER.getCode()))
map.put("RoleFlag", RoleFlagEnum.TEACHER.getFlag());
else { else {
SysUser user = UserUtil.getUser(); map.put("RoleFlag", RoleFlagEnum.STUDENT.getFlag());
if (user.getRole().getCode().equals(RoleEnum.TEACHER.getCode())) map.put("scoreList", bChapterService.queryScoreListBySlIdAndStuId(param.getSlId(), userId));
map.put("RoleFlag", RoleFlagEnum.TEACHER.getFlag()); }
else {
map.put("RoleFlag", RoleFlagEnum.STUDENT.getFlag());
map.put("scoreList", bChapterService.queryScoreListBySlIdAndStuId(param.getSlId(), user.getBusinessId()));
}
}*/
Map<String, Object> map = new HashedMap();
map.put("chapterList", bChapterService.queryBChapters(param)); map.put("chapterList", bChapterService.queryBChapters(param));
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
...@@ -254,10 +250,6 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -254,10 +250,6 @@ public class BChapterController extends PaginationController<BChapter> {
@PostMapping(value = "/complete") @PostMapping(value = "/complete")
public Result complete(ScoreInfoDTO scoreInfoDTO) { public Result complete(ScoreInfoDTO scoreInfoDTO) {
scoreInfoDTO.setIsComplete(IsCompleteEnum.COMPLETE.getCode()); scoreInfoDTO.setIsComplete(IsCompleteEnum.COMPLETE.getCode());
/*User user = UserUtils.getUser();
if (!user.getRole().getCode().equals(RoleEnum.STUDENT.getCode()))
throw new ServiceException(ResultServiceEnums.ROLE_ERROR);*/
scoreInfoDTO.setStudentId(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID)); scoreInfoDTO.setStudentId(UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID));
bChapterService.updateIsComplete(scoreInfoDTO,getToken()); bChapterService.updateIsComplete(scoreInfoDTO,getToken());
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
......
...@@ -26,6 +26,7 @@ import java.util.List; ...@@ -26,6 +26,7 @@ import java.util.List;
@AllArgsConstructor @AllArgsConstructor
public class BChapter extends IdEntity<BChapter> { public class BChapter extends IdEntity<BChapter> {
private static final long serialVersionUID = -8023388256391391541L;
/*开课id*/ /*开课id*/
//@NotEmpty(message = "开课id必填") //@NotEmpty(message = "开课id必填")
private String slId; private String slId;
......
...@@ -91,8 +91,6 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -91,8 +91,6 @@ public class BChapterServiceImpl implements BChapterService {
public PersistModel persist(BChapter model, String token){ public PersistModel persist(BChapter model, String token){
int line = 0; int line = 0;
if(model.getBusinessId()==null) { if(model.getBusinessId()==null) {
/*if (bSlRepository.selectByPrimaryKey(model.getSlId()) == null)
throw new ServiceException(ResultServiceEnums.SL_INFO_NOT_EXISTS);*/
UserUtil.setCurrentPersistOperation(model); UserUtil.setCurrentPersistOperation(model);
line = bChapterRepository.insertSelective(model); line = bChapterRepository.insertSelective(model);
}else { }else {
...@@ -103,7 +101,6 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -103,7 +101,6 @@ public class BChapterServiceImpl implements BChapterService {
UserUtil.setCurrentMergeOperation(model); UserUtil.setCurrentMergeOperation(model);
line = bChapterRepository.updateByPrimaryKeySelective(model); line = bChapterRepository.updateByPrimaryKeySelective(model);
} }
//FamilyLogger.sysInfo(UserUtils.getUser().getBusinessId(),UserUtils.getUser().getLoginName()+"新增了ID为"+user.getBusinessId()+"的用户");
return new PersistModel(line); return new PersistModel(line);
} }
...@@ -146,17 +143,6 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -146,17 +143,6 @@ public class BChapterServiceImpl implements BChapterService {
throw new ServiceException(ResultServiceEnums.SCORE_ERROR); throw new ServiceException(ResultServiceEnums.SCORE_ERROR);
if(id==null){ //查看该学生该章节是否已经完成学习 if(id==null){ //查看该学生该章节是否已经完成学习
throw new ServiceException(ResultServiceEnums.UN_COMPLETE); throw new ServiceException(ResultServiceEnums.UN_COMPLETE);
// BStudent b;
// if((b=bStudentRepository.selectByPrimaryKey(scoreInfoDTO.getStudentId()))==null) { //查看学生是否存在
// throw new BusinessException(ResultEnums.STUDENT_NOT_EXISTS);
// }
// BChapter bChapter;
// if((bChapter = bChapterRepository.selectByPrimaryKey(scoreInfoDTO.getChapterId()))==null) //查看章节是否存在
// throw new BusinessException(ResultEnums.CHAPTER_NOT_EXISTS);
// if(brSlStudentRepository.selectByStudentIdAndSlId(b.getCode(),bChapter.getSlId())==null) //查看该学生是否已经选择该门课程
// throw new BusinessException(ResultEnums.B_R_SL_STUDENT_NOT_EXISTS);
// scoreInfoDTO.setCommonBusinessId(); //未打分的话应该新添加该章节分数记录
// bChapterRepository.insertScoreInfo(scoreInfoDTO);
}else{ //已经学习则修改 }else{ //已经学习则修改
scoreInfoDTO.setBusinessId(id); scoreInfoDTO.setBusinessId(id);
UserUtil.setCurrentMergeOperation(scoreInfoDTO); UserUtil.setCurrentMergeOperation(scoreInfoDTO);
...@@ -204,22 +190,22 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -204,22 +190,22 @@ public class BChapterServiceImpl implements BChapterService {
List<BChapter> chapterList = new ArrayList<>(); List<BChapter> chapterList = new ArrayList<>();
//map存放章的ID(key:章名称 value:新的章ID) //map存放章的ID(key:章名称 value:新的章ID)
Map map = new HashMap(); Map map = new HashMap();
for (int i=0;i<lessonList.size();i++){ for (int i=0;i<lessonList.size();i++){
BChapter sl_chapter = new BChapter(); BChapter sl_chapter = new BChapter();
sl_chapter.setSlId(slId); sl_chapter.setSlId(slId);
sl_chapter.setChapterName(lessonList.get(i).getChapterName()); sl_chapter.setChapterName(lessonList.get(i).getChapterName());
sl_chapter.setChapterLevel(lessonList.get(i).getChapterLevel()); sl_chapter.setChapterLevel(lessonList.get(i).getChapterLevel());
sl_chapter.setChapterUrl(lessonList.get(i).getChapterUrl()); sl_chapter.setChapterUrl(lessonList.get(i).getChapterUrl());
sl_chapter.setMdFile(lessonList.get(i).getMdFile()); sl_chapter.setMdFile(lessonList.get(i).getMdFile());
sl_chapter.setIsTest(lessonList.get(i).getIsTest()); sl_chapter.setIsTest(lessonList.get(i).getIsTest());
sl_chapter.setClassHour(lessonList.get(i).getClassHour()); sl_chapter.setClassHour(lessonList.get(i).getClassHour());
sl_chapter.setState(StateEnum.CLOSE.getCode()); sl_chapter.setState(StateEnum.CLOSE.getCode());
sl_chapter.setLessonOrSl("0"); sl_chapter.setLessonOrSl("0");
UserUtil.setCurrentPersistOperation(sl_chapter); UserUtil.setCurrentPersistOperation(sl_chapter);
if(lessonList.get(i).getPid().equals("-1")){ if(lessonList.get(i).getPid().equals("-1")){
sl_chapter.setPid(lessonList.get(i).getPid()); sl_chapter.setPid(lessonList.get(i).getPid());
map.put(sl_chapter.getChapterName(),sl_chapter.getBusinessId()); map.put(sl_chapter.getChapterName(),sl_chapter.getBusinessId());
} }
chapterList.add(sl_chapter); chapterList.add(sl_chapter);
} }
for (int i=0;i<chapterList.size();i++){ for (int i=0;i<chapterList.size();i++){
......
...@@ -65,7 +65,6 @@ public class BClassServiceImpl implements BClassService { ...@@ -65,7 +65,6 @@ public class BClassServiceImpl implements BClassService {
}else }else
UserUtil.setCurrentMergeOperation(model); UserUtil.setCurrentMergeOperation(model);
line = bClassRepository.updateByPrimaryKeySelective(model); line = bClassRepository.updateByPrimaryKeySelective(model);
//FamilyLogger.sysInfo(UserUtils.getUser().getBusinessId(),UserUtils.getUser().getLoginName()+"新增了ID为"+user.getBusinessId()+"的用户");
return new PersistModel(line); return new PersistModel(line);
} }
......
...@@ -122,8 +122,6 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -122,8 +122,6 @@ public class BLessonController extends PaginationController<BLesson> {
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
bLessonService.selectOne(code)); bLessonService.selectOne(code));
}else{ }else{
/* result.setErrorMessage((ResultServiceEnums.UPLOAD_FILE_ERROR).getMessage(),null);
return result;*/
throw new ServiceException(ResultServiceEnums.UPLOAD_FILE_ERROR); throw new ServiceException(ResultServiceEnums.UPLOAD_FILE_ERROR);
} }
......
...@@ -92,7 +92,6 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -92,7 +92,6 @@ public class BLessonServiceImpl implements BLessonService {
direction.setLessionId(model.getBusinessId()); direction.setLessionId(model.getBusinessId());
bLessonRepository.updateDirectionByLessonId(direction); bLessonRepository.updateDirectionByLessonId(direction);
} }
//FamilyLogger.sysInfo(UserUtils.getUser().getBusinessId(),UserUtils.getUser().getLoginName()+"新增了ID为"+user.getBusinessId()+"的用户");
return new PersistModel(line); return new PersistModel(line);
} }
...@@ -135,12 +134,6 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -135,12 +134,6 @@ public class BLessonServiceImpl implements BLessonService {
} }
} }
// if(lessons.size()<1){
// if(repeatCode.size()<1&&errorCode.size()<1)
// throw new BusinessException(ResultEnums.EXCEL_IMPORT_DATA_NOT_EXIST);
// else
// throw new BusinessException(ResultEnums.EXCEL_IMPORT_DATA_NOT_EXIST.getCode(),"Excel内所有数据之前都已经导入。");
// }
String result =""; String result ="";
if(lessons.size()>0){ if(lessons.size()>0){
int line = bLessonRepository.insertList(lessons); int line = bLessonRepository.insertList(lessons);
......
...@@ -68,13 +68,13 @@ public class BNewsController extends PaginationController<BNews> { ...@@ -68,13 +68,13 @@ public class BNewsController extends PaginationController<BNews> {
} }
@ApiOperation(value="唯一查找", notes="根据ID查找一条记录") @ApiOperation(value="唯一查找", notes="根据ID查找一条记录")
@ApiImplicitParam(name = "id", value = "businessId", required = true, dataType = "varchar") @ApiImplicitParam(name = "businessId", value = "businessId", required = true, dataType = "varchar")
@GetMapping(value = "/oneWithoutAuth") @GetMapping(value = "/oneWithoutAuth")
public Result queryOne(String businessId) { public Result queryOne(String businessId) {
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
businessId); bNewsService.selectOne(businessId));
} }
......
...@@ -49,8 +49,6 @@ public class BStudentServiceImpl implements BStudentService { ...@@ -49,8 +49,6 @@ public class BStudentServiceImpl implements BStudentService {
private SysUserService userService; private SysUserService userService;
@Autowired @Autowired
private SysUserMapper sysUserMapper; private SysUserMapper sysUserMapper;
/*@Autowired
private IAction action;*/
@Autowired @Autowired
private Global global; private Global global;
@Autowired @Autowired
......
...@@ -7,9 +7,9 @@ import lombok.Getter; ...@@ -7,9 +7,9 @@ import lombok.Getter;
*/ */
@Getter @Getter
public enum RoleEnum { public enum RoleEnum {
ADMIN("1001"), ADMIN("ROLE_1001"),
TEACHER("1002"), TEACHER("ROLE_1002"),
STUDENT("1003"), STUDENT("ROLE_1003"),
; ;
RoleEnum(String code) { RoleEnum(String code) {
......
...@@ -164,4 +164,14 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -164,4 +164,14 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
"and sr.flag = '1'</script>") "and sr.flag = '1'</script>")
@ResultMap(value = "BaseResultMap") @ResultMap(value = "BaseResultMap")
List<SysRole> queryCodeByUsername(String username); List<SysRole> queryCodeByUsername(String username);
@Select("<script>SELECT sr.* from s_role sr " +
"LEFT JOIN s_r_user_role sur ON sr.business_id = sur.role_id " +
"LEFT JOIN s_user su on su.business_id = sur.user_id " +
"where su.business_id = #{businessId} " +
"and sr.del_flag = '0' " +
"and sr.flag = '1'</script>")
@ResultMap(value = "BaseResultMap")
List<SysRole> queryCodeByBusinessId(String businessId);
} }
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