package cn.com.tenlion.configcolumn.controller.app.api.configcolumnset;

import cn.com.tenlion.configcolumn.pojo.dtos.configcolumn.ConfigColumnDTO;
import cn.com.tenlion.configcolumn.pojo.dtos.configcolumngroup.ConfigColumnGroupDTO;
import cn.com.tenlion.configcolumn.pojo.vos.configcolumnset.ConfigColumnSetDisplayVO;
import cn.com.tenlion.configcolumn.pojo.vos.configcolumnset.ConfigColumnSetNameVO;
import ink.wgink.annotation.CheckRequestBodyAnnotation;
import ink.wgink.common.base.DefaultBaseController;
import ink.wgink.interfaces.consts.ISystemConstant;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.result.ErrorResult;
import ink.wgink.pojo.result.SuccessResult;
import ink.wgink.pojo.result.SuccessResultData;
import ink.wgink.pojo.result.SuccessResultList;
import cn.com.tenlion.configcolumn.pojo.dtos.configcolumnset.ConfigColumnSetDTO;
import cn.com.tenlion.configcolumn.pojo.vos.configcolumnset.ConfigColumnSetVO;
import cn.com.tenlion.configcolumn.service.configcolumnset.IConfigColumnSetService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: ConfigColumnSetAppController
 * @Description: 
 * @Author: CodeFactory
 * @Date: 2021-07-09 09:48:21
 * @Version: 3.0
 **/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "接口")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/configcolumnset")
public class ConfigColumnSetAppController extends DefaultBaseController {

    @Autowired
    private IConfigColumnSetService configColumnSetService;

    @ApiOperation(value = "用户自定义栏目隐藏", notes = "用户自定义栏目隐藏接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "token", paramType = "header")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @PostMapping("savedisplay")
    @CheckRequestBodyAnnotation
    public SuccessResult save(@RequestHeader("token") String token, @RequestBody ConfigColumnSetDisplayVO configColumnSetDisplayVO) {
        configColumnSetService.saveDisplay(token, configColumnSetDisplayVO);
        return new SuccessResult();
    }

    @ApiOperation(value = "用户自定义栏目名称", notes = "用户自定义栏目名称接口")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "token", value = "token", paramType = "header")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @PostMapping("savename")
    @CheckRequestBodyAnnotation
    public SuccessResult save(@RequestHeader("token") String token, @RequestBody ConfigColumnSetNameVO configColumnSetNameVO) {
        configColumnSetService.saveName(token, configColumnSetNameVO);
        return new SuccessResult();
    }

    @ApiOperation(value = "我的栏目配置列表", notes = "我的栏目配置列表接口")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "token", value = "token", paramType = "header")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("list")
    public List<ConfigColumnGroupDTO> list(@RequestHeader("token") String token) {
        Map<String, Object> params = requestParams();
        return configColumnSetService.listToApp(token, params);
    }

}