package com.ytpm.middle.controller;

import com.ytpm.agent.param.AppListParam;
import com.ytpm.agent.param.AppParam;
import com.ytpm.agent.view.AgentAppView;
import com.ytpm.general.Result;
import com.ytpm.general.ResultTable;
import com.ytpm.middle.service.ApkService;
import com.ytpm.middle.view.MiddleUserInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

@Api(tags = "出包管理")
@RestController
@RequestMapping("/outSourcing")
public class OutsourcingController {

    @Resource
    private ApkService apkService;

    /**
     * 出包应用列表
     */
    @ApiOperation("出包应用列表")
    @PostMapping("/searchApps")
    public ResultTable<AgentAppView> searchAll(@RequestBody AppListParam appListParam) {
        return apkService.searchAppList(appListParam);
    }

    /**
     * 保存应用
     */
    @ApiOperation("保存应用，新增修改共用")
    @PostMapping("/saveApp")
    public Result<?> saveApp(@RequestBody AppParam param, @ApiIgnore @AuthenticationPrincipal MiddleUserInfo userInfo) {
        return apkService.saveApp(param,userInfo);
    }

    /**
     * 修改子包配置
     */
    @ApiOperation("修改子包配置")
    @PostMapping("/changeConfig")
    public Result<?> changeConfig(@RequestBody AppParam param) {
        return apkService.changeConfig(param);
    }
}
