You've already forked FrameTour-BE
支持用户切换景区账号,单账号多景区权限
This commit is contained in:
@@ -16,4 +16,6 @@ public interface ScenicAccountService {
|
||||
List<ScenicAccountEntity> pageQuery(ScenicAccountReqQuery req);
|
||||
|
||||
int updateStatus(Long id);
|
||||
|
||||
ScenicAccountEntity getScenicAccountByAccount(String account);
|
||||
}
|
@@ -130,7 +130,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
}
|
||||
}
|
||||
LoginRespVO loginRespVO = new LoginRespVO();
|
||||
String token = jwtTokenUtil.generateToken(new JwtInfo(login.getStaffName(), login.getStaffId(), roleId, login.getAccount(), login.getAccount(), null,null));
|
||||
String token = jwtTokenUtil.generateToken(new JwtInfo(login.getStaffName(), login.getStaffId(), roleId, login.getAccount(), login.getAccount(), null));
|
||||
loginRespVO.setToken(token);
|
||||
loginRespVO.setName(login.getStaffName());
|
||||
loginRespVO.setTypeName(login.getTypeName());
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.service.pc.impl;
|
||||
|
||||
import com.ycwl.basic.exception.BaseException;
|
||||
import com.ycwl.basic.model.pc.scenic.entity.ScenicAccountEntity;
|
||||
import com.ycwl.basic.model.pc.scenic.req.ScenicAccountReqQuery;
|
||||
import com.ycwl.basic.service.pc.ScenicAccountService;
|
||||
@@ -30,12 +31,23 @@ public class ScenicAccountServiceImpl implements ScenicAccountService {
|
||||
|
||||
@Override
|
||||
public int updateScenicAccount(ScenicAccountEntity entity) {
|
||||
return mapper.update(entity);
|
||||
if (entity.getId() == null) {
|
||||
throw new BaseException("参数错误");
|
||||
}
|
||||
int update = mapper.update(entity);
|
||||
mapper.deleteRelationById(entity.getId());
|
||||
entity.getScenicId().forEach(scenicId -> {
|
||||
mapper.addAccountScenicRelation(entity.getId(), scenicId, entity.getIsSuper());
|
||||
});
|
||||
return update;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScenicAccountEntity getScenicAccountById(Long id) {
|
||||
return mapper.findAccountById(String.valueOf(id));
|
||||
ScenicAccountEntity account = mapper.findAccountById(String.valueOf(id));
|
||||
List<Long> scenicList = mapper.getAccountRelations(id);
|
||||
account.setScenicId(scenicList);
|
||||
return account;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,4 +65,12 @@ public class ScenicAccountServiceImpl implements ScenicAccountService {
|
||||
public int updateStatus(Long id) {
|
||||
return mapper.updateStatus(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScenicAccountEntity getScenicAccountByAccount(String account) {
|
||||
ScenicAccountEntity accountEntity = mapper.getByAccount(account);
|
||||
List<Long> scenicList = mapper.getAccountRelations(accountEntity.getId());
|
||||
accountEntity.setScenicId(scenicList);
|
||||
return accountEntity;
|
||||
}
|
||||
}
|
@@ -71,21 +71,20 @@ public class ScenicServiceImpl implements ScenicService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApiResponse<Boolean> add(ScenicAddOrUpdateReq scenicAddReq) {
|
||||
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicAddReq.getAccount());
|
||||
if (scenicAccount != null) {
|
||||
return ApiResponse.fail("账号已存在");
|
||||
}
|
||||
Long scenicId = SnowFlakeUtil.getLongId();
|
||||
scenicAddReq.setId(scenicId);
|
||||
int add = scenicMapper.add(scenicAddReq);
|
||||
ScenicAccountEntity account = new ScenicAccountEntity();
|
||||
account.setId(SnowFlakeUtil.getLongId());
|
||||
account.setScenicId(scenicId);
|
||||
account.setName(scenicAddReq.getName() + "管理员");
|
||||
account.setAccount(scenicAddReq.getAccount());
|
||||
account.setPassword(scenicAddReq.getPassword());
|
||||
account.setIsSuper(1);
|
||||
scenicAccountMapper.add(account);
|
||||
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicAddReq.getAccount());
|
||||
if (scenicAccount == null) {
|
||||
scenicAccount = new ScenicAccountEntity();
|
||||
scenicAccount.setId(SnowFlakeUtil.getLongId());
|
||||
scenicAccount.setName(scenicAddReq.getName() + "管理员");
|
||||
scenicAccount.setAccount(scenicAddReq.getAccount());
|
||||
scenicAccount.setPassword(scenicAddReq.getPassword());
|
||||
scenicAccount.setIsSuper(1);
|
||||
scenicAccountMapper.add(scenicAccount);
|
||||
}
|
||||
scenicAccountMapper.addAccountScenicRelation(scenicAccount.getId(), scenicId, 1);
|
||||
if (add > 0) {
|
||||
return ApiResponse.success(true);
|
||||
} else {
|
||||
@@ -98,7 +97,7 @@ public class ScenicServiceImpl implements ScenicService {
|
||||
public ApiResponse<Boolean> deleteById(Long id) {
|
||||
int i = scenicMapper.deleteById(id);
|
||||
if (i > 0) {
|
||||
scenicAccountMapper.deleteByScenicId(id);
|
||||
scenicAccountMapper.deleteRelationByScenicId(id);
|
||||
IFaceBodyAdapter adapter = getScenicFaceBodyAdapter(id);
|
||||
Thread.ofVirtual().start(() -> {
|
||||
adapter.deleteFaceDb(id.toString());
|
||||
@@ -117,6 +116,9 @@ public class ScenicServiceImpl implements ScenicService {
|
||||
|
||||
@Override
|
||||
public ApiResponse<Boolean> update(ScenicAddOrUpdateReq scenicUpdateReq) {
|
||||
if (scenicUpdateReq.getId() == null) {
|
||||
return ApiResponse.fail("参数错误");
|
||||
}
|
||||
if (StringUtils.isNotBlank(scenicUpdateReq.getAccount()) && StringUtils.isNotBlank(scenicUpdateReq.getPassword())) {
|
||||
ScenicAccountEntity scenicAccount = scenicAccountMapper.getByAccount(scenicUpdateReq.getAccount());
|
||||
if (scenicAccount != null) {
|
||||
@@ -132,13 +134,13 @@ public class ScenicServiceImpl implements ScenicService {
|
||||
} else {
|
||||
account = new ScenicAccountEntity();
|
||||
account.setId(SnowFlakeUtil.getLongId());
|
||||
account.setScenicId(scenicUpdateReq.getId());
|
||||
account.setName(scenicUpdateReq.getName() + "管理员");
|
||||
account.setAccount(scenicUpdateReq.getAccount());
|
||||
account.setPassword(scenicUpdateReq.getPassword());
|
||||
account.setIsSuper(1);
|
||||
scenicAccountMapper.add(account);
|
||||
}
|
||||
scenicAccountMapper.addAccountScenicRelation(account.getId(), scenicUpdateReq.getId(), 1);
|
||||
}
|
||||
int i = scenicMapper.update(scenicUpdateReq);
|
||||
if (i > 0) {
|
||||
|
Reference in New Issue
Block a user