|
|
@@ -1,12 +1,23 @@
|
|
|
package com.fs.app.controller;
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.fs.app.params.LoginBindCompanyParam;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
+import com.fs.common.exception.base.BaseException;
|
|
|
+import com.fs.common.param.LoginParam;
|
|
|
+import com.fs.common.utils.PatternUtils;
|
|
|
+import com.fs.common.utils.SecurityUtils;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.company.domain.Company;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.param.CompanyUserCodeParam;
|
|
|
+import com.fs.company.service.ICompanyPostService;
|
|
|
+import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.qw.domain.QwExternalContactInfo;
|
|
|
import com.fs.qw.domain.QwTagGroup;
|
|
|
@@ -31,11 +42,11 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Slf4j
|
|
|
@Api(tags = "企微会员相关接口")
|
|
|
@@ -58,6 +69,15 @@ public class QwUserController extends BaseController {
|
|
|
@Autowired
|
|
|
private ICompanyUserService companyUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ ICompanyUserService userService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICompanyService companyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ICompanyPostService postService;
|
|
|
+
|
|
|
@GetMapping("/details")
|
|
|
@ApiOperation("会员看课详情")
|
|
|
public R getUserDetails(@ApiParam(value = "外部联系人id", required = true) @RequestParam Long contactId,
|
|
|
@@ -165,4 +185,45 @@ public class QwUserController extends BaseController {
|
|
|
public R registerCompany(@RequestBody CompanyUserCodeParam userCodeParam) {
|
|
|
return companyUserService.registerCompany(userCodeParam);
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/login")
|
|
|
+ @ApiOperation("密码登录")
|
|
|
+ public R login(@Validated @RequestBody LoginBindCompanyParam param) {
|
|
|
+
|
|
|
+ // 密码校验
|
|
|
+ if (!PatternUtils.checkPassword(param.getPassword())) {
|
|
|
+ return R.error("密码格式不正确,需包含字母、数字和特殊字符,长度为 8-20位");
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ //判断用户基本规则
|
|
|
+ CompanyUser companyUser = userService.selectUserByUserName(param.getAccount());
|
|
|
+ if (companyUser == null) {
|
|
|
+ return R.error("工号不存在");
|
|
|
+ }
|
|
|
+ if (companyUser.getStatus().equals("1")) {
|
|
|
+ return R.error("用户已禁用");
|
|
|
+ }
|
|
|
+ if (!SecurityUtils.matchesPassword(param.getPassword(), companyUser.getPassword())) {
|
|
|
+ return R.error("密码错误");
|
|
|
+ }
|
|
|
+ if (companyUser.getIsAudit() == 0) {
|
|
|
+ return R.error("用户未审核");
|
|
|
+ }
|
|
|
+
|
|
|
+ Company company = companyService.selectCompanyById(companyUser.getCompanyId());
|
|
|
+ if (company == null || company.getStatus() == 0 || company.getIsDel() == 1) {
|
|
|
+ throw new BaseException("此用户所属公司不存在或已停用");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(company.getCourseMiniAppId()) && !company.getCourseMiniAppId().equals(param.getAppid())){
|
|
|
+ return R.error("登录用户不属于该小程序");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok("验证成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("登录异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|