From 413d5fb8681752b7a80b1cf7b509ed2bc4bfe3ee Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期四, 11 九月 2025 18:11:05 +0800 Subject: [PATCH] 上传接口 --- ruoyi-admin/src/main/resources/application-test.yml | 12 ruoyi-system/src/main/java/com/ruoyi/system/service/TSysObsConfigService.java | 16 + ruoyi-system/pom.xml | 7 ruoyi-system/src/main/java/com/ruoyi/system/mapper/TSysObsConfigMapper.java | 16 + ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java | 4 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java | 2 ruoyi-system/src/main/java/com/ruoyi/system/utils/util/ObsUploadUtil.java | 60 ++++++ ruoyi-system/src/main/java/com/ruoyi/system/model/TSysLive.java | 6 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysObsConfigController.java | 43 ++++ /dev/null | 61 ------ generator/src/test/java/com/xizang/CodeGeneratorTests.java | 2 ruoyi-system/src/main/resources/mapper/system/TSysObsConfigMapper.xml | 20 ++ ruoyi-admin/src/main/resources/application-prod.yml | 33 --- ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml | 4 ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java | 64 ++++++ ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java | 76 +++++++ ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysObsUploadController.java | 43 ++++ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysObsConfigServiceImpl.java | 20 ++ ruoyi-system/src/main/resources/mapper/system/TSysLiveMapper.xml | 4 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java | 40 +++ ruoyi-system/src/main/java/com/ruoyi/system/model/TSysObsConfig.java | 48 ++++ 21 files changed, 470 insertions(+), 111 deletions(-) diff --git a/generator/src/test/java/com/xizang/CodeGeneratorTests.java b/generator/src/test/java/com/xizang/CodeGeneratorTests.java index c87f2a6..f5c8687 100644 --- a/generator/src/test/java/com/xizang/CodeGeneratorTests.java +++ b/generator/src/test/java/com/xizang/CodeGeneratorTests.java @@ -144,7 +144,7 @@ // strategy.setTablePrefix(pc.getModuleName() + ""); // strategy.setLikeTable(new LikeTable("room")); //strategy.setLikeTable(new LikeTable("member")); - strategy.setLikeTable(new LikeTable("t_sys_inspection"));// 生成表名 + strategy.setLikeTable(new LikeTable("t_sys_obs_config"));// 生成表名 // strategy.setLikeTable(new LikeTable("t_hotel"));// 生成表名 // strategy.setLikeTable(new LikeTable("t_scan_message"));// 生成表名 // strategy.setNotLikeTable(new LikeTable("hotel_info"));// 不生成表名 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java index d81f78a..5c1c855 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TErpGoodsController.java @@ -8,6 +8,7 @@ import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.basic.PageInfo; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.R; @@ -68,11 +69,13 @@ private final TErpSupplierWarehousingService erpSupplierWarehousingService; private final TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService; private final TErpMaintenanceReminderService erpMaintenanceReminderService; + private final TCrmClinicService crmClinicService; + private final TCrmSupplierService crmSupplierService; @Autowired public TErpGoodsController(TErpGoodsService erpGoodsService, TokenService tokenService, TErpGoodsTypeService erpGoodsTypeService, TErpGoodsUnitService erpGoodsUnitService, TErpSupplierWarehousingBatchService erpSupplierWarehousingBatchService, TErpSupplierWarehousingService erpSupplierWarehousingService, - TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService, TErpMaintenanceReminderService erpMaintenanceReminderService) { + TErpSupplierOutboundGoodsService erpSupplierOutboundGoodsService, TErpMaintenanceReminderService erpMaintenanceReminderService, TCrmClinicService crmClinicService, TCrmSupplierService crmSupplierService) { this.erpGoodsService = erpGoodsService; this.tokenService = tokenService; this.erpGoodsTypeService = erpGoodsTypeService; @@ -81,6 +84,8 @@ this.erpSupplierWarehousingService = erpSupplierWarehousingService; this.erpSupplierOutboundGoodsService = erpSupplierOutboundGoodsService; this.erpMaintenanceReminderService = erpMaintenanceReminderService; + this.crmClinicService = crmClinicService; + this.crmSupplierService = crmSupplierService; } @@ -92,6 +97,21 @@ @PostMapping(value = "/pageList") public R<PageInfo<TErpGoodsVO>> pageList(@RequestBody TErpGoodsQuery query) { SysUser user = tokenService.getLoginUser().getUser(); + Integer roleType = user.getRoleType(); + if(roleType == 4){ + // 供应商 + TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) + .eq(TCrmSupplier::getUserId, user.getUserId()) + .last("LIMIT 1")); + query.setSupplierClinicId(crmSupplier.getId()); + } + if(roleType == 5){ + // 诊所 + TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) + .eq(TCrmClinic::getUserId, user.getUserId()) + .last("LIMIT 1")); + query.setSupplierClinicId(crmClinic.getId()); + } return R.ok(erpGoodsService.pageList(query,user)); } @@ -104,8 +124,24 @@ if (erpGoodsService.isExit(dto.getGoodsIdCode(), dto.getQuasiNumber())) { return R.fail("erp商品已存在"); } + Integer roleType = user.getRoleType(); TErpGoods goods = new TErpGoods(); - goods.setSupplierClinicId(user.getUserId().toString()); + if(roleType == 4){ + // 供应商 + TCrmSupplier crmSupplier = crmSupplierService.getOne(Wrappers.lambdaQuery(TCrmSupplier.class) + .eq(TCrmSupplier::getUserId, user.getUserId()) + .last("LIMIT 1")); + goods.setSupplierClinicId(crmSupplier.getId()); + goods.setGoodsSource(1); + } + if(roleType == 5){ + // 诊所 + TCrmClinic crmClinic = crmClinicService.getOne(Wrappers.lambdaQuery(TCrmClinic.class) + .eq(TCrmClinic::getUserId, user.getUserId()) + .last("LIMIT 1")); + goods.setSupplierClinicId(crmClinic.getId()); + goods.setGoodsSource(2); + } goods.setCreateId(user.getUserId().toString()); goods.setGoodsIdCode(dto.getGoodsIdCode()); goods.setQuasiNumber(dto.getQuasiNumber()); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java index 004cb54..54d7251 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java @@ -73,7 +73,6 @@ } // 计算结束时间 dto.setEndTime(dto.getStartTime().plusMinutes(dto.getExpectedDuration())); - dto.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); return R.ok(sysLiveService.save(dto)); } @@ -90,7 +89,6 @@ // } // 计算结束时间 dto.setEndTime(dto.getStartTime().plusMinutes(dto.getExpectedDuration())); - dto.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); return R.ok(sysLiveService.updateById(dto)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysObsConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysObsConfigController.java new file mode 100644 index 0000000..073f087 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysObsConfigController.java @@ -0,0 +1,43 @@ +package com.ruoyi.web.controller.api; + + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.model.TSysLive; +import com.ruoyi.system.model.TSysObsConfig; +import com.ruoyi.system.service.TSysLiveService; +import com.ruoyi.system.service.TSysObsConfigService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * <p> + * obs文件上传配置 前端控制器 + * </p> + * + * @author xiaochen + * @since 2025-09-11 + */ +@RestController +@RequestMapping("/t-sys-obs-config") +public class TSysObsConfigController { + private final TSysObsConfigService sysObsConfigService; + @Autowired + public TSysObsConfigController(TSysObsConfigService sysObsConfigService) { + this.sysObsConfigService = sysObsConfigService; + } + /** + * 查看obs文件上传配置 + */ + @GetMapping(value = "/getDetailById") + public R<TSysObsConfig> getDetailById() { + return R.ok(sysObsConfigService.getById(1)); + } + +} + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysObsUploadController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysObsUploadController.java new file mode 100644 index 0000000..5745ea1 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TSysObsUploadController.java @@ -0,0 +1,43 @@ +package com.ruoyi.web.controller.api; + + +import com.ruoyi.common.core.domain.R; +import com.ruoyi.system.model.TSysObsConfig; +import com.ruoyi.system.service.TSysObsConfigService; +import com.ruoyi.system.utils.util.ObsUploadUtil; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; + +/** + * <p> + * obs文件上传 前端控制器 + * </p> + * + * @author xiaochen + * @since 2025-09-11 + */ +@Api(tags = "obs文件上传") +@RestController +@RequestMapping("/obs-upload") +public class TSysObsUploadController { + /** + * obs文件上传 + */ + @ApiOperation(value = "obs文件上传") + @PostMapping(value = "/upload", headers = "content-type=multipart/form-data") + public R<String> upload(@RequestParam(value = "file") MultipartFile file) { + try { + String url = ObsUploadUtil.obsUpload(file); + return R.ok(url); + } catch (IOException e) { + return R.fail("上传失败"); + } + } + +} + diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgCodeUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgCodeUtil.java deleted file mode 100644 index 073f315..0000000 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgCodeUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.ruoyi.web.controller.tool; - -import com.alibaba.fastjson.JSONObject; -import com.ruoyi.system.code.SubmitTemplateReg; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.binary.Hex; - -import java.io.Serializable; -import java.nio.charset.StandardCharsets; - -/** - * 短信工具类 - */ -public class MsgCodeUtil implements Serializable { - - /**接口账号用户名*/ - private static final String AP_ID = ""; - /**企业名称*/ - private static final String EC_NAME = ""; - /**签名*/ - private static final String SECRET_KEY = ""; - /**签名编码*/ - private static final String SIGN = ""; - /**模板ID*/ - private static final String TEMPLATE_ID = ""; - - - /** - * 实体封装 - * @param code - * @return - */ - public static SubmitTemplateReg getSubmitTemplateReg(String code,String mobiles) { - SubmitTemplateReg submitReg =new SubmitTemplateReg(); - String[] paramss = {code}; - submitReg.setApId(AP_ID); - submitReg.setEcName(EC_NAME); - submitReg.setSecretKey(SECRET_KEY); - submitReg.setParams(JSONObject.toJSONString(paramss)); - submitReg.setMobiles(mobiles); - submitReg.setAddSerial(""); - submitReg.setSign(SIGN); - submitReg.setTemplateId(TEMPLATE_ID); - submitReg.setMac(TEMPLATE_ID); - StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(submitReg.getEcName( ));stringBuffer.append(submitReg.getApId()); - stringBuffer.append(submitReg.getSecretKey());stringBuffer.append(submitReg.getTemplateId());stringBuffer.append(submitReg.getMobiles()); - stringBuffer.append(submitReg.getParams());stringBuffer.append(submitReg.getSign());stringBuffer.append(submitReg.getAddSerial()); - submitReg.setMac(Hex.encodeHexString(stringBuffer.toString().getBytes(StandardCharsets.UTF_8))); - String regText = JSONObject.toJSONString(submitReg); - //加密 - String encode = Base64.encodeBase64String(regText.getBytes()); - System.err.println(encode); - return submitReg; - } - - public static void main(String[] args) { - getSubmitTemplateReg("123456","18398968484"); - } - -} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java new file mode 100644 index 0000000..245b96b --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/MsgUtils.java @@ -0,0 +1,64 @@ +package com.ruoyi.web.controller.tool; + +import com.aliyun.dysmsapi20170525.models.SendSmsRequest; +import com.aliyun.dysmsapi20170525.models.SendSmsResponse; +import com.aliyun.tea.TeaException; +import com.aliyun.teaopenapi.models.Config; +import com.aliyun.teautil.models.RuntimeOptions; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class MsgUtils { + + @Value("${code.config.accessKeyId}") + private String accessKeyId; + @Value("${code.config.accessKeySecret}") + private String accessKeySecret; + @Value("${code.config.signName}") + private String signName; + + /** + * 使用AK&SK初始化账号Client + * @param accessKeyId + * @param accessKeySecret + * @return Client + * @throws Exception + */ + public static com.aliyun.dysmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception { + Config config = new Config() + // 您的 AccessKey ID + .setAccessKeyId(accessKeyId) + // 您的 AccessKey Secret + .setAccessKeySecret(accessKeySecret); + // 访问的域名 + config.endpoint = "dysmsapi.aliyuncs.com"; + return new com.aliyun.dysmsapi20170525.Client(config); + } + + public void sendMsg(String phone,String code,String templateCode) throws Exception { + com.aliyun.dysmsapi20170525.Client client = MsgUtils.createClient(accessKeyId,accessKeySecret); + SendSmsRequest sendSmsRequest = new SendSmsRequest() + .setSignName(signName) + .setTemplateCode(templateCode) + .setPhoneNumbers(phone) + .setTemplateParam("{\"code\":\""+code+"\"}"); + RuntimeOptions runtime = new RuntimeOptions(); + try { + // 复制代码运行请自行打印 API 的返回值 + SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime); + log.info("短信发送成功:{},{}",sendSmsResponse.getBody().getMessage(),sendSmsResponse.getStatusCode()); + } catch (TeaException error) { + // 如有需要,请打印 error + com.aliyun.teautil.Common.assertAsString(error.message); + log.info("短信发送失败:{}",error.message); + } catch (Exception _error) { + TeaException error = new TeaException(_error.getMessage(), _error); + // 如有需要,请打印 error + com.aliyun.teautil.Common.assertAsString(error.message); + log.info("短信发送失败:{}",error.message); + } + } +} diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index 366ab73..e909611 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -210,33 +210,6 @@ #OSS及短信配置 code: config: - templateCodeTest: "SMS_154950909" - signNameTest: "阿里云短信测试" - accessKeyId: LTAI5tAdba8HtT1C6UqtSxBt - accessKeySecret: 0SRb6XGkciQDPWn2rYqbJtq2qRMDY8 - signName: "四川金达通信工程" - templateCode: "SMS_293985284" -cos: - client: - accessKey: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x - secretKey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU - bucket: xzgt-1305134071 - bucketAddr: ap-chengdu -# bucket: xzgttest-1305134071 -# rootSrc: https://xzgttest-1305134071.cos.ap-chengdu.myqcloud.com/ - rootSrc: https://xzgt-1305134071.cos.ap-chengdu.myqcloud.com - location: /xizang -sms: - enable: true - appId: 1400957506 - secretid: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x - secretkey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU - sign: 畅云出行 -com: - taxi591: - bank: - cer-path: /usr/local/bank/TrustPay.cer - base-url: http://hello.enjoy.abchina.com - enable: true - keystore-password: gggs6666 - pfx-path: /usr/local/bank/103882597000441.pfx \ No newline at end of file + accessKeyId: LTAI5t99NH2Wwoq48ho72u8M + accessKeySecret: wAGHKUEBrrTgDcbfjnBKTEt5858Ru5 + signName: "海诊通" \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/application-test.yml b/ruoyi-admin/src/main/resources/application-test.yml index e364e9b..4228d35 100644 --- a/ruoyi-admin/src/main/resources/application-test.yml +++ b/ruoyi-admin/src/main/resources/application-test.yml @@ -198,9 +198,9 @@ conf: appId: wxe91f1af7638aa5dd secretId: a787e1a462715604e0c9528b6d8960d1 -sms: - enable: true - appId: 1400957506 - secretid: AKIDCF5EF2c0DE1e5JK8r4EGJF4mNsMgp26x - secretkey: lLl184rUyFOOE0d5KNGC3kmfNsCWk4GU - sign: 畅云出行 \ No newline at end of file +#OSS及短信配置 +code: + config: + accessKeyId: LTAI5t99NH2Wwoq48ho72u8M + accessKeySecret: wAGHKUEBrrTgDcbfjnBKTEt5858Ru5 + signName: "海诊通" \ No newline at end of file diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java new file mode 100644 index 0000000..fe58ad2 --- /dev/null +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TSysLiveController.java @@ -0,0 +1,76 @@ +package com.ruoyi.web.controller.api; + + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.basic.PageInfo; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.model.TSysLive; +import com.ruoyi.system.query.TSysLiveQuery; +import com.ruoyi.system.service.TSysLiveService; +import com.ruoyi.system.vo.TSysLiveVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; +import java.util.List; + +/** + * <p> + * 直播管理 前端控制器 + * </p> + * + * @author xiaochen + * @since 2025-08-20 + */ +@Api(tags = "直播管理") +@RestController +@RequestMapping("/t-sys-live") +public class TSysLiveController { + + private final TSysLiveService sysLiveService; + private final TokenService tokenService; + @Autowired + public TSysLiveController(TSysLiveService sysLiveService, TokenService tokenService) { + this.sysLiveService = sysLiveService; + this.tokenService = tokenService; + } + + /** + * 获取直播管理管理列表 + */ + @ApiOperation(value = "获取直播管理分页列表") + @PostMapping(value = "/pageList") + public R<PageInfo<TSysLiveVO>> pageList(@RequestBody TSysLiveQuery query) { + return R.ok(sysLiveService.pageList(query)); + } + + /** + * 查看直播管理详情 + */ + @ApiOperation(value = "查看直播管理详情") + @GetMapping(value = "/getDetailById") + public R<TSysLive> getDetailById(@RequestParam String id) { + return R.ok(sysLiveService.getById(id)); + } + + /** + * 直播管理推送用户 + */ + @Log(title = "直播管理信息-推送用户", businessType = BusinessType.UPDATE) + @ApiOperation(value = "直播管理信息推送用户") + @PutMapping(value = "/pushUser") + public R<String> pushUser(@RequestParam(value = "id") String id, + @RequestParam(value = "pushType")String pushType) { + sysLiveService.pushUser(id,pushType); + return R.ok(); + } + +} + diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml index cfbce26..d40c998 100644 --- a/ruoyi-system/pom.xml +++ b/ruoyi-system/pom.xml @@ -69,7 +69,12 @@ <artifactId>easyexcel</artifactId> <version>2.1.6</version> </dependency> - + <!--华为云的obs--> + <dependency> + <groupId>com.huaweicloud</groupId> + <artifactId>esdk-obs-java</artifactId> + <version>3.19.5</version> + </dependency> <!-- <dependency>--> <!-- <groupId>org.apache.httpcomponents</groupId>--> diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TSysObsConfigMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TSysObsConfigMapper.java new file mode 100644 index 0000000..4d1c9ba --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/TSysObsConfigMapper.java @@ -0,0 +1,16 @@ +package com.ruoyi.system.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ruoyi.system.model.TSysObsConfig; + +/** + * <p> + * obs文件上传配置 Mapper 接口 + * </p> + * + * @author xiaochen + * @since 2025-09-11 + */ +public interface TSysObsConfigMapper extends BaseMapper<TSysObsConfig> { + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/model/TSysLive.java b/ruoyi-system/src/main/java/com/ruoyi/system/model/TSysLive.java index cadf707..7dca2d8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/model/TSysLive.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/model/TSysLive.java @@ -72,9 +72,9 @@ @TableField("live_type") private Integer liveType; - @ApiModelProperty(value = "密码") - @TableField("password") - private String password; + @ApiModelProperty(value = "直播地址") + @TableField("live_url") + private String liveUrl; @ApiModelProperty(value = "详情") @TableField("live_detail") diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/model/TSysObsConfig.java b/ruoyi-system/src/main/java/com/ruoyi/system/model/TSysObsConfig.java new file mode 100644 index 0000000..9c05bc4 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/model/TSysObsConfig.java @@ -0,0 +1,48 @@ +package com.ruoyi.system.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + * <p> + * obs文件上传配置 + * </p> + * + * @author xiaochen + * @since 2025-09-11 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@TableName("t_sys_obs_config") +@ApiModel(value="TSysObsConfig对象", description="obs文件上传配置") +public class TSysObsConfig implements Serializable { + + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @TableField("endPoint") + private String endPoint; + + @TableField("accessKeyId") + private String accessKeyId; + + @TableField("accessKeySecret") + private String accessKeySecret; + + @TableField("bucketName") + private String bucketName; + + @TableField("obs_url") + private String obsUrl; + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java index 3a943a8..618e293 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/TErpGoodsQuery.java @@ -1,5 +1,6 @@ package com.ruoyi.system.query; +import com.baomidou.mybatisplus.annotation.TableField; import com.ruoyi.common.core.domain.BasePage; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -28,5 +29,6 @@ @ApiModelProperty(value = "库存管理条件 不足传1") private Integer type; - + @ApiModelProperty(value = "供应商id/诊所id") + private String supplierClinicId; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TSysObsConfigService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TSysObsConfigService.java new file mode 100644 index 0000000..5ec5909 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TSysObsConfigService.java @@ -0,0 +1,16 @@ +package com.ruoyi.system.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ruoyi.system.model.TSysObsConfig; + +/** + * <p> + * obs文件上传配置 服务类 + * </p> + * + * @author xiaochen + * @since 2025-09-11 + */ +public interface TSysObsConfigService extends IService<TSysObsConfig> { + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysObsConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysObsConfigServiceImpl.java new file mode 100644 index 0000000..ebb8092 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TSysObsConfigServiceImpl.java @@ -0,0 +1,20 @@ +package com.ruoyi.system.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.system.mapper.TSysObsConfigMapper; +import com.ruoyi.system.model.TSysObsConfig; +import com.ruoyi.system.service.TSysObsConfigService; +import org.springframework.stereotype.Service; + +/** + * <p> + * obs文件上传配置 服务实现类 + * </p> + * + * @author xiaochen + * @since 2025-09-11 + */ +@Service +public class TSysObsConfigServiceImpl extends ServiceImpl<TSysObsConfigMapper, TSysObsConfig> implements TSysObsConfigService { + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/utils/util/ObsUploadUtil.java b/ruoyi-system/src/main/java/com/ruoyi/system/utils/util/ObsUploadUtil.java new file mode 100644 index 0000000..22ccc17 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/utils/util/ObsUploadUtil.java @@ -0,0 +1,60 @@ +package com.ruoyi.system.utils.util; + +import com.obs.services.ObsClient; +import com.obs.services.model.ObjectMetadata; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.io.InputStream; +import java.util.UUID; + +public class ObsUploadUtil { + //OBS图片访问域名 + public static String endPoint = "obs.cn-south-1.myhuaweicloud.com"; + public static String accessKeyId = "HPUA5AQBALRF13NDF1BK"; + public static String accessKeySecret = "4t19xNQip1rCeZpWTRSu96VWsY7bEZtPnLwwPxiH"; + public static String bucketName = "haizhentong"; + public static String oss_domain = "https://haizhentong.obs.cn-south-1.myhuaweicloud.com/"; + + + // 创建ObsClient实例 + public static ObsClient obsClient = new ObsClient(accessKeyId, accessKeySecret, endPoint); + + public static String obsUpload(MultipartFile file) throws IOException{ + String fileName = ""; + if(file!=null && !"".equals(file.getOriginalFilename()) && file.getOriginalFilename()!=null){ + InputStream content = file.getInputStream();//获得指定文件的输入流 + ObjectMetadata meta = new ObjectMetadata();// 创建上传Object的Metadata + meta.setContentLength(file.getSize()); // 必须设置ContentLength + String originalFilename = file.getOriginalFilename(); + fileName = UUID.randomUUID().toString().replaceAll("-","") + originalFilename.subSequence(originalFilename.lastIndexOf("."), originalFilename.length()); + obsClient.putObject(bucketName,"file/"+fileName,content,meta);// 上传Object. + if(fileName != null && !"".equals(fileName)){ + System.out.println(fileName); + fileName = oss_domain+"file/"+fileName; + } + } + return fileName; + } + + /** + * 删除某个Object + * + * @param bucketUrl + * @return + */ + public static boolean deleteObject(String bucketUrl) { + try { + bucketUrl=bucketUrl.replace(oss_domain+"web",""); + // 删除Object. + obsClient.deleteObject(bucketName, bucketUrl); + } catch (Exception e) { + e.printStackTrace(); + return false; + } finally { + //ossClient.shutdown(); + } + return true; + } + +} diff --git a/ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml index 9929444..9ffee44 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TErpGoodsMapper.xml @@ -71,10 +71,10 @@ and state = #{query.state} </if> <if test="user.roleType != null and user.roleType == 4 "> - and goods_source =1 and supplier_clinic_id =#{user.userId} + and goods_source =1 and supplier_clinic_id = #{query.supplierClinicId} </if> <if test="user.roleType != null and user.roleType == 5 "> - and goods_source =2 and supplier_clinic_id =#{user.userId} + and goods_source =2 and supplier_clinic_id = #{query.supplierClinicId} </if> order by create_time desc </select> diff --git a/ruoyi-system/src/main/resources/mapper/system/TSysLiveMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TSysLiveMapper.xml index caa893d..fd8083c 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TSysLiveMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TSysLiveMapper.xml @@ -15,7 +15,7 @@ <result column="live_mode" property="liveMode" /> <result column="live_lecturer" property="liveLecturer" /> <result column="live_type" property="liveType" /> - <result column="password" property="password" /> + <result column="live_url" property="liveUrl" /> <result column="live_detail" property="liveDetail" /> <result column="push_type" property="pushType" /> <result column="create_time" property="createTime" /> @@ -27,7 +27,7 @@ <!-- 通用查询结果列 --> <sql id="Base_Column_List"> - id, live_title, live_cover, live_introduction, start_time,end_time, expected_duration, live_way, live_mode, + id, live_title, live_cover, live_introduction, start_time,end_time, expected_duration, live_way, live_mode,live_url, live_lecturer, live_type, password, live_detail, push_type, create_time, update_time, create_by, update_by, disabled </sql> <select id="pageList" resultType="com.ruoyi.system.vo.TSysLiveVO"> diff --git a/ruoyi-system/src/main/resources/mapper/system/TSysObsConfigMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TSysObsConfigMapper.xml new file mode 100644 index 0000000..d09aa81 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/TSysObsConfigMapper.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<mapper namespace="com.ruoyi.system.mapper.TSysObsConfigMapper"> + + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TSysObsConfig"> + <id column="id" property="id" /> + <result column="endPoint" property="endPoint" /> + <result column="accessKeyId" property="accessKeyId" /> + <result column="accessKeySecret" property="accessKeySecret" /> + <result column="bucketName" property="bucketName" /> + <result column="obs_url" property="obsUrl" /> + </resultMap> + + <!-- 通用查询结果列 --> + <sql id="Base_Column_List"> + id, endPoint, accessKeyId, accessKeySecret, bucketName, obs_url + </sql> + +</mapper> -- Gitblit v1.7.1