1
This commit is contained in:
parent
43420aa8b2
commit
ab93f86dd2
@ -81,9 +81,8 @@ public class CustomerMainController {
|
||||
|
||||
@PostMapping("/saveCustomerAndCar")
|
||||
@Operation(summary = "保存客户及车辆信息")
|
||||
public CommonResult<Boolean> saveCustomerAndCar(@RequestBody CustomerMainSaveReqVO saveReqVO) throws Exception {
|
||||
customerCarService.saveCustomerAndCar(saveReqVO);
|
||||
return success(true);
|
||||
public CommonResult<?> saveCustomerAndCar(@RequestBody CustomerMainSaveReqVO saveReqVO) throws Exception {
|
||||
return CommonResult.success(customerCarService.saveCustomerAndCar(saveReqVO));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 客户车辆管理关联Service 接口
|
||||
@ -34,5 +35,5 @@ public interface CustomerCarService extends IService<CustomerCar> {
|
||||
* @param saveReqVO CustomerMainSaveReqVO
|
||||
* @return void
|
||||
**/
|
||||
void saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception;
|
||||
Map<String,String> saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception;
|
||||
}
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.custom.service.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.custom.entity.CarMain;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerCar;
|
||||
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
|
||||
@ -23,7 +25,9 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.common.BaseConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS;
|
||||
@ -93,8 +97,10 @@ public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, Custo
|
||||
* @date 15:51 2024/11/12
|
||||
**/
|
||||
@Override
|
||||
public void saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception {
|
||||
public Map<String,String> saveCustomerAndCar(CustomerMainSaveReqVO saveReqVO) throws Exception {
|
||||
Map<String,String> rtnMap = new HashMap<>();
|
||||
chekData(saveReqVO);
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
saveReqVO.getCar().setLicenseNumber(saveReqVO.getCar().getLicenseNumber().toUpperCase());
|
||||
//用户信息
|
||||
AdminUserRespDTO userDTO = adminUserApi.getUserByUsername(saveReqVO.getPhoneNumber());
|
||||
@ -108,6 +114,7 @@ public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, Custo
|
||||
user.setPassword(PASSWORD_DEFAULT);
|
||||
user.setMobile(saveReqVO.getPhoneNumber());
|
||||
user.setUserType(USER_TYPE_CUS);
|
||||
user.setTenantId(loginUser.getTenantId());
|
||||
//创建用户
|
||||
Long userId = adminUserApi.createUser(user);
|
||||
saveReqVO.setUserId(userId);
|
||||
@ -127,6 +134,8 @@ public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, Custo
|
||||
//默认车主
|
||||
customerCar.setIsOwner("1");
|
||||
this.save(customerCar);
|
||||
rtnMap.put("userId",userId.toString());
|
||||
rtnMap.put("carId",carMain.getId());
|
||||
} else {
|
||||
//已有 用户
|
||||
Long userId = userDTO.getId();
|
||||
@ -155,7 +164,10 @@ public class CustomerCarServiceImpl extends ServiceImpl<CustomerCarMapper, Custo
|
||||
customerCar.setIsOwner("1");
|
||||
this.save(customerCar);
|
||||
}
|
||||
rtnMap.put("userId",userId.toString());
|
||||
rtnMap.put("carId",carMain.getId());
|
||||
}
|
||||
return rtnMap;
|
||||
}
|
||||
|
||||
private void chekData(CustomerMainSaveReqVO saveReqVO) throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user