修改user.xml语句 , 新增保存功能

master
xiaoCJ 2 years ago
parent eeb5819633
commit 18636cf6b8

@ -135,7 +135,8 @@ public class TrainingScoreController {
public AjaxResult submitReport(@RequestBody JSONObject jsonObject) { public AjaxResult submitReport(@RequestBody JSONObject jsonObject) {
Long userId = jsonObject.getLong("userId"); Long userId = jsonObject.getLong("userId");
String content = jsonObject.getString("content"); String content = jsonObject.getString("content");
return trainingScoreService.submitReport(content, userId); boolean isSubmit = jsonObject.getBoolean("isSubmit");
return trainingScoreService.saveOrSubmitReport(content, userId,isSubmit);
} }
//学生端实验报告回显 //学生端实验报告回显

@ -139,7 +139,7 @@ public interface SysUserMapper
List<SysUser> selectClassStuNumberNameByClass(@Param("stuClass") String stuClass); List<SysUser> selectClassStuNumberNameByClass(@Param("stuClass") String stuClass);
@Select("select id from sys_user where studentnumber = #{studentNumber}") @Select("select user_id from sys_user where studentnumber = #{studentNumber}")
Long selectUserIDByStuNum(@Param("studentNumber") String studentNumber); Long selectUserIDByStuNum(@Param("studentNumber") String studentNumber);
} }

@ -15,7 +15,7 @@ public interface ISysTrainingScoreService {
AjaxResult uploadReport(MultipartFile file, String fileName, Long id); AjaxResult uploadReport(MultipartFile file, String fileName, Long id);
AjaxResult submitReport(String content, Long userId); AjaxResult saveOrSubmitReport(String content, Long userId,boolean isSubmit);
void updateByPrimaryKeySelective(SysTrainingScore sysTrainingScore); void updateByPrimaryKeySelective(SysTrainingScore sysTrainingScore);

@ -292,23 +292,51 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
} }
//提交 // 保存或提交学生输入的实验报告内容
@Override @Override
public AjaxResult submitReport(String content, Long userId) { public AjaxResult saveOrSubmitReport(String content, Long userId, boolean isSubmit) { // issubmit为true时提交 false保存
SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample(); SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample();
trainingScoreExample.createCriteria().andUseridEqualTo(userId); trainingScoreExample.createCriteria().andUseridEqualTo(userId);
List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample); List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample);
if (!sysTrainingScores.isEmpty()) { if (!sysTrainingScores.isEmpty()) {
SysTrainingScore sysTrainingScore = sysTrainingScores.get(0); SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
if (sysTrainingScore.getReportUploadPath() == null) { if (isSubmit) {
return AjaxResult.error("请先上传再提交"); if (sysTrainingScore.getReportUploadPath() == null) {
return AjaxResult.error("请先上传再提交");
}
sysTrainingScore.setReportContent(content);
sysTrainingScore.setReportstatus("已提交");
trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore);
return AjaxResult.success("提交成功");
} else {
if (sysTrainingScore.getReportstatus().equals("已提交")) {
return AjaxResult.error("报告已提交,无法修改");
}
sysTrainingScore.setReportContent(content);
trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore);
return AjaxResult.success("保存成功");
} }
sysTrainingScore.setReportContent(content);
trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore);
} }
return AjaxResult.success("提交成功"); return null;
} }
// //提交
// @Override
// public AjaxResult submitReport(String content, Long userId) {
// SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample();
// trainingScoreExample.createCriteria().andUseridEqualTo(userId);
// List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample);
// if (!sysTrainingScores.isEmpty()) {
// SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
// if (sysTrainingScore.getReportUploadPath() == null) {
// return AjaxResult.error("请先上传再提交");
// }
// sysTrainingScore.setReportContent(content);
// trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore);
// }
// return AjaxResult.success("提交成功");
// }
@Override @Override
public List<String> selectClass() { public List<String> selectClass() {

@ -219,7 +219,6 @@
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user( insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if>
<if test="userName != null and userName != ''">user_name,</if> <if test="userName != null and userName != ''">user_name,</if>
<if test="nickName != null and nickName != ''">nick_name,</if> <if test="nickName != null and nickName != ''">nick_name,</if>
@ -235,7 +234,6 @@
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
create_time create_time
)values( )values(
<if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if> <if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="userName != null and userName != ''">#{userName},</if> <if test="userName != null and userName != ''">#{userName},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if> <if test="nickName != null and nickName != ''">#{nickName},</if>

Loading…
Cancel
Save