//package com.gree.mall.manager.controller.admin.ew;
//
//import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.gree.mall.manager.bean.ExcelData;
//import com.gree.mall.manager.bean.admin.AdminUserCom;
//import com.gree.mall.manager.exception.RemoteServiceException;
//import com.gree.mall.manager.helper.ResponseHelper;
//import com.gree.mall.manager.logic.admin.ew.EnterpriseWechatWorkerLogic;
//import com.gree.mall.manager.logic.common.CommonLogic;
//import com.gree.mall.manager.plus.entity.EnterpriseWechatWorker;
//import com.gree.mall.manager.utils.CommonUtils;
//import com.gree.mall.manager.utils.excel.ExcelUtils;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import lombok.extern.slf4j.Slf4j;
//import me.chanjar.weixin.common.error.WxErrorException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.validation.constraints.NotBlank;
//import javax.validation.constraints.NotEmpty;
//import javax.validation.constraints.NotNull;
//import java.io.IOException;
//import java.util.List;
//
//@Slf4j
//@RestController
//@Api(value = "企业微信成员管理API", tags ={"企业微信成员管理API"} )
//@RequestMapping(value = "/wechat/enterprise", produces = "application/json; charset=utf-8")
//public class EnterpriseWechatWorkerController {
//
//    @Autowired
//    EnterpriseWechatWorkerLogic enterpriseWechatWorkerLogic;
//    @Autowired
//    CommonLogic commonLogic;
//
//    @GetMapping("/list")
//    @ApiOperation("成员列表")
//    public ResponseHelper<IPage<EnterpriseWechatWorker>> list(
//           @ApiParam(value = "keyword",required = false) @RequestParam(required = false) String keyword,
//           @ApiParam(value = "网点主键",required = false) @RequestParam(required = false) String adminWebsitId,
//           @ApiParam(value = "网点id",required = false) @RequestParam(required = false) Long websitId,
//           @ApiParam(value = "页号",required = true) @RequestParam(required = true) Integer pageNo,
//           @ApiParam(value = "页大小",required = true) @RequestParam(required = true) Integer pageSize,
//           HttpServletRequest request
//    ){
//        IPage<EnterpriseWechatWorker> list = enterpriseWechatWorkerLogic.list(keyword, adminWebsitId,websitId, pageNo, pageSize,request);
//        return ResponseHelper.success(list);
//    }
//
//    //String name,String wechatUserId,String position,String mobile,Integer gender,Long mainDepartmentId,String email
//    @PostMapping("/add")
//    @ApiOperation("新增")
//    public ResponseHelper add(
//            @ApiParam(value = "名称",required = true) @RequestParam(required = true) String name,
//            @ApiParam(value = "帐号",required = true) @RequestParam(required = true) String wechatUserId,
//            @ApiParam(value = "职位",required = true) @RequestParam(required = true) String position,
//            @ApiParam(value = "手机号",required = true) @RequestParam(required = true) String mobile,
//            @ApiParam(value = "性别(1=男 2=女 0=未知)",required = true) @RequestParam(required = true) Integer gender,
//            @ApiParam(value = "部门id",required = true) @RequestParam(required = true) Long mainDepartmentId,
//            @ApiParam(value = "邮箱",required = true) @RequestParam(required = true) String email,
//            HttpServletRequest request
//    ) throws RemoteServiceException, WxErrorException {
//        AdminUserCom adminUser = commonLogic.getAdminUser(request);
//        enterpriseWechatWorkerLogic.add(name,wechatUserId,position,mobile,gender,mainDepartmentId,email,adminUser.getAdminCompanyWechat());
//        return ResponseHelper.success();
//    }
//
//    @PostMapping("/update")
//    @ApiOperation("修改")
//    public ResponseHelper update(
//            @ApiParam(value = "id",required = true) @RequestParam(required = true) Integer id,
//            @ApiParam(value = "名称",required = false) @RequestParam(required = false) String name,
//            @ApiParam(value = "帐号",required = false) @RequestParam(required = false) String wechatUserId,
//            @ApiParam(value = "职位",required = false) @RequestParam(required = false) String position,
//            @ApiParam(value = "手机号",required = false) @RequestParam(required = false) String mobile,
//            @ApiParam(value = "性别(1=男 2=女 0=未知)",required = true) @RequestParam(required = false) Integer gender,
//            @ApiParam(value = "部门id",required = false) @RequestParam(required = false) Long mainDepartmentId,
//            @ApiParam(value = "邮箱",required = false) @RequestParam(required = false) String email,
//            HttpServletRequest request
//    ) throws RemoteServiceException, WxErrorException {
//        enterpriseWechatWorkerLogic.update(id,name,wechatUserId,position,mobile,gender,mainDepartmentId,email,request);
//        return ResponseHelper.success();
//    }
//
//    @PostMapping("/delete")
//    @ApiOperation("删除")
//    public ResponseHelper delete(
//            @RequestParam List<Integer> id,
//            HttpServletRequest request
//    ) throws WxErrorException {
//        enterpriseWechatWorkerLogic.delete(id,request);
//        return ResponseHelper.success();
//    }
//
//    @PostMapping("/excelDelete")
//    @ApiOperation("/导入删除")
//    public ResponseHelper<Void> loadDelete(
//            @RequestParam("file")MultipartFile file,
//            HttpServletRequest request
//    ) throws IOException, WxErrorException {
//
//        enterpriseWechatWorkerLogic.loadDelete(file,request);
//        return ResponseHelper.success();
//    }
//
//    @GetMapping("/downloadDeleteExcel")
//    @ApiOperation("下载导入删除模板")
//    public void downloadDeleteExcel(
//            HttpServletResponse response
//    ) throws Exception {
//        CommonUtils.downloadFile("/template/down_load_delete.xlsx",response);
//    }
//
//
//    @GetMapping("/detail")
//    @ApiOperation("详情")
//    public ResponseHelper<EnterpriseWechatWorker> detail(@RequestParam Integer id) throws WxErrorException {
//        EnterpriseWechatWorker detail = enterpriseWechatWorkerLogic.detail(id);
//        return ResponseHelper.success(detail);
//    }
//
//    @GetMapping("/export")
//    @ApiOperation("导出")
//    public void exportData(
//            @ApiParam(value = "keyword",required = false) @RequestParam(required = false) String keyword,
//            @ApiParam(value = "网点主键",required = false) @RequestParam(required = false) String adminWebsitId,
//            @ApiParam(value = "网点id",required = false) @RequestParam(required = false) Long websitId,
//            HttpServletRequest request,
//            HttpServletResponse response
//    ) throws Exception {
//        ExcelData excelData = enterpriseWechatWorkerLogic.exportData(request, keyword, adminWebsitId,websitId);
//        ExcelUtils.exportExcel(request,response,"成员.xlsx",excelData);
//    }
//
//
//    @PostMapping("/import")
//    @ApiOperation("导入")
//    public ResponseHelper importData(
//            @ApiParam(value = "附件",required = true) @RequestParam(required = true) MultipartFile file,
//            @ApiParam(value = "部门id",required = true) @RequestParam(required = true) Long mainDepartmentId,
//            HttpServletRequest request
//    ) throws Exception {
//        List<Object> datas = ExcelUtils.importExcel(file);
//        String s = enterpriseWechatWorkerLogic.importData(datas, mainDepartmentId,request);
//        return ResponseHelper.success(s);
//    }
//
//    @GetMapping("/download")
//    @ApiOperation("下载模板")
//    public void download(
//            HttpServletResponse response
//    ) throws Exception {
//        CommonUtils.downloadFile("/template/wechat_user.xlsx",response);
//    }
//
//}
