package com.artfess.manage.duty.controller;


import com.artfess.base.annotation.ApiGroup;
import com.artfess.base.constants.ApiGroupConsts;
import com.artfess.base.controller.BaseController;
import com.artfess.base.enums.ResponseErrorEnums;
import com.artfess.base.model.CommonResult;
import com.artfess.base.query.PageList;
import com.artfess.base.query.QueryFilter;
import com.artfess.base.valid.AddGroup;
import com.artfess.manage.duty.manager.CmgtDutyTeamMemberGpsinfoManager;
import com.artfess.manage.duty.manager.dto.CmgtDutyTeamMemberGpsinfoDto;
import com.artfess.manage.duty.model.CmgtDutyTeamMemberGpsinfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;

/**
 * 队员GPS信息 前端控制器
 *
 * @company 阿特菲斯信息技术有限公司
 * @author wujl
 * @since 2022-09-24
 */
@Slf4j
@Api(tags = "队员GPS信息")
@RestController
@RequestMapping("/manager/cmgtDutyTeamMemberGpsinfo")
@ApiGroup(group = {ApiGroupConsts.MANAGER_BIZ})
public class CmgtDutyTeamMemberGpsinfoController extends BaseController<CmgtDutyTeamMemberGpsinfoManager, CmgtDutyTeamMemberGpsinfo> {

    @Autowired
    private CmgtDutyTeamMemberGpsinfoManager cmgtDutyTeamMemberGpsinfoManager;


    @PostMapping(value="/pageQuery", produces={"application/json; charset=utf-8" })
    @ApiOperation("分页查询")
    public PageList<CmgtDutyTeamMemberGpsinfoDto> pageQuery(@ApiParam(name="queryFilter", value="分页查询信息") @RequestBody QueryFilter<CmgtDutyTeamMemberGpsinfo> queryFilter) {
        return cmgtDutyTeamMemberGpsinfoManager.pageQuery(queryFilter);
    }



    @PostMapping("/create")
    @ApiOperation("添加实体的接口")
    public CommonResult<String> create(@ApiParam(name = "model", value = "实体信息") @RequestBody @Validated({AddGroup.class}) CmgtDutyTeamMemberGpsinfoDto t) {
        String result =  cmgtDutyTeamMemberGpsinfoManager.create(t);
        if (result == null) {
            return new CommonResult<>(ResponseErrorEnums.FAIL_OPTION, "创建实体失败");
        }
        return new CommonResult<>(result);
    }


    @PutMapping("/update")
    @ApiOperation("更新实体的接口")
    public CommonResult<String> update(@ApiParam(name = "model", value = "实体信息") @RequestBody @Validated({AddGroup.class}) CmgtDutyTeamMemberGpsinfoDto t) {

        String result =  cmgtDutyTeamMemberGpsinfoManager.update(t);
        if (result == null) {
            return new CommonResult<>(ResponseErrorEnums.FAIL_OPTION, "更新实体失败");
        }
        return new CommonResult<>(result);
    }


    @DeleteMapping("/delete")
    @ApiOperation("根据id集合批量删除")
    public CommonResult<String> deleteByIds(@ApiParam(name = "ids", value = "实体集合") @RequestParam String... ids) {
        boolean result =  cmgtDutyTeamMemberGpsinfoManager.delete(Arrays.asList(ids));
        if (!result) {
            return new CommonResult<>(ResponseErrorEnums.FAIL_OPTION, "删除实体失败");
        }
        return new CommonResult<>();
    }



}
