| | |
| | | package org.springblade.modules.system.service.impl; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.flowable.idm.engine.impl.persistence.entity.UserEntity; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.common.cache.DictCache; |
| | | import org.springblade.common.cache.ParamCache; |
| | | import org.springblade.common.cache.SysCache; |
| | |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.constant.TenantConstant; |
| | | import org.springblade.common.enums.DictEnum; |
| | | import org.springblade.common.utils.SpinLockUtil; |
| | | 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.support.Kv; |
| | | import org.springblade.core.tool.utils.*; |
| | | import org.springblade.modules.auth.enums.UserEnum; |
| | | import org.springblade.modules.community.entity.CommunityEntity; |
| | | import org.springblade.modules.community.service.ICommunityService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springblade.modules.house.entity.HouseholdEntity; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.house.vo.HouseholdVO; |
| | | import org.springblade.modules.police.entity.PoliceAffairsGridEntity; |
| | | import org.springblade.modules.police.service.IPoliceAffairsGridService; |
| | | import org.springblade.modules.property.entity.PropertyCompanyEntity; |
| | |
| | | import org.springblade.modules.system.vo.UserDetailVO; |
| | | import org.springblade.modules.system.vo.UserVO; |
| | | import org.springblade.modules.system.wrapper.UserWrapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implements IUserService { |
| | | |
| | | private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class); |
| | | |
| | | private static final String GUEST_NAME = "guest"; |
| | | |
| | | private final IUserDeptService userDeptService; |
| | |
| | | private final IDeptService deptService; |
| | | private final BladeTenantProperties tenantProperties; |
| | | private final IPoliceAffairsGridService policeAffairsGridService; |
| | | |
| | | @Autowired |
| | | private SpinLockUtil spinLockUtil; |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | |
| | | private boolean submitUserDept(User user) { |
| | | List<Long> deptIdList = Func.toLongList(user.getDeptId()); |
| | | List<UserDept> userDeptList = new ArrayList<>(); |
| | | deptIdList.forEach(deptId -> { |
| | | UserDept userDept = new UserDept(); |
| | | userDept.setUserId(user.getId()); |
| | | userDept.setDeptId(deptId); |
| | | userDeptList.add(userDept); |
| | | }); |
| | | userDeptService.remove(Wrappers.<UserDept>update().lambda().eq(UserDept::getUserId, user.getId())); |
| | | boolean b = userDeptService.saveBatch(userDeptList); |
| | | return b; |
| | | try { |
| | | // 加锁 |
| | | boolean isLock = spinLockUtil.tryLock(user.getId().toString()); |
| | | boolean result = false; |
| | | List<Long> deptIdList = Func.toLongList(user.getDeptId()); |
| | | List<UserDept> userDeptList = new ArrayList<>(); |
| | | deptIdList.forEach(deptId -> { |
| | | UserDept userDept = new UserDept(); |
| | | userDept.setUserId(user.getId()); |
| | | userDept.setDeptId(deptId); |
| | | userDeptList.add(userDept); |
| | | }); |
| | | // 是否加锁成功 |
| | | logger.info("是否加锁成功:" + isLock); |
| | | if (isLock) { |
| | | userDeptService.remove(Wrappers.<UserDept>update().lambda().eq(UserDept::getUserId, user.getId())); |
| | | result = userDeptService.saveBatch(userDeptList); |
| | | } |
| | | // 释放锁 |
| | | spinLockUtil.unlock(user.getId().toString()); |
| | | return result; |
| | | } catch (Exception e) { |
| | | // 释放锁 |
| | | spinLockUtil.unlock(user.getId().toString()); |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IPage<User> selectUserPage(IPage<User> page, User user, String deptId, String tenantId) { |
| | |
| | | } |
| | | |
| | | user.setPassword(DigestUtil.encrypt(user.getPassword())); |
| | | user.setRoleId("1759487358708310017"); |
| | | user.setRoleId("1717429059648606209"); |
| | | boolean oauthTemp = save(user); |
| | | return (oauthTemp); |
| | | } |