Commit 9782b854 authored by YangZhaoJun1's avatar YangZhaoJun1

完善接口

parent 8662bc56
......@@ -63,8 +63,9 @@ public class BChapterController extends PaginationController<BChapter> {
@ApiImplicitParam(name = "chapterName", value = "章节名称", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "pid", value = "上一级", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "classHour", value = "课时", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "isTest", value = "1:实验 2:视频 3:PPT 4:pdf 5:资料", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "experimentType", value = "实验类型,1:java单文件 2:java工程 3:html单文件 4:html工程", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "lessonOrSl", value = "课程或开课;0:开课 1:课程", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "isTest", value = "1:实验 2:视频 3:PPT 4:pdf 5:资料", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "lessonId", value = "课程ID(课程ID和开课ID只能存在一个)", required = false, dataType = "varchar")})
@PreAuthorize("hasAnyRole('ROLE_1001','ROLE_1002')")
@PostMapping(value = "/add")
......@@ -459,4 +460,16 @@ public class BChapterController extends PaginationController<BChapter> {
MessageConstant.MESSAGE_ALERT_ERROR,
bChapter);
}
@ApiOperation(value="更改是否智评状态", notes="根据章节ID更改章节是否智评的状态")
@ApiImplicitParam(name = "businessId", value = "章节ID", required = true, dataType = "varchar")
@PostMapping(value = "/updateAutomatic")
public Result updateAutomatic(String businessId){
int data = bChapterService.updateAutomatic(businessId);
return Result.builder(new PersistModel(data),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
businessId);
}
}
......@@ -227,5 +227,13 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
"and sl_id = #{slId}</script>")
@ResultMap(value = "BaseResultMap" )
List<BChapter> queryChapterBySlId(String slId);
@Select("<script>select automatic from b_chapter " +
"where del_flag = 0 and flag = 1 " +
"and business_id = #{businessId}</script>")
String selectAutomatic(String businessId);
@Update("<script>update b_chapter set automatic = #{automatic} where business_id = #{businessId}</script>")
int updateAutomatic(@Param("automatic") String automatic, @Param("businessId") String businessId);
}
......@@ -60,6 +60,9 @@ public class BChapter extends IdEntity<BChapter> {
/*课时*/
private String classHour;
/*实验类型,1:java单文件 2:java工程 3:html单文件 4:html工程*/
private String experimentType;
/*章节排序*/
private Integer sort;
@Transient
......
package org.rcisoft.business.bchapter.enums;
import lombok.Getter;
/**
* Created by Administrator on 2018/1/8.
*/
@Getter
public enum AutomaticEnum {
AUTOMATIC_YES("1"),
AUTOMATIC_NO("0"),
;
AutomaticEnum(String code) {
this.code = code;
}
private String code;
}
......@@ -101,4 +101,6 @@ public interface BChapterService{
int updateTopChapter(BChapter bChapter);
int updateDownChapter(BChapter bChapter);
int updateAutomatic(String businessId);
}
......@@ -6,6 +6,7 @@ import org.rcisoft.business.bchapter.dto.QueryScoreListDTO;
import org.rcisoft.business.bchapter.dto.ScoreInfoDTO;
import org.rcisoft.business.bchapter.dto.StuScoreDTO;
import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.bchapter.enums.AutomaticEnum;
import org.rcisoft.business.bchapter.enums.ChapterLevelEnum;
import org.rcisoft.business.bchapter.enums.HasMarkEnum;
import org.rcisoft.business.bchapter.enums.StateEnum;
......@@ -427,4 +428,16 @@ public class BChapterServiceImpl implements BChapterService {
}
return result;
}
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public int updateAutomatic(String businessId) {
String nowAutomatic = bChapterRepository.selectAutomatic(businessId);
String automatic = AutomaticEnum.AUTOMATIC_YES.getCode();
if(nowAutomatic.equals(AutomaticEnum.AUTOMATIC_YES.getCode())){
automatic = AutomaticEnum.AUTOMATIC_NO.getCode();
}
int result = bChapterRepository.updateAutomatic(automatic,businessId);
return result;
}
}
......@@ -106,9 +106,9 @@ public class BFileController extends PaginationController<BFile> {
@ApiOperation(value="上传视频", notes="上传视频")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "videoName", value = "视频名称", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "videoUrl", value = "视频地址", required = false, dataType = "varchar"),
@ApiImplicitParams({@ApiImplicitParam(name = "chapterId", value = "章节ID", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "lessonId", value = "课程ID", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "slId", value = "开课ID", required = false, dataType = "varchar"),
@ApiImplicitParam(name = "type", value = "'0'为视频,'1'为附件,'2'为ppt,'3'为pdf", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "file", value = "视频文件", required = true, dataType = "MultipartFile")})
@PreAuthorize("hasAnyRole('ROLE_1001','ROLE_1002')")
......
......@@ -245,7 +245,16 @@ public class BFileServiceImpl implements BFileService {
+ pathName + File.separator;
bFile.setVideoName(name+ "." +uploadFileSuffix);//文件名
bFile.setVideoUrl(newPath+ filename);//存储地址
if (bFile.getType().equals("0")){
bFile.setVideoUrl(newPath+ filename);//视频路径
}else if(bFile.getType().equals("1")){
bFile.setFileUrl(newPath+ filename);//文件路径
}else if(bFile.getType().equals("2")){
bFile.setPptUrl(newPath+ filename);//ppt路径
}else{
bFile.setPdfUrl(newPath+ filename);//pdf路径
}
stream.close();
return bFile;
}
......
......@@ -24,7 +24,8 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
* @param param
* @return
*/
@Select("<script>select b.*, bd.name as directionName, bd.business_id as directionId from b_lesson b " +
@Select("<script>select b.*, bd.name as directionName, bd.business_id as directionId, bd.code as directionCode " +
"from b_lesson b " +
"left join b_lesson_direction bld on bld.lession_id = b.business_id " +
"left join b_direction bd on bd.business_id = bld.direction_id "+
"where b.del_flag != 1" +
......
......@@ -40,6 +40,9 @@ public class BLesson extends IdEntity<BLesson> {
@Transient
private String directionName;//课程方向名称
@Transient
private String directionCode;//课程方向编号
public BLesson(String code) {
this.code = code;
}
......
......@@ -12,7 +12,7 @@ import java.util.List;
*/
public interface BOpinionRepository extends BaseMapper<BOpinion> {
@Select("select * from b_opinion where sl_id = #{slId}")
@Select("select * from b_opinion where sl_id = #{slId} order by create_date DESC")
@ResultMap(value = "BaseResultMap")
List<BOpinion> queryOpinionBySlId(String slId);
}
......@@ -9,6 +9,8 @@ import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import java.text.DateFormat;
import java.util.Date;
import java.util.Map;
import java.util.List;
......@@ -34,9 +36,15 @@ public interface BTermRepository extends BaseMapper<BTerm> {
@ResultMap(value = "BaseResultMap" )
List<BTerm> queryBtermByCode(String code);
@Select("<script>select * from b_term where del_flag != 1 and flag = 1 and is_start = 1</script>")
@Select("<script>select * from b_term " +
"where del_flag != 1 and flag = 1 and is_start = 1 " +
"and (#{nowTime} BETWEEN start_date AND end_date) " +
"UNION " +
"select * from b_term " +
"where del_flag != 1 and flag = 1 and is_start = 1" +
"</script>")
@ResultMap(value = "BaseResultMap" )
List<BTerm> queryBTermList();
List<BTerm> queryBTermList(String nowTime);
/*
......
......@@ -18,10 +18,9 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
......@@ -112,7 +111,9 @@ public class BTermServiceImpl implements BTermService {
@Override
public List<SelectModel> queryBTermList() {
List<BTerm> bTerm = bTermRepository.queryBTermList();
Date date = new Date();
String nowTime = new SimpleDateFormat("yyyy-MM-dd").format(date);
List<BTerm> bTerm = bTermRepository.queryBTermList(nowTime);
ArrayList<SelectModel> comBoxModel = new ArrayList<SelectModel>();
for(BTerm c : bTerm){
SelectModel selectModel = new SelectModel();
......
......@@ -58,10 +58,12 @@ public class AuthenticationServiceImpl implements AuthenticationService {
public void register(SysUser userToAdd) {
Example example = new Example(SysUser.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("loginName", userToAdd.getLoginName());
List<SysUser> sysUser = sysUserMapper.selectByExample(example);
if (sysUser.size() > 0)
throw new ServiceException(ResultExceptionEnum.USER_EXISTS);
userToAdd.setPassword(passwordEncoder.encode(userToAdd.getPassword()));
userToAdd.setCommonBusinessId();
int result = sysUserMapper.insertSelective(userToAdd);
if(result==0)
throw new ServiceException(ResultExceptionEnum.SAVE_ERROR);
......
package org.rcisoft.sys.user.controller;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.common.component.Global;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Created by Andrew on 2017/7/6.
*/
@RestController
@RequestMapping(value = "/user")
public class SysUserController {
public class SysUserController extends PaginationController<SysUser> {
@Autowired
private SysUserService userServiceImpl;
@Autowired
private Global global;
@Autowired
private PasswordEncoder passwordEncoder;
@PostMapping(value = "/addUser")
public Result addUser(SysUser user, Result result){
try{
......@@ -29,4 +45,29 @@ public class SysUserController {
}
return result;
}
@ApiOperation(value="修改密码", notes="根据用户ID修改密码")
@ApiImplicitParams({@ApiImplicitParam(name = "oldPassword", value = "旧密码", required = true, dataType = "varchar"),
@ApiImplicitParam(name = "newPassword", value = "新密码", required = true, dataType = "varchar")})
@PostMapping(value = "/changePassword")
public Result changePassword(String oldPassword, String newPassword){
int min_length = Integer.parseInt(global.getPASSWORD_MIN_PASSWORD());
int max_length = Integer.parseInt(global.getPASSWORD_MAX_PASSWORD());
int this_length = newPassword.length();
if(this_length<min_length||this_length>max_length) {
throw new ServiceException(ResultServiceEnums.PASSWORD_LENGTH_ERROR);
}
String userId = UserUtil.getUserInfoProp(getToken(),UserUtil.USER_ID);
String encodePassword = userServiceImpl.checkPassword(userId);
boolean real =passwordEncoder.matches(oldPassword,encodePassword);
if(!real) {
throw new ServiceException(ResultServiceEnums.PASSWORD_ERROR);
}
PersistModel persistModel = new PersistModel(userServiceImpl.changePassword(userId,newPassword));
return Result.builder(persistModel,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
"");
}
}
......@@ -43,4 +43,14 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
@Delete("delete from s_user where login_name = #{code}")
int deleteByCode(String code);
@Select("<script>select * from s_user where business_id = #{userId} and password = #{password} limit 1</script>")
@ResultMap(value = "BaseResultMap")
SysUser checkPassword(@Param("userId") String userId, @Param("password") String password);
@Update("update s_user set password =#{password} where business_id = '${userId}'")
int changePassword(@Param("userId") String userId, @Param("password") String password);
@Select("<script>select password from s_user where business_id = #{userId} </script>")
String queryPasswordById(String userId);
}
......@@ -12,4 +12,8 @@ public interface SysUserService {
PersistModel persistUser(SysUser user);
void updateUser(SysUser user, String uid, int line);
String checkPassword(String userId);
int changePassword(String userId, String newPassword);
}
......@@ -4,6 +4,7 @@ import org.rcisoft.core.constant.UserConstant;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.service.SysUserService;
......@@ -48,4 +49,14 @@ public class SysUserServiceImpl implements SysUserService {
throw new ServiceException(ResultServiceEnums.UPDATE_ERROR);
}
}
@Override
public String checkPassword(String userId) {
return sysUserMapper.queryPasswordById(userId);
}
@Override
public int changePassword(String userId, String newPassword) {
return sysUserMapper.changePassword(userId,passwordEncoder.encode(newPassword));
}
}
......@@ -47,7 +47,7 @@ spring:
# enabled: true
multipart:
enabled: true
max-file-size: 100Mb
max-file-size: 500Mb
max-request-size: 1000Mb
mvc:
throw-exception-if-no-handler-found: true
......@@ -102,7 +102,7 @@ global:
min_password: 6
max_password: 16
path:
base_upload_server_location: E:\\eduFiles
base_upload_server_location: E:\\eduServer
course_location: course
lesson_location: lesson
sl_location: sl
......@@ -124,12 +124,14 @@ global:
cource_project_location: project
other:
server_url: http://gwf.natapp.cc/eduServer
is_server_linux: 1
is_server_linux: 5
max_code_length: 15
code:
admin: ROLE_1001
teacher: ROLE_1002
student: ROLE_1003
java: '001'
html: '002'
java_simple: '0001'
java_project: '0002'
html_simple: '1001'
......
......@@ -47,7 +47,7 @@ spring:
# enabled: true
multipart:
enabled: true
max-file-size: 100Mb
max-file-size: 500Mb
max-request-size: 1000Mb
mvc:
throw-exception-if-no-handler-found: true
......@@ -130,6 +130,8 @@ global:
admin: ROLE_1001
teacher: ROLE_1002
student: ROLE_1003
java: '001'
html: '002'
java_simple: '0001'
java_project: '0002'
html_simple: '1001'
......
......@@ -22,6 +22,7 @@
<result column="class_hour" jdbcType="VARCHAR" property="classHour"/>
<result column="state" jdbcType="VARCHAR" property="state"/>
<result column="sort" jdbcType="INTEGER" property="sort"/>
<result column="experiment_type" jdbcType="VARCHAR" property="experimentType"/>
</resultMap>
<resultMap id="SupperChildListResultMap" type="org.rcisoft.business.bchapter.entity.BChapter" extends="BaseResultMap">
......
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