package com.example.northglasserpclient.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.example.northglasserpclient.domain.po.CustomerUserLogin;
|
import com.example.northglasserpclient.domain.po.sd.Customer;
|
import com.example.northglasserpclient.mapper.CustomerUserLoginMapper;
|
import com.example.northglasserpclient.service.ICustomerUserLoginService;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.example.northglasserpclient.service.sd.ICustomerService;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.stereotype.Service;
|
|
/**
|
* <p>
|
* 服务实现类
|
* </p>
|
*
|
* @author guo
|
* @since 2025-09-18
|
*/
|
@Service
|
@RequiredArgsConstructor
|
public class CustomerUserLoginServiceImpl extends ServiceImpl<CustomerUserLoginMapper, CustomerUserLogin> implements ICustomerUserLoginService {
|
private final ICustomerService customerService;
|
@Override
|
public CustomerUserLogin login(CustomerUserLogin customerUserLogin) {
|
CustomerUserLogin user = this.baseMapper.selectOne(
|
new QueryWrapper<CustomerUserLogin>().eq("login_name", customerUserLogin.getLoginName())
|
.eq("password", customerUserLogin.getPassword()));
|
if(user != null){
|
user.setPassword(null);
|
Customer customer = customerService.getById(user.getCustomerId());
|
if (customer != null){
|
user.setCustomerName(customer.getCustomerName());
|
}
|
|
return user;
|
}
|
return null;
|
}
|
|
@Override
|
public Boolean register(CustomerUserLogin customerUserLogin) {
|
CustomerUserLogin user = this.baseMapper.selectOne(
|
new QueryWrapper<CustomerUserLogin>()
|
.eq("login_name", customerUserLogin.getLoginName())
|
.or()
|
.eq("customer_id", customerUserLogin.getCustomerId())
|
);
|
|
if (user == null) {
|
save(customerUserLogin);
|
return true;
|
}
|
return false;
|
}
|
}
|