package com.tofly.xrtygis.custom.controller.gs;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtygis.custom.entity.gs.AddressBook;
import com.tofly.xrtygis.custom.service.CustomNoteService;
import com.tofly.xrtygis.entity.Rxsmstxitem;
import com.tofly.xrtygis.entity.Rxsmstxlx;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

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

/**
 * 供水热线短信
 *
 * @author FlashWJL
 * @date 2021/4/1 13:49
 */
@RestController
@AllArgsConstructor
@RequestMapping("/note")
@Api(tags = "热线--供水热线短信配置")
public class CustomNoteController {
    private final CustomNoteService noteService;

    /**
     * 新增热线短信标题字段描述
     *
     * @param rxsmstxitem 热线短信标题字段描述
     * @return ResultRespone
     */
    //(title = "新增热线短信标题字段描述")
    @ApiOperation(value = "新增热线短信标题字段描述")
    @PostMapping("/noteTitile")
    @ToFlyAppLog(title = "新增热线短信标题字段描述")
    public ResultRespone saveTitile(@RequestBody Rxsmstxitem rxsmstxitem) {

        return ResultRespone.success(noteService.saveDxbt(rxsmstxitem));
    }

    /**
     * 分页查询
     *
     * @param rxsmstxitem 热线短信标题字段描述
     * @return
     */
    @GetMapping("/noteTitile")
    @ApiOperation(value = "短信标题字段描述分页查询")
    @ToFlyAppLog(title = "短信标题字段描述分页查询")
    public ResultRespone getTitile(Rxsmstxitem rxsmstxitem) {
        return ResultRespone.success(noteService.getTitile(rxsmstxitem));
    }

    /**
     * 修改热线短信标题字段描述
     *
     * @param rxsmstxitem 热线短信标题字段描述
     * @return ResultRespone
     */
    //(title = "修改热线短信标题字段描述")
    @ApiOperation(value = "修改热线短信标题字段描述")
    @PutMapping("/noteTitile")
    @ToFlyAppLog(title = "修改热线短信标题字段描述")
    public ResultRespone updateTitileById(@RequestBody Rxsmstxitem rxsmstxitem) {
        return ResultRespone.success(noteService.updateTitile(rxsmstxitem));
    }

    /**
     * 通过id批量删除热线短信标题字段描述
     *
     * @param ids id
     * @return ResultRespone
     */
    //(title = "通过id批量删除热线短信标题字段描述")
    @ApiOperation(value = "通过ID批量删除热线短信标题字段描述")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/noteTitile")
    @ToFlyAppLog(title = "通过ID批量删除热线短信标题字段描述")
    public ResultRespone delTitile(String ids) {
        List<String> idList = Arrays.asList(ids.split(","));
        return ResultRespone.success(noteService.delTitile(idList));
    }

    /**
     * 新增热线短信通讯类型表（模板表）
     *
     * @param rxsmstxlx 热线短信通讯类型表（模板表）
     * @return ResultRespone
     */
    //(title = "新增热线短信通讯类型表（模板表）")
    @ApiOperation(value = "新增热线短信通讯类型表（模板表）")
    @PostMapping("/noteTemplate")
    @ToFlyAppLog(title = "新增热线短信通讯类型表（模板表）")
    public ResultRespone saveTemplate(@RequestBody Rxsmstxlx rxsmstxlx) {
        return ResultRespone.success(noteService.saveTemplate(rxsmstxlx));
    }

    /**
     * 分页查询
     *
     * @param page      分页对象
     * @param rxsmstxlx 热线短信通讯类型表（模板表）
     * @return
     */
    @GetMapping("/noteTemplate")
    @ApiOperation(value = "短信模板分页查询")
    @ToFlyAppLog(title = "短信模板分页查询")
    public ResultRespone getTemplate(Page page, Rxsmstxlx rxsmstxlx) {
        return ResultRespone.success(noteService.getTemplate(page, rxsmstxlx));
    }

    /**
     * 修改热线短信通讯类型表（模板表）
     *
     * @param rxsmstxlx 热线短信通讯类型表（模板表）
     * @return ResultRespone
     */
    //(title = "修改热线短信通讯类型表（模板表）")
    @ApiOperation(value = "修改热线短信通讯类型表（模板表）")
    @PutMapping("/noteTemplate")
    @ToFlyAppLog(title = "修改热线短信通讯类型表（模板表）")
    public ResultRespone updateTemplate(@RequestBody Rxsmstxlx rxsmstxlx) {
        return ResultRespone.success(noteService.updateTemplate(rxsmstxlx));
    }

    /**
     * 通过id批量删除热线短信通讯类型表（模板表）
     *
     * @param ids id
     * @return ResultRespone
     */
    //(title = "通过id批量删除热线短信通讯类型表（模板表）")
    @ApiOperation(value = "通过ID批量删除热线短信通讯类型表（模板表）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/noteTemplate")
    @ToFlyAppLog(title = "通过ID批量删除热线短信通讯类型表（模板表）")
    public ResultRespone delTemplate(String ids) {
        return ResultRespone.success(noteService.delTemplate(Arrays.asList(ids.split(","))));
    }

    @ApiOperation(value = "查看内部通讯录")
    @GetMapping("/addressBook")
    @ToFlyAppLog(title = "查看内部通讯录")
    public ResultRespone getBook(Page page, AddressBook addressBook) {
        return ResultRespone.success(noteService.getBook(page,addressBook));
    }
    //(title = "修改用戶电话")
    @ApiOperation(value = "修改用戶电话")
    @PostMapping("/addressBook")
    @ToFlyAppLog(title = "修改用戶电话")
    public ResultRespone updateBook(@RequestBody AddressBook addressBook) {
        return ResultRespone.success(noteService.updateBook(addressBook));
    }


}
