|
|
|
@ -12,11 +12,13 @@ import com.bsd.cases.util.AjaxResult;
|
|
|
|
|
import com.bsd.cases.util.PageUtils;
|
|
|
|
|
import com.bsd.cases.vo.CaseCategoryVo;
|
|
|
|
|
import com.bsd.cases.vo.CaseSearchVo;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Service("caseCategoryService")
|
|
|
|
@ -106,5 +108,62 @@ public class CaseCategoryServiceImpl extends BaseServiceImpl<CaseCategoryMapper,
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增或者修改分类
|
|
|
|
|
* @param jsonObject
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult saveOrUpdateCategory(JSONObject jsonObject) {
|
|
|
|
|
AjaxResult ajaxResult = new AjaxResult();
|
|
|
|
|
Long categoryId = jsonObject.getLong("categoryId");
|
|
|
|
|
String name = jsonObject.getString("name");
|
|
|
|
|
Integer level = jsonObject.getInteger("level");
|
|
|
|
|
Long parentId = jsonObject.getLong("parentId");
|
|
|
|
|
String url = jsonObject.getString("url");
|
|
|
|
|
if (null == categoryId){
|
|
|
|
|
//走新增
|
|
|
|
|
CaseCategory caseCategory = new CaseCategory();
|
|
|
|
|
caseCategory.setCreateDateTime(new Date());
|
|
|
|
|
caseCategory.setUpdateDateTime(new Date());
|
|
|
|
|
caseCategory.setState(Constants.STATE_VALID);
|
|
|
|
|
if (StringUtils.isBlank(name)){
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("分类名不可为空");
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
caseCategory.setName(name);
|
|
|
|
|
if (null == level){
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("分级等级不可为空");
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}else {
|
|
|
|
|
caseCategory.setLevel(level);
|
|
|
|
|
if (1 != level){
|
|
|
|
|
if (null == parentId){
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("parentId不可为空");
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
caseCategory.setParentId(parentId);
|
|
|
|
|
if (3 == level){
|
|
|
|
|
if (StringUtils.isBlank(url)){
|
|
|
|
|
ajaxResult.setRetcode(AjaxResult.FAILED);
|
|
|
|
|
ajaxResult.setRetmsg("三级预览图地址不可为空");
|
|
|
|
|
return ajaxResult;
|
|
|
|
|
}
|
|
|
|
|
caseCategory.setUrl(url);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
//走更新
|
|
|
|
|
CaseCategory caseCategory = caseCategoryMapper.selectByPrimaryKey(categoryId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|