修复海报分组bug

1 parent 7796dde0
......@@ -42,7 +42,7 @@ public class WeMaterialController extends BaseController {
@Autowired
private IWeMaterialService materialService;
@Resource
@Autowired
private IWePosterService wePosterService;
......
......@@ -7,8 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableName;
import com.linkwechat.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import lombok.experimental.SuperBuilder;
import java.util.List;
......@@ -21,6 +21,9 @@ import java.util.List;
@Data
@TableName(value = "we_poster")
@ApiModel(value = "海报")
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class WePoster extends BaseEntity {
@TableId(type = IdType.AUTO)
......
......@@ -17,17 +17,20 @@ import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.file.FileUtils;
import com.linkwechat.wecom.client.WeMediaClient;
import com.linkwechat.wecom.domain.WeMaterial;
import com.linkwechat.wecom.domain.WePoster;
import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.vo.WeMaterialFileVO;
import com.linkwechat.wecom.mapper.WeMaterialMapper;
import com.linkwechat.wecom.service.IWeMaterialService;
import com.linkwechat.wecom.service.IWePosterService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
......@@ -55,6 +58,10 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
private RuoYiConfig ruoYiConfig;
@Autowired
private IWePosterService wePosterService;
@Override
public WeMaterialFileVO uploadWeMaterialFile(MultipartFile file, String type) {
if (null == file) {
......@@ -115,7 +122,16 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
List<String> materialList = Arrays.asList(StringUtils.splitByWholeSeparatorPreserveAllTokens(materials, WeConstans.COMMA));
if (CollectionUtil.isNotEmpty(materialList)) {
materialList.forEach(s -> {
weMaterialMapper.resetCategory(categoryId, s);
WeMaterial weMaterial = weMaterialMapper.findWeMaterialById(new Long(s));
if(null != weMaterial){
weMaterialMapper.resetCategory(categoryId, s);
}else{
wePosterService.updateById(WePoster.builder()
.categoryId(new Long(categoryId))
.id(new Long(s))
.build());
}
});
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!