| | |
| | | package com.lf.server.service.all; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.lf.server.entity.ctrl.IdNameEntity; |
| | | import com.lf.server.entity.data.DictEntity; |
| | | import com.lf.server.helper.AesHelper; |
| | | import com.lf.server.helper.ClassHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.mapper.all.BaseQueryMapper; |
| | | import com.lf.server.mapper.all.BasicMapper; |
| | | import com.lf.server.mapper.all.GeomBaseMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 父查询服务类 |
| | | * @author WWW |
| | | */ |
| | | @Service |
| | | public class BaseQueryService { |
| | | public class BaseQueryService implements BaseQueryMapper { |
| | | @Autowired |
| | | BaseQueryMapper baseQueryMapper; |
| | | |
| | | /** |
| | | * 表名Map |
| | | */ |
| | | private static Map<String, String> tabMap = new HashMap<String, String>(3); |
| | | |
| | | /** |
| | | * 获取父Mapper |
| | | * |
| | |
| | | * @return 表名 |
| | | */ |
| | | public String getTabName(BasicMapper basicMapper) { |
| | | Object obj = ClassHelper.createEntityByMapper(basicMapper); |
| | | if (obj == null) { |
| | | String className = ClassHelper.getClassName(basicMapper); |
| | | if (tabMap.containsKey(className)) { |
| | | return tabMap.get(className); |
| | | } |
| | | |
| | | return getTabName(className); |
| | | } |
| | | |
| | | /** |
| | | * 根据Mapper获取表名 |
| | | * |
| | | * @param className Mapper类名 |
| | | * @return 表名 |
| | | */ |
| | | private String getTabName(String className) { |
| | | Class clazz = ClassHelper.getEntityClass(className); |
| | | if (clazz == null) { |
| | | return null; |
| | | } |
| | | |
| | | return null; |
| | | TableName annotation = (TableName) clazz.getAnnotation(TableName.class); |
| | | |
| | | String tabName = annotation.value(); |
| | | if (tabName != null && !tabMap.containsKey(className)) { |
| | | tabMap.put(className, tabName); |
| | | } |
| | | |
| | | return tabName; |
| | | } |
| | | |
| | | @Override |
| | | public List<IdNameEntity> selectUserFuzzy(String name) { |
| | | name = StringHelper.getLikeStr(name); |
| | | |
| | | return baseQueryMapper.selectUserFuzzy(name); |
| | | } |
| | | |
| | | @Override |
| | | public List<IdNameEntity> selectDepFuzzy(String name) { |
| | | name = StringHelper.getLikeStr(name); |
| | | |
| | | return baseQueryMapper.selectDepFuzzy(name); |
| | | } |
| | | |
| | | @Override |
| | | public List<DictEntity> selectTabs() { |
| | | return baseQueryMapper.selectTabs(); |
| | | } |
| | | } |