yumeng %!s(int64=5) %!d(string=hai) anos
pai
achega
baafa3cd76
Modificáronse 28 ficheiros con 1687 adicións e 633 borrados
  1. 37 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AuthController.java
  2. 244 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AuthTaskController.java
  3. 23 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BindAccountAuthController.java
  4. 37 33
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BindAccountLoginController.java
  5. 68 25
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java
  6. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  7. 44 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/AuthTask.java
  8. 97 54
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/UserAllocation.java
  9. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/AuthTaskMapper.java
  10. 2 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/UserAllocationMapper.java
  11. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/AuthTaskMapper.xml
  12. 14 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IAuthTaskService.java
  13. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IBindAccountAuthService.java
  14. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IUserAllocationService.java
  15. 32 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/AuthTaskServiceImpl.java
  16. 29 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BindAccountAuthServiceImpl.java
  17. 13 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/UserAllocationServiceImpl.java
  18. 157 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/AuthTaskList.vue
  19. 22 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/UserAllocationList.vue
  20. 130 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/AuthTaskModal.vue
  21. 137 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/AuthTaskModal__Style#Drawer.vue
  22. 25 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/UserAllocationModal.vue
  23. 25 7
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/UserAllocationModal__Style#Drawer.vue
  24. 274 267
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java
  25. 8 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/SysUser.java
  26. 26 12
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysDepartService.java
  27. 218 199
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java
  28. 1 1
      jeecg-boot-module-system/src/main/resources/application-dev.yml

+ 37 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AuthController.java

@@ -8,11 +8,15 @@ import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import constant.KuaishouInterfaceConstant;
 import org.apache.commons.lang.StringUtils;
+import org.jeecg.modules.ctop.entity.AuthTask;
 import org.jeecg.modules.ctop.entity.CTopOauthToken;
+import org.jeecg.modules.ctop.entity.UserAllocation;
 import org.jeecg.modules.ctop.mapper.CTopOauthTokenMapper;
+import org.jeecg.modules.ctop.mapper.UserAllocationMapper;
+import org.jeecg.modules.ctop.service.IAuthTaskService;
 import org.jeecg.modules.ctop.service.IBindAccountAuthService;
 import org.jeecg.modules.ctop.service.ICTopOauthTokenService;
-import org.jeecg.modules.kuaishou.service.IKuaishouInterfaceService;
+import org.jeecg.modules.ctop.service.IUserAllocationService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,13 +36,18 @@ import java.util.UUID;
 @RequestMapping("/auth")
 public class AuthController {
     private static final Logger logger = LoggerFactory.getLogger(AuthController.class);
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
+
     @Autowired
     private IBindAccountAuthService bindAccountAuthService;
 
     @Autowired
     private CTopOauthTokenMapper cTopOauthTokenMapper;
+    @Autowired
+    private IAuthTaskService authTaskService;
+    @Autowired
+    private UserAllocationMapper allocationMapper;
+    @Autowired
+    private IUserAllocationService userAllocationService;
 
     @RequestMapping("/begin")
     public String authBegin(HttpServletRequest request,
@@ -109,12 +118,35 @@ public class AuthController {
             JSONObject data = resultObject.getJSONObject("data");
             CTopOauthToken token = new CTopOauthToken(accountId, data);
             if (Check.isNull(token)) {
+                AuthTask authTask = authTaskService.getAuthTask(state);
+                if (Check.isNull(authTask)) {
+                    throw new Exception("根据taskId未取到任务相关信息,taskId:" + state);
+                }
+                String advertiserId = authTask.getAdvertiserId();
+
                 Map<String, Object> deleteMap = new HashMap<>();
-                deleteMap.put("advertiser_id", state);
+                deleteMap.put("advertiser_id", advertiserId);
                 deleteMap.put("account_id", token.getAccountId());
                 cTopOauthTokenMapper.deleteByMap(deleteMap); //删除 广告主id下的相关授权信息
+                token.setAdvertiserId(advertiserId);
                 cTopOauthTokenMapper.insert(token);
-                bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, state); //账号绑定
+                bindAccountAuthService.addBindAccount(token.getAccountId(), KuaishouInterfaceConstant.LOGIN_TYPE_BYTEDANCE, advertiserId); //账号绑定
+
+                // 快手 更新账号分配表
+                UserAllocation userAllocation = userAllocationService.selectByTaskId(state);
+                userAllocation.setAccountId(token.getAccountId());
+                allocationMapper.deleteById(userAllocation.getId());
+
+                Map<String, Object> deleteUserMap = new HashMap<>();
+                deleteUserMap.put("account_id", accountId);
+                deleteUserMap.put("advertiser_id", advertiserId);
+                allocationMapper.deleteByMap(deleteUserMap);
+
+                int i = allocationMapper.insert(userAllocation);
+                if (i > 0) {
+                    logger.info("同步分配用户表完成,task_id:{},accountId:{}", state, accountId);
+
+                }
             }
         } catch (Exception e) {
             e.printStackTrace();

+ 244 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AuthTaskController.java

@@ -0,0 +1,244 @@
+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.AuthTask;
+import org.jeecg.modules.ctop.service.IAuthTaskService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * @Description: 关联用户分配
+ * @Author: jeecg-boot
+ * @Date:   2019-07-31
+ * @Version: V1.0
+ */
+@Slf4j
+@Api(tags="关联用户分配")
+@RestController
+@RequestMapping("/ctop/authTask")
+public class AuthTaskController {
+	@Autowired
+	private IAuthTaskService authTaskService;
+	
+	/**
+	  * 分页列表查询
+	 * @param authTask
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "关联用户分配-分页列表查询")
+	@ApiOperation(value="关联用户分配-分页列表查询", notes="关联用户分配-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<AuthTask>> queryPageList(AuthTask authTask,
+									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+									  HttpServletRequest req) {
+		Result<IPage<AuthTask>> result = new Result<IPage<AuthTask>>();
+		QueryWrapper<AuthTask> queryWrapper = QueryGenerator.initQueryWrapper(authTask, req.getParameterMap());
+		Page<AuthTask> page = new Page<AuthTask>(pageNo, pageSize);
+		IPage<AuthTask> pageList = authTaskService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+	
+	/**
+	  *   添加
+	 * @param authTask
+	 * @return
+	 */
+	@AutoLog(value = "关联用户分配-添加")
+	@ApiOperation(value="关联用户分配-添加", notes="关联用户分配-添加")
+	@PostMapping(value = "/add")
+	public Result<AuthTask> add(@RequestBody AuthTask authTask) {
+		Result<AuthTask> result = new Result<AuthTask>();
+		try {
+			authTaskService.save(authTask);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+	
+	/**
+	  *  编辑
+	 * @param authTask
+	 * @return
+	 */
+	@AutoLog(value = "关联用户分配-编辑")
+	@ApiOperation(value="关联用户分配-编辑", notes="关联用户分配-编辑")
+	@PutMapping(value = "/edit")
+	public Result<AuthTask> edit(@RequestBody AuthTask authTask) {
+		Result<AuthTask> result = new Result<AuthTask>();
+		AuthTask authTaskEntity = authTaskService.getById(authTask.getId());
+		if(authTaskEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = authTaskService.updateById(authTask);
+			//TODO 返回false说明什么?
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+		
+		return result;
+	}
+	
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "关联用户分配-通过id删除")
+	@ApiOperation(value="关联用户分配-通过id删除", notes="关联用户分配-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			authTaskService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+	
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "关联用户分配-批量删除")
+	@ApiOperation(value="关联用户分配-批量删除", notes="关联用户分配-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<AuthTask> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<AuthTask> result = new Result<AuthTask>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.authTaskService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+	
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "关联用户分配-通过id查询")
+	@ApiOperation(value="关联用户分配-通过id查询", notes="关联用户分配-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<AuthTask> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<AuthTask> result = new Result<AuthTask>();
+		AuthTask authTask = authTaskService.getById(id);
+		if(authTask==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(authTask);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<AuthTask> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              AuthTask authTask = JSON.parseObject(deString, AuthTask.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(authTask, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<AuthTask> pageList = authTaskService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "关联用户分配列表");
+      mv.addObject(NormalExcelConstants.CLASS, AuthTask.class);
+      mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("关联用户分配列表数据", "导出人:Jeecg", "导出信息"));
+      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+      return mv;
+  }
+
+  /**
+      * 通过excel导入数据
+   *
+   * @param request
+   * @param response
+   * @return
+   */
+  @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+  public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+          MultipartFile file = entity.getValue();// 获取上传文件对象
+          ImportParams params = new ImportParams();
+          params.setTitleRows(2);
+          params.setHeadRows(1);
+          params.setNeedSave(true);
+          try {
+              List<AuthTask> listAuthTasks = ExcelImportUtil.importExcel(file.getInputStream(), AuthTask.class, params);
+              authTaskService.saveBatch(listAuthTasks);
+              return Result.ok("文件导入成功!数据行数:" + listAuthTasks.size());
+          } catch (Exception e) {
+              log.error(e.getMessage(),e);
+              return Result.error("文件导入失败:"+e.getMessage());
+          } finally {
+              try {
+                  file.getInputStream().close();
+              } catch (IOException e) {
+                  e.printStackTrace();
+              }
+          }
+      }
+      return Result.ok("文件导入失败!");
+  }
+
+}

+ 23 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BindAccountAuthController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.utils.Check;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -13,6 +14,7 @@ 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.entity.UserAllocation;
 import org.jeecg.modules.ctop.service.IBindAccountAuthService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -53,7 +55,27 @@ public class BindAccountAuthController {
         Result<IPage<BindAccountAuth>> result = new Result<IPage<BindAccountAuth>>();
         String codeUrl = null;
         try {
-            codeUrl = bindAccountAuthService.bindAuthorization(json.getString("advertiserId"), json.getString("authorizationType"));
+            String advertiserId = json.getString("advertiserId");
+            if(Check.isNull(advertiserId)){
+                System.err.println("advertiserId不能为空");
+                result.setSuccess(false);
+                return result;
+            }
+            String authorizationType = json.getString("authorizationType");
+            String distributionName = json.getString("distributionName");//指定分配人姓名
+            String advertiserName = json.getString("advertiser_name"); // 广告主名称
+            String mediaId = json.getString("mediaId"); // 媒体类型: 1 头条 2 快手
+            String realName = json.getString("realName");
+            String departmentId = json.getString("departmentId"); //部门id
+            String userId = json.getString("userId"); //创建人
+            UserAllocation userAllocation = new UserAllocation();
+            userAllocation.setDistributionName(distributionName);
+            userAllocation.setUserId(userId);
+            userAllocation.setAdvertiserName(advertiserName);
+            userAllocation.setMediaId(mediaId);
+            userAllocation.setDepartmentId(departmentId);
+            userAllocation.setOperationName(realName);
+            codeUrl = bindAccountAuthService.bindAuthorization(advertiserId, authorizationType, userAllocation);
         } catch (UnsupportedEncodingException e) {
             e.printStackTrace();
         }

+ 37 - 33
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BindAccountLoginController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.utils.Check;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -12,14 +13,17 @@ 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.BindAccountLogin;
+import org.jeecg.modules.ctop.entity.UserAllocation;
+import org.jeecg.modules.ctop.mapper.UserAllocationMapper;
 import org.jeecg.modules.ctop.service.IBindAccountLoginService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -46,49 +50,49 @@ import java.util.Map;
 @RestController
 @RequestMapping("/ctop/bindAccountLogin")
 public class BindAccountLoginController {
+    private static final Logger logger = LoggerFactory.getLogger(BindAccountLoginController.class);
+
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
 
 
     @PostMapping(value = "/login")
     public Result<IPage<BindAccountLogin>> login(@RequestBody JSONObject json) {
-
-
-        System.err.println(json);
-
+        Result<IPage<BindAccountLogin>> result = new Result<IPage<BindAccountLogin>>();
         String advertiserId = json.getString("advertiserId");
-        String departmentId = json.getString("departmentId"); //部门id
-        String distributionName = json.getString("distributionName");//分配人姓名
-        String accountName = json.getString("accountName");
+        if (Check.isNull(advertiserId)) {
+            System.err.println("advertiserId不能为空");
+            result.setSuccess(false);
+            return result;
+        }
         String password = json.getString("password");
         String loginType = json.getString("loginType");
-
+        String accountName = json.getString("accountName"); //账号
         boolean trueOrFalse = bindAccountLoginService.bindLogin(advertiserId, accountName, password, loginType);
+        if (trueOrFalse) {
+            String realName = json.getString("realName");
+            String departmentId = json.getString("departmentId"); //部门id
+            String distributionName = json.getString("distributionName");//指定分配人姓名
+            String advertiserName = json.getString("advertiser_name"); // 广告主名称
+            String mediaId = json.getString("mediaId"); // 媒体类型: 1 头条 2 快手
+            String userId = json.getString("userId"); //创建人
+            UserAllocation userAllocation = new UserAllocation();
+            userAllocation.setDistributionName(distributionName);
+            userAllocation.setUserId(userId);
+            userAllocation.setAdvertiserId(advertiserId);
+            userAllocation.setDepartmentId(departmentId);
+            userAllocation.setAdvertiserName(advertiserName);
+            userAllocation.setAccountName(accountName);
+            userAllocation.setMediaId(mediaId);
+            userAllocation.setOperationName(realName);
+            int i = userAllocationMapper.insert(userAllocation);
+            if (i > 0) {
+                logger.info("用户分配入库完成,advertiserId:{}", advertiserId);
+            }
+        }
 
-
-       /* Subject subject = SecurityUtils.getSubject();
-        LoginUser sysUser = (LoginUser) subject.getPrincipal();
-        String realname = sysUser.getRealname(); //登录人姓名  分配人
-        String loginId = sysUser.getId();//登录id
-
-        UserAllocation userAllocation = new UserAllocation();
-        userAllocation.setAccountName(realname); //账号姓名
-        userAllocation.setDistributionName(realname); //分配人
-        userAllocation.setUserId(loginId);
-
-        bindAccountLoginService.bindLogin()
-
-        //userAllocation.setAdvertiserId(advertiserId);
-
-
-        // userAllocationService.userAllocation();
-
-
-        log.info(" 用户名:  " + sysUser.getRealname() + ",退出成功! ");
-        subject.logout();
-*/
-        Result<IPage<BindAccountLogin>> result = new Result<IPage<BindAccountLogin>>();
-        //  boolean trueOrFalse = bindAccountService.bindLogin(advertiserId, accountName, password, loginType);
         result.setSuccess(trueOrFalse);
         return result;
     }

+ 68 - 25
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/CallbackController.java

@@ -1,14 +1,23 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.utils.Check;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouAccessToken;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.material.service.IKuaishouAccessTokenService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import constant.KuaishouInterfaceConstant;
 import org.apache.commons.lang.StringUtils;
+import org.jeecg.modules.ctop.entity.AuthTask;
 import org.jeecg.modules.ctop.entity.CTopOauthToken;
+import org.jeecg.modules.ctop.entity.UserAllocation;
 import org.jeecg.modules.ctop.mapper.CTopOauthTokenMapper;
+import org.jeecg.modules.ctop.mapper.UserAllocationMapper;
+import org.jeecg.modules.ctop.service.IAuthTaskService;
 import org.jeecg.modules.ctop.service.IBindAccountAuthService;
+import org.jeecg.modules.ctop.service.IUserAllocationService;
 import org.jeecg.modules.kuaishou.service.IKuaishouInterfaceService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,6 +33,8 @@ import java.util.Map;
 @Controller
 @RequestMapping("/")
 public class CallbackController {
+    private static final Logger logger = LoggerFactory.getLogger(CallbackController.class);
+
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
     @Autowired
@@ -32,6 +43,13 @@ public class CallbackController {
     private CTopOauthTokenMapper cTopOauthTokenMapper;
     @Autowired
     private IBindAccountAuthService bindAccountAuthService;
+    @Autowired
+    private IAuthTaskService authTaskService;
+    @Autowired
+    private UserAllocationMapper allocationMapper;
+    @Autowired
+    private IUserAllocationService allocationService;
+
 
     @RequestMapping("/kuaishou")
     @ResponseBody
@@ -39,32 +57,57 @@ public class CallbackController {
                            HttpServletResponse response,
                            @RequestParam("auth_code") String authCode,
                            @RequestParam("state") String state) {
-        if (StringUtils.isNotBlank(authCode)) {
-            KuaishouResultToken accessToken = kuaishouInterfaceService.getAccessToken(authCode);
-            KuaishouAccessToken token = accessToken.getData();
-            if (token != null) {
-                CTopOauthToken topOauthToken = new CTopOauthToken();
-                Long accountId = token.getAccountId();
-                Map<String, Object> deleteMap = new HashMap<>();
-                deleteMap.put("advertiser_id", state);
-                deleteMap.put("account_id", accountId);
-                cTopOauthTokenMapper.deleteByMap(deleteMap); //删除 广告主id下的相关授权信息
-                topOauthToken.setAccountId(accountId);
-                topOauthToken.setMediaId("2");
-                topOauthToken.setAdvertiserId(state);
-                topOauthToken.setAccessToken(token.getAccessToken());
-                long accessTokenExpireIn = token.getAccessTokenExpiresIn() * 1000L;
-                long now = System.currentTimeMillis();
-                Date accessTokenExpireInDate = new Date(now + accessTokenExpireIn);
-                topOauthToken.setAccessTokenExpiresIn(accessTokenExpireInDate);
-                topOauthToken.setRefreshToken(token.getRefreshToken());
-                long refreshTokenExpireIn = token.getRefreshTokenExpiresIn() * 1000L;
-                Date refreshTokenExpireInDate = new Date(now + refreshTokenExpireIn);
-                topOauthToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
-                cTopOauthTokenMapper.insert(topOauthToken);
-                bindAccountAuthService.addBindAccount(accountId, KuaishouInterfaceConstant.LOGIN_TYPE_KUAISHOU, state); //账号绑定
+        try {
+            if (StringUtils.isNotBlank(authCode)) {
+                KuaishouResultToken accessToken = kuaishouInterfaceService.getAccessToken(authCode);
+                KuaishouAccessToken token = accessToken.getData();
+                if (token != null) {
+                    AuthTask authTask = authTaskService.getAuthTask(state);
+                    if (Check.isNull(authTask)) {
+                        throw new Exception("根据taskId未取到任务相关信息,taskId:" + state);
+                    }
+                    String advertiserId = authTask.getAdvertiserId();
+                    CTopOauthToken topOauthToken = new CTopOauthToken();
+                    Long accountId = token.getAccountId();
+                    Map<String, Object> deleteMap = new HashMap<>();
+                    deleteMap.put("advertiser_id", advertiserId);
+                    deleteMap.put("account_id", accountId);
+                    cTopOauthTokenMapper.deleteByMap(deleteMap); //删除 广告主id下的相关授权信息
+                    topOauthToken.setAccountId(accountId);
+                    topOauthToken.setMediaId("2");
+                    topOauthToken.setAdvertiserId(advertiserId);
+                    topOauthToken.setAccessToken(token.getAccessToken());
+                    long accessTokenExpireIn = token.getAccessTokenExpiresIn() * 1000L;
+                    long now = System.currentTimeMillis();
+                    Date accessTokenExpireInDate = new Date(now + accessTokenExpireIn);
+                    topOauthToken.setAccessTokenExpiresIn(accessTokenExpireInDate);
+                    topOauthToken.setRefreshToken(token.getRefreshToken());
+                    long refreshTokenExpireIn = token.getRefreshTokenExpiresIn() * 1000L;
+                    Date refreshTokenExpireInDate = new Date(now + refreshTokenExpireIn);
+                    topOauthToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
+                    cTopOauthTokenMapper.insert(topOauthToken);
+                    bindAccountAuthService.addBindAccount(accountId, KuaishouInterfaceConstant.LOGIN_TYPE_KUAISHOU, advertiserId); //账号绑定
+
+
+                    UserAllocation userAllocation = allocationService.selectByTaskId(state);
+                    userAllocation.setAccountId(accountId);
+                    allocationMapper.deleteById(userAllocation.getId());
+
+                    Map<String, Object> deleteUserMap = new HashMap<>();
+                    deleteUserMap.put("advertiser_id", advertiserId);
+                    deleteUserMap.put("account_id", accountId);
+                    allocationMapper.deleteByMap(deleteUserMap);
+
+                    int i = allocationMapper.insert(userAllocation);
+                    if (i > 0) {
+                        logger.info("同步分配用户表完成,task_id:{},accountId:{}", state, accountId);
+
+                    }
+                }
+                return "auth_success";
             }
-            return "auth_success";
+        } catch (Exception e) {
+            e.printStackTrace();
         }
         return "auth_fail";
     }

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -38,7 +38,7 @@ import io.swagger.annotations.ApiOperation;
  /**
  * @Description: 用户分配
  * @Author: jeecg-boot
- * @Date:   2019-07-30
+ * @Date:   2019-07-31
  * @Version: V1.0
  */
 @Slf4j

+ 44 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/AuthTask.java

@@ -0,0 +1,44 @@
+package org.jeecg.modules.ctop.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * @Description: 关联用户分配
+ * @Author: jeecg-boot
+ * @Date: 2019-07-31
+ * @Version: V1.0
+ */
+@Data
+@TableName("ctop_auth_task")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_auth_task对象", description = "关联用户分配")
+public class AuthTask {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键ID")
+    private Long id;
+    /**
+     * 广告主ID
+     */
+    @Excel(name = "广告主ID", width = 15)
+    @ApiModelProperty(value = "广告主ID")
+    private String advertiserId;
+    /**
+     * task_id
+     */
+    @Excel(name = "task_id", width = 15)
+    @ApiModelProperty(value = "task_id")
+    private String taskId;
+}

+ 97 - 54
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/UserAllocation.java

@@ -1,87 +1,130 @@
 package org.jeecg.modules.ctop.entity;
 
-import java.io.Serializable;
-import java.util.Date;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 /**
  * @Description: 用户分配
  * @Author: jeecg-boot
- * @Date:   2019-07-30
+ * @Date: 2019-07-31
  * @Version: V1.0
  */
 @Data
 @TableName("ctop_user_allocation")
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
-@ApiModel(value="ctop_user_allocation对象", description="用户分配")
+@ApiModel(value = "ctop_user_allocation对象", description = "用户分配")
 public class UserAllocation {
-    
-	/**主键ID*/
-	@TableId(type = IdType.UUID)
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "主键ID")
-	private Integer id;
-	/**登陆人id*/
-	@Excel(name = "登陆人id", width = 15)
+    private Long id;
+    /**
+     * 登陆人id
+     */
+    @Excel(name = "登陆人id", width = 15)
     @ApiModelProperty(value = "登陆人id")
-	private String userId;
-	/**账户id*/
-	@Excel(name = "账户id", width = 15)
-    @ApiModelProperty(value = "账户id")
-	private Integer accountId;
-	/**广告主ID*/
-	@Excel(name = "广告主ID", width = 15)
+    private String userId;
+    /**
+     * 账户id --授权
+     */
+    @Excel(name = "账户id --授权", width = 15)
+    @ApiModelProperty(value = "账户id --授权")
+    private Long accountId;
+    /**
+     * 广告主ID
+     */
+    @Excel(name = "广告主ID", width = 15)
     @ApiModelProperty(value = "广告主ID")
-	private String advertiserId;
-	/**分配人*/
-	@Excel(name = "分配人", width = 15)
-    @ApiModelProperty(value = "分配人")
-	private String distributionName;
-	/**部门id*/
-	@Excel(name = "部门id", width = 15)
+    private String advertiserId;
+    /**
+     * 指定分配人
+     */
+    @Excel(name = "指定分配人", width = 15)
+    @ApiModelProperty(value = "指定分配人")
+    private String distributionName;
+    /**
+     * 部门id
+     */
+    @Excel(name = "部门id", width = 15)
     @ApiModelProperty(value = "部门id")
-	private String departmentId;
-	/**管理员名称*/
-	@Excel(name = "管理员名称", width = 15)
+    private String departmentId;
+    /**
+     * 管理员名称
+     */
+    @Excel(name = "管理员名称", width = 15)
     @ApiModelProperty(value = "管理员名称")
-	private String adminName;
-	/**广告主名称*/
-	@Excel(name = "广告主名称", width = 15)
+    private String adminName;
+    /**
+     * 广告主名称
+     */
+    @Excel(name = "广告主名称", width = 15)
     @ApiModelProperty(value = "广告主名称")
-	private String advertiserName;
-	/**账号姓名*/
-	@Excel(name = "账号姓名", width = 15)
-    @ApiModelProperty(value = "账号姓名")
-	private String accountName;
-	/**创建时间*/
-	@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private String advertiserName;
+    /**
+     * 输入账号  --登陆
+     */
+    @Excel(name = "输入账号  --登陆", width = 15)
+    @ApiModelProperty(value = "输入账号  --登陆")
+    private String accountName;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建时间")
-	private Date createTime;
-	/**创建人*/
-	@Excel(name = "创建人", width = 15)
+    private Date createTime;
+    /**
+     * task_id
+     */
+    @Excel(name = "task_id", width = 15)
+    @ApiModelProperty(value = "task_id")
+    private String taskId;
+    /**
+     * 操作人姓名
+     */
+    @Excel(name = "操作人姓名", width = 15)
+    @ApiModelProperty(value = "操作人姓名")
+    private String operationName;
+    /**
+     * 创建人
+     */
+    @Excel(name = "创建人", width = 15)
     @ApiModelProperty(value = "创建人")
-	private String createBy;
-	/**修改人*/
-	@Excel(name = "修改人", width = 15)
+    private String createBy;
+    /**
+     * 修改人
+     */
+    @Excel(name = "修改人", width = 15)
     @ApiModelProperty(value = "修改人")
-	private String updateBy;
-	/**修改时间*/
-	@Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private String updateBy;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "修改时间")
-	private Date updateTime;
+    private Date updateTime;
+    /**
+     * 平台类型 1 头条 2快手
+     */
+    @Excel(name = "平台类型 1 头条 2快手", width = 15)
+    @ApiModelProperty(value = "平台类型 1 头条 2快手")
+    private String mediaId;
 }

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/AuthTaskMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.AuthTask;
+
+/**
+ * @Description: 关联用户分配
+ * @Author: jeecg-boot
+ * @Date: 2019-07-31
+ * @Version: V1.0
+ */
+public interface AuthTaskMapper extends BaseMapper<AuthTask> {
+
+}

+ 2 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/UserAllocationMapper.java

@@ -1,15 +1,12 @@
 package org.jeecg.modules.ctop.mapper;
 
-import java.util.List;
-
-import org.apache.ibatis.annotations.Param;
-import org.jeecg.modules.ctop.entity.UserAllocation;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.UserAllocation;
 
 /**
  * @Description: 用户分配
  * @Author: jeecg-boot
- * @Date:   2019-07-30
+ * @Date: 2019-07-31
  * @Version: V1.0
  */
 public interface UserAllocationMapper extends BaseMapper<UserAllocation> {

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/AuthTaskMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.ctop.mapper.AuthTaskMapper">
+
+</mapper>

+ 14 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IAuthTaskService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.ctop.service;
+
+import org.jeecg.modules.ctop.entity.AuthTask;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 关联用户分配
+ * @Author: jeecg-boot
+ * @Date: 2019-07-31
+ * @Version: V1.0
+ */
+public interface IAuthTaskService extends IService<AuthTask> {
+    AuthTask getAuthTask(String taskId);
+}

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IBindAccountAuthService.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.ctop.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.ctop.entity.BindAccountAuth;
+import org.jeecg.modules.ctop.entity.UserAllocation;
 
 import java.io.UnsupportedEncodingException;
 
@@ -13,7 +14,7 @@ import java.io.UnsupportedEncodingException;
  */
 public interface IBindAccountAuthService extends IService<BindAccountAuth> {
 
-    String bindAuthorization(String advertiserId, String authorizationType) throws UnsupportedEncodingException;
+    String bindAuthorization(String advertiserId, String authorizationType, UserAllocation userAllocation) throws UnsupportedEncodingException;
 
     String getKuaishouCodeUrl(String state) throws UnsupportedEncodingException;
 

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IUserAllocationService.java

@@ -6,9 +6,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
 /**
  * @Description: 用户分配
  * @Author: jeecg-boot
- * @Date:   2019-07-30
+ * @Date:   2019-07-31
  * @Version: V1.0
  */
 public interface IUserAllocationService extends IService<UserAllocation> {
 
+    UserAllocation selectByTaskId(String state);
 }

+ 32 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/AuthTaskServiceImpl.java

@@ -0,0 +1,32 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.jeecg.modules.ctop.entity.AuthTask;
+import org.jeecg.modules.ctop.entity.CTopOauthToken;
+import org.jeecg.modules.ctop.mapper.AuthTaskMapper;
+import org.jeecg.modules.ctop.service.IAuthTaskService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: 关联用户分配
+ * @Author: jeecg-boot
+ * @Date: 2019-07-31
+ * @Version: V1.0
+ */
+@Service
+public class AuthTaskServiceImpl extends ServiceImpl<AuthTaskMapper, AuthTask> implements IAuthTaskService {
+
+    @Autowired
+    private AuthTaskMapper authTaskMapper;
+
+    @Override
+    public AuthTask getAuthTask(String taskId) {
+        QueryWrapper<AuthTask> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("task_id", taskId).orderByDesc("create_time");
+        AuthTask authTask = authTaskMapper.selectOne(queryWrapper);
+        return authTask;
+    }
+}

+ 29 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/BindAccountAuthServiceImpl.java

@@ -4,8 +4,12 @@ import cn.com.ctop.common.utils.PropertiesUtils;
 import cn.com.ctop.toutiao.common.BytedanceInterfaceConstant;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import constant.KuaishouInterfaceConstant;
+import org.jeecg.modules.ctop.entity.AuthTask;
 import org.jeecg.modules.ctop.entity.BindAccountAuth;
+import org.jeecg.modules.ctop.entity.UserAllocation;
+import org.jeecg.modules.ctop.mapper.AuthTaskMapper;
 import org.jeecg.modules.ctop.mapper.BindAccountAuthMapper;
+import org.jeecg.modules.ctop.mapper.UserAllocationMapper;
 import org.jeecg.modules.ctop.service.IBindAccountAuthService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -16,6 +20,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.UUID;
 
 /**
  * @Description: 账号绑定-授权
@@ -26,10 +31,15 @@ import java.util.Map;
 @Service
 public class BindAccountAuthServiceImpl extends ServiceImpl<BindAccountAuthMapper, BindAccountAuth> implements IBindAccountAuthService {
     private static final Logger logger = LoggerFactory.getLogger(BindAccountAuthServiceImpl.class);
+    @Autowired
+    private AuthTaskMapper authTaskMapper;
 
     @Autowired
     private BindAccountAuthMapper bindAccountAuthMapper;
 
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+
     /**
      * 授权
      *
@@ -38,13 +48,29 @@ public class BindAccountAuthServiceImpl extends ServiceImpl<BindAccountAuthMappe
      * @return
      */
     @Override
-    public String bindAuthorization(String advertiserId, String authorizationType) throws UnsupportedEncodingException {
+    public String bindAuthorization(String advertiserId, String authorizationType, UserAllocation userAllocation) throws UnsupportedEncodingException {
+        String taskId = UUID.randomUUID().toString();
+        AuthTask authTask = new AuthTask();
+        authTask.setAdvertiserId(advertiserId);
+        authTask.setTaskId(taskId);
+        int i = authTaskMapper.insert(authTask);
+        if (i > 0) {
+            logger.info("广告主关联id,auth_task入库完成,advertiserId:{}", advertiserId);
+        }
+
+        userAllocation.setTaskId(taskId);
+        userAllocation.setAdvertiserId(advertiserId);
+        int y = userAllocationMapper.insert(userAllocation);
+        if (y > 0) {
+            logger.info("用户分配,入库完成,advertiserId:{}", advertiserId);
+        }
+
         String codeUrl = "";
         if ("kuaishou".equals(authorizationType)) {
-            codeUrl = getKuaishouCodeUrl(advertiserId);
+            codeUrl = getKuaishouCodeUrl(taskId);
         }
         if ("toutiao".equals(authorizationType)) {
-            codeUrl = getByteDanceCodeUrl(advertiserId);
+            codeUrl = getByteDanceCodeUrl(taskId);
         }
 
         return codeUrl;

+ 13 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/UserAllocationServiceImpl.java

@@ -1,8 +1,11 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.jeecg.modules.ctop.entity.CTopOauthToken;
 import org.jeecg.modules.ctop.entity.UserAllocation;
 import org.jeecg.modules.ctop.mapper.UserAllocationMapper;
 import org.jeecg.modules.ctop.service.IUserAllocationService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -10,10 +13,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 /**
  * @Description: 用户分配
  * @Author: jeecg-boot
- * @Date:   2019-07-30
+ * @Date: 2019-07-31
  * @Version: V1.0
  */
 @Service
 public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper, UserAllocation> implements IUserAllocationService {
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
 
+    @Override
+    public UserAllocation selectByTaskId(String state) {
+        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("task_id", state).orderByDesc("create_time");
+        UserAllocation userAllocation = userAllocationMapper.selectOne(queryWrapper);
+        return userAllocation;
+    }
 }

+ 157 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/AuthTaskList.vue

@@ -0,0 +1,157 @@
+<template>
+  <a-card :bordered="false">
+
+    <!-- 查询区域 -->
+    <div class="table-page-search-wrapper">
+      <a-form layout="inline">
+        <a-row :gutter="24">
+
+          <a-col :md="6" :sm="8">
+            <a-form-item label="广告主ID">
+              <a-input placeholder="请输入广告主ID" v-model="queryParam.advertiserId"></a-input>
+            </a-form-item>
+          </a-col>
+          <a-col :md="6" :sm="8">
+            <a-form-item label="task_id">
+              <a-input placeholder="请输入task_id" v-model="queryParam.taskId"></a-input>
+            </a-form-item>
+          </a-col>
+          </template>
+          <a-col :md="6" :sm="8" >
+            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
+              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
+              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
+              <a @click="handleToggleSearch" style="margin-left: 8px">
+                {{ toggleSearchStatus ? '收起' : '展开' }}
+                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
+              </a>
+            </span>
+          </a-col>
+
+        </a-row>
+      </a-form>
+    </div>
+
+    <!-- 操作按钮区域 -->
+    <div class="table-operator">
+      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
+      <a-button type="primary" icon="download" @click="handleExportXls('关联用户分配')">导出</a-button>
+      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
+        <a-button type="primary" icon="import">导入</a-button>
+      </a-upload>
+      <a-dropdown v-if="selectedRowKeys.length > 0">
+        <a-menu slot="overlay">
+          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
+        </a-menu>
+        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
+      </a-dropdown>
+    </div>
+
+    <!-- table区域-begin -->
+    <div>
+      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
+        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
+        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
+      </div>
+
+      <a-table
+        ref="table"
+        size="middle"
+        bordered
+        rowKey="id"
+        :columns="columns"
+        :dataSource="dataSource"
+        :pagination="ipagination"
+        :loading="loading"
+        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
+        @change="handleTableChange">
+
+        <span slot="action" slot-scope="text, record">
+          <a @click="handleEdit(record)">编辑</a>
+
+          <a-divider type="vertical" />
+          <a-dropdown>
+            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
+            <a-menu slot="overlay">
+              <a-menu-item>
+                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
+                  <a>删除</a>
+                </a-popconfirm>
+              </a-menu-item>
+            </a-menu>
+          </a-dropdown>
+        </span>
+
+      </a-table>
+    </div>
+    <!-- table区域-end -->
+
+    <!-- 表单区域 -->
+    <authTask-modal ref="modalForm" @ok="modalFormOk"></authTask-modal>
+  </a-card>
+</template>
+
+<script>
+  import AuthTaskModal from './modules/AuthTaskModal'
+  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+
+  export default {
+    name: "AuthTaskList",
+    mixins:[JeecgListMixin],
+    components: {
+      AuthTaskModal
+    },
+    data () {
+      return {
+        description: '关联用户分配管理页面',
+        // 表头
+        columns: [
+          {
+            title: '#',
+            dataIndex: '',
+            key:'rowIndex',
+            width:60,
+            align:"center",
+            customRender:function (t,r,index) {
+              return parseInt(index)+1;
+            }
+           },
+		   {
+            title: '广告主ID',
+            align:"center",
+            dataIndex: 'advertiserId'
+           },
+		   {
+            title: 'task_id',
+            align:"center",
+            dataIndex: 'taskId'
+           },
+          {
+            title: '操作',
+            dataIndex: 'action',
+            align:"center",
+            scopedSlots: { customRender: 'action' },
+          }
+        ],
+		url: {
+          list: "/ctop/authTask/list",
+          delete: "/ctop/authTask/delete",
+          deleteBatch: "/ctop/authTask/deleteBatch",
+          exportXlsUrl: "ctop/authTask/exportXls",
+          importExcelUrl: "ctop/authTask/importExcel",
+       },
+    }
+  },
+  computed: {
+    importExcelUrl: function(){
+      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
+    }
+  },
+    methods: {
+     
+    }
+  }
+</script>
+<style scoped>
+  @import '~@assets/less/common.less'
+</style>

+ 22 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/UserAllocationList.vue

@@ -12,8 +12,8 @@
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="8">
-            <a-form-item label="账户id">
-              <a-input placeholder="请输入账户id" v-model="queryParam.accountId"></a-input>
+            <a-form-item label="账户id --授权">
+              <a-input placeholder="请输入账户id --授权" v-model="queryParam.accountId"></a-input>
             </a-form-item>
           </a-col>
         <template v-if="toggleSearchStatus">
@@ -23,8 +23,8 @@
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="8">
-            <a-form-item label="分配人">
-              <a-input placeholder="请输入分配人" v-model="queryParam.distributionName"></a-input>
+            <a-form-item label="指定分配人">
+              <a-input placeholder="请输入指定分配人" v-model="queryParam.distributionName"></a-input>
             </a-form-item>
           </a-col>
           <a-col :md="6" :sm="8">
@@ -138,7 +138,7 @@
             dataIndex: 'userId'
            },
 		   {
-            title: '账户id',
+            title: '账户id --授权',
             align:"center",
             dataIndex: 'accountId'
            },
@@ -148,7 +148,7 @@
             dataIndex: 'advertiserId'
            },
 		   {
-            title: '分配人',
+            title: '指定分配人',
             align:"center",
             dataIndex: 'distributionName'
            },
@@ -168,10 +168,25 @@
             dataIndex: 'advertiserName'
            },
 		   {
-            title: '账号姓名',
+            title: '输入账号  --登陆',
             align:"center",
             dataIndex: 'accountName'
            },
+		   {
+            title: 'task_id',
+            align:"center",
+            dataIndex: 'taskId'
+           },
+		   {
+            title: '操作人姓名',
+            align:"center",
+            dataIndex: 'operationName'
+           },
+		   {
+            title: '平台类型 1 头条 2快手',
+            align:"center",
+            dataIndex: 'mediaId'
+           },
           {
             title: '操作',
             dataIndex: 'action',

+ 130 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/AuthTaskModal.vue

@@ -0,0 +1,130 @@
+<template>
+  <a-modal
+    :title="title"
+    :width="800"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    @ok="handleOk"
+    @cancel="handleCancel"
+    cancelText="关闭">
+    
+    <a-spin :spinning="confirmLoading">
+      <a-form :form="form">
+      
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="广告主ID">
+          <a-input placeholder="请输入广告主ID" v-decorator="['advertiserId', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="task_id">
+          <a-input placeholder="请输入task_id" v-decorator="['taskId', {}]" />
+        </a-form-item>
+		
+      </a-form>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+  import { httpAction } from '@/api/manage'
+  import pick from 'lodash.pick'
+  import moment from "moment"
+
+  export default {
+    name: "AuthTaskModal",
+    data () {
+      return {
+        title:"操作",
+        visible: false,
+        model: {},
+        labelCol: {
+          xs: { span: 24 },
+          sm: { span: 5 },
+        },
+        wrapperCol: {
+          xs: { span: 24 },
+          sm: { span: 16 },
+        },
+
+        confirmLoading: false,
+        form: this.$form.createForm(this),
+        validatorRules:{
+        },
+        url: {
+          add: "/ctop/authTask/add",
+          edit: "/ctop/authTask/edit",
+        },
+      }
+    },
+    created () {
+    },
+    methods: {
+      add () {
+        this.edit({});
+      },
+      edit (record) {
+        this.form.resetFields();
+        this.model = Object.assign({}, record);
+        this.visible = true;
+        this.$nextTick(() => {
+          this.form.setFieldsValue(pick(this.model,'advertiserId','taskId'))
+		  //时间格式化
+        });
+
+      },
+      close () {
+        this.$emit('close');
+        this.visible = false;
+      },
+      handleOk () {
+        const that = this;
+        // 触发表单验证
+        this.form.validateFields((err, values) => {
+          if (!err) {
+            that.confirmLoading = true;
+            let httpurl = '';
+            let method = '';
+            if(!this.model.id){
+              httpurl+=this.url.add;
+              method = 'post';
+            }else{
+              httpurl+=this.url.edit;
+               method = 'put';
+            }
+            let formData = Object.assign(this.model, values);
+            //时间格式化
+            
+            console.log(formData)
+            httpAction(httpurl,formData,method).then((res)=>{
+              if(res.success){
+                that.$message.success(res.message);
+                that.$emit('ok');
+              }else{
+                that.$message.warning(res.message);
+              }
+            }).finally(() => {
+              that.confirmLoading = false;
+              that.close();
+            })
+
+
+
+          }
+        })
+      },
+      handleCancel () {
+        this.close()
+      },
+
+
+    }
+  }
+</script>
+
+<style lang="less" scoped>
+
+</style>

+ 137 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/AuthTaskModal__Style#Drawer.vue

@@ -0,0 +1,137 @@
+<template>
+  <a-drawer
+      :title="title"
+      :width="800"
+      placement="right"
+      :closable="false"
+      @close="close"
+      :visible="visible"
+  >
+
+    <a-spin :spinning="confirmLoading">
+      <a-form :form="form">
+      
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="广告主ID">
+          <a-input placeholder="请输入广告主ID" v-decorator="['advertiserId', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="task_id">
+          <a-input placeholder="请输入task_id" v-decorator="['taskId', {}]" />
+        </a-form-item>
+		
+      </a-form>
+    </a-spin>
+    <a-button type="primary" @click="handleOk">确定</a-button>
+    <a-button type="primary" @click="handleCancel">取消</a-button>
+  </a-drawer>
+</template>
+
+<script>
+  import { httpAction } from '@/api/manage'
+  import pick from 'lodash.pick'
+  import moment from "moment"
+
+  export default {
+    name: "AuthTaskModal",
+    data () {
+      return {
+        title:"操作",
+        visible: false,
+        model: {},
+        labelCol: {
+          xs: { span: 24 },
+          sm: { span: 5 },
+        },
+        wrapperCol: {
+          xs: { span: 24 },
+          sm: { span: 16 },
+        },
+
+        confirmLoading: false,
+        form: this.$form.createForm(this),
+        validatorRules:{
+        },
+        url: {
+          add: "/ctop/authTask/add",
+          edit: "/ctop/authTask/edit",
+        },
+      }
+    },
+    created () {
+    },
+    methods: {
+      add () {
+        this.edit({});
+      },
+      edit (record) {
+        this.form.resetFields();
+        this.model = Object.assign({}, record);
+        this.visible = true;
+        this.$nextTick(() => {
+          this.form.setFieldsValue(pick(this.model,'advertiserId','taskId'))
+		  //时间格式化
+        });
+
+      },
+      close () {
+        this.$emit('close');
+        this.visible = false;
+      },
+      handleOk () {
+        const that = this;
+        // 触发表单验证
+        this.form.validateFields((err, values) => {
+          if (!err) {
+            that.confirmLoading = true;
+            let httpurl = '';
+            let method = '';
+            if(!this.model.id){
+              httpurl+=this.url.add;
+              method = 'post';
+            }else{
+              httpurl+=this.url.edit;
+               method = 'put';
+            }
+            let formData = Object.assign(this.model, values);
+            //时间格式化
+            
+            console.log(formData)
+            httpAction(httpurl,formData,method).then((res)=>{
+              if(res.success){
+                that.$message.success(res.message);
+                that.$emit('ok');
+              }else{
+                that.$message.warning(res.message);
+              }
+            }).finally(() => {
+              that.confirmLoading = false;
+              that.close();
+            })
+
+
+
+          }
+        })
+      },
+      handleCancel () {
+        this.close()
+      },
+
+
+    }
+  }
+</script>
+
+<style lang="less" scoped>
+/** Button按钮间距 */
+  .ant-btn {
+    margin-left: 30px;
+    margin-bottom: 30px;
+    float: right;
+  }
+</style>

+ 25 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/UserAllocationModal.vue

@@ -20,8 +20,8 @@
         <a-form-item
           :labelCol="labelCol"
           :wrapperCol="wrapperCol"
-          label="账户id">
-          <a-input placeholder="请输入账户id" v-decorator="['accountId', {}]" />
+          label="账户id --授权">
+          <a-input placeholder="请输入账户id --授权" v-decorator="['accountId', {}]" />
         </a-form-item>
         <a-form-item
           :labelCol="labelCol"
@@ -32,8 +32,8 @@
         <a-form-item
           :labelCol="labelCol"
           :wrapperCol="wrapperCol"
-          label="分配人">
-          <a-input placeholder="请输入分配人" v-decorator="['distributionName', {}]" />
+          label="指定分配人">
+          <a-input placeholder="请输入指定分配人" v-decorator="['distributionName', {}]" />
         </a-form-item>
         <a-form-item
           :labelCol="labelCol"
@@ -56,8 +56,26 @@
         <a-form-item
           :labelCol="labelCol"
           :wrapperCol="wrapperCol"
-          label="账号姓名">
-          <a-input placeholder="请输入账号姓名" v-decorator="['accountName', {}]" />
+          label="输入账号  --登陆">
+          <a-input placeholder="请输入输入账号  --登陆" v-decorator="['accountName', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="task_id">
+          <a-input placeholder="请输入task_id" v-decorator="['taskId', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="操作人姓名">
+          <a-input placeholder="请输入操作人姓名" v-decorator="['operationName', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="平台类型 1 头条 2快手">
+          <a-input placeholder="请输入平台类型 1 头条 2快手" v-decorator="['mediaId', {}]" />
         </a-form-item>
 		
       </a-form>
@@ -107,7 +125,7 @@
         this.model = Object.assign({}, record);
         this.visible = true;
         this.$nextTick(() => {
-          this.form.setFieldsValue(pick(this.model,'userId','accountId','advertiserId','distributionName','departmentId','adminName','advertiserName','accountName'))
+          this.form.setFieldsValue(pick(this.model,'userId','accountId','advertiserId','distributionName','departmentId','adminName','advertiserName','accountName','taskId','operationName','mediaId'))
 		  //时间格式化
         });
 

+ 25 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vue/modules/UserAllocationModal__Style#Drawer.vue

@@ -20,8 +20,8 @@
         <a-form-item
           :labelCol="labelCol"
           :wrapperCol="wrapperCol"
-          label="账户id">
-          <a-input placeholder="请输入账户id" v-decorator="['accountId', {}]" />
+          label="账户id --授权">
+          <a-input placeholder="请输入账户id --授权" v-decorator="['accountId', {}]" />
         </a-form-item>
         <a-form-item
           :labelCol="labelCol"
@@ -32,8 +32,8 @@
         <a-form-item
           :labelCol="labelCol"
           :wrapperCol="wrapperCol"
-          label="分配人">
-          <a-input placeholder="请输入分配人" v-decorator="['distributionName', {}]" />
+          label="指定分配人">
+          <a-input placeholder="请输入指定分配人" v-decorator="['distributionName', {}]" />
         </a-form-item>
         <a-form-item
           :labelCol="labelCol"
@@ -56,8 +56,26 @@
         <a-form-item
           :labelCol="labelCol"
           :wrapperCol="wrapperCol"
-          label="账号姓名">
-          <a-input placeholder="请输入账号姓名" v-decorator="['accountName', {}]" />
+          label="输入账号  --登陆">
+          <a-input placeholder="请输入输入账号  --登陆" v-decorator="['accountName', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="task_id">
+          <a-input placeholder="请输入task_id" v-decorator="['taskId', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="操作人姓名">
+          <a-input placeholder="请输入操作人姓名" v-decorator="['operationName', {}]" />
+        </a-form-item>
+        <a-form-item
+          :labelCol="labelCol"
+          :wrapperCol="wrapperCol"
+          label="平台类型 1 头条 2快手">
+          <a-input placeholder="请输入平台类型 1 头条 2快手" v-decorator="['mediaId', {}]" />
         </a-form-item>
 		
       </a-form>
@@ -109,7 +127,7 @@
         this.model = Object.assign({}, record);
         this.visible = true;
         this.$nextTick(() => {
-          this.form.setFieldsValue(pick(this.model,'userId','accountId','advertiserId','distributionName','departmentId','adminName','advertiserName','accountName'))
+          this.form.setFieldsValue(pick(this.model,'userId','accountId','advertiserId','distributionName','departmentId','adminName','advertiserName','accountName','taskId','operationName','mediaId'))
 		  //时间格式化
         });
 

+ 274 - 267
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/LoginController.java

@@ -39,291 +39,298 @@ import java.util.*;
  */
 @RestController
 @RequestMapping("/sys")
-@Api(tags="用户登录")
+@Api(tags = "用户登录")
 @Slf4j
 public class LoginController {
-	@Autowired
-	private ISysUserService sysUserService;
-	@Autowired
-	private ISysBaseAPI sysBaseAPI;
-	@Autowired
-	private ISysLogService logService;
-	@Autowired
+    @Autowired
+    private ISysUserService sysUserService;
+    @Autowired
+    private ISysBaseAPI sysBaseAPI;
+    @Autowired
+    private ISysLogService logService;
+    @Autowired
     private RedisUtil redisUtil;
-	@Autowired
+    @Autowired
     private ISysDepartService sysDepartService;
 
-	@RequestMapping(value = "/login", method = RequestMethod.POST)
-	@ApiOperation("登录接口")
-	public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) throws Exception {
-		Result<JSONObject> result = new Result<JSONObject>();
-		String username = sysLoginModel.getUsername();
-		String password = sysLoginModel.getPassword();
-		//步骤1:TODO 前端密码加密,后端进行密码解密,防止传输密码篡改等问题,不配就直接提示密码错误,并记录日志后期进行统计分析是否锁定
-		password = AesEncryptUtil.desEncrypt(sysLoginModel.getPassword()).trim();//密码解密
-		//1. 校验用户是否有效
-		SysUser sysUser = sysUserService.getUserByName(username);
-		result = sysUserService.checkUserIsEffective(sysUser);
-		if(!result.isSuccess()) {
-			return result;
-		}
-		
-		//2. 校验用户名或密码是否正确
-		String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
-		String syspassword = sysUser.getPassword();
-		if (!syspassword.equals(userpassword)) {
-			result.error500("用户名或密码错误");
-			return result;
-		}
-				
-		//用户登录信息
-		userInfo(sysUser, result);
-		sysBaseAPI.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
-		return result;
-	}
-	
-	/**
-	 * 退出登录
-	 * @param request
-	 * @param response
-	 * @return
-	 */
-	@RequestMapping(value = "/logout")
-	public Result<Object> logout(HttpServletRequest request,HttpServletResponse response) {
-		//用户退出逻辑
-		Subject subject = SecurityUtils.getSubject();
-		LoginUser sysUser = (LoginUser)subject.getPrincipal();
-		sysBaseAPI.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null);
-		log.info(" 用户名:  "+sysUser.getRealname()+",退出成功! ");
-	    subject.logout();
+    @RequestMapping(value = "/login", method = RequestMethod.POST)
+    @ApiOperation("登录接口")
+    public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) throws Exception {
+        Result<JSONObject> result = new Result<JSONObject>();
+        String username = sysLoginModel.getUsername();
+        String password = sysLoginModel.getPassword();
+        //步骤1:TODO 前端密码加密,后端进行密码解密,防止传输密码篡改等问题,不配就直接提示密码错误,并记录日志后期进行统计分析是否锁定
+        password = AesEncryptUtil.desEncrypt(sysLoginModel.getPassword()).trim();//密码解密
+        //1. 校验用户是否有效
+        SysUser sysUser = sysUserService.getUserByName(username);
+        String departId = sysDepartService.selectIdByOrdCode(sysUser.getOrgCode());
+        sysUser.setDepartId(departId);
+        result = sysUserService.checkUserIsEffective(sysUser);
+        if (!result.isSuccess()) {
+            return result;
+        }
 
-	    String token = request.getHeader(DefContants.X_ACCESS_TOKEN);
-	    //清空用户Token缓存
-	    redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
-	    //清空用户权限缓存:权限Perms和角色集合
-	    redisUtil.del(CommonConstant.LOGIN_USER_CACHERULES_ROLE + sysUser.getUsername());
-	    redisUtil.del(CommonConstant.LOGIN_USER_CACHERULES_PERMISSION + sysUser.getUsername());
-		return Result.ok("退出登录成功!");
-	}
-	
-	/**
-	 * 获取访问量
-	 * @return
-	 */
-	@GetMapping("loginfo")
-	public Result<JSONObject> loginfo() {
-		Result<JSONObject> result = new Result<JSONObject>();
-		JSONObject obj = new JSONObject();
-		//update-begin--Author:zhangweijian  Date:20190428 for:传入开始时间,结束时间参数
-		// 获取一天的开始和结束时间
-		Calendar calendar = new GregorianCalendar();
-		calendar.set(Calendar.HOUR_OF_DAY, 0);
-		calendar.set(Calendar.MINUTE, 0);
-		calendar.set(Calendar.SECOND, 0);
-		calendar.set(Calendar.MILLISECOND, 0);
-		Date dayStart = calendar.getTime();
-		calendar.add(Calendar.DATE, 1);
-		Date dayEnd = calendar.getTime();
-		// 获取系统访问记录
-		Long totalVisitCount = logService.findTotalVisitCount();
-		obj.put("totalVisitCount", totalVisitCount);
-		Long todayVisitCount = logService.findTodayVisitCount(dayStart,dayEnd);
-		obj.put("todayVisitCount", todayVisitCount);
-		Long todayIp = logService.findTodayIp(dayStart,dayEnd);
-		//update-end--Author:zhangweijian  Date:20190428 for:传入开始时间,结束时间参数
-		obj.put("todayIp", todayIp);
-		result.setResult(obj);
-		result.success("登录成功");
-		return result;
-	}
-	
-	/**
-	 * 获取访问量
-	 * @return
-	 */
-	@GetMapping("visitInfo")
-	public Result<List<Map<String,Object>>> visitInfo() {
-		Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
-		Calendar calendar = new GregorianCalendar();
-		calendar.set(Calendar.HOUR_OF_DAY,0);
-        calendar.set(Calendar.MINUTE,0);
-        calendar.set(Calendar.SECOND,0);
-        calendar.set(Calendar.MILLISECOND,0);
+        //2. 校验用户名或密码是否正确
+        String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
+        String syspassword = sysUser.getPassword();
+        if (!syspassword.equals(userpassword)) {
+            result.error500("用户名或密码错误");
+            return result;
+        }
+
+        //用户登录信息
+        userInfo(sysUser, result);
+        sysBaseAPI.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
+        return result;
+    }
+
+    /**
+     * 退出登录
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/logout")
+    public Result<Object> logout(HttpServletRequest request, HttpServletResponse response) {
+        //用户退出逻辑
+        Subject subject = SecurityUtils.getSubject();
+        LoginUser sysUser = (LoginUser) subject.getPrincipal();
+        sysBaseAPI.addLog("用户名: " + sysUser.getRealname() + ",退出成功!", CommonConstant.LOG_TYPE_1, null);
+        log.info(" 用户名:  " + sysUser.getRealname() + ",退出成功! ");
+        subject.logout();
+
+        String token = request.getHeader(DefContants.X_ACCESS_TOKEN);
+        //清空用户Token缓存
+        redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
+        //清空用户权限缓存:权限Perms和角色集合
+        redisUtil.del(CommonConstant.LOGIN_USER_CACHERULES_ROLE + sysUser.getUsername());
+        redisUtil.del(CommonConstant.LOGIN_USER_CACHERULES_PERMISSION + sysUser.getUsername());
+        return Result.ok("退出登录成功!");
+    }
+
+    /**
+     * 获取访问量
+     *
+     * @return
+     */
+    @GetMapping("loginfo")
+    public Result<JSONObject> loginfo() {
+        Result<JSONObject> result = new Result<JSONObject>();
+        JSONObject obj = new JSONObject();
+        //update-begin--Author:zhangweijian  Date:20190428 for:传入开始时间,结束时间参数
+        // 获取一天的开始和结束时间
+        Calendar calendar = new GregorianCalendar();
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        Date dayStart = calendar.getTime();
+        calendar.add(Calendar.DATE, 1);
+        Date dayEnd = calendar.getTime();
+        // 获取系统访问记录
+        Long totalVisitCount = logService.findTotalVisitCount();
+        obj.put("totalVisitCount", totalVisitCount);
+        Long todayVisitCount = logService.findTodayVisitCount(dayStart, dayEnd);
+        obj.put("todayVisitCount", todayVisitCount);
+        Long todayIp = logService.findTodayIp(dayStart, dayEnd);
+        //update-end--Author:zhangweijian  Date:20190428 for:传入开始时间,结束时间参数
+        obj.put("todayIp", todayIp);
+        result.setResult(obj);
+        result.success("登录成功");
+        return result;
+    }
+
+    /**
+     * 获取访问量
+     *
+     * @return
+     */
+    @GetMapping("visitInfo")
+    public Result<List<Map<String, Object>>> visitInfo() {
+        Result<List<Map<String, Object>>> result = new Result<List<Map<String, Object>>>();
+        Calendar calendar = new GregorianCalendar();
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
         calendar.add(Calendar.DAY_OF_MONTH, 1);
         Date dayEnd = calendar.getTime();
         calendar.add(Calendar.DAY_OF_MONTH, -7);
         Date dayStart = calendar.getTime();
-        List<Map<String,Object>> list = logService.findVisitCount(dayStart, dayEnd);
-		result.setResult(oConvertUtils.toLowerCasePageList(list));
-		return result;
-	}
-	
-	
-	/**
-	 * 登陆成功选择用户当前部门
-	 * @param user
-	 * @return
-	 */
-	@RequestMapping(value = "/selectDepart", method = RequestMethod.PUT)
-	public Result<?> selectDepart(@RequestBody SysUser user) {
-		String username = user.getUsername();
-		if(oConvertUtils.isEmpty(username)) {
-			LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
-			username = sysUser.getUsername();
-		}
-		String orgCode= user.getOrgCode();
-		this.sysUserService.updateUserDepart(username, orgCode);
-		return Result.ok();
-	}
+        List<Map<String, Object>> list = logService.findVisitCount(dayStart, dayEnd);
+        result.setResult(oConvertUtils.toLowerCasePageList(list));
+        return result;
+    }
+
+
+    /**
+     * 登陆成功选择用户当前部门
+     *
+     * @param user
+     * @return
+     */
+    @RequestMapping(value = "/selectDepart", method = RequestMethod.PUT)
+    public Result<?> selectDepart(@RequestBody SysUser user) {
+        String username = user.getUsername();
+        if (oConvertUtils.isEmpty(username)) {
+            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            username = sysUser.getUsername();
+        }
+        String orgCode = user.getOrgCode();
+        this.sysUserService.updateUserDepart(username, orgCode);
+        return Result.ok();
+    }
+
+    /**
+     * 短信登录接口
+     *
+     * @param jsonObject
+     * @return
+     */
+    @PostMapping(value = "/sms")
+    public Result<String> sms(@RequestBody JSONObject jsonObject) {
+        Result<String> result = new Result<String>();
+        String mobile = jsonObject.get("mobile").toString();
+        String smsmode = jsonObject.get("smsmode").toString();
+        log.info(mobile);
+        Object object = redisUtil.get(mobile);
+        if (object != null) {
+            result.setMessage("验证码10分钟内,仍然有效!");
+            result.setSuccess(false);
+            return result;
+        }
+
+        //随机数
+        String captcha = RandomUtil.randomNumbers(6);
+        try {
+            boolean b = false;
+            //注册模板
+            if (CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)) {
+                SysUser sysUser = sysUserService.getUserByPhone(mobile);
+                if (sysUser != null) {
+                    result.error500(" 手机号已经注册,请直接登录!");
+                    sysBaseAPI.addLog("手机号已经注册,请直接登录!", CommonConstant.LOG_TYPE_1, null);
+                    return result;
+                }
+                b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.REGISTER_TEMPLATE_CODE);
+            } else {
+                //登录模式,校验用户有效性
+                SysUser sysUser = sysUserService.getUserByPhone(mobile);
+                result = sysUserService.checkUserIsEffective(sysUser);
+                if (!result.isSuccess()) {
+                    return result;
+                }
+
+                /**
+                 * smsmode 短信模板方式  0 .登录模板、1.注册模板、2.忘记密码模板
+                 */
+                if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
+                    //登录模板
+                    b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.LOGIN_TEMPLATE_CODE);
+                } else if (CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
+                    //忘记密码模板
+                    b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.FORGET_PASSWORD_TEMPLATE_CODE);
+                }
+            }
+
+            if (b == false) {
+                result.setMessage("短信验证码发送失败,请稍后重试");
+                result.setSuccess(false);
+                return result;
+            }
+            //验证码10分钟内有效
+            redisUtil.set(mobile, captcha, 600);
+            result.setResult(captcha);
+            result.setSuccess(true);
 
-	/**
-	 * 短信登录接口
-	 * 
-	 * @param jsonObject
-	 * @return
-	 */
-	@PostMapping(value = "/sms")
-	public Result<String> sms(@RequestBody JSONObject jsonObject) {
-		Result<String> result = new Result<String>();
-		String mobile = jsonObject.get("mobile").toString();
-		String smsmode=jsonObject.get("smsmode").toString();
-		log.info(mobile);	
-		Object object = redisUtil.get(mobile);
-		if (object != null) {
-			result.setMessage("验证码10分钟内,仍然有效!");
-			result.setSuccess(false);
-			return result;
-		}
+        } catch (ClientException e) {
+            e.printStackTrace();
+        }
+        return result;
+    }
 
-		//随机数
-		String captcha = RandomUtil.randomNumbers(6);
-		try {
-			boolean b = false;
-			//注册模板
-			if (CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)) {
-				SysUser sysUser = sysUserService.getUserByPhone(mobile);
-				if(sysUser!=null) {
-					result.error500(" 手机号已经注册,请直接登录!");
-					sysBaseAPI.addLog("手机号已经注册,请直接登录!", CommonConstant.LOG_TYPE_1, null);
-					return result;
-				}
-				b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.REGISTER_TEMPLATE_CODE);
-			}else {
-				//登录模式,校验用户有效性
-				SysUser sysUser = sysUserService.getUserByPhone(mobile);
-				result = sysUserService.checkUserIsEffective(sysUser);
-				if(!result.isSuccess()) {
-					return result;
-				}
-				
-				/**
-				 * smsmode 短信模板方式  0 .登录模板、1.注册模板、2.忘记密码模板
-				 */
-				if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
-					//登录模板
-					b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.LOGIN_TEMPLATE_CODE);
-				} else if(CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
-					//忘记密码模板
-					b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.FORGET_PASSWORD_TEMPLATE_CODE);
-				}
-			}
 
-			if (b == false) {
-				result.setMessage("短信验证码发送失败,请稍后重试");
-				result.setSuccess(false);
-				return result;
-			}
-			//验证码10分钟内有效
-			redisUtil.set(mobile, captcha, 600);
-			result.setResult(captcha);
-			result.setSuccess(true);
+    /**
+     * 手机号登录接口
+     *
+     * @param jsonObject
+     * @return
+     */
+    @PostMapping("/phoneLogin")
+    public Result<JSONObject> login(@RequestBody JSONObject jsonObject) {
+        Result<JSONObject> result = new Result<JSONObject>();
+        String phone = jsonObject.getString("mobile");
 
-		} catch (ClientException e) {
-			e.printStackTrace();
-		}
-		return result;
-	}
-	
+        //校验用户有效性
+        SysUser sysUser = sysUserService.getUserByPhone(phone);
+        result = sysUserService.checkUserIsEffective(sysUser);
+        if (!result.isSuccess()) {
+            return result;
+        }
 
-	/**
-	 * 手机号登录接口
-	 * 
-	 * @param jsonObject
-	 * @return
-	 */
-	@PostMapping("/phoneLogin")
-	public Result<JSONObject> login(@RequestBody JSONObject jsonObject) {
-		Result<JSONObject> result = new Result<JSONObject>();
-		String phone = jsonObject.getString("mobile");
-		
-		//校验用户有效性
-		SysUser sysUser = sysUserService.getUserByPhone(phone);
-		result = sysUserService.checkUserIsEffective(sysUser);
-		if(!result.isSuccess()) {
-			return result;
-		}
-		
-		String smscode = jsonObject.getString("captcha");
-		Object code = redisUtil.get(phone);
-		if (!smscode.equals(code)) {
-			result.setMessage("手机验证码错误");
-			return result;
-		}
-		//用户信息
-		userInfo(sysUser, result);
-		//添加日志
-		sysBaseAPI.addLog("用户名: " + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
+        String smscode = jsonObject.getString("captcha");
+        Object code = redisUtil.get(phone);
+        if (!smscode.equals(code)) {
+            result.setMessage("手机验证码错误");
+            return result;
+        }
+        //用户信息
+        userInfo(sysUser, result);
+        //添加日志
+        sysBaseAPI.addLog("用户名: " + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
 
-		return result;
-	}
+        return result;
+    }
 
 
-	/**
-	 * 用户信息
-	 *
-	 * @param sysUser
-	 * @param result
-	 * @return
-	 */
-	private Result<JSONObject> userInfo(SysUser sysUser, Result<JSONObject> result) {
-		String syspassword = sysUser.getPassword();
-		String username = sysUser.getUsername();
-		// 生成token
-		String token = JwtUtil.sign(username, syspassword);
-		redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
-		// 设置超时时间
-		redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
+    /**
+     * 用户信息
+     *
+     * @param sysUser
+     * @param result
+     * @return
+     */
+    private Result<JSONObject> userInfo(SysUser sysUser, Result<JSONObject> result) {
+        String syspassword = sysUser.getPassword();
+        String username = sysUser.getUsername();
+        // 生成token
+        String token = JwtUtil.sign(username, syspassword);
+        redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
+        // 设置超时时间
+        redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
 
-		// 获取用户部门信息
-		JSONObject obj = new JSONObject();
-		List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
-		obj.put("departs", departs);
-		if (departs == null || departs.size() == 0) {
-			obj.put("multi_depart", 0);
-		} else if (departs.size() == 1) {
-			sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
-			obj.put("multi_depart", 1);
-		} else {
-			obj.put("multi_depart", 2);
-		}
-		obj.put("token", token);
-		obj.put("userInfo", sysUser);
-		result.setResult(obj);
-		result.success("登录成功");
-		return result;
-	}
+        // 获取用户部门信息
+        JSONObject obj = new JSONObject();
+        List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
+        obj.put("departs", departs);
+        if (departs == null || departs.size() == 0) {
+            obj.put("multi_depart", 0);
+        } else if (departs.size() == 1) {
+            sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
+            obj.put("multi_depart", 1);
+        } else {
+            obj.put("multi_depart", 2);
+        }
+        obj.put("token", token);
+        obj.put("userInfo", sysUser);
+        result.setResult(obj);
+        result.success("登录成功");
+        return result;
+    }
 
-	/**
-	 * 获取加密字符串
-	 * @return
-	 */
-	@GetMapping(value = "/getEncryptedString")
-	public Result<Map<String,String>> getEncryptedString(){
-		Result<Map<String,String>> result = new Result<Map<String,String>>();
-		Map<String,String> map = new HashMap<String,String>();
-		map.put("key", EncryptedString.key);
-		map.put("iv",EncryptedString.iv);
-		result.setResult(map);
-		return result;
-	}
+    /**
+     * 获取加密字符串
+     *
+     * @return
+     */
+    @GetMapping(value = "/getEncryptedString")
+    public Result<Map<String, String>> getEncryptedString() {
+        Result<Map<String, String>> result = new Result<Map<String, String>>();
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("key", EncryptedString.key);
+        map.put("iv", EncryptedString.iv);
+        result.setResult(map);
+        return result;
+    }
 }

+ 8 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/SysUser.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.system.entity;
 
 import java.util.Date;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import org.jeecg.common.aspect.annotation.Dict;
 import org.jeecgframework.poi.excel.annotation.Excel;
@@ -77,7 +78,7 @@ public class SysUser implements Serializable {
     /**
      * 性别(1:男 2:女)
      */
-    @Excel(name = "性别", width = 15,dicCode="sex")
+    @Excel(name = "性别", width = 15, dicCode = "sex")
     @Dict(dicCode = "sex")
     private Integer sex;
 
@@ -101,14 +102,14 @@ public class SysUser implements Serializable {
     /**
      * 状态(1:正常  2:冻结 )
      */
-    @Excel(name = "状态", width = 15,dicCode="user_status")
+    @Excel(name = "状态", width = 15, dicCode = "user_status")
     @Dict(dicCode = "user_status")
     private Integer status;
 
     /**
      * 删除状态(0,正常,1已删除)
      */
-    @Excel(name = "删除状态", width = 15,dicCode="del_flag")
+    @Excel(name = "删除状态", width = 15, dicCode = "del_flag")
     @TableLogic
     private String delFlag;
 
@@ -137,4 +138,8 @@ public class SysUser implements Serializable {
     private String activitiSync;
 
 
+    @TableField(exist = false)
+    private String departId;
+
+
 }

+ 26 - 12
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysDepartService.java

@@ -3,64 +3,78 @@ package org.jeecg.modules.system.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.system.entity.SysDepart;
 import org.jeecg.modules.system.model.SysDepartTreeModel;
+
 import java.util.List;
 
 /**
  * <p>
  * 部门表 服务实现类
  * <p>
- * 
+ *
  * @Author:Steve
- * @Since:   2019-01-22
+ * @Since: 2019-01-22
  */
-public interface ISysDepartService extends IService<SysDepart>{
+public interface ISysDepartService extends IService<SysDepart> {
 
 
     /**
      * 查询所有部门信息,并分节点进行显示
+     *
      * @return
      */
     List<SysDepartTreeModel> queryTreeList();
 
     /**
      * 保存部门数据
+     *
      * @param sysDepart
      */
-    void saveDepartData(SysDepart sysDepart,String username);
+    void saveDepartData(SysDepart sysDepart, String username);
 
     /**
      * 更新depart数据
+     *
      * @param sysDepart
      * @return
      */
-    Boolean updateDepartDataById(SysDepart sysDepart,String username);
-    
+    Boolean updateDepartDataById(SysDepart sysDepart, String username);
+
     /**
      * 删除depart数据
      * @param id
      * @return
      */
-	/* boolean removeDepartDataById(String id); */
-    
+    /* boolean removeDepartDataById(String id); */
+
     /**
      * 根据关键字搜索相关的部门数据
+     *
      * @param keyWord
      * @return
      */
     List<SysDepartTreeModel> searhBy(String keyWord);
-    
+
     /**
      * 根据部门id删除并删除其可能存在的子级部门
+     *
      * @param id
      * @return
      */
     boolean delete(String id);
-    
+
     /**
      * 查询SysDepart集合
+     *
      * @param userId
      * @return
      */
-	public List<SysDepart> queryUserDeparts(String userId);
-    
+    public List<SysDepart> queryUserDeparts(String userId);
+
+    /**
+     * 查询departId
+     *
+     * @param orgCode
+     * @return
+     */
+    String selectIdByOrdCode(String orgCode);
 }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 218 - 199
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysDepartServiceImpl.java


+ 1 - 1
jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -90,7 +90,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://192.168.1.21:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          url: jdbc:mysql://192.168.0.23:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           password: 123456
           driver-class-name: com.mysql.jdbc.Driver