Commit 17d3c94c authored by YangZhaoJun1's avatar YangZhaoJun1

完善接口

parent 15d0c4cb
......@@ -27,6 +27,8 @@ import org.rcisoft.core.result.ResultCode;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UploadUtil;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -53,10 +55,9 @@ public class BChapterController extends PaginationController<BChapter> {
private BChapterService bChapterService;
@Autowired
private BSlService bSlService;
/*@Autowired
private IAction action;*/
@Autowired
private BRSlStudentService brSlStudentService;
private SysRoleRepository sysRoleRepository;
@Autowired
private Global global;
......@@ -143,7 +144,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation(value="分页查询章节", notes="根据条件分页查询章节")
@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 = "chapterLevel", value = "等级,1:章 2:节", required = false, dataType = "Byte"),
@ApiImplicitParam(name = "pid", value = "上一级", required = false, dataType = "varchar"),
......@@ -164,7 +165,7 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiOperation(value="根据条件查询章节", notes="根据条件查询章节")
@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 = "chapterLevel", value = "等级,1:章 2:节", required = false, dataType = "Byte"),
@ApiImplicitParam(name = "pid", value = "上一级", required = false, dataType = "varchar"),
......@@ -176,22 +177,17 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")})
@GetMapping(value = "/queryBChaptersWithoutAuth")
public Result queryBChapters(BChapter param) {
/*if (StringUtils.isEmpty(param.getSlId()))
if (StringUtils.isEmpty(param.getSlId()))
throw new ServiceException(ResultServiceEnums.PARAMER_ERROR);
Map<String, Object> map = new HashedMap();
boolean islogin = UserUtil.isLogin();
if (!islogin)
map.put("RoleFlag", RoleFlagEnum.TOURIST.getFlag());
else {
SysUser user = UserUtil.getUser();
if (user.getRole().getCode().equals(RoleEnum.TEACHER.getCode()))
String userId = UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID);
List<SysRole> role = sysRoleRepository.queryCodeByBusinessId(userId);
if (role.get(0).getCode().equals(RoleEnum.TEACHER.getCode()))
map.put("RoleFlag", RoleFlagEnum.TEACHER.getFlag());
else {
map.put("RoleFlag", RoleFlagEnum.STUDENT.getFlag());
map.put("scoreList", bChapterService.queryScoreListBySlIdAndStuId(param.getSlId(), user.getBusinessId()));
map.put("scoreList", bChapterService.queryScoreListBySlIdAndStuId(param.getSlId(), userId));
}
}*/
Map<String, Object> map = new HashedMap();
map.put("chapterList", bChapterService.queryBChapters(param));
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
......@@ -254,10 +250,6 @@ public class BChapterController extends PaginationController<BChapter> {
@PostMapping(value = "/complete")
public Result complete(ScoreInfoDTO scoreInfoDTO) {
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));
bChapterService.updateIsComplete(scoreInfoDTO,getToken());
return Result.builder(new PersistModel(1),
......
......@@ -26,6 +26,7 @@ import java.util.List;
@AllArgsConstructor
public class BChapter extends IdEntity<BChapter> {
private static final long serialVersionUID = -8023388256391391541L;
/*开课id*/
//@NotEmpty(message = "开课id必填")
private String slId;
......
......@@ -91,8 +91,6 @@ public class BChapterServiceImpl implements BChapterService {
public PersistModel persist(BChapter model, String token){
int line = 0;
if(model.getBusinessId()==null) {
/*if (bSlRepository.selectByPrimaryKey(model.getSlId()) == null)
throw new ServiceException(ResultServiceEnums.SL_INFO_NOT_EXISTS);*/
UserUtil.setCurrentPersistOperation(model);
line = bChapterRepository.insertSelective(model);
}else {
......@@ -103,7 +101,6 @@ public class BChapterServiceImpl implements BChapterService {
UserUtil.setCurrentMergeOperation(model);
line = bChapterRepository.updateByPrimaryKeySelective(model);
}
//FamilyLogger.sysInfo(UserUtils.getUser().getBusinessId(),UserUtils.getUser().getLoginName()+"新增了ID为"+user.getBusinessId()+"的用户");
return new PersistModel(line);
}
......@@ -146,17 +143,6 @@ public class BChapterServiceImpl implements BChapterService {
throw new ServiceException(ResultServiceEnums.SCORE_ERROR);
if(id==null){ //查看该学生该章节是否已经完成学习
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{ //已经学习则修改
scoreInfoDTO.setBusinessId(id);
UserUtil.setCurrentMergeOperation(scoreInfoDTO);
......
......@@ -65,7 +65,6 @@ public class BClassServiceImpl implements BClassService {
}else
UserUtil.setCurrentMergeOperation(model);
line = bClassRepository.updateByPrimaryKeySelective(model);
//FamilyLogger.sysInfo(UserUtils.getUser().getBusinessId(),UserUtils.getUser().getLoginName()+"新增了ID为"+user.getBusinessId()+"的用户");
return new PersistModel(line);
}
......
......@@ -122,8 +122,6 @@ public class BLessonController extends PaginationController<BLesson> {
MessageConstant.MESSAGE_ALERT_ERROR,
bLessonService.selectOne(code));
}else{
/* result.setErrorMessage((ResultServiceEnums.UPLOAD_FILE_ERROR).getMessage(),null);
return result;*/
throw new ServiceException(ResultServiceEnums.UPLOAD_FILE_ERROR);
}
......
......@@ -92,7 +92,6 @@ public class BLessonServiceImpl implements BLessonService {
direction.setLessionId(model.getBusinessId());
bLessonRepository.updateDirectionByLessonId(direction);
}
//FamilyLogger.sysInfo(UserUtils.getUser().getBusinessId(),UserUtils.getUser().getLoginName()+"新增了ID为"+user.getBusinessId()+"的用户");
return new PersistModel(line);
}
......@@ -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 ="";
if(lessons.size()>0){
int line = bLessonRepository.insertList(lessons);
......
......@@ -68,13 +68,13 @@ public class BNewsController extends PaginationController<BNews> {
}
@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")
public Result queryOne(String businessId) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
businessId);
bNewsService.selectOne(businessId));
}
......
......@@ -49,8 +49,6 @@ public class BStudentServiceImpl implements BStudentService {
private SysUserService userService;
@Autowired
private SysUserMapper sysUserMapper;
/*@Autowired
private IAction action;*/
@Autowired
private Global global;
@Autowired
......
......@@ -7,9 +7,9 @@ import lombok.Getter;
*/
@Getter
public enum RoleEnum {
ADMIN("1001"),
TEACHER("1002"),
STUDENT("1003"),
ADMIN("ROLE_1001"),
TEACHER("ROLE_1002"),
STUDENT("ROLE_1003"),
;
RoleEnum(String code) {
......
......@@ -164,4 +164,14 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
"and sr.flag = '1'</script>")
@ResultMap(value = "BaseResultMap")
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