Commit 010cbd85 by 吕明尚

用户信息增加职务判断

parent 92c09319
......@@ -15,6 +15,7 @@ import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.enums.BusinessType;
import share.system.domain.SConsumer;
import share.system.domain.vo.SConsumerVo;
import share.system.service.SConsumerService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
......@@ -38,7 +39,7 @@ public class SConsumerController extends BaseController
*/
@ApiOperation(value = "个人中心-用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
public R<SConsumer> getSConsumerCenter() {
public R<SConsumerVo> getSConsumerCenter() {
return R.ok(sConsumerService.getSConsumer());
}
......
......@@ -81,7 +81,7 @@ public class SStoreController extends BaseController
/**
* 用户负责的门店设备
*/
@GetMapping("/storeListByConsumer")
@GetMapping("/storeList")
@ApiOperation(value = "查询全部门店及全部房间,每个房间绑定的设备列表")
public AjaxResult storeList() {
return success(sStoreService.storeList());
......
......@@ -16,4 +16,8 @@ public class SConsumerVo extends SConsumer {
private Integer position;
private Boolean isCleaner;
private Boolean isAdmin;
}
......@@ -99,4 +99,5 @@ public interface ISStoreService extends IService<SStore>
int dataSync();
List<SStoreVo> storeList();
}
......@@ -91,7 +91,7 @@ public interface SConsumerService extends IService<SConsumer>
* 获取当前登陆用户个人信息(空则返回异常)
* @return
*/
SConsumer getSConsumer();
SConsumerVo getSConsumer();
/**
* 获取当前登陆用户个人信息
......
......@@ -12,11 +12,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import share.common.constant.Constants;
import share.common.constant.SmsConstants;
import share.common.enums.ConsumerCouponUseStatusEnum;
import share.common.enums.PayStatusEnum;
import share.common.enums.PositionEnum;
import share.common.enums.RoleTypeEnum;
import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
......@@ -172,7 +176,7 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
}
@Override
public SConsumer getSConsumer() {
public SConsumerVo getSConsumer() {
SConsumer currentUser = getInfo();
SConsumerCoupon sConsumerCoupon = new SConsumerCoupon();
sConsumerCoupon.setConsumerId(currentUser.getId());
......@@ -181,10 +185,25 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
if(count>0){
currentUser.setNumber(count);
}
SConsumerVo vo = new SConsumerVo();
BeanUtils.copyProperties(currentUser, vo);
List<Long> longList = storeConsumerMapper.selectByConsumerId(currentUser.getId(), PositionEnum.CLEANER.getCode());
if (CollectionUtils.isEmpty(longList)) {
vo.setIsCleaner(false);
} else {
vo.setIsCleaner(true);
}
List<Long> adminList = storeConsumerMapper.selectByConsumerId(currentUser.getId(), PositionEnum.ADMIN.getCode());
if (CollectionUtils.isEmpty(adminList)) {
vo.setIsAdmin(false);
} else {
vo.setIsAdmin(true);
}
if (ObjectUtil.isNull(currentUser)) {
throw new BaseException("您的登录已过期,请先登录");
}
return currentUser;
return vo;
}
/**
......
......@@ -443,19 +443,19 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
}
return 0;
}
@Override
public List<SStoreVo> storeList() {
//查询所有门店
List<SStore> sStores = baseMapper.selectSStoreList(new SStore());
SConsumer user = consumerService.getInfo();
if (!user.getRoleType().equals(RoleTypeEnum.CLEANER.getCode())) {
throw new BaseException("当前用户不是店员!");
}
List<Long> storeIds = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.CLEANER.getCode());
List<Long> storeIds = storeConsumerMapper.selectByConsumerId(user.getId(), PositionEnum.ADMIN.getCode());
if (CollectionUtils.isEmpty(storeIds)) {
return new ArrayList<>();
}
//查询所有门店
List<SStore> sStores = baseMapper.selectList(new LambdaQueryWrapper<SStore>().in(SStore::getId, storeIds));
List<SStoreVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sStores)) {
voList = convertDosToVos(sStores);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment