|
|
|
@ -113,35 +113,43 @@ public class ClassifyServiceImpl implements ClassifyService { |
|
|
|
|
|
|
|
@Override |
|
|
|
public int addNewClass(String pullTopclass, String topClass, String sonClass,Integer userid,String uname) { |
|
|
|
int ret=0; |
|
|
|
Classify classify = new Classify(); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
try { |
|
|
|
Date crt = sdf.parse(sdf.format(System.currentTimeMillis())); |
|
|
|
classify.setCreatetime(crt); |
|
|
|
// 该段代码由php 转来,完全搞不懂为啥要加这个判断
|
|
|
|
String newTopClass=topClass; |
|
|
|
if(StringUtils.isNotEmpty(pullTopclass)){ |
|
|
|
newTopClass=pullTopclass; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int ret=0; //执行返回结果
|
|
|
|
Date nowdate = new Date(); |
|
|
|
//类目class
|
|
|
|
Classify classify = new Classify(); |
|
|
|
classify.setSonClass(sonClass); |
|
|
|
classify.setUserId(userid); |
|
|
|
classify.setCreatetime(nowdate); |
|
|
|
classify.setIsDeleted(0); |
|
|
|
classify.setStatus(0); |
|
|
|
//保存操作记录
|
|
|
|
OperationLog oplog = new OperationLog(); |
|
|
|
oplog.setType("class"); |
|
|
|
String msg =sdf.format(nowdate)+"由"+uname+"创建"; |
|
|
|
oplog.setMessage(msg); |
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(pullTopclass)){ |
|
|
|
classify.setTopClass(pullTopclass); |
|
|
|
classify.setSonClass(sonClass); |
|
|
|
classify.setUserId(userid); |
|
|
|
ret = classifyMapper.addClassify(classify); |
|
|
|
//保存操作记录
|
|
|
|
OperationLog oplog = new OperationLog(); |
|
|
|
// ID 为返回的自编号
|
|
|
|
oplog.setLogid(classify.getId()); |
|
|
|
oplog.setType("class"); |
|
|
|
String msg ="由"+uname+"创建"; |
|
|
|
oplog.setMessage(msg); |
|
|
|
operationLogMapper.addLog(oplog); |
|
|
|
}catch (Exception ex){ |
|
|
|
log.error(ex); |
|
|
|
} |
|
|
|
// 查找类目
|
|
|
|
Classify clsfy= classifyMapper.getClassify(topClass); |
|
|
|
if(clsfy!=null){ |
|
|
|
classify.setTopClass(topClass); |
|
|
|
ret = classifyMapper.addClassify(classify); |
|
|
|
oplog.setLogid(clsfy.getId()); |
|
|
|
operationLogMapper.addLog(oplog); |
|
|
|
}else{ |
|
|
|
classify.setTopClass(topClass); |
|
|
|
ret = classifyMapper.addClassify(classify); |
|
|
|
oplog.setLogid(classify.getId()); |
|
|
|
operationLogMapper.addLog(oplog); |
|
|
|
} |
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
|