增加字段名称常量类
This commit is contained in:
@ -16,6 +16,10 @@ public interface FieldNameConstants {
|
||||
* 名称
|
||||
*/
|
||||
String FULL_NAME = "名称";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 本币
|
||||
*/
|
||||
String LOCAL_SIGN = "本币";
|
||||
}
|
||||
|
||||
@ -12,18 +12,19 @@ import com.xjrsoft.common.page.ConventPage;
|
||||
import com.xjrsoft.common.page.PageOutput;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.utils.VoToColumnUtil;
|
||||
import com.xjrsoft.module.mdm.dto.AddLngBCurrencyDto;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBCurrencyDto;
|
||||
import com.xjrsoft.module.mdm.dto.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
|
||||
import com.xjrsoft.module.mdm.dto.LngBCurrencyPageDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBCurrency;
|
||||
import com.xjrsoft.module.mdm.entity.LngBPriceTerm;
|
||||
import com.xjrsoft.module.mdm.service.ICurrencyService;
|
||||
import com.xjrsoft.module.mdm.vo.LngBCurrencyPageVo;
|
||||
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
|
||||
import com.xjrsoft.module.datalog.entity.DataChangeLog;
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.mdm.vo.LngBCurrencyVo;
|
||||
import com.xjrsoft.module.mdm.vo.LngBPriceTermPageVo;
|
||||
import com.xjrsoft.module.mdm.vo.LngBPriceTermVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -53,15 +54,14 @@ public class CurrencyController {
|
||||
@ApiOperation(value="LngBCurrency列表(分页)")
|
||||
@SaCheckPermission("currency:list")
|
||||
public R page(@Valid LngBCurrencyPageDto dto){
|
||||
|
||||
LambdaQueryWrapper<LngBCurrency> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper
|
||||
.like(StrUtil.isNotBlank(dto.getFullName()),LngBCurrency::getFullName,dto.getFullName())
|
||||
.like(StrUtil.isNotBlank(dto.getValid()),LngBCurrency::getValid,dto.getValid())
|
||||
.like(StrUtil.isNotBlank(dto.getCode()),LngBCurrency::getCode,dto.getCode())
|
||||
.like(StrUtil.isNotBlank(dto.getLocalSign()),LngBCurrency::getLocalSign,dto.getLocalSign())
|
||||
.like(StrUtil.isNotBlank(dto.getNote()),LngBCurrency::getNote,dto.getNote())
|
||||
.orderByDesc(LngBCurrency::getId)
|
||||
.and(StrUtil.isNotBlank(dto.getFullName()), r ->
|
||||
r.like(LngBCurrency::getCode, dto.getFullName())
|
||||
.or()
|
||||
.like(LngBCurrency::getFullName, dto.getFullName()))
|
||||
.eq(StrUtil.isNotBlank(dto.getValid()),LngBCurrency::getValid,dto.getValid())
|
||||
.orderByAsc(LngBCurrency::getSort, LngBCurrency::getCode)
|
||||
.select(LngBCurrency.class,x -> VoToColumnUtil.fieldsToColumns(LngBCurrencyPageVo.class).contains(x.getProperty()));
|
||||
IPage<LngBCurrency> page = currencyService.page(ConventPage.getPage(dto), queryWrapper);
|
||||
PageOutput<LngBCurrencyPageVo> pageOutput = ConventPage.getPageOutput(page, LngBCurrencyPageVo.class);
|
||||
@ -78,29 +78,19 @@ public class CurrencyController {
|
||||
}
|
||||
return R.ok(BeanUtil.toBean(lngBCurrency, LngBCurrencyVo.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/datalog")
|
||||
@ApiOperation(value="根据id查询LngBCurrency数据详细日志")
|
||||
@SaCheckPermission("currency:datalog")
|
||||
public R datalog(@RequestParam Long id){
|
||||
List<DataChangeLogVo> logs = dataService.findLogsByEntityId(UpdateLngBCurrencyDto.class,id);
|
||||
return R.ok(logs);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增LngBCurrency")
|
||||
@SaCheckPermission("currency:add")
|
||||
public R add(@Valid @RequestBody UpdateLngBCurrencyDto dto){
|
||||
UpdateLngBCurrencyDto res = dataService.insert(dto);
|
||||
return R.ok(res.getId());
|
||||
return R.ok(currencyService.add(dto));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改LngBCurrency")
|
||||
@SaCheckPermission("currency:edit")
|
||||
public R update(@Valid @RequestBody UpdateLngBCurrencyDto dto){
|
||||
return R.ok(dataService.updateById(dto));
|
||||
return R.ok(currencyService.updateByDTO(dto));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ -110,6 +100,18 @@ public class CurrencyController {
|
||||
return R.ok(dataService.deleteByIds(UpdateLngBCurrencyDto.class, ids));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/enable")
|
||||
@ApiOperation(value = "启用LngBCurrency")
|
||||
@SaCheckPermission("currency:enable")
|
||||
public R enable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(currencyService.enable(ids));
|
||||
}
|
||||
|
||||
@PostMapping("/disable")
|
||||
@ApiOperation(value = "禁用LngBCurrency")
|
||||
@SaCheckPermission("currency:disable")
|
||||
public R disable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(currencyService.disable(ids));
|
||||
}
|
||||
}
|
||||
@ -1,28 +1,20 @@
|
||||
package com.xjrsoft.module.mdm.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.xjrsoft.common.constant.GlobalConstant;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.page.ConventPage;
|
||||
import com.xjrsoft.common.page.PageOutput;
|
||||
import com.xjrsoft.common.model.result.R;
|
||||
import com.xjrsoft.common.utils.VoToColumnUtil;
|
||||
import com.xjrsoft.module.mdm.dto.AddLngBPriceTermDto;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBPriceTermDto;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.mdm.dto.LngBPriceTermPageDto;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBPriceTermDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBPriceTerm;
|
||||
import com.xjrsoft.module.mdm.service.IPriceTermsService;
|
||||
import com.xjrsoft.module.mdm.vo.LngBPriceTermPageVo;
|
||||
import com.xjrsoft.module.datalog.vo.DataChangeLogVo;
|
||||
import com.xjrsoft.module.datalog.entity.DataChangeLog;
|
||||
import com.xjrsoft.module.datalog.service.DatalogService;
|
||||
import com.xjrsoft.module.mdm.vo.LngBPriceTermVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -30,7 +22,6 @@ import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -53,16 +44,14 @@ public class PriceTermsController {
|
||||
@ApiOperation(value="LngBPriceTerm列表(分页)")
|
||||
@SaCheckPermission("priceTerms:list")
|
||||
public R page(@Valid LngBPriceTermPageDto dto){
|
||||
|
||||
LambdaQueryWrapper<LngBPriceTerm> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper
|
||||
.like(StrUtil.isNotBlank(dto.getFullName()),LngBPriceTerm::getFullName,dto.getFullName())
|
||||
.like(StrUtil.isNotBlank(dto.getValid()),LngBPriceTerm::getValid,dto.getValid())
|
||||
.like(StrUtil.isNotBlank(dto.getCode()),LngBPriceTerm::getCode,dto.getCode())
|
||||
.like(StrUtil.isNotBlank(dto.getFreightSign()),LngBPriceTerm::getFreightSign,dto.getFreightSign())
|
||||
.like(StrUtil.isNotBlank(dto.getInsuranceSign()),LngBPriceTerm::getInsuranceSign,dto.getInsuranceSign())
|
||||
.like(StrUtil.isNotBlank(dto.getNote()),LngBPriceTerm::getNote,dto.getNote())
|
||||
.orderByDesc(LngBPriceTerm::getId)
|
||||
.and(StrUtil.isNotBlank(dto.getFullName()), r ->
|
||||
r.like(LngBPriceTerm::getCode, dto.getFullName())
|
||||
.or()
|
||||
.like(LngBPriceTerm::getFullName, dto.getFullName()))
|
||||
.eq(StrUtil.isNotBlank(dto.getValid()),LngBPriceTerm::getValid,dto.getValid())
|
||||
.orderByAsc(LngBPriceTerm::getSort, LngBPriceTerm::getCode)
|
||||
.select(LngBPriceTerm.class,x -> VoToColumnUtil.fieldsToColumns(LngBPriceTermPageVo.class).contains(x.getProperty()));
|
||||
IPage<LngBPriceTerm> page = priceTermsService.page(ConventPage.getPage(dto), queryWrapper);
|
||||
PageOutput<LngBPriceTermPageVo> pageOutput = ConventPage.getPageOutput(page, LngBPriceTermPageVo.class);
|
||||
@ -79,38 +68,39 @@ public class PriceTermsController {
|
||||
}
|
||||
return R.ok(BeanUtil.toBean(lngBPriceTerm, LngBPriceTermVo.class));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/datalog")
|
||||
@ApiOperation(value="根据id查询LngBPriceTerm数据详细日志")
|
||||
@SaCheckPermission("priceTerms:datalog")
|
||||
public R datalog(@RequestParam Long id){
|
||||
List<DataChangeLogVo> logs = dataService.findLogsByEntityId(UpdateLngBPriceTermDto.class,id);
|
||||
return R.ok(logs);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增LngBPriceTerm")
|
||||
@SaCheckPermission("priceTerms:add")
|
||||
public R add(@Valid @RequestBody UpdateLngBPriceTermDto dto){
|
||||
UpdateLngBPriceTermDto res = dataService.insert(dto);
|
||||
return R.ok(res.getId());
|
||||
return R.ok(priceTermsService.add(dto));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "修改LngBPriceTerm")
|
||||
@SaCheckPermission("priceTerms:edit")
|
||||
public R update(@Valid @RequestBody UpdateLngBPriceTermDto dto){
|
||||
return R.ok(dataService.updateById(dto));
|
||||
return R.ok(priceTermsService.updateByDTO(dto));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation(value = "删除")
|
||||
@SaCheckPermission("priceTerms:delete")
|
||||
public R delete(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(dataService.deleteByIds(UpdateLngBPriceTermDto.class, ids));
|
||||
|
||||
return R.ok(dataService.deleteByIds(UpdateLngBPriceTermDto.class, ids));
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/enable")
|
||||
@ApiOperation(value = "启用LngBPriceTerm")
|
||||
@SaCheckPermission("priceTerms:enable")
|
||||
public R enable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(priceTermsService.enable(ids));
|
||||
}
|
||||
|
||||
@PostMapping("/disable")
|
||||
@ApiOperation(value = "禁用LngBPriceTerm")
|
||||
@SaCheckPermission("priceTerms:disable")
|
||||
public R disable(@Valid @RequestBody List<Long> ids){
|
||||
return R.ok(priceTermsService.disable(ids));
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,10 @@
|
||||
package com.xjrsoft.module.mdm.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.github.yulichang.base.MPJBaseService;
|
||||
import com.github.yulichang.extension.mapping.base.MPJDeepService;
|
||||
import com.github.yulichang.extension.mapping.base.MPJRelationService;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBCurrencyDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBCurrency;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -16,4 +15,11 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public interface ICurrencyService extends IService<LngBCurrency> {
|
||||
Long add(@Valid UpdateLngBCurrencyDto dto);
|
||||
|
||||
boolean updateByDTO(@Valid UpdateLngBCurrencyDto dto);
|
||||
|
||||
boolean enable(@Valid List<Long> ids);
|
||||
|
||||
boolean disable(@Valid List<Long> ids);
|
||||
}
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
package com.xjrsoft.module.mdm.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.github.yulichang.base.MPJBaseService;
|
||||
import com.github.yulichang.extension.mapping.base.MPJDeepService;
|
||||
import com.github.yulichang.extension.mapping.base.MPJRelationService;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBPriceTermDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBPriceTerm;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -16,4 +15,12 @@ import java.util.List;
|
||||
*/
|
||||
|
||||
public interface IPriceTermsService extends IService<LngBPriceTerm> {
|
||||
|
||||
Long add(@Valid UpdateLngBPriceTermDto dto);
|
||||
|
||||
boolean updateByDTO(@Valid UpdateLngBPriceTermDto dto);
|
||||
|
||||
boolean enable(@Valid List<Long> ids);
|
||||
|
||||
boolean disable(@Valid List<Long> ids);
|
||||
}
|
||||
|
||||
@ -1,17 +1,27 @@
|
||||
package com.xjrsoft.module.mdm.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.pictc.constant.FieldNameConstants;
|
||||
import com.pictc.constant.TableNameConstants;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.pictc.enums.ExceptionCommonCode;
|
||||
import com.pictc.enums.ValidEnum;
|
||||
import com.pictc.utils.DataLogTools;
|
||||
import com.xjrsoft.common.enums.YesOrNoEnum;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.module.common.db.service.CommonCallService;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBCurrencyDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBCurrency;
|
||||
import com.xjrsoft.module.mdm.mapper.LngBCurrencyMapper;
|
||||
import com.xjrsoft.module.mdm.service.ICurrencyService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
@ -22,4 +32,83 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CurrencyServiceImpl extends ServiceImpl<LngBCurrencyMapper, LngBCurrency> implements ICurrencyService {
|
||||
private final CommonCallService commonCallService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(UpdateLngBCurrencyDto dto) {
|
||||
this.checkParams(dto);
|
||||
UpdateLngBCurrencyDto res = DataLogTools.insert(dto);
|
||||
this.addOrUpdateAfter(res.getId());
|
||||
return res.getId();
|
||||
}
|
||||
|
||||
private void checkParams(UpdateLngBCurrencyDto dto) {
|
||||
Long codeCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBCurrency>()
|
||||
.eq(LngBCurrency::getCode, dto.getCode())
|
||||
.ne(!Objects.isNull(dto.getId()), LngBCurrency::getId, dto.getId()));
|
||||
if (codeCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.CODE));
|
||||
}
|
||||
Long nameCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBCurrency>()
|
||||
.eq(LngBCurrency::getFullName, dto.getFullName())
|
||||
.ne(!Objects.isNull(dto.getId()), LngBCurrency::getId, dto.getId()));
|
||||
if (nameCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.FULL_NAME));
|
||||
}
|
||||
if (YesOrNoEnum.YES.getTextCode().equals(dto.getLocalSign())) {
|
||||
Long validCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBCurrency>()
|
||||
.eq(LngBCurrency::getLocalSign, YesOrNoEnum.YES.getTextCode())
|
||||
.eq(LngBCurrency::getValid, ValidEnum.ENABLE.getCode())
|
||||
.ne(!Objects.isNull(dto.getId()), LngBCurrency::getId, dto.getId()));
|
||||
if (validCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.LOCAL_SIGN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addOrUpdateAfter(Long id) {
|
||||
String msg = commonCallService.saveAfter(TableNameConstants.LNG_B_CURRENCY, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateByDTO(UpdateLngBCurrencyDto dto) {
|
||||
this.checkParams(dto);
|
||||
DataLogTools.update(dto);
|
||||
this.addOrUpdateAfter(dto.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean enable(List<Long> ids) {
|
||||
DataLogTools.enable(UpdateLngBCurrencyDto.class, ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_CURRENCY, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean disable(List<Long> ids) {
|
||||
DataLogTools.disable(UpdateLngBCurrencyDto.class, ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.disableBefore(TableNameConstants.LNG_B_CURRENCY, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,25 @@
|
||||
package com.xjrsoft.module.mdm.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.base.MPJBaseServiceImpl;
|
||||
import com.pictc.constant.FieldNameConstants;
|
||||
import com.pictc.constant.TableNameConstants;
|
||||
import com.pictc.enums.BusinessCode;
|
||||
import com.pictc.enums.ExceptionCommonCode;
|
||||
import com.pictc.utils.DataLogTools;
|
||||
import com.xjrsoft.common.exception.BusinessException;
|
||||
import com.xjrsoft.module.common.db.service.CommonCallService;
|
||||
import com.xjrsoft.module.mdm.dto.UpdateLngBPriceTermDto;
|
||||
import com.xjrsoft.module.mdm.entity.LngBPriceTerm;
|
||||
import com.xjrsoft.module.mdm.mapper.LngBPriceTermMapper;
|
||||
import com.xjrsoft.module.mdm.service.IPriceTermsService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
|
||||
/**
|
||||
* @title: service
|
||||
@ -22,4 +30,74 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class PriceTermsServiceImpl extends ServiceImpl<LngBPriceTermMapper, LngBPriceTerm> implements IPriceTermsService {
|
||||
|
||||
private final CommonCallService commonCallService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long add(UpdateLngBPriceTermDto dto) {
|
||||
this.checkParams(dto);
|
||||
UpdateLngBPriceTermDto res = DataLogTools.insert(dto);
|
||||
this.addOrUpdateAfter(res.getId());
|
||||
return res.getId();
|
||||
}
|
||||
|
||||
private void checkParams(UpdateLngBPriceTermDto dto) {
|
||||
Long codeCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBPriceTerm>()
|
||||
.eq(LngBPriceTerm::getCode, dto.getCode())
|
||||
.ne(!Objects.isNull(dto.getId()), LngBPriceTerm::getId, dto.getId()));
|
||||
if (codeCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.CODE));
|
||||
}
|
||||
Long nameCount = this.baseMapper.selectCount(new LambdaQueryWrapper<LngBPriceTerm>()
|
||||
.eq(LngBPriceTerm::getFullName, dto.getFullName())
|
||||
.ne(!Objects.isNull(dto.getId()), LngBPriceTerm::getId, dto.getId()));
|
||||
if (nameCount > 0) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DATA_FIELD_DUPLICATION,
|
||||
FieldNameConstants.FULL_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
private void addOrUpdateAfter(Long id) {
|
||||
String msg = commonCallService.saveAfter(TableNameConstants.LNG_B_PRICE_TERM, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateByDTO(UpdateLngBPriceTermDto dto) {
|
||||
this.checkParams(dto);
|
||||
DataLogTools.update(dto);
|
||||
this.addOrUpdateAfter(dto.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean enable(List<Long> ids) {
|
||||
DataLogTools.enable(UpdateLngBPriceTermDto.class, ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.enableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean disable(List<Long> ids) {
|
||||
DataLogTools.disable(UpdateLngBPriceTermDto.class, ids);
|
||||
for (Long id : ids) {
|
||||
String msg = commonCallService.disableBefore(TableNameConstants.LNG_B_PRICE_TERM, id);
|
||||
if (StringUtils.isNotBlank(msg)) {
|
||||
throw new BusinessException(BusinessCode.ofArgs(ExceptionCommonCode.DB_FUNCTION_EXEC_ERROR, msg));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user