|
|
@ -6,13 +6,14 @@ import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.yomahub.tlog.core.annotation.TLogAspect; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.common.aspect.exception.BadRequestException; |
|
|
|
import org.nl.common.domain.query.PageQuery; |
|
|
|
import org.nl.common.utils.MapOf; |
|
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
|
import org.nl.system.service.param.ISysParamService; |
|
|
|
import org.nl.system.service.param.ISysParamService; |
|
|
|
import org.nl.system.service.param.dao.Param; |
|
|
|
import org.nl.system.service.param.dao.mapper.SysParamMapper; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -22,9 +23,7 @@ import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* 系统参数表 服务实现类 |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @author generator |
|
|
|
* @since 2022-12-14 |
|
|
@ -33,59 +32,66 @@ import java.util.Map; |
|
|
|
@RequiredArgsConstructor |
|
|
|
@Slf4j |
|
|
|
@Transactional |
|
|
|
public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> implements ISysParamService { |
|
|
|
public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> |
|
|
|
implements ISysParamService { |
|
|
|
|
|
|
|
private final SysParamMapper paramMapper; |
|
|
|
private final SysParamMapper paramMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public Page<Param> queryPage(Map whereJson, PageQuery page) { |
|
|
|
log.info("111"); |
|
|
|
QueryWrapper<Param> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.orderBy(true, true, "create_time"); |
|
|
|
Page<Param> paramPage = paramMapper.selectPage(page.build(), queryWrapper); |
|
|
|
return paramPage; |
|
|
|
} |
|
|
|
@Override |
|
|
|
@TLogAspect |
|
|
|
public Page<Param> queryPage(Map whereJson, PageQuery page) { |
|
|
|
log.info("这是第一条日志"); |
|
|
|
log.info("这是第二条日志"); |
|
|
|
log.info("这是第三条日志"); |
|
|
|
new Thread(() -> log.info("这是异步日志")).start(); |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void create(Param param) { |
|
|
|
List code = paramMapper.selectByMap(MapOf.of("code", param.getCode())); |
|
|
|
if (ObjectUtil.isNotEmpty(code)) throw new BadRequestException("编码不能一致"); |
|
|
|
param.setId(IdUtil.getSnowflake(1, 1).nextIdStr()); |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
param.setCreateId(currentUserId); |
|
|
|
param.setCreateName(nickName); |
|
|
|
param.setCreateTime(now); |
|
|
|
param.setUpdateId(currentUserId); |
|
|
|
param.setUpdateName(nickName); |
|
|
|
param.setUpdateTime(now); |
|
|
|
paramMapper.insert(param); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(Param param) { |
|
|
|
Param paramObj = paramMapper.selectById(param.getId()); |
|
|
|
if (ObjectUtil.isEmpty(paramObj)) throw new BadRequestException("被删除或无权限,操作失败!"); |
|
|
|
param.setUpdateId(SecurityUtils.getCurrentUserId()); |
|
|
|
param.setUpdateName(SecurityUtils.getCurrentNickName()); |
|
|
|
param.setUpdateTime(DateUtil.now()); |
|
|
|
paramMapper.updateById(param); |
|
|
|
} |
|
|
|
QueryWrapper<Param> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.orderBy(true, true, "create_time"); |
|
|
|
Page<Param> paramPage = paramMapper.selectPage(page.build(), queryWrapper); |
|
|
|
return paramPage; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void deleteByIds(List<String> ids) { |
|
|
|
paramMapper.deleteBatchIds(ids); |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void create(Param param) { |
|
|
|
List code = paramMapper.selectByMap(MapOf.of("code", param.getCode())); |
|
|
|
if (ObjectUtil.isNotEmpty(code)) throw new BadRequestException("编码不能一致"); |
|
|
|
param.setId(IdUtil.getSnowflake(1, 1).nextIdStr()); |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
param.setCreateId(currentUserId); |
|
|
|
param.setCreateName(nickName); |
|
|
|
param.setCreateTime(now); |
|
|
|
param.setUpdateId(currentUserId); |
|
|
|
param.setUpdateName(nickName); |
|
|
|
param.setUpdateTime(now); |
|
|
|
paramMapper.insert(param); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Param findByCode(String code) { |
|
|
|
QueryWrapper<Param> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("code", code); |
|
|
|
Param param = paramMapper.selectOne(queryWrapper); |
|
|
|
return param; |
|
|
|
} |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(Param param) { |
|
|
|
Param paramObj = paramMapper.selectById(param.getId()); |
|
|
|
if (ObjectUtil.isEmpty(paramObj)) throw new BadRequestException("被删除或无权限,操作失败!"); |
|
|
|
param.setUpdateId(SecurityUtils.getCurrentUserId()); |
|
|
|
param.setUpdateName(SecurityUtils.getCurrentNickName()); |
|
|
|
param.setUpdateTime(DateUtil.now()); |
|
|
|
paramMapper.updateById(param); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void deleteByIds(List<String> ids) { |
|
|
|
paramMapper.deleteBatchIds(ids); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Param findByCode(String code) { |
|
|
|
QueryWrapper<Param> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("code", code); |
|
|
|
Param param = paramMapper.selectOne(queryWrapper); |
|
|
|
return param; |
|
|
|
} |
|
|
|
} |
|
|
|