|
@@ -2,29 +2,26 @@ package org.jeecg.modules.system.app.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.apache.shiro.SecurityUtils;
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
-import org.jeecg.modules.system.app.dto.AppCategoryDTO;
|
|
|
|
-import org.jeecg.modules.system.app.dto.AppSiteDTO;
|
|
|
|
-import org.jeecg.modules.system.app.entity.AppCategory;
|
|
|
|
|
|
+import org.jeecg.modules.system.app.dto.*;
|
|
import org.jeecg.modules.system.app.entity.AppSite;
|
|
import org.jeecg.modules.system.app.entity.AppSite;
|
|
import org.jeecg.modules.system.app.entity.AppSitePriceRules;
|
|
import org.jeecg.modules.system.app.entity.AppSitePriceRules;
|
|
import org.jeecg.modules.system.app.mapper.AppSiteMapper;
|
|
import org.jeecg.modules.system.app.mapper.AppSiteMapper;
|
|
import org.jeecg.modules.system.app.mapper.AppSitePriceRulesMapper;
|
|
import org.jeecg.modules.system.app.mapper.AppSitePriceRulesMapper;
|
|
import org.jeecg.modules.system.app.service.IAppSiteService;
|
|
import org.jeecg.modules.system.app.service.IAppSiteService;
|
|
-import org.jeecg.modules.system.app.vo.AppCategoryVO;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
|
|
import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
|
|
@@ -43,9 +40,11 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Boolean saveWitchPriceRules(AppSiteDTO appSiteDTO) {
|
|
public Boolean saveWitchPriceRules(AppSiteDTO appSiteDTO) {
|
|
- AppSite site = appSiteDTO.getSite();
|
|
|
|
- if (null == site.getType()) throw new JeecgBootException("场地类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
|
|
|
+ AppSiteCuDTO siteCuDTO = appSiteDTO.getSite();
|
|
|
|
+ if (null == siteCuDTO.getType()) throw new JeecgBootException("场地类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
+ AppSite site = new AppSite();
|
|
|
|
+ BeanUtils.copyProperties(siteCuDTO, site);
|
|
site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
|
|
site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
|
|
site.setTenantId(sysUser.getOrgId());
|
|
site.setTenantId(sysUser.getOrgId());
|
|
int saveSiteResult = baseMapper.insert(site);
|
|
int saveSiteResult = baseMapper.insert(site);
|
|
@@ -55,14 +54,15 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
|
|
}
|
|
}
|
|
|
|
|
|
// 获取价格规则列表
|
|
// 获取价格规则列表
|
|
- List<AppSitePriceRules> priceRulesList = appSiteDTO.getPriceRulesList();
|
|
|
|
- for (AppSitePriceRules rule : priceRulesList) {
|
|
|
|
|
|
+ List<AppSiteRuleDTO> priceRulesList = appSiteDTO.getPriceRulesList();
|
|
|
|
+ for (AppSiteRuleDTO rule : priceRulesList) {
|
|
// 设置当前规则对应的场地 ID
|
|
// 设置当前规则对应的场地 ID
|
|
- rule.setSiteId(site.getId());
|
|
|
|
- rule.setOrgCode(site.getOrgCode());
|
|
|
|
- rule.setTenantId(site.getTenantId());
|
|
|
|
|
|
+ AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
|
|
|
|
+ appSitePriceRules.setSiteId(site.getId());
|
|
|
|
+ appSitePriceRules.setOrgCode(site.getOrgCode());
|
|
|
|
+ appSitePriceRules.setTenantId(site.getTenantId());
|
|
// 调用 priceRulesMapper 插入价格规则
|
|
// 调用 priceRulesMapper 插入价格规则
|
|
- int savePriceResult = priceRulesMapper.insert(rule);
|
|
|
|
|
|
+ int savePriceResult = priceRulesMapper.insert(appSitePriceRules);
|
|
// 如果插入失败,抛出自定义异常提示“场地价格规则保存失败”
|
|
// 如果插入失败,抛出自定义异常提示“场地价格规则保存失败”
|
|
if (savePriceResult < 1) {
|
|
if (savePriceResult < 1) {
|
|
throw new JeecgBootException("场地价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
throw new JeecgBootException("场地价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
@@ -76,12 +76,14 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Boolean editWitchPriceRules(AppSiteDTO appSiteDTO) {
|
|
public Boolean editWitchPriceRules(AppSiteDTO appSiteDTO) {
|
|
- AppSite site = appSiteDTO.getSite();
|
|
|
|
|
|
+ AppSiteCuDTO siteCuDTO = appSiteDTO.getSite();
|
|
|
|
+ AppSite site = new AppSite();
|
|
|
|
+ BeanUtils.copyProperties(siteCuDTO, site);
|
|
if (null == site.getType()) throw new JeecgBootException("场地类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
|
|
if (null == site.getType()) throw new JeecgBootException("场地类型不能为空", SC_INTERNAL_SERVER_ERROR_500);
|
|
AppSite dbSite = baseMapper.selectById(site.getId());
|
|
AppSite dbSite = baseMapper.selectById(site.getId());
|
|
if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
|
|
if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
- checkPermission(dbSite,sysUser);
|
|
|
|
|
|
+// checkPermission(dbSite,sysUser);
|
|
site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
|
|
site.setOrgCode(sysUser.getOrgCode());//部门默认登录用户部门
|
|
site.setTenantId(sysUser.getOrgId());
|
|
site.setTenantId(sysUser.getOrgId());
|
|
int updateSiteResult = baseMapper.updateById(site);
|
|
int updateSiteResult = baseMapper.updateById(site);
|
|
@@ -89,12 +91,14 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
|
|
throw new JeecgBootException("场地信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
throw new JeecgBootException("场地信息保存失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
}
|
|
}
|
|
|
|
|
|
- List<AppSitePriceRules> priceRulesList = appSiteDTO.getPriceRulesList();
|
|
|
|
- for (AppSitePriceRules rule : priceRulesList) {
|
|
|
|
- rule.setSiteId(site.getId());
|
|
|
|
- rule.setOrgCode(site.getOrgCode());
|
|
|
|
- rule.setTenantId(site.getTenantId());
|
|
|
|
- int savePriceResult = priceRulesMapper.updateById(rule); // 保证每个操作都在事务中
|
|
|
|
|
|
+ List<AppSiteRuleDTO> priceRulesList = appSiteDTO.getPriceRulesList();
|
|
|
|
+ for (AppSiteRuleDTO rule : priceRulesList) {
|
|
|
|
+ AppSitePriceRules appSitePriceRules = new AppSitePriceRules();
|
|
|
|
+ BeanUtils.copyProperties(rule, appSitePriceRules);
|
|
|
|
+ appSitePriceRules.setSiteId(site.getId());
|
|
|
|
+ appSitePriceRules.setOrgCode(site.getOrgCode());
|
|
|
|
+ appSitePriceRules.setTenantId(site.getTenantId());
|
|
|
|
+ int savePriceResult = priceRulesMapper.updateById(appSitePriceRules); // 保证每个操作都在事务中
|
|
if (savePriceResult < 1) {
|
|
if (savePriceResult < 1) {
|
|
throw new JeecgBootException("场地价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
throw new JeecgBootException("场地价格规则保存失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
}
|
|
}
|
|
@@ -107,10 +111,18 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
|
|
public AppSiteDTO queryWitchPriceRulesById(String id) {
|
|
public AppSiteDTO queryWitchPriceRulesById(String id) {
|
|
AppSite dbSite = baseMapper.selectById(id);
|
|
AppSite dbSite = baseMapper.selectById(id);
|
|
if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
|
|
if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
|
+ AppSiteCuDTO appSiteCuDTO = new AppSiteCuDTO();
|
|
|
|
+ BeanUtils.copyProperties(dbSite, appSiteCuDTO);
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
- checkPermission(dbSite,sysUser);
|
|
|
|
|
|
+// checkPermission(dbSite,sysUser);
|
|
List<AppSitePriceRules> priceRulesList = priceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, id));
|
|
List<AppSitePriceRules> priceRulesList = priceRulesMapper.selectList(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, id));
|
|
- return new AppSiteDTO(dbSite,priceRulesList);
|
|
|
|
|
|
+ List<AppSiteRuleDTO> priceRulesDTOList = new ArrayList<>();
|
|
|
|
+ priceRulesList.forEach(rule-> {
|
|
|
|
+ AppSiteRuleDTO appSiteRuleDTO = new AppSiteRuleDTO();
|
|
|
|
+ BeanUtils.copyProperties(rule, appSiteRuleDTO);
|
|
|
|
+ priceRulesDTOList.add(appSiteRuleDTO);
|
|
|
|
+ });
|
|
|
|
+ return new AppSiteDTO(appSiteCuDTO,priceRulesDTOList);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -119,7 +131,7 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
|
|
AppSite dbSite = baseMapper.selectById(id);
|
|
AppSite dbSite = baseMapper.selectById(id);
|
|
if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
|
|
if (null==dbSite) throw new JeecgBootException("未找到对应数据", SC_INTERNAL_SERVER_ERROR_500);
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
- checkPermission(dbSite,sysUser);
|
|
|
|
|
|
+// checkPermission(dbSite,sysUser);
|
|
int deleteSiteResult = baseMapper.deleteById(id);
|
|
int deleteSiteResult = baseMapper.deleteById(id);
|
|
if (deleteSiteResult>0){
|
|
if (deleteSiteResult>0){
|
|
int deletePriceResult = priceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, id));
|
|
int deletePriceResult = priceRulesMapper.delete(Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, id));
|
|
@@ -131,17 +143,26 @@ public class AppSiteServiceImpl extends ServiceImpl<AppSiteMapper, AppSite> impl
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public IPage<AppSite> querySiteList(AppSiteDTO dto) {
|
|
|
|
-// Page<AppSite> page = new Page<>(dto.getPageNum(), dto.getPageSize());
|
|
|
|
-// LambdaQueryWrapper<AppSite> wrapper = Wrappers.<AppSite>lambdaQuery()
|
|
|
|
-// .like(StringUtils.isNotBlank(dto.getName()), AppSite::getName, dto.getName());
|
|
|
|
-// IPage<AppSite> resultPage = baseMapper.selectPage(page, wrapper);
|
|
|
|
-// return resultPage.convert(record -> {
|
|
|
|
-// AppSiteVO vo = new AppCategoryVO();
|
|
|
|
-// BeanUtils.copyProperties(record, vo);
|
|
|
|
-// return vo;
|
|
|
|
-// });
|
|
|
|
- return null;
|
|
|
|
|
|
+ public IPage<AppSiteDTO> querySiteList(AppSitePageDTO dto) {
|
|
|
|
+ Page<AppSite> page = new Page<>(dto.getPageNum(), dto.getPageSize());
|
|
|
|
+ LambdaQueryWrapper<AppSite> wrapper = Wrappers.<AppSite>lambdaQuery()
|
|
|
|
+ .like(StringUtils.isNotBlank(dto.getName()), AppSite::getName, dto.getName());
|
|
|
|
+ IPage<AppSite> resultPage = baseMapper.selectPage(page, wrapper);
|
|
|
|
+
|
|
|
|
+ return resultPage.convert(record -> {
|
|
|
|
+ AppSiteCuDTO cuDTO = new AppSiteCuDTO();
|
|
|
|
+ BeanUtils.copyProperties(record, cuDTO);
|
|
|
|
+ List<AppSitePriceRules> priceRulesList = priceRulesMapper.selectList(
|
|
|
|
+ Wrappers.<AppSitePriceRules>lambdaQuery().eq(AppSitePriceRules::getSiteId, record.getId()));
|
|
|
|
+ List<AppSiteRuleDTO> priceRulesDTOList = new ArrayList<>();
|
|
|
|
+ priceRulesList.forEach(rule-> {
|
|
|
|
+ AppSiteRuleDTO appSiteRuleDTO = new AppSiteRuleDTO();
|
|
|
|
+ BeanUtils.copyProperties(rule, appSiteRuleDTO);
|
|
|
|
+ priceRulesDTOList.add(appSiteRuleDTO);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return new AppSiteDTO(cuDTO, priceRulesDTOList);
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|