|
|
@ -1,13 +1,16 @@
|
|
|
|
package com.bsd.cases.service.impl;
|
|
|
|
package com.bsd.cases.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.bsd.cases.constants.Constants;
|
|
|
|
import com.bsd.cases.constants.Constants;
|
|
|
|
import com.bsd.cases.mapper.CaseCategoryMapper;
|
|
|
|
import com.bsd.cases.mapper.CaseCategoryMapper;
|
|
|
|
import com.bsd.cases.model.CaseCategory;
|
|
|
|
import com.bsd.cases.model.CaseCategory;
|
|
|
|
|
|
|
|
import com.bsd.cases.model.CaseContent;
|
|
|
|
import com.bsd.cases.service.CaseCategoryService;
|
|
|
|
import com.bsd.cases.service.CaseCategoryService;
|
|
|
|
import com.bsd.cases.util.AjaxRequest;
|
|
|
|
import com.bsd.cases.util.AjaxRequest;
|
|
|
|
import com.bsd.cases.util.AjaxResult;
|
|
|
|
import com.bsd.cases.util.AjaxResult;
|
|
|
|
import com.bsd.cases.util.PageUtils;
|
|
|
|
import com.bsd.cases.util.PageUtils;
|
|
|
|
|
|
|
|
import com.bsd.cases.vo.CaseCategoryVo;
|
|
|
|
import com.bsd.cases.vo.CaseSearchVo;
|
|
|
|
import com.bsd.cases.vo.CaseSearchVo;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@ -52,13 +55,33 @@ public class CaseCategoryServiceImpl extends BaseServiceImpl<CaseCategoryMapper,
|
|
|
|
findCaseCategory2.setState(Constants.STATE_VALID);
|
|
|
|
findCaseCategory2.setState(Constants.STATE_VALID);
|
|
|
|
List<CaseCategory> caseCategoryList2 = caseCategoryMapper.select(findCaseCategory2);
|
|
|
|
List<CaseCategory> caseCategoryList2 = caseCategoryMapper.select(findCaseCategory2);
|
|
|
|
findCaseCategory.setState(Constants.STATE_VALID);
|
|
|
|
findCaseCategory.setState(Constants.STATE_VALID);
|
|
|
|
findCaseCategory.setParentId(caseCategoryList2.get(0).getId());
|
|
|
|
parentId = caseCategoryList2.get(0).getId();
|
|
|
|
|
|
|
|
findCaseCategory.setParentId(parentId);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
findCaseCategory.setState(Constants.STATE_VALID);
|
|
|
|
findCaseCategory.setState(Constants.STATE_VALID);
|
|
|
|
findCaseCategory.setParentId(parentId);
|
|
|
|
findCaseCategory.setParentId(parentId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<CaseCategory> caseCategoryList = caseCategoryMapper.select(findCaseCategory);
|
|
|
|
List<CaseCategory> caseCategoryList = caseCategoryMapper.select(findCaseCategory);
|
|
|
|
JSONObject pageJson = PageUtils.page(caseCategoryList,pageNum,pageSize);
|
|
|
|
JSONObject pageJson = PageUtils.page(caseCategoryList,pageNum,pageSize);
|
|
|
|
|
|
|
|
JSONArray jsonArray = pageJson.getJSONArray("list");
|
|
|
|
|
|
|
|
caseCategoryList = JSONObject.parseArray(JSONObject.toJSONString(jsonArray), CaseCategory.class);
|
|
|
|
|
|
|
|
List<CaseCategoryVo> newCaseCategoryVoList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (CaseCategory caseCategory:caseCategoryList){
|
|
|
|
|
|
|
|
CaseCategoryVo caseCategoryVo = new CaseCategoryVo();
|
|
|
|
|
|
|
|
caseCategoryVo.setName(caseCategory.getName());
|
|
|
|
|
|
|
|
caseCategoryVo.setLevel(caseCategory.getLevel());
|
|
|
|
|
|
|
|
caseCategoryVo.setParentId(parentId);
|
|
|
|
|
|
|
|
caseCategoryVo.setUrl(caseCategory.getUrl());
|
|
|
|
|
|
|
|
String parenName = caseCategoryMapper.selectByPrimaryKey(parentId).getName();
|
|
|
|
|
|
|
|
caseCategoryVo.setParentName(parenName);
|
|
|
|
|
|
|
|
newCaseCategoryVoList.add(caseCategoryVo);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
|
|
jsonObject.put("list",newCaseCategoryVoList);
|
|
|
|
|
|
|
|
jsonObject.put("total",pageJson.getInteger("total"));
|
|
|
|
|
|
|
|
jsonObject.put("pageNum",pageNum);
|
|
|
|
|
|
|
|
jsonObject.put("pages",(int) Math.ceil(Double.valueOf(pageJson.getInteger("total")) / Double.valueOf(pageSize)));
|
|
|
|
|
|
|
|
jsonObject.put("pageSize",pageSize);
|
|
|
|
return pageJson;
|
|
|
|
return pageJson;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|