Commit 71b4c40f by danmo

素材上传接口

1 parent 8f21886b
......@@ -7,13 +7,11 @@ import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.Threads;
import com.linkwechat.common.utils.poi.ExcelUtil;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.vo.WeMakeCustomerTag;
import com.linkwechat.wecom.service.IWeCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
......
......@@ -145,4 +145,11 @@ public class WeMaterialController extends BaseController {
return AjaxResult.success(weMediaDto);
}
@Log(title = "上传素材图片", businessType = BusinessType.OTHER)
@PostMapping("/uploadimg")
@ApiOperation("上传素材图片")
public AjaxResult<WeMediaDto> uploadImg(MultipartFile file){
return AjaxResult.success(materialService.uploadImg(file));
}
}
......@@ -19,23 +19,13 @@ import java.io.InputStream;
*/
@BaseRequest(interceptor = WeAccessTokenInterceptor.class)
public interface WeMediaClient {
/**
* 上传临时素材
* @param file
* @param type
* @return
*/
@Post(url="/media/upload")
WeMediaDto upload(@DataFile(value = "media") File file, @Query("type") String type);
/**
* 上传图片
* @param multipartFile
* @return
*/
@Post(url="/media/uploadimg")
WeMediaDto uploadimg(@DataFile(value = "file") MultipartFile multipartFile);
WeMediaDto uploadimg(@DataFile(value = "fieldNameHere") MultipartFile multipartFile);
/**
......
......@@ -84,14 +84,6 @@ public interface IWeMaterialService {
*/
void resetCategory(String categoryId, String materials);
/**
* 上传企微临时素材
* @param url 素材路径
* @param type 素材类型
* @return
*/
public WeMediaDto uploadTemporaryMaterial(String url, String type);
/**
* 上传企微临时素材
......@@ -102,4 +94,10 @@ public interface IWeMaterialService {
*/
public WeMediaDto uploadTemporaryMaterial(String url, String type,String name);
/**
* 上传素材图片
* @param file
* @return
*/
WeMediaDto uploadImg(MultipartFile file);
}
......@@ -123,18 +123,6 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
}
@Override
public WeMediaDto uploadTemporaryMaterial(String url, String type) {
try {
File file = new File(url);
return weMediaClient.upload(file, type);
} catch (Exception e) {
e.printStackTrace();
log.error("上传临时文件失败......url:{},type:{},ex:{},st:{}",url,type,e.getMessage(),e.getStackTrace());
}
return null;
}
@Override
public WeMediaDto uploadTemporaryMaterial(String url, String type, String name) {
HttpURLConnection conn = null;
try{
......@@ -155,4 +143,9 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
return null;
}
@Override
public WeMediaDto uploadImg(MultipartFile file) {
return weMediaClient.uploadimg(file);
}
}
......@@ -31,7 +31,7 @@
<poi.version>3.17</poi.version>
<velocity.version>1.7</velocity.version>
<jwt.version>0.9.0</jwt.version>
<forest.version>1.5.0-RC3</forest.version>
<forest.version>1.5.0</forest.version>
<lombok.version>1.18.16</lombok.version>
<reflectasm.version>1.11.9</reflectasm.version>
<hutool.version>5.4.1</hutool.version>
......@@ -211,7 +211,7 @@
<!--forset-->
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>spring-boot-starter-forest</artifactId>
<artifactId>forest-spring-boot-starter</artifactId>
<version>${forest.version}</version>
</dependency>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!