|
|
|
@ -1,6 +1,8 @@
@@ -1,6 +1,8 @@
|
|
|
|
|
package com.cloud.kicc.commonbiz.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.map.MapUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
@ -8,16 +10,21 @@ import com.cloud.kicc.common.core.api.R;
@@ -8,16 +10,21 @@ import com.cloud.kicc.common.core.api.R;
|
|
|
|
|
import com.cloud.kicc.common.core.constant.AppConstants; |
|
|
|
|
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 io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.apache.ibatis.annotations.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.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* <p> |
|
|
|
@ -34,6 +41,8 @@ import java.util.Map;
@@ -34,6 +41,8 @@ import java.util.Map;
|
|
|
|
|
public class PushConcernFanController { |
|
|
|
|
|
|
|
|
|
private final IPushConcernFanService iPushConcernFanService; |
|
|
|
|
private final IPushConcernFanTypeService iPushConcernFanTypeService; |
|
|
|
|
private final IPushTypeService iPushTypeService; |
|
|
|
|
|
|
|
|
|
@ApiOperation("分页查询") |
|
|
|
|
@GetMapping("/list") |
|
|
|
@ -63,6 +72,47 @@ public class PushConcernFanController {
@@ -63,6 +72,47 @@ public class PushConcernFanController {
|
|
|
|
|
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() |
|
|
|
|
.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()) |
|
|
|
|
).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
if (!pushConcernFanTypes.isEmpty()) { |
|
|
|
|
pushConcernFanTypes.get(0).setDefaultType("1"); |
|
|
|
|
iPushConcernFanTypeService.saveBatch(pushConcernFanTypes); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ApiOperation("修改") |
|
|
|
|
@PutMapping("/update") |
|
|
|
|
public R update(@Valid @RequestBody PushConcernFan pushConcernFan) { |
|
|
|
@ -70,9 +120,47 @@ public class PushConcernFanController {
@@ -70,9 +120,47 @@ public class PushConcernFanController {
|
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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)); |
|
|
|
|
return R.ok(); |
|
|
|
|
} |
|
|
|
|