jiangqs
2023-06-28 a016ab9f97b76c3b4905b890662d344d47f24005
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.ruoyi.shop.service.impl.shop;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.shop.domain.pojo.shop.ShopRelUser;
import com.ruoyi.shop.mapper.shop.ShopRelUserMapper;
import com.ruoyi.shop.service.shop.ShopRelUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
/**
 * <p>
 * 商户关联员工 服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-04-25
 */
@Service
public class ShopRelUserServiceImpl extends ServiceImpl<ShopRelUserMapper, ShopRelUser> implements ShopRelUserService {
 
    @Resource
    private ShopRelUserMapper shopRelUserMapper;
 
    /**
     * 通过商户id删除关联
     * @param shopId
     */
    @Override
    public void deleteByShopId(Long shopId){
        shopRelUserMapper.deleteByShopId(shopId);
    }
 
    /**
     * 通过商户id获取关联用户
     * @param shopId
     * @return
     */
    @Override
    public List<ShopRelUser> listByShopId(Long shopId){
        LambdaQueryWrapper<ShopRelUser> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ShopRelUser::getDelFlag, 0).eq(ShopRelUser::getShopId, shopId);
        return this.list(queryWrapper);
    }
 
 
    /**
     *
     * @param userId
     * @return
     */
    @Override
    public ShopRelUser getByUserId(Long userId){
        LambdaQueryWrapper<ShopRelUser> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(ShopRelUser::getDelFlag, 0).eq(ShopRelUser::getUserId, userId);
        return this.getOne(queryWrapper,false);
    }
 
    /**
     * 通过用户id删除关联
     * @param userId
     */
    @Override
    public void deleteByUserId(Long userId){
        LambdaUpdateWrapper<ShopRelUser> updateWrapper = new LambdaUpdateWrapper();
        updateWrapper.set(ShopRelUser::getDelFlag,1);
        updateWrapper.eq(ShopRelUser::getUserId,userId);
        updateWrapper.eq(ShopRelUser::getDelFlag,0);
        this.update(updateWrapper);
    }
}