|
@@ -1,72 +1,59 @@
|
|
package org.jeecg.modules.ctop.controller;
|
|
package org.jeecg.modules.ctop.controller;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.io.IOException;
|
|
|
|
-import java.io.UnsupportedEncodingException;
|
|
|
|
-import java.net.URLDecoder;
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
-
|
|
|
|
-import org.jeecg.common.api.vo.Result;
|
|
|
|
-import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
-import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
-import org.jeecg.common.util.oConvertUtils;
|
|
|
|
-import org.jeecg.modules.ctop.entity.BindAccount;
|
|
|
|
-import org.jeecg.modules.ctop.service.IBindAccountService;
|
|
|
|
-
|
|
|
|
-import java.util.Date;
|
|
|
|
-
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-
|
|
|
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
|
+import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
|
+import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
+import org.jeecg.common.util.oConvertUtils;
|
|
|
|
+import org.jeecg.modules.ctop.entity.BindAccountAuth;
|
|
|
|
+import org.jeecg.modules.ctop.service.IBindAccountAuthService;
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
-
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
-import io.swagger.annotations.Api;
|
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
+import java.net.URLDecoder;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * @Description: 账户绑定
|
|
|
|
|
|
+ * @Description: 账号绑定-授权
|
|
* @Author: jeecg-boot
|
|
* @Author: jeecg-boot
|
|
- * @Date: 2019-07-30
|
|
|
|
|
|
+ * @Date: 2019-07-31
|
|
* @Version: V1.0
|
|
* @Version: V1.0
|
|
*/
|
|
*/
|
|
@Slf4j
|
|
@Slf4j
|
|
-@Api(tags = "账户绑定")
|
|
|
|
|
|
+@Api(tags = "账号绑定-授权")
|
|
@RestController
|
|
@RestController
|
|
-@RequestMapping("/ctop/bindAccount")
|
|
|
|
-public class BindAccountController {
|
|
|
|
|
|
+@RequestMapping("/ctop/bindAccountAuth")
|
|
|
|
+public class BindAccountAuthController {
|
|
@Autowired
|
|
@Autowired
|
|
- private IBindAccountService bindAccountService;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @GetMapping(value = "/login")
|
|
|
|
- public Result<IPage<BindAccount>> login(String advertiserId, String accountName, String password, String loginType) {
|
|
|
|
- Result<IPage<BindAccount>> result = new Result<IPage<BindAccount>>();
|
|
|
|
- boolean trueOrFalse = bindAccountService.bindLogin(advertiserId, accountName, password, loginType);
|
|
|
|
- result.setSuccess(trueOrFalse);
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
|
|
+ private IBindAccountAuthService bindAccountAuthService;
|
|
|
|
|
|
- @GetMapping(value = "/authorization")
|
|
|
|
- public Result<IPage<BindAccount>> authorization(String advertiserId, String authorizationType) {
|
|
|
|
- Result<IPage<BindAccount>> result = new Result<IPage<BindAccount>>();
|
|
|
|
|
|
+ @PostMapping(value = "/authorization")
|
|
|
|
+ public Result<IPage<BindAccountAuth>> authorization(@RequestBody JSONObject json) {
|
|
|
|
+ Result<IPage<BindAccountAuth>> result = new Result<IPage<BindAccountAuth>>();
|
|
String codeUrl = null;
|
|
String codeUrl = null;
|
|
try {
|
|
try {
|
|
- codeUrl = bindAccountService.bindAuthorization(advertiserId, authorizationType);
|
|
|
|
|
|
+ codeUrl = bindAccountAuthService.bindAuthorization(json.getString("advertiserId"), json.getString("authorizationType"));
|
|
} catch (UnsupportedEncodingException e) {
|
|
} catch (UnsupportedEncodingException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -79,23 +66,23 @@ public class BindAccountController {
|
|
/**
|
|
/**
|
|
* 分页列表查询
|
|
* 分页列表查询
|
|
*
|
|
*
|
|
- * @param bindAccount
|
|
|
|
|
|
+ * @param bindAccountAuth
|
|
* @param pageNo
|
|
* @param pageNo
|
|
* @param pageSize
|
|
* @param pageSize
|
|
* @param req
|
|
* @param req
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @AutoLog(value = "账户绑定-分页列表查询")
|
|
|
|
- @ApiOperation(value = "账户绑定-分页列表查询", notes = "账户绑定-分页列表查询")
|
|
|
|
|
|
+ @AutoLog(value = "账号绑定-授权-分页列表查询")
|
|
|
|
+ @ApiOperation(value = "账号绑定-授权-分页列表查询", notes = "账号绑定-授权-分页列表查询")
|
|
@GetMapping(value = "/list")
|
|
@GetMapping(value = "/list")
|
|
- public Result<IPage<BindAccount>> queryPageList(BindAccount bindAccount,
|
|
|
|
- @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
- @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
|
- HttpServletRequest req) {
|
|
|
|
- Result<IPage<BindAccount>> result = new Result<IPage<BindAccount>>();
|
|
|
|
- QueryWrapper<BindAccount> queryWrapper = QueryGenerator.initQueryWrapper(bindAccount, req.getParameterMap());
|
|
|
|
- Page<BindAccount> page = new Page<BindAccount>(pageNo, pageSize);
|
|
|
|
- IPage<BindAccount> pageList = bindAccountService.page(page, queryWrapper);
|
|
|
|
|
|
+ public Result<IPage<BindAccountAuth>> queryPageList(BindAccountAuth bindAccountAuth,
|
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
|
+ HttpServletRequest req) {
|
|
|
|
+ Result<IPage<BindAccountAuth>> result = new Result<IPage<BindAccountAuth>>();
|
|
|
|
+ QueryWrapper<BindAccountAuth> queryWrapper = QueryGenerator.initQueryWrapper(bindAccountAuth, req.getParameterMap());
|
|
|
|
+ Page<BindAccountAuth> page = new Page<BindAccountAuth>(pageNo, pageSize);
|
|
|
|
+ IPage<BindAccountAuth> pageList = bindAccountAuthService.page(page, queryWrapper);
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
result.setResult(pageList);
|
|
result.setResult(pageList);
|
|
return result;
|
|
return result;
|
|
@@ -104,16 +91,16 @@ public class BindAccountController {
|
|
/**
|
|
/**
|
|
* 添加
|
|
* 添加
|
|
*
|
|
*
|
|
- * @param bindAccount
|
|
|
|
|
|
+ * @param bindAccountAuth
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @AutoLog(value = "账户绑定-添加")
|
|
|
|
- @ApiOperation(value = "账户绑定-添加", notes = "账户绑定-添加")
|
|
|
|
|
|
+ @AutoLog(value = "账号绑定-授权-添加")
|
|
|
|
+ @ApiOperation(value = "账号绑定-授权-添加", notes = "账号绑定-授权-添加")
|
|
@PostMapping(value = "/add")
|
|
@PostMapping(value = "/add")
|
|
- public Result<BindAccount> add(@RequestBody BindAccount bindAccount) {
|
|
|
|
- Result<BindAccount> result = new Result<BindAccount>();
|
|
|
|
|
|
+ public Result<BindAccountAuth> add(@RequestBody BindAccountAuth bindAccountAuth) {
|
|
|
|
+ Result<BindAccountAuth> result = new Result<BindAccountAuth>();
|
|
try {
|
|
try {
|
|
- bindAccountService.save(bindAccount);
|
|
|
|
|
|
+ bindAccountAuthService.save(bindAccountAuth);
|
|
result.success("添加成功!");
|
|
result.success("添加成功!");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage(), e);
|
|
log.error(e.getMessage(), e);
|
|
@@ -125,19 +112,19 @@ public class BindAccountController {
|
|
/**
|
|
/**
|
|
* 编辑
|
|
* 编辑
|
|
*
|
|
*
|
|
- * @param bindAccount
|
|
|
|
|
|
+ * @param bindAccountAuth
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @AutoLog(value = "账户绑定-编辑")
|
|
|
|
- @ApiOperation(value = "账户绑定-编辑", notes = "账户绑定-编辑")
|
|
|
|
|
|
+ @AutoLog(value = "账号绑定-授权-编辑")
|
|
|
|
+ @ApiOperation(value = "账号绑定-授权-编辑", notes = "账号绑定-授权-编辑")
|
|
@PutMapping(value = "/edit")
|
|
@PutMapping(value = "/edit")
|
|
- public Result<BindAccount> edit(@RequestBody BindAccount bindAccount) {
|
|
|
|
- Result<BindAccount> result = new Result<BindAccount>();
|
|
|
|
- BindAccount bindAccountEntity = bindAccountService.getById(bindAccount.getId());
|
|
|
|
- if (bindAccountEntity == null) {
|
|
|
|
|
|
+ public Result<BindAccountAuth> edit(@RequestBody BindAccountAuth bindAccountAuth) {
|
|
|
|
+ Result<BindAccountAuth> result = new Result<BindAccountAuth>();
|
|
|
|
+ BindAccountAuth bindAccountAuthEntity = bindAccountAuthService.getById(bindAccountAuth.getId());
|
|
|
|
+ if (bindAccountAuthEntity == null) {
|
|
result.error500("未找到对应实体");
|
|
result.error500("未找到对应实体");
|
|
} else {
|
|
} else {
|
|
- boolean ok = bindAccountService.updateById(bindAccount);
|
|
|
|
|
|
+ boolean ok = bindAccountAuthService.updateById(bindAccountAuth);
|
|
//TODO 返回false说明什么?
|
|
//TODO 返回false说明什么?
|
|
if (ok) {
|
|
if (ok) {
|
|
result.success("修改成功!");
|
|
result.success("修改成功!");
|
|
@@ -153,12 +140,12 @@ public class BindAccountController {
|
|
* @param id
|
|
* @param id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @AutoLog(value = "账户绑定-通过id删除")
|
|
|
|
- @ApiOperation(value = "账户绑定-通过id删除", notes = "账户绑定-通过id删除")
|
|
|
|
|
|
+ @AutoLog(value = "账号绑定-授权-通过id删除")
|
|
|
|
+ @ApiOperation(value = "账号绑定-授权-通过id删除", notes = "账号绑定-授权-通过id删除")
|
|
@DeleteMapping(value = "/delete")
|
|
@DeleteMapping(value = "/delete")
|
|
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
|
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
|
try {
|
|
try {
|
|
- bindAccountService.removeById(id);
|
|
|
|
|
|
+ bindAccountAuthService.removeById(id);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("删除失败", e.getMessage());
|
|
log.error("删除失败", e.getMessage());
|
|
return Result.error("删除失败!");
|
|
return Result.error("删除失败!");
|
|
@@ -172,15 +159,15 @@ public class BindAccountController {
|
|
* @param ids
|
|
* @param ids
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @AutoLog(value = "账户绑定-批量删除")
|
|
|
|
- @ApiOperation(value = "账户绑定-批量删除", notes = "账户绑定-批量删除")
|
|
|
|
|
|
+ @AutoLog(value = "账号绑定-授权-批量删除")
|
|
|
|
+ @ApiOperation(value = "账号绑定-授权-批量删除", notes = "账号绑定-授权-批量删除")
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
- public Result<BindAccount> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
|
- Result<BindAccount> result = new Result<BindAccount>();
|
|
|
|
|
|
+ public Result<BindAccountAuth> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
|
|
|
+ Result<BindAccountAuth> result = new Result<BindAccountAuth>();
|
|
if (ids == null || "".equals(ids.trim())) {
|
|
if (ids == null || "".equals(ids.trim())) {
|
|
result.error500("参数不识别!");
|
|
result.error500("参数不识别!");
|
|
} else {
|
|
} else {
|
|
- this.bindAccountService.removeByIds(Arrays.asList(ids.split(",")));
|
|
|
|
|
|
+ this.bindAccountAuthService.removeByIds(Arrays.asList(ids.split(",")));
|
|
result.success("删除成功!");
|
|
result.success("删除成功!");
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
@@ -192,16 +179,16 @@ public class BindAccountController {
|
|
* @param id
|
|
* @param id
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @AutoLog(value = "账户绑定-通过id查询")
|
|
|
|
- @ApiOperation(value = "账户绑定-通过id查询", notes = "账户绑定-通过id查询")
|
|
|
|
|
|
+ @AutoLog(value = "账号绑定-授权-通过id查询")
|
|
|
|
+ @ApiOperation(value = "账号绑定-授权-通过id查询", notes = "账号绑定-授权-通过id查询")
|
|
@GetMapping(value = "/queryById")
|
|
@GetMapping(value = "/queryById")
|
|
- public Result<BindAccount> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
|
- Result<BindAccount> result = new Result<BindAccount>();
|
|
|
|
- BindAccount bindAccount = bindAccountService.getById(id);
|
|
|
|
- if (bindAccount == null) {
|
|
|
|
|
|
+ public Result<BindAccountAuth> queryById(@RequestParam(name = "id", required = true) String id) {
|
|
|
|
+ Result<BindAccountAuth> result = new Result<BindAccountAuth>();
|
|
|
|
+ BindAccountAuth bindAccountAuth = bindAccountAuthService.getById(id);
|
|
|
|
+ if (bindAccountAuth == null) {
|
|
result.error500("未找到对应实体");
|
|
result.error500("未找到对应实体");
|
|
} else {
|
|
} else {
|
|
- result.setResult(bindAccount);
|
|
|
|
|
|
+ result.setResult(bindAccountAuth);
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
@@ -216,13 +203,13 @@ public class BindAccountController {
|
|
@RequestMapping(value = "/exportXls")
|
|
@RequestMapping(value = "/exportXls")
|
|
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
|
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
|
// Step.1 组装查询条件
|
|
// Step.1 组装查询条件
|
|
- QueryWrapper<BindAccount> queryWrapper = null;
|
|
|
|
|
|
+ QueryWrapper<BindAccountAuth> queryWrapper = null;
|
|
try {
|
|
try {
|
|
String paramsStr = request.getParameter("paramsStr");
|
|
String paramsStr = request.getParameter("paramsStr");
|
|
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
|
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
|
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
|
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
|
- BindAccount bindAccount = JSON.parseObject(deString, BindAccount.class);
|
|
|
|
- queryWrapper = QueryGenerator.initQueryWrapper(bindAccount, request.getParameterMap());
|
|
|
|
|
|
+ BindAccountAuth bindAccountAuth = JSON.parseObject(deString, BindAccountAuth.class);
|
|
|
|
+ queryWrapper = QueryGenerator.initQueryWrapper(bindAccountAuth, request.getParameterMap());
|
|
}
|
|
}
|
|
} catch (UnsupportedEncodingException e) {
|
|
} catch (UnsupportedEncodingException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -230,11 +217,11 @@ public class BindAccountController {
|
|
|
|
|
|
//Step.2 AutoPoi 导出Excel
|
|
//Step.2 AutoPoi 导出Excel
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
- List<BindAccount> pageList = bindAccountService.list(queryWrapper);
|
|
|
|
|
|
+ List<BindAccountAuth> pageList = bindAccountAuthService.list(queryWrapper);
|
|
//导出文件名称
|
|
//导出文件名称
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "账户绑定列表");
|
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, BindAccount.class);
|
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("账户绑定列表数据", "导出人:Jeecg", "导出信息"));
|
|
|
|
|
|
+ mv.addObject(NormalExcelConstants.FILE_NAME, "账号绑定-授权列表");
|
|
|
|
+ mv.addObject(NormalExcelConstants.CLASS, BindAccountAuth.class);
|
|
|
|
+ mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("账号绑定-授权列表数据", "导出人:Jeecg", "导出信息"));
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
return mv;
|
|
return mv;
|
|
}
|
|
}
|
|
@@ -257,9 +244,9 @@ public class BindAccountController {
|
|
params.setHeadRows(1);
|
|
params.setHeadRows(1);
|
|
params.setNeedSave(true);
|
|
params.setNeedSave(true);
|
|
try {
|
|
try {
|
|
- List<BindAccount> listBindAccounts = ExcelImportUtil.importExcel(file.getInputStream(), BindAccount.class, params);
|
|
|
|
- bindAccountService.saveBatch(listBindAccounts);
|
|
|
|
- return Result.ok("文件导入成功!数据行数:" + listBindAccounts.size());
|
|
|
|
|
|
+ List<BindAccountAuth> listBindAccountAuths = ExcelImportUtil.importExcel(file.getInputStream(), BindAccountAuth.class, params);
|
|
|
|
+ bindAccountAuthService.saveBatch(listBindAccountAuths);
|
|
|
|
+ return Result.ok("文件导入成功!数据行数:" + listBindAccountAuths.size());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage(), e);
|
|
log.error(e.getMessage(), e);
|
|
return Result.error("文件导入失败:" + e.getMessage());
|
|
return Result.error("文件导入失败:" + e.getMessage());
|