|
@ -5,9 +5,11 @@ import com.yihu.iot.dao.dict.IotSystemDictDao;
|
|
import com.yihu.iot.service.common.MyJdbcTemplate;
|
|
import com.yihu.iot.service.common.MyJdbcTemplate;
|
|
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
|
|
import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@ -39,6 +41,26 @@ public class IotSystemDictService extends BaseJpaService<IotSystemDictDO,IotSyst
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IotSystemDictDO create(IotSystemDictDO dictDO) {
|
|
|
|
String value = dictDO.getValue();
|
|
|
|
//判断新增或者编辑
|
|
|
|
if(StringUtils.isNotBlank(dictDO.getCode())){
|
|
|
|
dictDO = iotSystemDictDao.findByDictNameAndCodeAndDel(dictDO.getDictName(), dictDO.getCode(), 1);
|
|
|
|
dictDO.setValue(value);
|
|
|
|
dictDO.setUpdateTime(new Date());
|
|
|
|
}else {
|
|
|
|
//获取最近一条添加记录的code
|
|
|
|
List<IotSystemDictDO> dictDOList = iotSystemDictDao.getAllByDictNameAndOrderByCodeDesc(dictDO.getDictName());
|
|
|
|
if(dictDOList.size() > 0){
|
|
|
|
dictDO.setCode((Long.parseLong(dictDOList.get(0).getCode()) + 1) + "");
|
|
|
|
}else {
|
|
|
|
dictDO.setCode("1");
|
|
|
|
}
|
|
|
|
dictDO.setSaasId(getCode());
|
|
|
|
dictDO.setDel(1);
|
|
|
|
dictDO.setCreateTime(new Date());
|
|
|
|
}
|
|
|
|
iotSystemDictDao.save(dictDO);
|
|
|
|
return dictDO;
|
|
|
|
}
|
|
}
|
|
}
|