@ -107,38 +107,7 @@ public class CommonController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用上传请求(无需登录认证)
|
|
||||||
*/
|
|
||||||
@PostMapping("/common/wxAccountUpload")
|
|
||||||
public AjaxResult wxAccountUpload(MultipartFile file) throws Exception {
|
|
||||||
try {
|
|
||||||
// 上传文件路径
|
|
||||||
String filePath = RuoYiConfig.getUploadPath();
|
|
||||||
// 上传并返回新文件名称
|
|
||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
|
||||||
String url = serverConfig.getUrl() + fileName;
|
|
||||||
|
|
||||||
String accessToken = redisCache.getCacheObject(WxTokenUtils.KEY_ACCESS_TOKEN);
|
|
||||||
if (StringUtils.isEmpty(accessToken)) {
|
|
||||||
WxAccessToken wxAccessToken = WxTokenUtils.fetchAccessToken();
|
|
||||||
redisCache.setCacheObject(WxTokenUtils.KEY_ACCESS_TOKEN, wxAccessToken.getAccessToken(), wxAccessToken.getExpiresIn(), TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
WxFileUploadResult result = WxTokenUtils.uploadImage(filePath, accessToken);
|
|
||||||
if(result == null) {
|
|
||||||
return AjaxResult.error("上传微信失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
AjaxResult ajax = AjaxResult.success();
|
|
||||||
ajax.put("fileName", fileName);
|
|
||||||
ajax.put("mediaId", result.getMediaId());
|
|
||||||
ajax.put("url", url);
|
|
||||||
return ajax;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return AjaxResult.error(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地资源通用下载
|
* 本地资源通用下载
|
||||||
|
@ -15,6 +15,7 @@ import com.stdiet.custom.domain.wechat.WxAccessToken;
|
|||||||
import com.stdiet.custom.domain.wechat.WxFileUploadResult;
|
import com.stdiet.custom.domain.wechat.WxFileUploadResult;
|
||||||
import com.stdiet.custom.service.ISysWxSaleAccountService;
|
import com.stdiet.custom.service.ISysWxSaleAccountService;
|
||||||
import com.stdiet.custom.utils.WxTokenUtils;
|
import com.stdiet.custom.utils.WxTokenUtils;
|
||||||
|
import com.stdiet.framework.config.ServerConfig;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -38,6 +39,9 @@ public class SysWxSaleAccountController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ServerConfig serverConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询微信销售账号列表
|
* 查询微信销售账号列表
|
||||||
*/
|
*/
|
||||||
@ -100,15 +104,17 @@ public class SysWxSaleAccountController extends BaseController {
|
|||||||
return toAjax(sysWxSaleAccountService.deleteSysWxSaleAccountByIds(ids));
|
return toAjax(sysWxSaleAccountService.deleteSysWxSaleAccountByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用上传请求(无需登录认证)
|
||||||
|
*/
|
||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, SysWxSaleAccount sysWxSaleAccount) throws Exception {
|
public AjaxResult wxAccountUpload(MultipartFile file) throws Exception {
|
||||||
try {
|
try {
|
||||||
// 上传文件路径
|
// 上传文件路径
|
||||||
String filePath = RuoYiConfig.getUploadPath();
|
String filePath = RuoYiConfig.getUploadPath();
|
||||||
// 上传并返回新文件名称
|
// 上传并返回新文件名称
|
||||||
String fileName = FileUploadUtils.upload(filePath, file);
|
String fileName = FileUploadUtils.upload(filePath, file);
|
||||||
|
String url = serverConfig.getUrl() + fileName;
|
||||||
sysWxSaleAccount.setImgUrl(fileName);
|
|
||||||
|
|
||||||
String accessToken = redisCache.getCacheObject(WxTokenUtils.KEY_ACCESS_TOKEN);
|
String accessToken = redisCache.getCacheObject(WxTokenUtils.KEY_ACCESS_TOKEN);
|
||||||
if (StringUtils.isEmpty(accessToken)) {
|
if (StringUtils.isEmpty(accessToken)) {
|
||||||
@ -116,18 +122,19 @@ public class SysWxSaleAccountController extends BaseController {
|
|||||||
redisCache.setCacheObject(WxTokenUtils.KEY_ACCESS_TOKEN, wxAccessToken.getAccessToken(), wxAccessToken.getExpiresIn(), TimeUnit.SECONDS);
|
redisCache.setCacheObject(WxTokenUtils.KEY_ACCESS_TOKEN, wxAccessToken.getAccessToken(), wxAccessToken.getExpiresIn(), TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
WxFileUploadResult result = WxTokenUtils.uploadImage(fileName, accessToken);
|
WxFileUploadResult result = WxTokenUtils.uploadImage(filePath, accessToken);
|
||||||
if (StringUtils.isNotNull(result)) {
|
if (result == null) {
|
||||||
|
return AjaxResult.error("上传微信失败");
|
||||||
sysWxSaleAccount.setMediaId(result.getMediaId());
|
|
||||||
|
|
||||||
return toAjax(sysWxSaleAccountService.insertSysWxSaleAccount(sysWxSaleAccount));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return AjaxResult.error("empty");
|
|
||||||
|
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("fileName", fileName);
|
||||||
|
ajax.put("mediaId", result.getMediaId());
|
||||||
|
ajax.put("url", url);
|
||||||
|
return ajax;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -103,7 +103,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
"/custom/wxUserLog/wx/**",
|
"/custom/wxUserLog/wx/**",
|
||||||
"/wx/**",
|
"/wx/**",
|
||||||
"/investigate/**",
|
"/investigate/**",
|
||||||
"/common/customerUploadFile"
|
"/common/customerUploadFile",
|
||||||
|
"/custom/WxAccount/upload"
|
||||||
).anonymous()
|
).anonymous()
|
||||||
.antMatchers(
|
.antMatchers(
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
|
@ -224,9 +224,11 @@
|
|||||||
// 是否禁用上传
|
// 是否禁用上传
|
||||||
isUploading: false,
|
isUploading: false,
|
||||||
// 上传的地址
|
// 上传的地址
|
||||||
url: process.env.VUE_APP_BASE_API + "/common/wxAccountUpload",
|
url: process.env.VUE_APP_BASE_API + "/custom/WxAccount/upload",
|
||||||
// 设置上传的请求头部
|
// 设置上传的请求头部
|
||||||
headers: {},
|
headers: {
|
||||||
|
|
||||||
|
},
|
||||||
// 其他需要携带的数据
|
// 其他需要携带的数据
|
||||||
data: {},
|
data: {},
|
||||||
//文件列表
|
//文件列表
|
||||||
|
@ -253,12 +253,12 @@
|
|||||||
<span class="cus-unit">
|
<span class="cus-unit">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="scope.row.cusWeight"
|
v-model="scope.row.cusWeight"
|
||||||
size="small"
|
size="mini"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
step="0.5"
|
step="0.5"
|
||||||
:min="0.5"
|
:min="0.5"
|
||||||
/>
|
/>
|
||||||
<el-select size="small" v-model="scope.row.cusUnit">
|
<el-select size="mini" v-model="scope.row.cusUnit">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="dict in cusUnitOptions"
|
v-for="dict in cusUnitOptions"
|
||||||
:key="dict.dictValue"
|
:key="dict.dictValue"
|
||||||
@ -740,10 +740,12 @@ export default {
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style >
|
||||||
|
/**
|
||||||
/deep/ :focus {
|
/deep/ :focus {
|
||||||
outline: 0;
|
outline: 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
.el-transfer-panel__filter {
|
.el-transfer-panel__filter {
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
@ -753,7 +755,7 @@ export default {
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cus-unit .el-input-number--small {
|
.cus-unit .el-input-number--mini {
|
||||||
width: 38px;
|
width: 38px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user