AppPushController.java 5.4 KB
/*
package com.brframework.commonapppush.web;

import com.brframework.commonapppush.domain.UPushConfig;
import com.brframework.commonapppush.entity.PushClientInfo;
import com.brframework.commonapppush.entity.PushLog;
import com.brframework.commonapppush.json.AppUPushSendBroadcastParam;
import com.brframework.commonapppush.json.AppUPushSendUnicastParam;
import com.brframework.commonapppush.json.PushLogSimpleResult;
import com.brframework.commonapppush.service.AppPushService;
import com.brframework.commonapppush.service.PushClientInfoService;
import com.brframework.commonapppush.service.PushLogService;
import com.brframework.commonapppush.service.UPushConfigService;
import com.brframework.commoncms.annatotion.AdminMenu;
import com.brframework.commoncms.annatotion.layout.EditAlertLayout;
import com.brframework.commoncms.annatotion.layout.EditLayout;
import com.brframework.commoncms.annatotion.layout.PageLayout;
import com.brframework.commoncms.annatotion.layout.ViewLayout;
import com.brframework.commoncms.annatotion.option.CmsOption;
import com.brframework.commoncms.core.Icons;
import com.brframework.commonweb.json.JSONResult;
import com.brframework.commonweb.json.Page;
import com.brframework.commonweb.json.PageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import static com.brframework.commondb.core.ControllerPageHandle.jpaPageConvertToPage;
import static com.brframework.commondb.core.ControllerPageHandle.jpaPageToPage;

*/
/**
 * @author xu
 * @date 2019/11/18 20:16
 *//*

@RestController
@Api(tags = "APP推送")
@RequestMapping("/admin/access")
@AdminMenu(menuName = "APP推送", icon = Icons.DEVELOPMENT_LAPTOP, order = Integer.MIN_VALUE + 201)
public class AppPushController {

    @Autowired
    PushLogService pushLogService;

    @Autowired
    PushClientInfoService pushClientInfoService;

    @Autowired
    AppPushService appPushService;

    @Autowired
    UPushConfigService uPushConfigService;

    @ApiOperation(value = "推送管理", notes = "推送管理")
    @GetMapping("v1/app/push/list")
    @PageLayout(
            options = {
                    @CmsOption(name = "发送单播", uriMappingMethod = "appUPushSendUnicast"),
                    @CmsOption(name = "发送广播", uriMappingMethod = "appUPushSendBroadcast")
            },
            columnOptions = {
                    @CmsOption(name = "查看", uriMappingMethod = "appPushGet")
            }
    )
    @PreAuthorize("hasRole('app-push-list')")
    @AdminMenu(menuName = "推送管理", order = 0)
    public JSONResult<Page<PushLogSimpleResult>> appPushList(@Valid PageParam page) {
        return JSONResult.ok(jpaPageConvertToPage(
                pushLogService.page(page, null),
                page, PushLogSimpleResult.class
        ));
    }

    @ApiOperation(value = "推送详情", notes = "推送详情")
    @GetMapping("v1/app/push/get/{id}")
    @ViewLayout(paddingMappingMethod = "appPushGet")
    @PreAuthorize("hasRole('app-push-list')")
    public JSONResult<PushLog> appPushGet(@PathVariable Long id) {
        return JSONResult.ok(pushLogService.accessObject(id));
    }

    @ApiOperation(value = "发送单播", notes = "发送单播")
    @PostMapping("/v1/app/upush/send/unicast")
    @EditAlertLayout
    @PreAuthorize("hasRole('app-upush-send-unicast')")
    public JSONResult appUPushSendUnicast(@RequestBody AppUPushSendUnicastParam param) {
        appPushService.sendUnicastNotification(param.getUserTokens(), param.getTitle(),
                param.getText(), param.getUri(), param.getDescription());
        return JSONResult.ok();
    }

    @ApiOperation(value = "发送广播", notes = "发送广播")
    @PostMapping("/v1/app/upush/send/broadcast")
    @EditAlertLayout
    @PreAuthorize("hasRole('app-upush-send-broadcast')")
    public JSONResult appUPushSendBroadcast(@RequestBody AppUPushSendBroadcastParam param) {
        appPushService.sendBroadcastNotification(param.getTitle(), param.getText(), param.getUri(), param.getDescription());
        return JSONResult.ok();
    }


    @ApiOperation(value = "客户端用户关系表", notes = "客户端用户关系表")
    @GetMapping("v1/app/push/client-user/list")
    @PageLayout
    @PreAuthorize("hasRole('app-push-client-user-list')")
    @AdminMenu(menuName = "客户端用户关系表", order = 5)
    public JSONResult<Page<PushClientInfo>> appPushClientUserList(@Valid PageParam page) {
        return JSONResult.ok(jpaPageToPage(
                pushClientInfoService.page(page, null),
                page
        ));
    }

    @ApiOperation(value = "友盟推送配置", notes = "友盟推送配置")
    @PostMapping("/v1/app/upush/config")
    @EditLayout(paddingMappingMethod = "appUPushConfigGet")
    @PreAuthorize("hasRole('app-upush-config')")
    @AdminMenu(menuName = "友盟推送配置", order = 50)
    public JSONResult appUPushConfig(@RequestBody UPushConfig param) {
        uPushConfigService.set(param);
        return JSONResult.ok();
    }

    @ApiOperation(value = "获取热更新配置", notes = "获取热更新配置")
    @GetMapping("/v1/app/upush/config")
    @PreAuthorize("hasRole('app-upush-config')")
    public JSONResult<UPushConfig> appUPushConfigGet() {
        return JSONResult.ok(uPushConfigService.get());
    }


}
*/