@ -2,28 +2,28 @@ package com.cloud.kicc.commonbiz.controller;
@@ -2,28 +2,28 @@ package com.cloud.kicc.commonbiz.controller;
import cn.hutool.core.map.MapUtil ;
import cn.hutool.core.util.Object Util ;
import cn.hutool.core.util.Str Util ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
import com.cloud.kicc.common.core.api.R ;
import com.cloud.kicc.common.core.constant.AppConstants ;
import com.cloud.kicc.common.security.annotation.Inner ;
import com.cloud.kicc.common.security.util.SecurityUtils ;
import com.cloud.kicc.commonbiz.api.entity.PushConcernFan ;
import com.cloud.kicc.commonbiz.api.entity.PushConcernFanType ;
import com.cloud.kicc.commonbiz.api.entity.PushType ;
import com.cloud.kicc.commonbiz.service.IPushConcernFanService ;
import com.cloud.kicc.commonbiz.service.IPushConcernFanTypeService ;
import com.cloud.kicc.commonbiz.service.IPushTypeService ;
import com.cloud.kicc.commonbiz.api.entity.* ;
import com.cloud.kicc.commonbiz.service.* ;
import com.cloud.kicc.system.api.entity.User ;
import io.swagger.annotations.Api ;
import io.swagger.annotations.ApiOperation ;
import lombok.AllArgsConstructor ;
import org.springframework.data.repository.query.Param ;
import org.springframework.web.bind.annotation.* ;
import javax.validation.Valid ;
import java.util.Arrays ;
import java.util.List ;
import java.util.Map ;
import java.util.Set ;
import java.util.stream.Collectors ;
/ * *
@ -43,6 +43,10 @@ public class PushConcernFanController {
@@ -43,6 +43,10 @@ public class PushConcernFanController {
private final IPushConcernFanService iPushConcernFanService ;
private final IPushConcernFanTypeService iPushConcernFanTypeService ;
private final IPushTypeService iPushTypeService ;
private final IPushApplicationService iPushApplicationService ;
private final IPushChatMessageService iPushChatMessageService ;
private final IPushEnterpriseService iPushEnterpriseService ;
private final IPushRingtoneService iPushRingtoneService ;
@ApiOperation ( "分页查询" )
@GetMapping ( "/list" )
@ -60,56 +64,34 @@ public class PushConcernFanController {
@@ -60,56 +64,34 @@ public class PushConcernFanController {
}
@ApiOperation ( "根据ID查询" )
@GetMapping ( "/{id:\\w+} " )
public R getById ( @PathVariable ( "id" ) String id ) {
return R . ok ( iPushConcernFanService . getByPushConcernFanId ( id ) ) ;
@GetMapping ( "/getById " )
public R getById ( String id , String onType ) {
return R . ok ( iPushConcernFanService . getByPushConcernFanId ( id , onType ) ) ;
}
@ApiOperation ( "保存" )
@PostMapping ( "/save" )
public R save ( @Valid @RequestBody PushConcernFan pushConcernFan ) {
iPushConcernFanService . save ( pushConcernFan ) ;
return R . ok ( ) ;
}
@ApiOperation ( "企业用户关联保存" )
@PostMapping ( "/enterpriseUserSave" )
public R enterpriseUserSave ( String enterpriseUserId ) {
// 企业内部用户保存默认强制关注系统内部所有用户
IPage < Map < String , Object > > list = iPushConcernFanService . selectPushFriendList ( new Page ( 1 , 999 ) ,
MapUtil . < String , Object > builder ( ) . put ( "createById" , enterpriseUserId ) . build ( ) ) ;
List < PushType > pushTypes = iPushTypeService . list ( Wrappers . < PushType > lambdaQuery ( ) . eq ( PushType : : getCreateById , enterpriseUserId ) ) ;
list . getRecords ( ) . forEach ( item - > {
PushConcernFan pushConcernFan = new PushConcernFan ( ) ;
pushConcernFan . setFanUserId ( enterpriseUserId ) ;
pushConcernFan . setConcernUserId ( item . get ( "id" ) . toString ( ) ) ;
pushConcernFan . setType ( "1" ) ;
pushConcernFan . setStatus ( "1" ) ;
iPushConcernFanService . save ( pushConcernFan ) ;
// 保存用户自定义推送类型
List < PushConcernFanType > pushConcernFanTypes = pushTypes . stream ( )
. map ( pushType - > new PushConcernFanType ( )
// 同步推送类型
if ( StrUtil . equals ( pushConcernFan . getStatus ( ) , "1" ) ) {
List < PushType > pushTypes = iPushTypeService . list ( Wrappers . < PushType > lambdaQuery ( ) . eq ( PushType : : getCreateById , pushConcernFan . getConcernUserId ( ) ) ) ;
List < PushConcernFanType > pushConcernFanTypes = pushTypes . stream ( ) . map ( item - > new PushConcernFanType ( )
. setName ( item . getName ( ) )
. setConcernFanId ( pushConcernFan . getId ( ) )
. setName ( pushType . getName ( ) )
. setConcernUserId ( pushConcernFan . getConcernUserId ( ) )
. setFanUserId ( pushConcernFan . getFanUserId ( ) )
. setTypeId ( pushType . getId ( ) )
. setPlaySound ( pushType . getPlaySound ( ) )
. setPlayVibrate ( pushType . getPlayVibrate ( ) )
. setPlayLights ( pushType . getPlayLights ( ) )
. setPlayToText ( pushType . getPlayToText ( ) )
. setOnlineRingtone ( pushType . getOnlineRingtone ( ) )
. setOfflineRingtone ( pushType . getOfflineRingtone ( ) )
. setTypeId ( item . getId ( ) )
. setDefaultType ( item . getDefaultType ( ) )
. setPlaySound ( item . getPlaySound ( ) )
. setPlayVibrate ( item . getPlayVibrate ( ) )
. setPlayLights ( item . getPlayLights ( ) )
. setPlayToText ( item . getPlayToText ( ) )
. setOnlineRingtone ( item . getOnlineRingtone ( ) )
. setOfflineRingtone ( item . getOfflineRingtone ( ) )
) . collect ( Collectors . toList ( ) ) ;
if ( ! pushConcernFanTypes . isEmpty ( ) ) {
pushConcernFanTypes . get ( 0 ) . setDefaultType ( "1" ) ;
iPushConcernFanTypeService . saveBatch ( pushConcernFanTypes ) ;
}
} ) ;
iPushConcernFanTypeService . saveBatch ( pushConcernFanTypes ) ;
}
return R . ok ( ) ;
}
@ -120,48 +102,82 @@ public class PushConcernFanController {
@@ -120,48 +102,82 @@ public class PushConcernFanController {
return R . ok ( ) ;
}
@Inner
@ApiOperation ( "内部企业用户粉丝保存" )
@PostMapping ( "/enterpriseUserFanSave" )
public R enterpriseUserFanSave ( String innerEnterpriseUserId , @Valid @RequestBody List < User > userList ) {
// 企业内部用户保存默认强制关注系统内除自己以外的所有用户
userList . forEach ( item - > {
// 添加系统内部用户为粉丝
PushConcernFan pushConcernFan = new PushConcernFan ( ) ;
pushConcernFan . setFanUserId ( item . getId ( ) ) ;
pushConcernFan . setConcernUserId ( innerEnterpriseUserId ) ;
pushConcernFan . setType ( "1" ) ;
pushConcernFan . setStatus ( "1" ) ;
iPushConcernFanService . save ( pushConcernFan ) ;
} ) ;
return R . ok ( ) ;
}
@ApiOperation ( "审核" )
@GetMapping ( "/audit" )
public R audit ( String id ) {
iPushConcernFanService . update ( Wrappers . < PushConcernFan > lambdaUpdate ( ) . set ( PushConcernFan : : getStatus , "1" ) . in ( PushConcernFan : : getId , id ) ) ;
PushConcernFan pushConcernFan = iPushConcernFanService . getById ( id ) ;
if ( ObjectUtil . isNotEmpty ( pushConcernFan ) ) {
List < PushType > pushTypes = iPushTypeService . list ( Wrappers . < PushType > lambdaQuery ( ) . eq ( PushType : : getCreateById , pushConcernFan . getConcernUserId ( ) ) ) ;
List < PushConcernFanType > pushConcernFanTypes = pushTypes . stream ( )
. map ( item - > new PushConcernFanType ( )
. setConcernFanId ( pushConcernFan . getId ( ) )
. setName ( item . getName ( ) )
. setConcernUserId ( pushConcernFan . getConcernUserId ( ) )
. setFanUserId ( pushConcernFan . getFanUserId ( ) )
. setTypeId ( item . getId ( ) )
. setPlaySound ( item . getPlaySound ( ) )
. setPlayVibrate ( item . getPlayVibrate ( ) )
. setPlayLights ( item . getPlayLights ( ) )
. setPlayToText ( item . getPlayToText ( ) )
. setOnlineRingtone ( item . getOnlineRingtone ( ) )
. setOfflineRingtone ( item . getOfflineRingtone ( ) )
)
. collect ( Collectors . toList ( ) ) ;
if ( ! pushConcernFanTypes . isEmpty ( ) ) {
pushConcernFanTypes . get ( 0 ) . setDefaultType ( "1" ) ;
iPushConcernFanTypeService . saveBatch ( pushConcernFanTypes ) ;
}
}
// 同步推送类型
List < PushType > pushTypes = iPushTypeService . list ( Wrappers . < PushType > lambdaQuery ( ) . eq ( PushType : : getCreateById , pushConcernFan . getConcernUserId ( ) ) ) ;
List < PushConcernFanType > pushConcernFanTypes = pushTypes . stream ( ) . map ( item - > new PushConcernFanType ( )
. setName ( item . getName ( ) )
. setConcernFanId ( pushConcernFan . getId ( ) )
. setConcernUserId ( pushConcernFan . getConcernUserId ( ) )
. setFanUserId ( pushConcernFan . getFanUserId ( ) )
. setTypeId ( item . getId ( ) )
. setDefaultType ( item . getDefaultType ( ) )
. setPlaySound ( item . getPlaySound ( ) )
. setPlayVibrate ( item . getPlayVibrate ( ) )
. setPlayLights ( item . getPlayLights ( ) )
. setPlayToText ( item . getPlayToText ( ) )
. setOnlineRingtone ( item . getOnlineRingtone ( ) )
. setOfflineRingtone ( item . getOfflineRingtone ( ) )
) . collect ( Collectors . toList ( ) ) ;
iPushConcernFanTypeService . saveBatch ( pushConcernFanTypes ) ;
return R . ok ( ) ;
}
@ApiOperation ( "删除" )
@DeleteMapping ( "/remove/{ids:[\\w,]+}" )
public R < Boolean > removeById ( @PathVariable String [ ] ids ) {
List < String > list = Arrays . asList ( ids ) ;
// 删除用户自定义推送类型
list . forEach ( id - > {
PushConcernFan pushConcernFan = iPushConcernFanService . getById ( id ) ;
iPushConcernFanTypeService . remove ( Wrappers . < PushConcernFanType > lambdaQuery ( )
. eq ( PushConcernFanType : : getConcernUserId , pushConcernFan . getConcernUserId ( ) )
. eq ( PushConcernFanType : : getFanUserId , pushConcernFan . getFanUserId ( ) ) ) ;
} ) ;
iPushConcernFanService . removeByIds ( Arrays . asList ( ids ) ) ;
iPushConcernFanTypeService . remove ( Wrappers . < PushConcernFanType > lambdaQuery ( ) . in ( PushConcernFanType : : getConcernFanId , ids ) ) ;
return R . ok ( ) ;
}
@Inner
@ApiOperation ( "移除用户推送相关数据" )
@DeleteMapping ( "/removeUserPushData" )
public R < Boolean > removeUserPushData ( @RequestParam Set < String > userIds ) {
// 移除推送关注粉丝
iPushConcernFanService . remove ( Wrappers . < PushConcernFan > lambdaQuery ( )
. in ( PushConcernFan : : getConcernUserId , userIds )
. or ( ) . in ( PushConcernFan : : getFanUserId , userIds ) ) ;
// 移除推送关注粉丝子表推送类型
iPushConcernFanTypeService . remove ( Wrappers . < PushConcernFanType > lambdaQuery ( )
. in ( PushConcernFanType : : getConcernUserId , userIds )
. or ( ) . in ( PushConcernFanType : : getFanUserId , userIds ) ) ;
iPushTypeService . remove ( Wrappers . < PushType > lambdaQuery ( )
. in ( PushType : : getCreateById , userIds ) ) ;
// 移除推送应用
iPushApplicationService . remove ( Wrappers . < PushApplication > lambdaQuery ( )
. in ( PushApplication : : getCreateById , userIds ) ) ;
// 移除推送聊天消息
iPushChatMessageService . remove ( Wrappers . < PushChatMessage > lambdaQuery ( )
. in ( PushChatMessage : : getUserId , userIds ) ) ;
// 移除企业用户认证信息
iPushEnterpriseService . remove ( Wrappers . < PushEnterprise > lambdaQuery ( )
. in ( PushEnterprise : : getUserId , userIds ) ) ;
// 移除用户在线铃声
iPushRingtoneService . remove ( Wrappers . < PushRingtone > lambdaQuery ( )
. in ( PushRingtone : : getCreateById , userIds ) ) ;
return R . ok ( ) ;
}