|
@@ -13,10 +13,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -62,6 +59,26 @@ public class PushMsgController {
|
|
|
return ResponseEntity.ok(JsonResult.success(result));
|
|
|
}
|
|
|
|
|
|
+ @PostMapping
|
|
|
+ @ApiOperation(value = "新增智能推送")
|
|
|
+ public ResponseEntity<JsonResult<List<AccountPush>>> addAccountPush(@RequestHeader String token,
|
|
|
+ @RequestBody AccountPush push) {
|
|
|
+ String userId = JwtTokenUtil.getUserId(token);
|
|
|
+ logger.info("用户:{}查询推送消息列表",userId);
|
|
|
+ List<Account> accounts = accountService.queryAccountByUserId(userId);
|
|
|
+ List<String> accIds = accounts.stream().map(Account::getId).collect(Collectors.toList());
|
|
|
+ List<AccountPush> pushList = pushService.queryAccountPush(accIds);
|
|
|
+ List<AccountPush> result = new ArrayList<>(accIds.size());
|
|
|
+ for (Account account : accounts) {
|
|
|
+ AccountPush var = pushList.stream()
|
|
|
+ .filter(e->account.getId().equals(e.getAccountId()))
|
|
|
+ .findAny()
|
|
|
+ .orElseGet(()->nonPush(account));
|
|
|
+ result.add(var);
|
|
|
+ }
|
|
|
+ return ResponseEntity.ok(JsonResult.success(result));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
private AccountPush nonPush (Account account){
|