|
|
@@ -7,6 +7,7 @@ import com.template.annotation.DESRespondSecret;
|
|
|
import com.template.api.SmartGradeControllerAPI;
|
|
|
import com.template.common.utils.*;
|
|
|
import com.template.config.ControlConfig;
|
|
|
+import com.template.model.pojo.SmartClass;
|
|
|
import com.template.model.pojo.SmartGrade;
|
|
|
import com.template.model.pojo.SmartSchool;
|
|
|
import com.template.model.pojo.SmartSubject;
|
|
|
@@ -17,6 +18,7 @@ import com.template.model.result.PageUtils;
|
|
|
import com.template.model.vo.BsGradeNoVo;
|
|
|
import com.template.model.vo.BsGradeVo;
|
|
|
import com.template.model.vo.SemesterVo;
|
|
|
+import com.template.services.SmartClassService;
|
|
|
import com.template.services.SmartGradeService;
|
|
|
import com.template.services.SmartSubjectService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -55,6 +57,8 @@ public class SmartGradeController implements SmartGradeControllerAPI {
|
|
|
private SmartGradeService smartGradeService;
|
|
|
@Autowired
|
|
|
private SmartSubjectService smartSubjectService;
|
|
|
+ @Autowired
|
|
|
+ private SmartClassService smartClassService;
|
|
|
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
@@ -133,14 +137,14 @@ public class SmartGradeController implements SmartGradeControllerAPI {
|
|
|
|
|
|
for (SmartGrade sg : result.getList()) {
|
|
|
sg.setSubjectIds(sg.getSubjectId() == null ? new ArrayList<>() : Arrays.asList(sg.getSubjectId().split(",")));
|
|
|
- if(subjects != null && subjects.size() > 0){
|
|
|
- if(sg.getSubjectIds() == null){
|
|
|
+ if (subjects != null && subjects.size() > 0) {
|
|
|
+ if (sg.getSubjectIds() == null) {
|
|
|
sg.setSubjectStrs(new ArrayList<>());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
List<String> subjectStrs = new ArrayList<>();
|
|
|
- for (String subjectId:sg.getSubjectIds()) {
|
|
|
+ for (String subjectId : sg.getSubjectIds()) {
|
|
|
Optional<SmartSubject> ownerSubject = subjects.stream().filter(e -> e.getId().toString().equals(subjectId)).findFirst();
|
|
|
- if(ownerSubject != null && ownerSubject.isPresent()){
|
|
|
+ if (ownerSubject != null && ownerSubject.isPresent()) {
|
|
|
subjectStrs.add(ownerSubject.get().getName());
|
|
|
}
|
|
|
}
|
|
|
@@ -154,8 +158,53 @@ public class SmartGradeController implements SmartGradeControllerAPI {
|
|
|
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
- public CommonResult deleteSmartGradeById(int id) {
|
|
|
- return null;
|
|
|
+ public CommonResult deleteSmartGradeById(int id) throws Exception {
|
|
|
+ //若此年级下有班级则无法删除
|
|
|
+ SmartGrade grade = smartGradeService.querySmartGradeById(id);
|
|
|
+ if (grade == null) {
|
|
|
+ return CommonResult.fail("年级数据无效,删除失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartClass> classes = smartClassService.getSmartClassByGradeID(id);
|
|
|
+ if (classes != null && classes.size() > 0) {
|
|
|
+ return CommonResult.fail(grade.getName() + "下存在班级数据,年级数据不能被删除");
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 删除百胜中的年级数据
|
|
|
+ String appId = controlConfig.getAppId();
|
|
|
+ String schoolno = controlConfig.getSchoolCode();
|
|
|
+ String timestamp = TimeExchange.DateNowTimeStamo();
|
|
|
+ String gradeNo = grade.getBsGradeNo();
|
|
|
+ String appSecret = controlConfig.getAppSecret();
|
|
|
+ String url = controlConfig.getUrl() + "grade/delete";
|
|
|
+
|
|
|
+ JSONObject jsonobject = new JSONObject();
|
|
|
+ jsonobject.put("appid", appId);
|
|
|
+ jsonobject.put("timestamp", timestamp);
|
|
|
+ jsonobject.put("schoolno", schoolno);
|
|
|
+ String str = "{\"grade_no\":\"" + gradeNo + "\"}";
|
|
|
+ String aesStr = URLEncoder.encode(AesTestOne.encrypt(str, controlConfig.getAppSecret()), "UTF-8");
|
|
|
+ jsonobject.put("data", aesStr);
|
|
|
+
|
|
|
+
|
|
|
+ //appid=ymdd36ed157ac423e2&carNo=赣U123659&parkKey=wdcmq9rc&rand=9.94995525689689966&reserveEndTime=2023-12-22 20:12:10&reserveTime=2023-12-21 18:12:10&version=v1.0&50596cd243dc4547b4c05f01f8ea02a4
|
|
|
+ String md5Str = "appid=" + appId + "×tamp=" + timestamp + "&schoolno=" + schoolno + "&data={\"grade_no\":\"" + gradeNo + "\"}" + "&key=" + appSecret;
|
|
|
+ String sign = CommonUtil.MD5(md5Str);
|
|
|
+ //sign签名
|
|
|
+ jsonobject.put("sign", sign);
|
|
|
+
|
|
|
+ //返回的结果中 code为1表示成功
|
|
|
+ String result = RequestUtils.httpPost(url, jsonobject.toJSONString());
|
|
|
+
|
|
|
+ if (result.contains("删除成功")) {
|
|
|
+ int delete = smartGradeService.deleteGradeById(id);
|
|
|
+ if(delete <= 0){
|
|
|
+ return CommonResult.fail("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
+ return CommonResult.ok("删除成功");
|
|
|
}
|
|
|
|
|
|
@Override
|