| | |
| | | package com.yeshi.fanli.service.impl.lable;
|
| | |
|
| | | import java.io.InputStream;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | |
| | |
|
| | | @Resource
|
| | | private LabelMapper labelMapper;
|
| | | @Resource
|
| | | private LabelService labelService;
|
| | |
|
| | | @Resource
|
| | | private LabelGoodsMapper labelGoodsMapper;
|
| | |
| | |
|
| | | // 上传图片
|
| | | if (file != null) {
|
| | | labelService.uploadPicture(file, label);
|
| | | uploadPicture(file, label);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | Label label = labelMapper.selectByPrimaryKey(id);
|
| | | if (label != null) {
|
| | | // 删除图片
|
| | | labelService.deleteImg(label);
|
| | | deleteImg(label);
|
| | | // 删除数据信息
|
| | | labelMapper.deleteByPrimaryKey(id);
|
| | |
|
| | |
| | |
|
| | | for (String title : titles) {
|
| | |
|
| | | List<Label> labels = labelService.selectByTitle(title.trim());
|
| | | List<Label> labels = selectByTitle(title.trim());
|
| | | // 若已存在则不存入数据库
|
| | | if (labels == null || labels.size() == 0) {
|
| | | Label label = new Label();
|
| | |
| | | label.setUpdatetime(nowTime);
|
| | | label.setCreateUser(admin);
|
| | |
|
| | | labelService.insertSelective(label);
|
| | | insertSelective(label);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | label.setPicture(uploadFilePath);
|
| | | label.setUpdatetime(nowTime);
|
| | |
|
| | | result = labelService.updateByPrimaryKeySelective(label);
|
| | | result = updateByPrimaryKeySelective(label);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | label.setPicture(null);
|
| | | label.setUpdatetime(nowTime);
|
| | | // 更新数据库
|
| | | result = labelService.updateByPrimaryKey(label);
|
| | | result = updateByPrimaryKey(label);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | return labelMapper.getByGoodsId(goodsId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Label> addBatchByNames(String lableNames, AdminUser admin) throws LabelException{
|
| | | if (lableNames == null || lableNames.trim().length() == 0) {
|
| | | return null;
|
| | | }
|
| | |
|
| | | List<Label> listLabs = new ArrayList<Label>();
|
| | | // 空格隔开
|
| | | String[] arrtitles = lableNames.split("\\s+");
|
| | | |
| | | for (String title : arrtitles) {
|
| | | /* 遍历标签名称:查询数据库中是否已存在 */
|
| | | List<Label> labels = selectByTitle(title.trim());
|
| | | if (labels != null && labels.size() > 0) {
|
| | | Label label = labels.get(0);
|
| | | listLabs.add(label);
|
| | | } else {
|
| | | // 新增
|
| | | Label label = new Label();
|
| | | label.setTitle(title);// 名称
|
| | | label.setEntrymode(Label.MODE_SYSTEM); // 批量录入
|
| | | label.setCreatetime(new Date());
|
| | | label.setUpdatetime(new Date());
|
| | | label.setCreateUser(admin);
|
| | | label.setIosClick(0l);
|
| | | label.setAndroidClick(0l);
|
| | | insertSelective(label);
|
| | | |
| | | listLabs.add(label);
|
| | | }
|
| | | }
|
| | | |
| | | return listLabs;
|
| | | }
|
| | | |
| | | }
|
| | |
|