package com.iotechn.unimall.admin.api.admin;


import com.google.zxing.WriterException;
import com.iotechn.unimall.core.Const;
import com.iotechn.unimall.core.annotation.HttpMethod;
import com.iotechn.unimall.core.annotation.HttpOpenApi;
import com.iotechn.unimall.core.annotation.HttpParam;
import com.iotechn.unimall.core.annotation.HttpParamType;
import com.iotechn.unimall.core.annotation.param.NotNull;
import com.iotechn.unimall.core.exception.ServiceException;
import com.iotechn.unimall.data.domain.AdminDO;
import com.iotechn.unimall.data.domain.UserDO;
import com.iotechn.unimall.data.dto.AdminDTO;
import com.iotechn.unimall.data.model.Page;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;

/**
 * Created by rize on 2019/4/8.
 */
@HttpOpenApi(group = "admin", description = "管理员服务")
public interface AdminService {

    @HttpMethod(description = "管理员登录 返回AccessToken")
    String login(
            @NotNull @HttpParam(name = "username", type = HttpParamType.COMMON, description = "用户名") String username,
            @NotNull @HttpParam(name = "password", type = HttpParamType.COMMON, description = "密码") String password,
            @NotNull @HttpParam(name = "verifyCode", type = HttpParamType.COMMON, description = "验证码") String verifyCode) throws ServiceException;

    @HttpMethod(description = "管理员登出")
    String logout(
            @NotNull @HttpParam(name = Const.ADMIN_ACCESS_TOKEN, type = HttpParamType.HEADER, description = "访问Token") String accessToken,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;

    @HttpMethod(description = "管理员信息")
    AdminDTO info(
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;

    @HttpMethod(description = "列表", permission = "admin:admin:list", permissionParentName = "系统管理", permissionName = "管理员")
    Page<AdminDTO> list(
            @HttpParam(name = "username", type = HttpParamType.COMMON, description = "管理员名称搜索") String name,
            @HttpParam(name = "page", type = HttpParamType.COMMON, description = "页码", valueDef = "1") Integer page,
            @HttpParam(name = "limit", type = HttpParamType.COMMON, description = "页长度", valueDef = "20") Integer limit,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId,
            @NotNull @HttpParam(name = "companyId", type = HttpParamType.COMPANY_ID, description = "管理员ID") Long companyId) throws ServiceException;

    @HttpMethod(description = "创建", permission = "admin:admin:create", permissionParentName = "系统管理", permissionName = "管理员")
    AdminDTO create(
            @NotNull @HttpParam(name = "adminDTO", type = HttpParamType.COMMON, description = "欲创建的admin对象JSON") AdminDTO adminDTO,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId,
            @NotNull @HttpParam(name = "companyId", type = HttpParamType.COMPANY_ID, description = "管理员ID") Long companyId) throws ServiceException;

    @HttpMethod(description = "修改", permission = "admin:admin:update", permissionParentName = "系统管理", permissionName = "管理员")
    String update(
            @NotNull @HttpParam(name = "adminDTO", type = HttpParamType.COMMON, description = "欲修改的admin对象JSON") AdminDTO adminDTO,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId,
            @NotNull @HttpParam(name = "companyId", type = HttpParamType.COMPANY_ID, description = "管理员ID") Long companyId) throws ServiceException;

    @HttpMethod(description = "删除", permission = "admin:admin:delete", permissionParentName = "系统管理", permissionName = "管理员")
    String delete(
            @NotNull @HttpParam(name = "id", type = HttpParamType.COMMON, description = "目标删除Id") Long id,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;

    @HttpMethod(description = "更改密码")
    String newPassword(
            @HttpParam(name = Const.ADMIN_ACCESS_TOKEN, type = HttpParamType.HEADER, description = "访问Token") String accessToken,
            @NotNull @HttpParam(name = "oldPassword", type = HttpParamType.COMMON, description = "老密码") String oldPassword,
            @NotNull @HttpParam(name = "newPassword", type = HttpParamType.COMMON, description = "新密码") String newPassword,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;

    @HttpMethod(description = "发送登陆短信")
    Boolean sendLoginMsg(
            @NotNull @HttpParam(name = "username", type = HttpParamType.COMMON, description = "用户名") String username,
            @NotNull @HttpParam(name = "password", type = HttpParamType.COMMON, description = "密码") String password) throws ServiceException;

    @HttpMethod(description = "绑定通知公众号")
    String bindUniNotify(
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId) throws ServiceException;
    @HttpMethod(description = "用户枚举")

    List<AdminDO> getAdminList(
            @HttpParam(name = "roleName", type = HttpParamType.COMMON, description = "角色ID") String roleName,
            @NotNull @HttpParam(name = "adminId", type = HttpParamType.ADMIN_ID, description = "管理员ID") Long adminId,
            @NotNull @HttpParam(name = "companyId", type = HttpParamType.COMPANY_ID, description = "管理员ID") Long companyId) throws ServiceException;
    @HttpMethod(description = "测试接口")
    void test() throws IOException, WriterException;

}
