From 4ad55b92a42cbaa068fb551c30162178c53bd75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8D=9A?= Date: Mon, 18 Nov 2024 17:03:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E6=85=A7=E6=A0=A1=E5=9B=AD=E8=81=94?= =?UTF-8?q?=E7=B3=BB=E4=BA=BA=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/annotation/Snowflake.java | 2 +- .../common/aspect/SnowflakeAspect.java | 30 ---- .../common/config/MybatisPlusConfig.java | 2 +- .../handler/CustomizeTableNameHandler.java | 3 +- .../common/handler/SnowflakeHandler.java | 16 ++ .../modules/fegin/OpFeignInterceptor.java | 4 +- .../shapelight/modules/fegin/OpHystrix.java | 39 +--- .../modules/mobile/entity/MobileContact.java | 26 ++- .../mobile/entity/MobilePackageOrder.java | 169 ------------------ .../mobile/mapper/MobileContactMapper.java | 6 +- .../service/impl/TenPersonServiceImpl.java | 7 +- .../mapper/mobile/MobileContactMapper.xml | 24 +++ 12 files changed, 75 insertions(+), 253 deletions(-) delete mode 100644 shapelight-admin/src/main/java/net/shapelight/common/aspect/SnowflakeAspect.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/common/handler/SnowflakeHandler.java create mode 100644 shapelight-admin/src/main/resources/mapper/mobile/MobileContactMapper.xml diff --git a/shapelight-admin/src/main/java/net/shapelight/common/annotation/Snowflake.java b/shapelight-admin/src/main/java/net/shapelight/common/annotation/Snowflake.java index 1307002..7182f36 100644 --- a/shapelight-admin/src/main/java/net/shapelight/common/annotation/Snowflake.java +++ b/shapelight-admin/src/main/java/net/shapelight/common/annotation/Snowflake.java @@ -5,7 +5,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -@Target(ElementType.METHOD) +@Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface Snowflake { } \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/common/aspect/SnowflakeAspect.java b/shapelight-admin/src/main/java/net/shapelight/common/aspect/SnowflakeAspect.java deleted file mode 100644 index b76eb22..0000000 --- a/shapelight-admin/src/main/java/net/shapelight/common/aspect/SnowflakeAspect.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.shapelight.common.aspect; - -import net.shapelight.common.utils.SnowflakeIdWorker; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -@Aspect -public class SnowflakeAspect { - - @Around("@annotation(net.shapelight.common.annotation.Snowflake)") - public Object generateSnowflakeId(ProceedingJoinPoint joinPoint) throws Throwable { - // 生成Snowflake ID - SnowflakeIdWorker snowflakeIdWorker = new SnowflakeIdWorker(); - long snowflakeId = snowflakeIdWorker.nextId(); - - // 修改方法参数或者返回值来设置Snowflake ID - Object[] args = joinPoint.getArgs(); - if (args != null && args.length > 0) { - // 假设第一个参数是传递Snowflake ID的参数 - args[0] = snowflakeId; - } - - // 继续执行原方法,并且可以返回修改后的结果 - return joinPoint.proceed(args); - } -} diff --git a/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java b/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java index 8860601..6c2280c 100644 --- a/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java +++ b/shapelight-admin/src/main/java/net/shapelight/common/config/MybatisPlusConfig.java @@ -40,7 +40,7 @@ public class MybatisPlusConfig { DynamicTableNameInnerInterceptor dynamicTableNameInnerInterceptor = new DynamicTableNameInnerInterceptor(); dynamicTableNameInnerInterceptor.setTableNameHandler( //可以传多个表名参数,指定哪些表使用MonthTableNameHandler处理表名称 - new CustomizeTableNameHandler("ten_person_extract,mobile_device,mobile_package_order,mobile_call_logs") + new CustomizeTableNameHandler("ten_person_extract,mobile_device,mobile_package_order,mobile_call_logs,mobile_contact") ); //以拦截器的方式处理表名称 diff --git a/shapelight-admin/src/main/java/net/shapelight/common/handler/CustomizeTableNameHandler.java b/shapelight-admin/src/main/java/net/shapelight/common/handler/CustomizeTableNameHandler.java index 64c0ea5..5a253ea 100644 --- a/shapelight-admin/src/main/java/net/shapelight/common/handler/CustomizeTableNameHandler.java +++ b/shapelight-admin/src/main/java/net/shapelight/common/handler/CustomizeTableNameHandler.java @@ -10,7 +10,7 @@ import java.util.List; */ public class CustomizeTableNameHandler implements TableNameHandler { //用于记录哪些表可以使用该月份动态表名处理器(即哪些表可以分表) - private List tableNames; + private final List tableNames; //构造函数,构造动态表名处理器的时候,传递tableNames参数 public CustomizeTableNameHandler(String ...tableNames) { @@ -39,4 +39,5 @@ public class CustomizeTableNameHandler implements TableNameHandler { return tableName; //表名原样返回 } } + } diff --git a/shapelight-admin/src/main/java/net/shapelight/common/handler/SnowflakeHandler.java b/shapelight-admin/src/main/java/net/shapelight/common/handler/SnowflakeHandler.java new file mode 100644 index 0000000..6a26cd9 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/common/handler/SnowflakeHandler.java @@ -0,0 +1,16 @@ +package net.shapelight.common.handler; + +import net.shapelight.common.utils.SnowflakeIdWorker; +import org.apache.ibatis.plugin.Interceptor; +import org.apache.ibatis.plugin.Invocation; + +public class SnowflakeHandler implements Interceptor { + @Override + public Object intercept(Invocation invocation) throws Throwable { + SnowflakeIdWorker snowflakeIdWorker = new SnowflakeIdWorker(); + Object target = invocation.getTarget(); + // 检查字段并生成 ID 的逻辑... + target = snowflakeIdWorker.nextId(); + return invocation.proceed(); + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpFeignInterceptor.java b/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpFeignInterceptor.java index f02714d..4251578 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpFeignInterceptor.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpFeignInterceptor.java @@ -14,8 +14,8 @@ public class OpFeignInterceptor implements RequestInterceptor { @Override public void apply(RequestTemplate requestTemplate) { - requestTemplate.header("access_token", redisUtils.get("wxToken").toString()); - //requestTemplate.header("empowerText", KeysEntity.empowerText); + //requestTemplate.header("access_token", redisUtils.get("wxToken").toString()); + requestTemplate.header("empowerText", KeysEntity.empowerText); log.info("feign拦截器"); } } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpHystrix.java b/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpHystrix.java index c78be72..e8c52e5 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpHystrix.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/fegin/OpHystrix.java @@ -29,44 +29,7 @@ public class OpHystrix implements FallbackFactory { } @Override - public JSONObject getToken(Map params) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("errorMessage","token获取失败"); - return jsonObject; - } - - @Override - public JSONObject createIotGroupId(Map params) { - return null; - } - - @Override - public JSONObject removeIotGroupDevice(Map params) { - return null; - } - - @Override - public JSONObject addIotGroupDevice(Map params) { - return null; - } - - @Override - public JSONObject getIotGroupInfo(Map params) { - return null; - } - - @Override - public JSONObject activeLicenseDevice(Map params) { - return null; - } - - @Override - public JSONObject getLicenseDeviceInfo(Map params) { - return null; - } - - @Override - public JSONObject createOrder(Map params) { + public JSONObject getData(Map params) { return null; } }; diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileContact.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileContact.java index 5ec9650..f051291 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileContact.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobileContact.java @@ -5,19 +5,22 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; +import java.util.Date; + import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import net.shapelight.common.annotation.Snowflake; import org.hibernate.validator.constraints.Length; /** * * @TableName mobile_contact */ -@Data -@ApiModel("联系人信息") @TableName("mobile_contact") +@ApiModel("联系人信息") +@Data public class MobileContact implements Serializable { /** @@ -25,14 +28,15 @@ public class MobileContact implements Serializable { */ @NotNull(message="[联系人ID]不能为空") @ApiModelProperty("联系人ID") + @Snowflake private Long contactId; /** - * 联系人姓名 + * 联系人称呼 */ @Size(max= 20,message="编码长度不能超过20") - @ApiModelProperty("联系人姓名") + @ApiModelProperty("联系人称呼") @Length(max= 20,message="编码长度不能超过20") - private String name; + private String callName; /** * 联系人电话 */ @@ -49,7 +53,7 @@ public class MobileContact implements Serializable { * 排序字段 */ @ApiModelProperty("排序字段") - private Integer order; + private Integer sort; /** * 家长ID */ @@ -60,5 +64,15 @@ public class MobileContact implements Serializable { */ @ApiModelProperty("绑定状态") private Integer bindStatus; + /** + * 是否主联系人 + */ + @ApiModelProperty("是否主联系人") + private Integer isMain; + /** + * 绑定时间 + */ + @ApiModelProperty("绑定时间") + private Date bindTime; } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobilePackageOrder.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobilePackageOrder.java index 49b68a1..235d6c3 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobilePackageOrder.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/entity/MobilePackageOrder.java @@ -86,173 +86,4 @@ public class MobilePackageOrder implements Serializable { @ApiModelProperty("到期时间") private Date expireTime; - /** - * 订单ID - */ - private void setOrderId(Long orderId){ - this.orderId = orderId; - } - - /** - * 学生ID - */ - private void setPersonId(Long personId){ - this.personId = personId; - } - - /** - * 套餐ID - */ - private void setPackageId(Long packageId){ - this.packageId = packageId; - } - - /** - * 支付金额 - */ - private void setPayment(BigDecimal payment){ - this.payment = payment; - } - - /** - * 付款时间 - */ - private void setPayTime(Date payTime){ - this.payTime = payTime; - } - - /** - * 支付状态(1已支付0未支付) - */ - private void setPayStatus(Integer payStatus){ - this.payStatus = payStatus; - } - - /** - * 生效时间 - */ - private void setEffectiveDate(Date effectiveDate){ - this.effectiveDate = effectiveDate; - } - - /** - * 剩余时长 - */ - private void setRemainderTime(Integer remainderTime){ - this.remainderTime = remainderTime; - } - - /** - * 剩余次数 - */ - private void setRemainderCount(Integer remainderCount){ - this.remainderCount = remainderCount; - } - - /** - * 生效状态 - */ - private void setStatus(Integer status){ - this.status = status; - } - - /** - * 学生姓名 - */ - private void setPersonName(String personName){ - this.personName = personName; - } - - /** - * 到期时间 - */ - private void setExpireTime(Date expireTime){ - this.expireTime = expireTime; - } - - - /** - * 订单ID - */ - private Long getOrderId(){ - return this.orderId; - } - - /** - * 学生ID - */ - private Long getPersonId(){ - return this.personId; - } - - /** - * 套餐ID - */ - private Long getPackageId(){ - return this.packageId; - } - - /** - * 支付金额 - */ - private BigDecimal getPayment(){ - return this.payment; - } - - /** - * 付款时间 - */ - private Date getPayTime(){ - return this.payTime; - } - - /** - * 支付状态(1已支付0未支付) - */ - private Integer getPayStatus(){ - return this.payStatus; - } - - /** - * 生效时间 - */ - private Date getEffectiveDate(){ - return this.effectiveDate; - } - - /** - * 剩余时长 - */ - private Integer getRemainderTime(){ - return this.remainderTime; - } - - /** - * 剩余次数 - */ - private Integer getRemainderCount(){ - return this.remainderCount; - } - - /** - * 生效状态 - */ - private Integer getStatus(){ - return this.status; - } - - /** - * 学生姓名 - */ - private String getPersonName(){ - return this.personName; - } - - /** - * 到期时间 - */ - private Date getExpireTime(){ - return this.expireTime; - } - } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobileContactMapper.java b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobileContactMapper.java index fb83c21..df205aa 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobileContactMapper.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/mobile/mapper/MobileContactMapper.java @@ -2,13 +2,15 @@ package net.shapelight.modules.mobile.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import net.shapelight.modules.mobile.entity.MobileContact; +import org.apache.ibatis.annotations.Mapper; /** * @author zhangbo * @description 针对表【mobile_contact】的数据库操作Mapper -* @createDate 2024-11-18 13:29:24 -* @Entity net.shapelight.modules.mobile.entity.MobileContact +* @createDate 2024-11-18 16:03:51 +* @Entity net.shapelight.modules.mobile.MobileContact */ +@Mapper public interface MobileContactMapper extends BaseMapper { } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java index f2d6ac5..90ab6c6 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenPersonServiceImpl.java @@ -37,7 +37,6 @@ import net.shapelight.modules.fegin.OpFeignClient; import net.shapelight.modules.vo.*; import org.apache.commons.codec.digest.DigestUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; @@ -161,6 +160,9 @@ public class TenPersonServiceImpl implements TenPersonService { new QueryWrapper() .eq("person_id", personEntity.getPersonId()) ); + List mobileContacts = mobileContactService.list(new LambdaQueryWrapper().eq(MobileContact::getPersonId,personEntity.getPersonId())); + CustomizeTableNameHandler.removeData(); + personEntity.setMobileContactList(mobileContacts); if (extracts != null) { personEntity.setExtractCount(extracts.size()); personEntity.setExtractList(extracts); @@ -177,7 +179,6 @@ public class TenPersonServiceImpl implements TenPersonService { personEntity.setDeptAllName(deptAllName); } } - CustomizeTableNameHandler.removeData(); } return new PageUtils(page); } @@ -471,7 +472,7 @@ public class TenPersonServiceImpl implements TenPersonService { appUserService.updateById(appUser); } if (entity.getPersonType().equals(Constant.PERSON_TYPE_OWNER)) { - + mobileContactService.saveBatch(entity.getMobileContactList()); } //发送设备通知 diff --git a/shapelight-admin/src/main/resources/mapper/mobile/MobileContactMapper.xml b/shapelight-admin/src/main/resources/mapper/mobile/MobileContactMapper.xml new file mode 100644 index 0000000..7f2aef5 --- /dev/null +++ b/shapelight-admin/src/main/resources/mapper/mobile/MobileContactMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + contact_id,call_name,mobile, + person_id,sort,parent_id, + bind_status,is_main,bind_time + +