package com.sqx.modules.dlssqjl.controller;


import com.sqx.common.utils.Result;
import com.sqx.modules.dlssqjl.entity.Dlssqjl;
import com.sqx.modules.dlssqjl.service.DlssqjlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;

@RestController
@RequestMapping("/dlssqjl")
@Api(value = "代理商申请信息", tags = {"代理商申请信息"})
public class DlssqjlController {

    @Autowired
    private DlssqjlService dlssqjlService;

    @PostMapping("/insertDlssqjl")
    @ApiOperation("添加代理商")
    public Result insertDlssqjl(@RequestBody Dlssqjl dlssqjl){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dlssqjl.setCreateTime(new Date());
        dlssqjlService.save(dlssqjl);
        return Result.success();
    }

    @PostMapping("/updateDlssqjl")
    @ApiOperation("修改代理商")
    public Result updateDlssqjl(@RequestBody Dlssqjl dlssqjl){
        dlssqjlService.updateById(dlssqjl);
        return Result.success();
    }

    @PostMapping("/deleteDlssqjl")
    @ApiOperation("删除代理商")
    public Result deleteDlssqjl(Long DlssqjlId){
        dlssqjlService.removeById(DlssqjlId);
        return Result.success();
    }


    @GetMapping("/selectDlssqjlPage")
    @ApiOperation("查询代理商（分页）")
    public Result selectDlssqjlPage(Integer page,Integer limit,String name,String phone){
        return dlssqjlService.selectDlssqjlPage(page, limit,name,phone);
    }

    @GetMapping("/selectDlssqjlById")
    @ApiOperation("查询详情")
    public Result selectDlssqjlById(Long DlssqjlId){
        return Result.success().put("data",dlssqjlService.getById(DlssqjlId));
    }

}
