|
@@ -30,7 +30,7 @@ public class FeishuAccountController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICompanyUserService companyUserService;
|
|
private ICompanyUserService companyUserService;
|
|
|
|
|
|
|
|
- /** 鎴戠殑椋炰功璐﹀彿鍒楄〃锛堝綋鍓嶇敤鎴锋暟鎹�級 */
|
|
|
|
|
|
|
+ /** ??????????б??????????????? */
|
|
|
@GetMapping("/my/list")
|
|
@GetMapping("/my/list")
|
|
|
public TableDataInfo myList(@RequestParam(required = false) Integer status,
|
|
public TableDataInfo myList(@RequestParam(required = false) Integer status,
|
|
|
@RequestParam(required = false) String phone,
|
|
@RequestParam(required = false) String phone,
|
|
@@ -44,7 +44,7 @@ public class FeishuAccountController extends BaseController {
|
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 浼佷笟椋炰功璐﹀彿鍒楄〃锛堢�鐞嗗憳鏌ョ湅/鍒嗛厤锛� */
|
|
|
|
|
|
|
+ /** ???????????б?????????????/?????? */
|
|
|
@GetMapping("/company/list")
|
|
@GetMapping("/company/list")
|
|
|
public TableDataInfo companyList(@RequestParam(required = false) Integer status,
|
|
public TableDataInfo companyList(@RequestParam(required = false) Integer status,
|
|
|
@RequestParam(required = false) String phone,
|
|
@RequestParam(required = false) String phone,
|
|
@@ -86,8 +86,8 @@ public class FeishuAccountController extends BaseController {
|
|
|
return AjaxResult.success(account);
|
|
return AjaxResult.success(account);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 鎴戠殑椋炰功璐﹀彿 - 鏂板� */
|
|
|
|
|
- @Log(title = "鎴戠殑椋炰功璐﹀彿", businessType = BusinessType.INSERT)
|
|
|
|
|
|
|
+ /** ????????? - ????? */
|
|
|
|
|
+ @Log(title = "?????????", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/my")
|
|
@PostMapping("/my")
|
|
|
public AjaxResult addMy(@RequestBody FeishuAccount account) {
|
|
public AjaxResult addMy(@RequestBody FeishuAccount account) {
|
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
@@ -97,28 +97,51 @@ public class FeishuAccountController extends BaseController {
|
|
|
return toAjax(feishuAccountService.insertFeishuAccount(account));
|
|
return toAjax(feishuAccountService.insertFeishuAccount(account));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 浼佷笟椋炰功璐﹀彿 - 鏂板�骞跺垎閰嶉攢鍞� */
|
|
|
|
|
- @Log(title = "椋炰功璐﹀彿绠$悊", businessType = BusinessType.INSERT)
|
|
|
|
|
|
|
+ /** ????????? - ???????? */
|
|
|
|
|
+ @Log(title = "?????????", businessType = BusinessType.INSERT)
|
|
|
|
|
+ @PostMapping("/my/batch")
|
|
|
|
|
+ public AjaxResult addMyBatch(@RequestBody List<FeishuAccount> accounts) {
|
|
|
|
|
+ CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
|
+ prepareBatchAccounts(accounts, user.getCompanyId(), false);
|
|
|
|
|
+ for (FeishuAccount account : accounts) {
|
|
|
|
|
+ account.setCompanyUserId(user.getUserId());
|
|
|
|
|
+ }
|
|
|
|
|
+ int count = feishuAccountService.insertFeishuAccountBatch(accounts);
|
|
|
|
|
+ return AjaxResult.success("??????? " + count + " ?????");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /** ?????????? - ?????????????? */
|
|
|
|
|
+ @Log(title = "??????????", businessType = BusinessType.INSERT)
|
|
|
@PostMapping("/company")
|
|
@PostMapping("/company")
|
|
|
public AjaxResult addCompany(@RequestBody FeishuAccount account) {
|
|
public AjaxResult addCompany(@RequestBody FeishuAccount account) {
|
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
account.setCompanyId(user.getCompanyId());
|
|
account.setCompanyId(user.getCompanyId());
|
|
|
if (account.getCompanyUserId() == null) {
|
|
if (account.getCompanyUserId() == null) {
|
|
|
- throw new CustomException("璇烽€夋嫨閿€鍞�汉鍛�");
|
|
|
|
|
|
|
+ throw new CustomException("????????????");
|
|
|
}
|
|
}
|
|
|
requireCompanyUser(account.getCompanyUserId(), user.getCompanyId());
|
|
requireCompanyUser(account.getCompanyUserId(), user.getCompanyId());
|
|
|
validateAccountPayload(account, true);
|
|
validateAccountPayload(account, true);
|
|
|
return toAjax(feishuAccountService.insertFeishuAccount(account));
|
|
return toAjax(feishuAccountService.insertFeishuAccount(account));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** ?????????? - ?????????????????? */
|
|
|
|
|
+ @Log(title = "??????????", businessType = BusinessType.INSERT)
|
|
|
|
|
+ @PostMapping("/company/batch")
|
|
|
|
|
+ public AjaxResult addCompanyBatch(@RequestBody List<FeishuAccount> accounts) {
|
|
|
|
|
+ CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
|
|
+ prepareBatchAccounts(accounts, user.getCompanyId(), true);
|
|
|
|
|
+ int count = feishuAccountService.insertFeishuAccountBatch(accounts);
|
|
|
|
|
+ return AjaxResult.success("??????? " + count + " ?????");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Log(title = "Feishu account", businessType = BusinessType.INSERT)
|
|
@Log(title = "Feishu account", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
public AjaxResult add(@RequestBody FeishuAccount account) {
|
|
public AjaxResult add(@RequestBody FeishuAccount account) {
|
|
|
return addMy(account);
|
|
return addMy(account);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 鎴戠殑椋炰功璐﹀彿 - 缂栬緫 */
|
|
|
|
|
- @Log(title = "鎴戠殑椋炰功璐﹀彿", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
|
+ /** ????????? - ?? */
|
|
|
|
|
+ @Log(title = "?????????", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/my")
|
|
@PutMapping("/my")
|
|
|
public AjaxResult editMy(@RequestBody FeishuAccount account) {
|
|
public AjaxResult editMy(@RequestBody FeishuAccount account) {
|
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
@@ -130,8 +153,8 @@ public class FeishuAccountController extends BaseController {
|
|
|
return toAjax(feishuAccountService.updateFeishuAccount(account));
|
|
return toAjax(feishuAccountService.updateFeishuAccount(account));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /** 浼佷笟椋炰功璐﹀彿 - 缂栬緫/閲嶆柊鍒嗛厤 */
|
|
|
|
|
- @Log(title = "椋炰功璐﹀彿绠$悊", businessType = BusinessType.UPDATE)
|
|
|
|
|
|
|
+ /** ?????????? - ??/???·??? */
|
|
|
|
|
+ @Log(title = "??????????", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping("/company")
|
|
@PutMapping("/company")
|
|
|
public AjaxResult editCompany(@RequestBody FeishuAccount account) {
|
|
public AjaxResult editCompany(@RequestBody FeishuAccount account) {
|
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
@@ -153,7 +176,7 @@ public class FeishuAccountController extends BaseController {
|
|
|
return editMy(account);
|
|
return editMy(account);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Log(title = "鎴戠殑椋炰功璐﹀彿", businessType = BusinessType.DELETE)
|
|
|
|
|
|
|
+ @Log(title = "?????????", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/my/{id}")
|
|
@DeleteMapping("/my/{id}")
|
|
|
public AjaxResult removeMy(@PathVariable Long id) {
|
|
public AjaxResult removeMy(@PathVariable Long id) {
|
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
@@ -162,7 +185,7 @@ public class FeishuAccountController extends BaseController {
|
|
|
return toAjax(feishuAccountService.deleteFeishuAccountById(id));
|
|
return toAjax(feishuAccountService.deleteFeishuAccountById(id));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Log(title = "椋炰功璐﹀彿绠$悊", businessType = BusinessType.DELETE)
|
|
|
|
|
|
|
+ @Log(title = "??????????", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/company/{id}")
|
|
@DeleteMapping("/company/{id}")
|
|
|
public AjaxResult removeCompany(@PathVariable Long id) {
|
|
public AjaxResult removeCompany(@PathVariable Long id) {
|
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
CompanyUser user = SecurityUtils.getLoginUser().getUser();
|
|
@@ -193,10 +216,10 @@ public class FeishuAccountController extends BaseController {
|
|
|
|
|
|
|
|
private void validateAccountPayload(FeishuAccount account, boolean requireSecret) {
|
|
private void validateAccountPayload(FeishuAccount account, boolean requireSecret) {
|
|
|
if (StringUtils.isBlank(account.getAppId())) {
|
|
if (StringUtils.isBlank(account.getAppId())) {
|
|
|
- throw new CustomException("AppId涓嶈兘涓虹┖");
|
|
|
|
|
|
|
+ throw new CustomException("AppId???????");
|
|
|
}
|
|
}
|
|
|
if (requireSecret && StringUtils.isBlank(account.getAppSecret())) {
|
|
if (requireSecret && StringUtils.isBlank(account.getAppSecret())) {
|
|
|
- throw new CustomException("AppSecret涓嶈兘涓虹┖");
|
|
|
|
|
|
|
+ throw new CustomException("AppSecret???????");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -209,7 +232,27 @@ public class FeishuAccountController extends BaseController {
|
|
|
private void requireCompanyUser(Long companyUserId, Long companyId) {
|
|
private void requireCompanyUser(Long companyUserId, Long companyId) {
|
|
|
CompanyUser companyUser = companyUserService.selectCompanyUserById(companyUserId);
|
|
CompanyUser companyUser = companyUserService.selectCompanyUserById(companyUserId);
|
|
|
if (companyUser == null || !companyId.equals(companyUser.getCompanyId())) {
|
|
if (companyUser == null || !companyId.equals(companyUser.getCompanyId())) {
|
|
|
- throw new CustomException("鎵€閫変汉鍛樹笉灞炰簬褰撳墠浼佷笟");
|
|
|
|
|
|
|
+ throw new CustomException("所选人员不属于当前企业");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void prepareBatchAccounts(List<FeishuAccount> accounts, Long companyId, boolean requireSales) {
|
|
|
|
|
+ if (accounts == null || accounts.isEmpty()) {
|
|
|
|
|
+ throw new CustomException("请至少添加一个账号");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long companyUserId = accounts.get(0).getCompanyUserId();
|
|
|
|
|
+ if (requireSales && companyUserId == null) {
|
|
|
|
|
+ throw new CustomException("请选择销售人员");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (requireSales) {
|
|
|
|
|
+ requireCompanyUser(companyUserId, companyId);
|
|
|
|
|
+ }
|
|
|
|
|
+ for (FeishuAccount account : accounts) {
|
|
|
|
|
+ account.setCompanyId(companyId);
|
|
|
|
|
+ if (requireSales) {
|
|
|
|
|
+ account.setCompanyUserId(companyUserId);
|
|
|
|
|
+ }
|
|
|
|
|
+ validateAccountPayload(account, true);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|