1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- package com.zy.omp.service;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
- import com.zy.omp.mapper.RelationMapper;
- import com.zy.omp.model.Relation;
- import org.springframework.stereotype.Service;
- import java.util.List;
- /**
- * 用户设备绑定关系Service
- *
- * @author chenyi
- * Create on 2020/4/10
- */
- @Service
- public class RelationService extends ServiceImpl<RelationMapper, Relation> {
- /**
- * 查询用户的所有设备
- *
- * @param openId 用户ID
- */
- public Relation getDefaultByOpenId(String openId) {
- QueryWrapper<Relation> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("openId", openId)
- .eq("isDefault", 1);
- return baseMapper.selectOne(queryWrapper);
- }
- /**
- * 查询用户的所有设备
- *
- * @param openId 用户ID
- */
- public List<Relation> getListByOpenId(String openId) {
- QueryWrapper<Relation> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("openId", openId)
- .orderByDesc("isDefault", "updateTime");
- return baseMapper.selectList(queryWrapper);
- }
- /**
- * 查询设备是否有绑定关系
- *
- * @param openNum 设备ID
- */
- public boolean checkBind(String openNum) {
- return baseMapper.checkBind(openNum) > 0;
- }
- /**
- * 查询设备是否属于该用户
- *
- * @param openId 用户ID
- * @param openNum 设备ID
- */
- public boolean checkBelong(String openNum, String openId) {
- return baseMapper.checkBelong(openNum, openId) > 0;
- }
- }
|