/*
java service 服务接口
*/
package tx.txservice.service;
import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import tx.txservice.enums.TxConstants;
import java.util.List;
public interface TemplateService<TDTO, TVO> extends IService<TDTO> {
default Long getTotal(List<?> pList)
/*****
* Author:狂客
* QQ:214109721
* @Description:获取信息总数
* @param pList 集合
* @return:信息总数
*****/
{
return new PageInfo(pList).getTotal();
}
//查询列表
public List<TDTO> getList(QueryWrapper<TDTO> queryWrapper);
public default List<TDTO> getList(QueryWrapper<TDTO> queryWrapper, Boolean delIgnore)
/*****
* Author:狂客
* QQ:214109721
* @Description:查询列表
* @param queryWrapper 条件
* @param delIgnore 删除是否忽略
* @return:无
*****/
{
if (delIgnore) {
queryWrapper.eq("is_del", TxConstants.DATA_NORMAL);
}
return getList(queryWrapper);
}
//DTO格式化
public TDTO formatDTO(TDTO pItem);
public default List<TDTO> formatDTO(List<TDTO> pList)
/*****
* Author:狂客
* QQ:214109721
* @Description:列表DTO格式化
* @param pList 集合
* @return:无
*****/
{
pList.forEach(vItem -> {
formatDTO(vItem);
});
return pList;
}
public default List<TVO> formatVO(List<TDTO> pList, Class<TVO> pClass)
/*****
* Author:狂客
* QQ:214109721
* @Description:列表VO格式化
* @param pList 集合
* @param pClass VO class
* @return:无
*****/
{
List<TVO> vList = Convert.toList(pClass, pList);
vList.forEach(vItem -> {
formatVO(vItem);
});
return vList;
}
//单条VO格式化
public default TVO formatVO(TDTO pItem, Class<TVO> pClass) {
return formatVO(Convert.convert(pClass, pItem));
}
//单条VO格式化
public TVO formatVO(TVO pItem);
//查询单条数据
public TDTO getOne(QueryWrapper<TDTO> pQuery, Boolean pDelIgnore);
//查询单条数据
public TDTO getOne(QueryWrapper<TDTO> pQuery);
//根据ID查询单条数据
public TDTO getOneById(Long pId, Boolean pDelIgnore);
//根据ID查询单条数据
public TDTO getOneById(Long pId);
//id解密
public Long idDecode(String pSid);
//id加密
public String idEncode(Long pId);
//删除
public void delete(String[] pSid);
//编辑
public void edit(TDTO pItem);
//添加
public void add(TDTO pItem);
}
/*
template service impl 服务实现类
*/
package tx.txservice.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.crypto.symmetric.AES;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import tx.txservice.service.TemplateService;
import java.util.List;
public class TemplateServiceImpl<TMAPPER, TDTO, TVO> extends ServiceImpl<TMAPPER, TDTO> implements TemplateService<TDTO, TVO> {
//加密类
@Autowired
private AES encodeAES;
@Override
public List<TDTO> getList(QueryWrapper<TDTO> queryWrapper) {
return null;
}
@Override
public TVO formatVO(TVO pItem) {
return null;
}
@Override
public TDTO getOne(QueryWrapper<TDTO> pQuery) {
return null;
}
@Override
public TDTO getOneById(Long pId) {
return null;
}
@Override
public Long idDecode(String pSid) {
Long vId = new Long(encodeAES.decryptStr(pSid));
return vId;
}
@Override
public String idEncode(Long pId) {
return encodeAES.encryptHex(Convert.toStr(pId));
}
@Override
public void delete(String[] pSid) {
}
@Override
public void edit(TDTO pItem) {
}
@Override
public void add(TDTO pItem) {
}
}
/*
接口继承
*/
package tx.txservice.service;
import tx.txservice.domain.KuangKeDTO;
import tx.txservice.domain.vo.KuangKeVO;
public interface KuangKeService extends TemplateService<KuangKeDTO, KuangKeVO> {
}
/*
实现类继承
*/
package tx.txservice.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tx.txservice.domain.KuangKeDTO;
import tx.txservice.domain.vo.KuangKeVO;
import tx.txservice.mapper.KuangKeMapper;
import tx.txservice.service.KuangKeService;
import java.util.List;
@Service
public class KuangKeServiceImpl extends TemplateServiceImpl<KuangKeMapper, KuangKeDTO, KuangKeVO> implements KuangKeService {
@Autowired
private KuangKeMapper kuangKeMapper;
@Override
public List<KuangKeDTO> getList(QueryWrapper<KuangKeDTO> queryWrapper) {
return kuangKeMapper.selectList(queryWrapper);
}
@Override
public KuangKeVO formatVO(KuangKeVO pItem)
/*****
* Author:狂客
* QQ:214109721
* @Description:VO格式化输出
* @param pItem 内容
* @return:新内容
*****/
{
return null;
}
@Override
public KuangKeDTO getOne(QueryWrapper<KuangKeDTO> pQuery)
/*****
* Author:狂客
* QQ:214109721
* @Description:获取单条内容
* @param pQuery 查询条件
* @return:内容
*****/
{
return kuangKeMapper.selectOne(pQuery);
}
@Override
public KuangKeDTO getOneById(Long pId)
/*****
* Author:狂客
* QQ:214109721
* @Description:根据id获取单条内容
* @param pId id
* @return:内容
*****/
{
return null;
}
@Override
public void delete(String[] pSid) {
}
@Override
public void edit(KuangKeDTO pItem) {
}
@Override
public void add(KuangKeDTO pItem) {
}
}
/*
Mapper
*/
@Component
public interface KuangKeMapper extends BaseMapper<KuangKeDTO> {
}