| | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void save(Long classId, String taobaoCids) {
|
| | | if (StringUtil.isNullOrEmpty(taobaoCids) || "null".equalsIgnoreCase(taobaoCids)) {
|
| | | public void save(Long classId, List<Long> taobaoCids) {
|
| | | if (taobaoCids == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | | List<Long> listId = new ArrayList<Long>();
|
| | | List<TaoBaoClass> listExist = taoBaoClassMapper.listBySystemCid(0, Integer.MAX_VALUE, classId);
|
| | | if (listExist != null && listExist.size() > 0) {
|
| | | for (TaoBaoClass taoBaoClass : listExist) {
|
| | | listId.add(taoBaoClass.getId());
|
| | | }
|
| | | }
|
| | |
|
| | | String[] array = taobaoCids.split(",");
|
| | | for (String info : array) {
|
| | | if (StringUtil.isNullOrEmpty(info)) {
|
| | | // 删除之前的,插入现在的
|
| | | taoBaoClassRelationMapper.deleteByCid(classId);
|
| | | for (Long categoryId : taobaoCids) {
|
| | | TaoBaoClass taoBaoClass = taoBaoClassMapper.getByCategoryId(Integer.parseInt(categoryId + ""));
|
| | | if (taoBaoClass == null)
|
| | | continue;
|
| | | }
|
| | |
|
| | | try {
|
| | | String[] taobaoArray = info.split("-");
|
| | |
|
| | | Integer categoryId = Integer.parseInt(taobaoArray[1]);
|
| | | if (listExist != null && listExist.size() > 0) {
|
| | | for (int i = 0; i < listExist.size(); i++) {
|
| | | TaoBaoClass taoBaoClass = listExist.get(i);
|
| | | Integer categoryId2 = taoBaoClass.getCategoryId();
|
| | | if (categoryId == categoryId2 || categoryId.equals(categoryId2)) {
|
| | | if (listId.size() > 0) {
|
| | | listId.remove(taoBaoClass.getId());
|
| | | listExist.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | TaoBaoClass tbClass = taoBaoClassMapper.getByCategoryId(Integer.parseInt(taobaoArray[1]));
|
| | | if (tbClass == null) {
|
| | | tbClass = new TaoBaoClass();
|
| | | tbClass.setCategoryName(taobaoArray[0].trim());
|
| | | tbClass.setCategoryId(Integer.parseInt(taobaoArray[1].trim()));
|
| | | tbClass.setCreatetime(new Date());
|
| | | tbClass.setUpdatetime(new Date());
|
| | | taoBaoClassMapper.insert(tbClass);
|
| | | }
|
| | |
|
| | | TaoBaoClassRelation relation = taoBaoClassRelationMapper.getByLocalCid(tbClass.getId());
|
| | | if (relation != null) {
|
| | | if (classId.equals(relation.getCid()) || classId == relation.getCid()) {
|
| | | continue;
|
| | | }
|
| | | TaoBaoClassRelation updateRelation = new TaoBaoClassRelation();
|
| | | updateRelation.setId(relation.getId());
|
| | | updateRelation.setCid(classId);
|
| | | updateRelation.setUpdatetime(new Date());
|
| | | taoBaoClassRelationMapper.updateByPrimaryKeySelective(updateRelation);
|
| | | } else {
|
| | | relation = new TaoBaoClassRelation();
|
| | | relation.setCid(classId);
|
| | | relation.setTaobaoCid(tbClass.getId());
|
| | | relation.setCreatetime(new Date());
|
| | | relation.setUpdatetime(new Date());
|
| | | relation.setWeight(0.0);
|
| | | taoBaoClassRelationMapper.insertSelective(relation);
|
| | | }
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | if (listId.size() > 0) {
|
| | | for (Long id : listId) {
|
| | | taoBaoClassMapper.deleteByPrimaryKey(id);
|
| | | taoBaoClassRelationMapper.deleteRelationByLocalCid(id);
|
| | | }
|
| | | TaoBaoClassRelation relation = new TaoBaoClassRelation();
|
| | | relation.setCid(classId);
|
| | | relation.setTaobaoCid(taoBaoClass.getId());
|
| | | relation.setCreatetime(new Date());
|
| | | relation.setUpdatetime(new Date());
|
| | | relation.setWeight(0.0);
|
| | | taoBaoClassRelationMapper.insertSelective(relation);
|
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void saveSub(Long subClassId, List<Long> taobaoCids) {
|
| | | if (taobaoCids == null || taobaoCids.size() == 0) {
|
| | | if (taobaoCids == null) {
|
| | | return;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public List<TaoBaoClass> listBySystemSubCid(long start, int count, Long systemSubCid) {
|
| | | |
| | |
|
| | | return taoBaoClassMapper.listBySystemSubCid(start, count, systemSubCid);
|
| | | }
|
| | |
|