|
@@ -8,6 +8,7 @@ import com.alibaba.excel.context.AnalysisContext;
|
|
|
import com.alibaba.excel.event.AnalysisEventListener;
|
|
import com.alibaba.excel.event.AnalysisEventListener;
|
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
import com.alibaba.excel.support.ExcelTypeEnum;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
+import com.cyksj.common.annotation.NoSubmit;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
@@ -164,9 +165,19 @@ public class CmsAccountController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/post")
|
|
@PostMapping("/post")
|
|
|
|
|
+ @NoSubmit
|
|
|
public Result<String> add(@RequestBody Account account){
|
|
public Result<String> add(@RequestBody Account account){
|
|
|
account.setAccount(account.getAccount().trim());
|
|
account.setAccount(account.getAccount().trim());
|
|
|
account.setPassword(account.getPassword().trim());
|
|
account.setPassword(account.getPassword().trim());
|
|
|
|
|
+ //账号是否已经添加过
|
|
|
|
|
+ if (!account.getAccount().contains("客服")) {
|
|
|
|
|
+ int count = accountService.count(Wrappers.lambdaQuery(Account.class)
|
|
|
|
|
+ .eq(Account::getAccount, account.getAccount())
|
|
|
|
|
+ .eq(Account::getGoodsId, account.getGoodsId()));
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("该平台下已生成该账号");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
accountService.save(account);
|
|
accountService.save(account);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
}
|
|
@@ -185,6 +196,11 @@ public class CmsAccountController {
|
|
|
|
|
|
|
|
@DeleteMapping("/delete/{id}")
|
|
@DeleteMapping("/delete/{id}")
|
|
|
public Result<String> update(@PathVariable Long id){
|
|
public Result<String> update(@PathVariable Long id){
|
|
|
|
|
+ //是否关联了车队
|
|
|
|
|
+ Integer count = groupsMapper.selectCount(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getAccountId, id));
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("已经发布账号,必须先删除车队才可删除账号");
|
|
|
|
|
+ }
|
|
|
accountService.removeById(id);
|
|
accountService.removeById(id);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
}
|