|
@@ -1,8 +1,20 @@
|
|
|
package com.fs.app.controller;
|
|
|
|
|
|
+import com.fs.app.params.LoginBindCompanyParam;
|
|
|
+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.utils.PatternUtils;
|
|
|
+import com.fs.common.utils.SecurityUtils;
|
|
|
+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.course.param.FsCourseListBySidebarParam;
|
|
|
import com.fs.qw.domain.QwExternalContactInfo;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
@@ -21,6 +33,7 @@ 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;
|
|
@@ -42,6 +55,19 @@ public class ApisQwUserController extends BaseController {
|
|
|
@Autowired
|
|
|
private ISopUserLogsInfoService iSopUserLogsInfoService;
|
|
|
|
|
|
+ @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,
|
|
@@ -116,4 +142,50 @@ public class ApisQwUserController extends BaseController {
|
|
|
return R.ok().put("data", result);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 注册或者绑定销售
|
|
|
+ */
|
|
|
+ @PostMapping("/registerCompany")
|
|
|
+ @Log(title = "注册或者绑定销售", businessType = BusinessType.INSERT)
|
|
|
+ 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("此用户所属公司不存在或已停用");
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok("验证成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.error("登录异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|