test-demo-record

server/2024/11/23 16:34:53/

常规

java">@ApiOperation(value = "发送短信")@PostMapping("/test/sendSms")@ActionLog(action = "发送短信", remark = "发送短信")public R sendSms(@Valid @RequestBody SendSmsREQ req , @RequestHeader("Tenant-Id") String tenantId) {R r = shopRegisterService.sendSms(req, tenantId);return r;}
java">import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;import javax.validation.constraints.NotBlank;
import java.io.Serializable;@Data
@ApiModel(value = "短信发送对象")
public class SendSmsREQ implements Serializable {private static final long serialVersionUID = 1L;/*** 手机号*/@ApiModelProperty(value = "手机号")@NotBlank(message = "手机号不能为空")private String phonenum;/*** 发送短信场景(0:用户注册;1:申请成为合作伙伴;2:忘记密码;3:个人设置修改绑定手机号 4:绑定手机号)* //用于校验一小时内短信发送次数不能超过配置的最大值*/@NotBlank(message = "发送短信场景枚举值不能为空")private String scene;}
java">@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_sms_code")
@ApiModel(value="SysSmsCode对象", description="短信验证码表")
public class SysSmsCode {private static final long serialVersionUID = 1L;@ApiModelProperty(value = "手机号码")@TableField("phonenum")private String phonenum;@ApiModelProperty(value = "验证码内容")@TableField("code")private String code;@ApiModelProperty(value = "最后修改时间")@TableField("update_time")private Date updateTime;@ApiModelProperty(value = "创建人id")@TableField("creator_id")private Long creatorId;@ApiModelProperty(value = "更新人id")@TableField("update_id")private Long updateId;@ApiModelProperty(value = "发送短信场景")@TableField("scene")private String scene;}
java">@Overridepublic Integer queryCountByPhoneNum(Map<String, Object> paramMap) {Date oneHourBefore = DateUtils.addHours(new Date(), -1);paramMap.put("oneHourBefore", oneHourBefore);int count = shopRegisterMapper.queryCountByPhoneNum(paramMap);return count;}
java">public interface RegisterMapper extends BaseMapper<SysSmsCode> {Integer queryCountByPhoneNum(Map<String,Object> paramMap);Integer queryUserByAccount(@Param("account") String account);}
java">   <select id="queryCountByPhoneNum" parameterType="java.util.Map" resultType="java.lang.Integer">select count(*) fromsys_sms_codewhere phonenum =#{phoneNum}and create_time between #{oneHourBefore} and now()and scene = #{scene}</select><select id="queryUserByAccount" parameterType="java.lang.String" resultType="java.lang.Integer">select count(*) from user where account=#{account} and is_deleted=0</select>
Mapper.java
java">	User queryUserByPhone(Map<String,Object> paramMap);IPage<ShopUserVO> getShopUserList(@Param("req") UserQueryREQ req, @Param("page") Page page);
java">    <select id="queryUserByPhone" parameterType="java.util.Map" resultType="org.test.entity.User">select u.id,u.account,u.phonenumfrom user u join tenant_user_rel tur on u.id = tur.user_idwhereu.is_deleted = '0' andu.phonenum = #{phoneNum}<if test="boundRealPhone != null and boundRealPhone != '' ">AND tur.bound_real_phone = #{boundRealPhone}</if></select><select id="getShopUserList" resultType="org.test.vo.ShopUserVO">SELECTt1.id,t1.account,t1.phonenum,t1.supplier_id,t1.status,t1.update_time,t1.create_time,t2.supplier_nameFROM`user` t1INNER JOIN `shop_supplier` t2 ON t1.`supplier_id` = t2.`id`<where>t1.is_deleted = '0' AND t1.supplier_id <![CDATA[ <> ]]> 0<if test="req.search != null and req.search!='' ">AND t1.phonenum LIKE concat('%',#{req.search},'%')</if><if test="req.status != null and req.status!= '' ">AND t1.status = #{req.status}</if><if test="req.supplierName != null and req.supplierName!= '' ">AND t2.supplier_name = #{req.supplierName}</if><if test="req.startTime != null and req.startTime!=''">AND t1.update_time <![CDATA[>=]]> #{req.startTime}</if><if test="req.endTime != null and req.endTime!='' ">AND t1.update_time <![CDATA[<=]]> #{req.endTime}</if></where>order by t1.id desc</select><insert id="saveTenantUserRelInfo" parameterType="org.test.user.entity.TenantUserRel">INSERT INTO tenant_user_rel(id,user_id,bound_real_phone,register_type)values (#{id},#{userId},#{boundRealPhone},#{registerType})</insert><update id="updateTenantUserRelInfo" parameterType="java.util.Map" >update tenant_user_rel set bound_real_phone = #{boundRealPhone}where user_id = #{userId}</update>

mybatis-plus 的stream写法

java">TutorStudent one = this.lambdaQuery().eq(TutorStudent::getId, req.getId()).one();@Overridepublic List<ShopOrder> getOrderPayList(String param) {return this.lambdaQuery().eq(ShopOrder::getOrderStatus, CommonConstant.ORDER_STATUS).eq(ShopOrder::getIsDeleted, CommonConstant.NO).list();}@Overridepublic Boolean deleteOrderPayInfo(Long orderId) {boolean flag = this.lambdaUpdate().eq(ShopOrder::getId, orderId).set(ShopOrder::getIsDeleted, CommonConstant.YES).update();return flag;}boolean result = this.lambdaUpdate().set(CourseApplication::getApproveStatus, status).eq(CourseApplication::getId, id).update();@Overridepublic Boolean addBatchTypeAbilityBusiness(List<CommonAttachmentAddREQ> entitys) {if(Func.isEmpty(entitys)){return false;}Set<String> ablrIds = entitys.stream().map(CommonAttachmentAddREQ::getBizId).collect(Collectors.toSet());this.lambdaUpdate().in(CommonAttachment::getBizId, ablrIds).eq(CommonAttachment::getCreatorId, AuthUtil.getUserId()).eq(CommonAttachment::getType, "ability").remove();return this.addBatchTypeAbility(entitys);
}List<String> userIds = this.lambdaQuery().select(LiveSignUp::getUserId).in(LiveSignUp::getId, signUpIds).list().stream().map(e -> Func.toStr(e.getUserId())).collect(Collectors.toList());List<Long> userLongs = userIds.stream().map(Func::toLong).collect(Collectors.toList());@Overridepublic R<Boolean> updateUserInfoById(String userId) {ShopUser user = shopUserService.lambdaQuery().eq(ShopUser::getId, userId).eq(ShopUser::getStatus, CommonConstant.YES).one();if (Func.isEmpty(user)) {return R.status(false);}boolean flag = this.lambdaUpdate().eq(ShopSupplier::getId, user.getSupplierId()).set(ShopSupplier::getIsCommissionid, CommonConstant.YES).set(ShopSupplier::getUpdateTime, new Date()).update();if (flag) {return R.status(true);}return R.status(false);}

导出

java">controller/*** 导出线上必修总览统计*/@GetMapping("/v1/export")@ApiOperation(value = "导出线上必修总览统计", notes = "导出线上必修总览统计")public void complusoryOverviewExport(@NotBlank String startTime, @NotBlank String endTime, @NotBlank String exportSignature) throws Exception {countCompulsoryService.compulsoryOverviewExport(startTime, endTime, exportSignature);}
java">public interface ICountCompulsoryService {
void compulsoryOverviewExport(String startTime,String endTime,String exportSignature) throws IOException;
}
java">impl@Overridepublic void compulsoryOverviewExport(String startTime,String endTime,String exportSignature) throws IOException {CountCompulsoryREQ req = new CountCompulsoryREQ ();req.setStartTime(startTime);req.setEndTime(endTime);List<CountCompulsoryOverviewVO> compulsoryOverviewList = countCompulsoryMapper.queryCompulsoryOverviewList(req);// 异步处理导出AsyncExportStudyPlanOverviewImpl impl = SpringUtil.getBean(AsyncExportStudyPlanOverviewImpl.class);impl.exportToRedisRela(startTime, endTime, exportSignature, CountCompulsoryOverviewVO.class, AuthUtil.getTenantId(), compulsoryOverviewList.size(),DataScopeUtil.getParam(DataScopeUtil.getMgmtDeptAncestors(AuthUtil.getUser())));}@Async(CommonConstant.ASYNC_EXECUTOR)public <T> CompletableFuture<String> exportToRedis(String startTime, String endTime, String key, Class<T> clz, String tenantId, int count, String mgmtOrgIds) {try {key = key + ":" + tenantId;redisUtils.setExpireTime(key, 60L, TimeUnit.MINUTES);if (count < 1) {// 说明无数据redisUtils.set(key, EXPORT_NO_RESULT);return CompletableFuture.completedFuture("");} else {String fileName = startTime + "-" + endTime + ".xlsx";int totalSheet = (int) Math.ceil((double) count / HALF_MILLION);ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();// 这里 指定文件try(ExcelWriter excelWriter = EasyExcel.write(byteArrayOutputStream, clz).build()){for (int i = 0; i < totalSheet; i++) {// 每次都要创建writeSheet 这里注意必须指定sheetNo 而且sheetName必须不一样WriteSheet writeSheet = EasyExcel.writerSheet(i, "sheet" + i).build();// 分页去数据库查询数据 这里可以去数据库查询每一页的数据int sheetStart = i * HALF_MILLION;List data = exportRealData(startTime, endTime, sheetStart, HALF_MILLION, mgmtOrgIds);// 写数据excelWriter.write(data, writeSheet);}}// 将输出流转为输入流ByteArrayInputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());// 上传至华为OBS 并拿到文件地址MultipartFile file = generateMultipartFile(inputStream, fileName);R response = client.putFile(file, tenantId);String fileUrl = null;if (response.isSuccess()) {fileUrl = (String) response.getResponse();// 存入RedisredisUtils.set(key, fileUrl);return CompletableFuture.completedFuture("");}redisUtils.set(key, EXPORT_FAIL);}} catch (Exception e) {redisUtils.set(key, EXPORT_FAIL);e.printStackTrace();}return CompletableFuture.completedFuture("");}private MultipartFile generateMultipartFile(ByteArrayInputStream inputStream, String fileName) {FileItemFactory factory = new DiskFileItemFactory();DiskFileItem item = (DiskFileItem) factory.createItem("file", MediaType.APPLICATION_OCTET_STREAM_VALUE, true, fileName);try (OutputStream out = item.getOutputStream()) {IOUtils.copy(inputStream, out);return new CommonsMultipartFile(item);} catch (IOException e) {e.printStackTrace();return null;}}@Overridepublic R putFile(MultipartFile file, String tenantId) throws IOException {BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), file.getInputStream());return R.data(bladeFile.getLink());}

http://www.ppmy.cn/server/20903.html

相关文章

Elasticsearch进阶篇(三):ik分词器的使用与项目应用

ik分词器的使用 一、下载并安装1.1 已有作者编译后的包文件1.2 只有源代码的版本1.3 安装ik分词插件 二、ik分词器的模式2.1 ik_smart演示2.2 ik_max_word演示2.3 standard演示 三、ik分词器在项目中的使用四、ik配置文件4.1 配置文件的说明4.2 自定义词库 五、参考链接 一、下…

mmdetection3.1.0 bug(已解决)

mmdetection版本3.1.0 想这训练rpn网络&#xff0c;但是训练后val的时候出现了问题&#xff0c;根据Traceback&#xff0c;找到bug。 报错信息&#xff1a;ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dim…

全视通智慧手术室对讲方案,让手术更安全更高效

在医疗领域&#xff0c;手术室是挽救生命、治疗疾病的前线阵地。随着科技的不断进步&#xff0c;传统的手术室正在经历一场革命性的变革。作为一家专业的智慧医康养解决方案提供商&#xff0c;全视通深知手术室沟通的重要性&#xff0c;因此研发出一套集高效、精准、智能于一体…

Java面试题:如何使用JVM工具(如jconsole, jstack, jmap)来分析内存使用情况?

JVM提供了多种内置工具来帮助开发者分析内存使用情况和诊断问题&#xff0c;这些工具可以独立使用&#xff0c;也可以结合使用以获得更全面的视角。以下是jconsole、jstack和jmap工具的基本使用方法&#xff1a; jconsole&#xff08;Java Monitoring and Management Console&…

自动化爬虫工具:you-get安装与使用

Windows下的安装命令&#xff1a; pip install you-get linux下的安装命令&#xff1a; pip3 install you-get 下载完成后&#xff0c;我们可以看到如下的警告&#xff0c;意思就是这个工具并未被添加到环境变量中&#xff0c;如果我们想在命令行中直接调用&#xff0c;需要…

MySQL-多表查询

多表查询 多表查询简介 笛卡尔乘积 笛卡尔乘积的形成&#xff0c;当: 一个连接条件被遗漏时 一个连接条件不正确时 在第一个表中的所有行被连接到第二个表的所有行时 为了避免笛卡尔乘积的形成&#xff0c;在WHERE子句中应当总是包含正确的连接条件 笛卡尔乘积 &#xf…

机器学习中的 SVM(支持向量机)和随机森林及其优缺点

SVM&#xff08;支持向量机&#xff09;和随机森林是机器学习中常用的两种算法。 支持向量机是一种监督学习算法&#xff0c;主要用于二分类问题。其基本原理是通过在数据集中找到一个超平面&#xff0c;将两个不同的类别分隔开来。SVM的核心思想是尽可能将超平面与两个类别的…

力扣HOT100 - 124. 二叉树中的最大路径和

解题思路&#xff1a; class Solution {int max Integer.MIN_VALUE;public int maxPathSum(TreeNode root) {maxGain(root);return max;}public int maxGain(TreeNode node) {if (node null) return 0;int leftGain Math.max(maxGain(node.left), 0);int rightGain Math.ma…