| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- package ${packageName}.${backendModuleName}.${busName}.service.impl;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import cn.hutool.core.collection.CollectionUtil;
- import cn.hutool.core.util.*;
- import org.springframework.transaction.annotation.Transactional;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import ${packageName}.${backendModuleName}.${busName}.repository.${className}Repository;
- import ${packageName}.${backendModuleName}.${busName}.po.${className}PO;
- import ${packageName}.${backendModuleName}.${busName}.dto.${className}DTO;
- import ${packageName}.${backendModuleName}.${busName}.dto.${className}QueryDTO;
- import java.util.*;
- import ${packageName}.${backendModuleName}.${busName}.service.I${className}Service;
- import ${packageName}.${backendModuleName}.mapper.${className}Mapper;
- /**
- * ${functionName}Service接口实现类
- *
- * @author ${authorName}
- * @date ${genTime}
- **/
- @Service
- public class ${className}ServiceImpl implements I${className}Service {
- @Autowired
- private ${className}Repository baseRepository;
- /**
- * 根据条件查询${functionName}
- * @param query 查询参数
- * @author ${authorName}
- * @date ${genTime}
- */
- @Override
- public List<${className}DTO> select${className}List(${className}QueryDTO query){
- return ${className}Mapper.INSTANCE.convertDtoList(
- baseRepository.selectList(new LambdaQueryWrapper<${className}PO>()
- <% for(var i = 0; i < configList.~size; i++) { %>
- <% if(configList[i].queryWhether != null && configList[i].queryWhether ) { %>
- <% if(configList[i].queryType == "like"){ %>
- .like(Objects.nonNull(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},
- query.get${configList[i].fieldNameCamelCaseFirstUpper}())
- <% } %>
- <% if(configList[i].queryType == "notLike"){ %>
- .notLike(Objects.nonNull(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},query.get${configList[i].fieldNameCamelCaseFirstUpper}())
- <% } %>
- <% if(configList[i].queryType == "eq"){ %>
- .eq(Objects.nonNull(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},query.get${configList[i].fieldNameCamelCaseFirstUpper}())
- <% } %>
- <% if(configList[i].queryType == "ne"){ %>
- .ne(Objects.nonNull(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},query.get${configList[i].fieldNameCamelCaseFirstUpper}())
- <% } %>
- <% if(configList[i].queryType == "gt"){ %>
- .gt(Objects.nonNull(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},query.get${configList[i].fieldNameCamelCaseFirstUpper}())
- <% } %>
- <% if(configList[i].queryType == "ge"){ %>
- .ge(Objects.nonNull(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},query.get${configList[i].fieldNameCamelCaseFirstUpper}())
- <% } %>
- <% if(configList[i].queryType == "lt"){ %>
- .lt(Objects.nonNull(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},query.get${configList[i].fieldNameCamelCaseFirstUpper}())
- <% } %>
- <% if(configList[i].queryType == "le"){ %>
- .le(Objects.nonNull(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},query.get${configList[i].fieldNameCamelCaseFirstUpper}())
- <% } %>
- <% if(configList[i].queryType == "BETWEEN"){ %>
- .le(CollectionUtil.isNotEmpty(query.get${configList[i].fieldNameCamelCaseFirstUpper}()),${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},CollectionUtil.query.get${configList[i].fieldNameCamelCaseFirstUpper}(),0))
- .ge(CollectionUtil.size(query.get${configList[i].fieldNameCamelCaseFirstUpper}())>1,${className}PO::get${configList[i].fieldNameCamelCaseFirstUpper},CollectionUtil.get(query.get${configList[i].fieldNameCamelCaseFirstUpper}(),1))
- <% } %>
- <% } %>
- <% } %>
- )
- );
- };
- /**
- * 根据id查询${functionName}
- * @param id 主键id
- * @author ${authorName}
- * @date ${genTime}
- */
- @Override
- public ${className}DTO select${className}ById(String id){
- return ${className}Mapper.INSTANCE.convertDto(baseRepository.selectById(id));
- };
- /**
- * 编辑${functionName}
- * @param source 编辑实体类
- * @author ${authorName}
- * @date ${genTime}
- */
- @Transactional(rollbackFor = Exception.class)
- @Override
- public boolean update${className}ById(${className}DTO source){
- return baseRepository.updateById(${className}Mapper.INSTANCE.convertPO(source))!=0;
- };
- /**
- * 新增${functionName}
- * @param source 新增实体类
- * @author ${authorName}
- * @date ${genTime}
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public boolean insert${className}(${className}DTO source){
- return baseRepository.insert(${className}Mapper.INSTANCE.convertPO(source))!=0;
- };
- /**
- * 删除${functionName}详情
- * @param ids 删除主键集合
- * @author ${authorName}
- * @date ${genTime}
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public int remove${className}ByIds(Collection<String> ids){
- return baseRepository.deleteBatchIds(ids);
- };
- }
|