guoyujie
2025-10-13 a3ef00def72882e9f28f2813a861c477220dab2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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;
    }
}