| | |
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass;
|
| | | import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass;
|
| | | import com.yeshi.fanli.exception.GoodsClassException;
|
| | | import com.yeshi.fanli.exception.goods.GoodsClassException;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.GoodsSubClassService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelClassService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<GoodsClass> listquery() throws Exception {
|
| | | public List<GoodsClass> listquery(Integer sex) throws Exception {
|
| | |
|
| | | List<GoodsClass> list = goodsClassMapper.getGoodsClassAll();
|
| | | List<GoodsClass> list = goodsClassMapper.getGoodsClassAll(sex);
|
| | |
|
| | | if (list != null && list.size() == 0) {
|
| | | return list;
|
| | |
| | | }
|
| | |
|
| | | public List<GoodsClass> getGoodsClassAll() {
|
| | | return goodsClassMapper.getGoodsClassAll();
|
| | | return goodsClassMapper.getGoodsClassAll(null);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | public void saveObject(MultipartFile file, GoodsClass record) throws GoodsClassException, Exception {
|
| | |
|
| | | String name = record.getName();
|
| | | if (name == null || name.trim().length() == 0) {
|
| | | throw new GoodsClassException(1, "分类名称不能为空");
|
| | | }
|
| | |
|
| | | |
| | | Integer sex = record.getSex();
|
| | | if (sex == null) {
|
| | | throw new GoodsClassException(1, "性别设置不能为空");
|
| | | }
|
| | | |
| | | // 图片上传
|
| | | String picture = null;
|
| | | if (file != null) {
|
| | |
| | |
|
| | | // 保存淘宝商品分类id
|
| | | String taobaoCids = record.getTaobaoCids();
|
| | | List<Long> tbCidList = new ArrayList<>();
|
| | | if (!StringUtil.isNullOrEmpty(taobaoCids) && !"null".equalsIgnoreCase(taobaoCids)) {
|
| | | taoBaoClassService.save(record.getId(), taobaoCids);
|
| | |
|
| | | String[] sts = taobaoCids.split(",");
|
| | | for (String st : sts) {
|
| | | String cid = st.split("-")[st.split("-").length - 1].trim();
|
| | | tbCidList.add(Long.parseLong(cid));
|
| | | }
|
| | | }
|
| | | taoBaoClassService.save(record.getId(), tbCidList);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/GoodsClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.goodsClass.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl = "ClassImg/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String fileUrl = FilePathEnum.goodsClassOld.getPath()+ UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | boolean deleteFile = true;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void switchState(Long id) throws GoodsClassException {
|
| | | if (id == null) {
|
| | | throw new GoodsClassException(1, "请传递正确参数");
|
| | | }
|
| | | GoodsClass resultObj = goodsClassMapper.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | throw new GoodsClassException(1, "此内容已不存在");
|
| | | }
|
| | | |
| | | Integer state = resultObj.getState();
|
| | | if (state == null || state == 0) {
|
| | | state = 1;
|
| | | } else {
|
| | | state = 0;
|
| | | }
|
| | | |
| | | GoodsClass updateObj = new GoodsClass();
|
| | | updateObj.setId(id);
|
| | | updateObj.setState(state);
|
| | | goodsClassMapper.updateByPrimaryKeySelective(updateObj);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Cacheable(value = "classCache", key = "'getEffectiveClassCache'")
|
| | | public List<GoodsClass> getEffectiveClassCache() throws Exception {
|
| | | public List<GoodsClass> getEffectiveClassCache() {
|
| | | return goodsClassMapper.getEffectiveClass();
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | @Transactional(rollbackFor=Exception.class)
|
| | | public void updateOrder(Long id, Integer moveType) throws GoodsClassException {
|
| | |
|
| | | if (id == null || moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
|