智慧保安后台管理-外网项目备份
guoshilong
2024-01-04 60a4193a0921393e1b42cef4313e844103681cfd
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
package org.springblade.modules.system.service.impl;
 
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.DigestUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.system.entity.UserWx;
import org.springblade.modules.system.mapper.UserWxMapper;
import org.springblade.modules.system.service.IUserWxService;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
public class UserWxServiceImpl extends BaseServiceImpl<UserWxMapper, UserWx> implements IUserWxService {
    @Override
    public Boolean wxRegister(UserWx user) {
 
        //密码加密
        if (Func.isNotEmpty(user.getPassword())) {
            user.setPassword(DigestUtil.encrypt(user.getPassword()));
        }
 
        UserWx params = new UserWx();
        params.setCardid(user.getCardid());
        //查看数据库是否有相同身份证号
        List<UserWx> list = list(Condition.getQueryWrapper(params));
        if (list.size()>0){
            throw new ServiceException("该身份证号已注册");
        }
 
        //注册新用户
        user.setAccount(user.getPhone());
        //微信注册角色
        user.setRoleId("1734015564173127681");
        //微信注册机构
        user.setDeptId("1734016112398020609");
        user.setTenantId("000000");
        if (StringUtil.isNotBlank(user.getRealName())){
            user.setName(user.getRealName());
        }else{
            user.setName("微信用户"+user.getPhone());
            user.setRealName("微信用户"+user.getPhone());
        }
        boolean save = save(user);
        return save;
    }
 
    @Override
    public UserWx getUserWx(String tenantId, String account, String password) {
        return baseMapper.getUserWx(tenantId, account, password);
    }
}