parent
da0160b7cb
commit
1fc227d2d2
@ -0,0 +1,110 @@
|
|||||||
|
package com.yunxi.scm.module.system.controller.admin.enterprisebranch;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||||
|
import com.yunxi.scm.framework.common.pojo.CommonResult;
|
||||||
|
import static com.yunxi.scm.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import com.yunxi.scm.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import com.yunxi.scm.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import static com.yunxi.scm.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
import com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo.*;
|
||||||
|
import com.yunxi.scm.module.system.dal.dataobject.enterprisebranch.EnterpriseBranchDO;
|
||||||
|
import com.yunxi.scm.module.system.convert.enterprisebranch.EnterpriseBranchConvert;
|
||||||
|
import com.yunxi.scm.module.system.service.enterprisebranch.EnterpriseBranchService;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 分支机构")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/enterprise-branch")
|
||||||
|
@Validated
|
||||||
|
public class EnterpriseBranchController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseBranchService enterpriseBranchService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建分支机构")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:enterprise-branch:create')")
|
||||||
|
public CommonResult<Long> createEnterpriseBranch(@Valid @RequestBody EnterpriseBranchCreateReqVO createReqVO) {
|
||||||
|
return success(enterpriseBranchService.createEnterpriseBranch(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新分支机构")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:enterprise-branch:update')")
|
||||||
|
public CommonResult<Boolean> updateEnterpriseBranch(@Valid @RequestBody EnterpriseBranchUpdateReqVO updateReqVO) {
|
||||||
|
enterpriseBranchService.updateEnterpriseBranch(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除分支机构")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:enterprise-branch:delete')")
|
||||||
|
public CommonResult<Boolean> deleteEnterpriseBranch(@RequestParam("id") Long id) {
|
||||||
|
enterpriseBranchService.deleteEnterpriseBranch(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得分支机构")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:enterprise-branch:query')")
|
||||||
|
public CommonResult<EnterpriseBranchRespVO> getEnterpriseBranch(@RequestParam("id") Long id) {
|
||||||
|
EnterpriseBranchDO enterpriseBranch = enterpriseBranchService.getEnterpriseBranch(id);
|
||||||
|
return success(EnterpriseBranchConvert.INSTANCE.convert(enterpriseBranch));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "获得分支机构列表")
|
||||||
|
@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:enterprise-branch:query')")
|
||||||
|
public CommonResult<List<EnterpriseBranchRespVO>> getEnterpriseBranchList(@RequestParam("ids") Collection<Long> ids) {
|
||||||
|
List<EnterpriseBranchDO> list = enterpriseBranchService.getEnterpriseBranchList(ids);
|
||||||
|
return success(EnterpriseBranchConvert.INSTANCE.convertList(list));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得分支机构分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:enterprise-branch:query')")
|
||||||
|
public CommonResult<PageResult<EnterpriseBranchRespVO>> getEnterpriseBranchPage(@Valid EnterpriseBranchPageReqVO pageVO) {
|
||||||
|
PageResult<EnterpriseBranchDO> pageResult = enterpriseBranchService.getEnterpriseBranchPage(pageVO);
|
||||||
|
return success(EnterpriseBranchConvert.INSTANCE.convertPage(pageResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page1")
|
||||||
|
@Operation(summary = "自定义获得分支机构分页1")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:enterprise-branch:query1')")
|
||||||
|
public CommonResult<PageResult<EnterpriseBranchRespVO>> getEnterpriseBranchPage1(@Valid EnterpriseBranchPageReqVO pageVO) {
|
||||||
|
PageResult<EnterpriseBranchDO> pageResult = enterpriseBranchService.getEnterpriseBranchPageList(pageVO);
|
||||||
|
return success(EnterpriseBranchConvert.INSTANCE.convertPage(pageResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出分支机构 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('system:enterprise-branch:export')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void exportEnterpriseBranchExcel(@Valid EnterpriseBranchExportReqVO exportReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
List<EnterpriseBranchDO> list = enterpriseBranchService.getEnterpriseBranchList(exportReqVO);
|
||||||
|
// 导出 Excel
|
||||||
|
List<EnterpriseBranchExcelVO> datas = EnterpriseBranchConvert.INSTANCE.convertList02(list);
|
||||||
|
ExcelUtils.write(response, "分支机构.xls", "数据", EnterpriseBranchExcelVO.class, datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分支机构创建 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class EnterpriseBranchCreateReqVO extends EnterpriseBranchBaseVO {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分支机构 Response VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class EnterpriseBranchRespVO extends EnterpriseBranchBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7497")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 分支机构更新 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class EnterpriseBranchUpdateReqVO extends EnterpriseBranchBaseVO {
|
||||||
|
|
||||||
|
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7497")
|
||||||
|
@NotNull(message = "ID不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.yunxi.scm.module.system.convert.enterprisebranch;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
import com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo.*;
|
||||||
|
import com.yunxi.scm.module.system.dal.dataobject.enterprisebranch.EnterpriseBranchDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分支机构 Convert
|
||||||
|
*
|
||||||
|
* @author 长江云息
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface EnterpriseBranchConvert {
|
||||||
|
|
||||||
|
EnterpriseBranchConvert INSTANCE = Mappers.getMapper(EnterpriseBranchConvert.class);
|
||||||
|
|
||||||
|
EnterpriseBranchDO convert(EnterpriseBranchCreateReqVO bean);
|
||||||
|
|
||||||
|
EnterpriseBranchDO convert(EnterpriseBranchUpdateReqVO bean);
|
||||||
|
|
||||||
|
EnterpriseBranchRespVO convert(EnterpriseBranchDO bean);
|
||||||
|
|
||||||
|
List<EnterpriseBranchRespVO> convertList(List<EnterpriseBranchDO> list);
|
||||||
|
|
||||||
|
PageResult<EnterpriseBranchRespVO> convertPage(PageResult<EnterpriseBranchDO> page);
|
||||||
|
|
||||||
|
List<EnterpriseBranchExcelVO> convertList02(List<EnterpriseBranchDO> list);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.yunxi.scm.module.system.dal.mysql.enterprisebranch;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||||
|
import com.yunxi.scm.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.yunxi.scm.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.yunxi.scm.module.system.dal.dataobject.enterprisebranch.EnterpriseBranchDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo.*;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分支机构 Mapper
|
||||||
|
*
|
||||||
|
* @author 长江云息
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface EnterpriseBranchMapper extends BaseMapperX<EnterpriseBranchDO> {
|
||||||
|
|
||||||
|
default PageResult<EnterpriseBranchDO> selectPage(EnterpriseBranchPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<EnterpriseBranchDO>()
|
||||||
|
.likeIfPresent(EnterpriseBranchDO::getBranchName, reqVO.getBranchName())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getBranchType, reqVO.getBranchType())
|
||||||
|
.likeIfPresent(EnterpriseBranchDO::getAdminName, reqVO.getAdminName())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getTelephone, reqVO.getTelephone())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getBranchRemark, reqVO.getBranchRemark())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getBranchSuperior, reqVO.getBranchSuperior())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getLogo, reqVO.getLogo())
|
||||||
|
.betweenIfPresent(EnterpriseBranchDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(EnterpriseBranchDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<EnterpriseBranchDO> selectList(EnterpriseBranchExportReqVO reqVO) {
|
||||||
|
return selectList(new LambdaQueryWrapperX<EnterpriseBranchDO>()
|
||||||
|
.likeIfPresent(EnterpriseBranchDO::getBranchName, reqVO.getBranchName())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getBranchType, reqVO.getBranchType())
|
||||||
|
.likeIfPresent(EnterpriseBranchDO::getAdminName, reqVO.getAdminName())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getTelephone, reqVO.getTelephone())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getBranchRemark, reqVO.getBranchRemark())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getBranchSuperior, reqVO.getBranchSuperior())
|
||||||
|
.eqIfPresent(EnterpriseBranchDO::getLogo, reqVO.getLogo())
|
||||||
|
.betweenIfPresent(EnterpriseBranchDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(EnterpriseBranchDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
//自定义分页
|
||||||
|
IPage<EnterpriseBranchDO> selectListPage(IPage<EnterpriseBranchDO> page, @Param("reqVO") EnterpriseBranchPageReqVO reqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package com.yunxi.scm.module.system.service.enterprisebranch;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo.*;
|
||||||
|
import com.yunxi.scm.module.system.dal.dataobject.enterprisebranch.EnterpriseBranchDO;
|
||||||
|
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分支机构 Service 接口
|
||||||
|
*
|
||||||
|
* @author 长江云息
|
||||||
|
*/
|
||||||
|
public interface EnterpriseBranchService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建分支机构
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createEnterpriseBranch(@Valid EnterpriseBranchCreateReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新分支机构
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateEnterpriseBranch(@Valid EnterpriseBranchUpdateReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除分支机构
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteEnterpriseBranch(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分支机构
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 分支机构
|
||||||
|
*/
|
||||||
|
EnterpriseBranchDO getEnterpriseBranch(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分支机构列表
|
||||||
|
*
|
||||||
|
* @param ids 编号
|
||||||
|
* @return 分支机构列表
|
||||||
|
*/
|
||||||
|
List<EnterpriseBranchDO> getEnterpriseBranchList(Collection<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分支机构分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 分支机构分页
|
||||||
|
*/
|
||||||
|
PageResult<EnterpriseBranchDO> getEnterpriseBranchPage(EnterpriseBranchPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得分支机构列表, 用于 Excel 导出
|
||||||
|
*
|
||||||
|
* @param exportReqVO 查询条件
|
||||||
|
* @return 分支机构列表
|
||||||
|
*/
|
||||||
|
List<EnterpriseBranchDO> getEnterpriseBranchList(EnterpriseBranchExportReqVO exportReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义分页
|
||||||
|
*
|
||||||
|
* @param reqVO 查询条件
|
||||||
|
* @return 分支机构列表
|
||||||
|
*/
|
||||||
|
PageResult<EnterpriseBranchDO> getEnterpriseBranchPageList(EnterpriseBranchPageReqVO reqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
package com.yunxi.scm.module.system.service.enterprisebranch;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo.*;
|
||||||
|
import com.yunxi.scm.module.system.dal.dataobject.enterprisebranch.EnterpriseBranchDO;
|
||||||
|
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import com.yunxi.scm.module.system.convert.enterprisebranch.EnterpriseBranchConvert;
|
||||||
|
import com.yunxi.scm.module.system.dal.mysql.enterprisebranch.EnterpriseBranchMapper;
|
||||||
|
|
||||||
|
import static com.yunxi.scm.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.yunxi.scm.module.system.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分支机构 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 长江云息
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class EnterpriseBranchServiceImpl implements EnterpriseBranchService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseBranchMapper enterpriseBranchMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createEnterpriseBranch(EnterpriseBranchCreateReqVO createReqVO) {
|
||||||
|
// 插入
|
||||||
|
EnterpriseBranchDO enterpriseBranch = EnterpriseBranchConvert.INSTANCE.convert(createReqVO);
|
||||||
|
enterpriseBranchMapper.insert(enterpriseBranch);
|
||||||
|
// 返回
|
||||||
|
return enterpriseBranch.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEnterpriseBranch(EnterpriseBranchUpdateReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateEnterpriseBranchExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
EnterpriseBranchDO updateObj = EnterpriseBranchConvert.INSTANCE.convert(updateReqVO);
|
||||||
|
enterpriseBranchMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEnterpriseBranch(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateEnterpriseBranchExists(id);
|
||||||
|
// 删除
|
||||||
|
enterpriseBranchMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateEnterpriseBranchExists(Long id) {
|
||||||
|
if (enterpriseBranchMapper.selectById(id) == null) {
|
||||||
|
throw exception(ENTERPRISE_BRANCH_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnterpriseBranchDO getEnterpriseBranch(Long id) {
|
||||||
|
return enterpriseBranchMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EnterpriseBranchDO> getEnterpriseBranchList(Collection<Long> ids) {
|
||||||
|
return enterpriseBranchMapper.selectBatchIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<EnterpriseBranchDO> getEnterpriseBranchPage(EnterpriseBranchPageReqVO pageReqVO) {
|
||||||
|
return enterpriseBranchMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EnterpriseBranchDO> getEnterpriseBranchList(EnterpriseBranchExportReqVO exportReqVO) {
|
||||||
|
return enterpriseBranchMapper.selectList(exportReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<EnterpriseBranchDO> getEnterpriseBranchPageList(EnterpriseBranchPageReqVO reqVO) {
|
||||||
|
IPage<EnterpriseBranchDO> page=new Page<>(reqVO.getPageNo(),reqVO.getPageSize());
|
||||||
|
enterpriseBranchMapper.selectListPage(page,reqVO);
|
||||||
|
return new PageResult<>(page.getRecords(),page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,207 @@
|
|||||||
|
package com.yunxi.scm.module.system.service.enterprisebranch;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import com.yunxi.scm.framework.test.core.ut.BaseDbUnitTest;
|
||||||
|
|
||||||
|
import com.yunxi.scm.module.system.controller.admin.enterprisebranch.vo.*;
|
||||||
|
import com.yunxi.scm.module.system.dal.dataobject.enterprisebranch.EnterpriseBranchDO;
|
||||||
|
import com.yunxi.scm.module.system.dal.mysql.enterprisebranch.EnterpriseBranchMapper;
|
||||||
|
import com.yunxi.scm.framework.common.pojo.PageResult;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.hutool.core.util.RandomUtil.*;
|
||||||
|
import static com.yunxi.scm.module.system.enums.ErrorCodeConstants.*;
|
||||||
|
import static com.yunxi.scm.framework.test.core.util.AssertUtils.*;
|
||||||
|
import static com.yunxi.scm.framework.test.core.util.RandomUtils.*;
|
||||||
|
import static com.yunxi.scm.framework.common.util.date.LocalDateTimeUtils.*;
|
||||||
|
import static com.yunxi.scm.framework.common.util.object.ObjectUtils.*;
|
||||||
|
import static com.yunxi.scm.framework.common.util.date.DateUtils.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link EnterpriseBranchServiceImpl} 的单元测试类
|
||||||
|
*
|
||||||
|
* @author 长江云息
|
||||||
|
*/
|
||||||
|
@Import(EnterpriseBranchServiceImpl.class)
|
||||||
|
public class EnterpriseBranchServiceImplTest extends BaseDbUnitTest {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseBranchServiceImpl enterpriseBranchService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private EnterpriseBranchMapper enterpriseBranchMapper;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateEnterpriseBranch_success() {
|
||||||
|
// 准备参数
|
||||||
|
EnterpriseBranchCreateReqVO reqVO = randomPojo(EnterpriseBranchCreateReqVO.class);
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
Long enterpriseBranchId = enterpriseBranchService.createEnterpriseBranch(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertNotNull(enterpriseBranchId);
|
||||||
|
// 校验记录的属性是否正确
|
||||||
|
EnterpriseBranchDO enterpriseBranch = enterpriseBranchMapper.selectById(enterpriseBranchId);
|
||||||
|
assertPojoEquals(reqVO, enterpriseBranch);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateEnterpriseBranch_success() {
|
||||||
|
// mock 数据
|
||||||
|
EnterpriseBranchDO dbEnterpriseBranch = randomPojo(EnterpriseBranchDO.class);
|
||||||
|
enterpriseBranchMapper.insert(dbEnterpriseBranch);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
EnterpriseBranchUpdateReqVO reqVO = randomPojo(EnterpriseBranchUpdateReqVO.class, o -> {
|
||||||
|
o.setId(dbEnterpriseBranch.getId()); // 设置更新的 ID
|
||||||
|
});
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
enterpriseBranchService.updateEnterpriseBranch(reqVO);
|
||||||
|
// 校验是否更新正确
|
||||||
|
EnterpriseBranchDO enterpriseBranch = enterpriseBranchMapper.selectById(reqVO.getId()); // 获取最新的
|
||||||
|
assertPojoEquals(reqVO, enterpriseBranch);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateEnterpriseBranch_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
EnterpriseBranchUpdateReqVO reqVO = randomPojo(EnterpriseBranchUpdateReqVO.class);
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> enterpriseBranchService.updateEnterpriseBranch(reqVO), ENTERPRISE_BRANCH_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteEnterpriseBranch_success() {
|
||||||
|
// mock 数据
|
||||||
|
EnterpriseBranchDO dbEnterpriseBranch = randomPojo(EnterpriseBranchDO.class);
|
||||||
|
enterpriseBranchMapper.insert(dbEnterpriseBranch);// @Sql: 先插入出一条存在的数据
|
||||||
|
// 准备参数
|
||||||
|
Long id = dbEnterpriseBranch.getId();
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
enterpriseBranchService.deleteEnterpriseBranch(id);
|
||||||
|
// 校验数据不存在了
|
||||||
|
assertNull(enterpriseBranchMapper.selectById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteEnterpriseBranch_notExists() {
|
||||||
|
// 准备参数
|
||||||
|
Long id = randomLongId();
|
||||||
|
|
||||||
|
// 调用, 并断言异常
|
||||||
|
assertServiceException(() -> enterpriseBranchService.deleteEnterpriseBranch(id), ENTERPRISE_BRANCH_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetEnterpriseBranchPage() {
|
||||||
|
// mock 数据
|
||||||
|
EnterpriseBranchDO dbEnterpriseBranch = randomPojo(EnterpriseBranchDO.class, o -> { // 等会查询到
|
||||||
|
o.setBranchName(null);
|
||||||
|
o.setBranchType(null);
|
||||||
|
o.setAdminName(null);
|
||||||
|
o.setTelephone(null);
|
||||||
|
o.setBranchRemark(null);
|
||||||
|
o.setBranchSuperior(null);
|
||||||
|
o.setLogo(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
enterpriseBranchMapper.insert(dbEnterpriseBranch);
|
||||||
|
// 测试 branchName 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setBranchName(null)));
|
||||||
|
// 测试 branchType 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setBranchType(null)));
|
||||||
|
// 测试 adminName 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setAdminName(null)));
|
||||||
|
// 测试 telephone 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setTelephone(null)));
|
||||||
|
// 测试 branchRemark 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setBranchRemark(null)));
|
||||||
|
// 测试 branchSuperior 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setBranchSuperior(null)));
|
||||||
|
// 测试 logo 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setLogo(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
EnterpriseBranchPageReqVO reqVO = new EnterpriseBranchPageReqVO();
|
||||||
|
reqVO.setBranchName(null);
|
||||||
|
reqVO.setBranchType(null);
|
||||||
|
reqVO.setAdminName(null);
|
||||||
|
reqVO.setTelephone(null);
|
||||||
|
reqVO.setBranchRemark(null);
|
||||||
|
reqVO.setBranchSuperior(null);
|
||||||
|
reqVO.setLogo(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
PageResult<EnterpriseBranchDO> pageResult = enterpriseBranchService.getEnterpriseBranchPage(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, pageResult.getTotal());
|
||||||
|
assertEquals(1, pageResult.getList().size());
|
||||||
|
assertPojoEquals(dbEnterpriseBranch, pageResult.getList().get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||||
|
public void testGetEnterpriseBranchList() {
|
||||||
|
// mock 数据
|
||||||
|
EnterpriseBranchDO dbEnterpriseBranch = randomPojo(EnterpriseBranchDO.class, o -> { // 等会查询到
|
||||||
|
o.setBranchName(null);
|
||||||
|
o.setBranchType(null);
|
||||||
|
o.setAdminName(null);
|
||||||
|
o.setTelephone(null);
|
||||||
|
o.setBranchRemark(null);
|
||||||
|
o.setBranchSuperior(null);
|
||||||
|
o.setLogo(null);
|
||||||
|
o.setCreateTime(null);
|
||||||
|
});
|
||||||
|
enterpriseBranchMapper.insert(dbEnterpriseBranch);
|
||||||
|
// 测试 branchName 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setBranchName(null)));
|
||||||
|
// 测试 branchType 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setBranchType(null)));
|
||||||
|
// 测试 adminName 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setAdminName(null)));
|
||||||
|
// 测试 telephone 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setTelephone(null)));
|
||||||
|
// 测试 branchRemark 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setBranchRemark(null)));
|
||||||
|
// 测试 branchSuperior 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setBranchSuperior(null)));
|
||||||
|
// 测试 logo 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setLogo(null)));
|
||||||
|
// 测试 createTime 不匹配
|
||||||
|
enterpriseBranchMapper.insert(cloneIgnoreId(dbEnterpriseBranch, o -> o.setCreateTime(null)));
|
||||||
|
// 准备参数
|
||||||
|
EnterpriseBranchExportReqVO reqVO = new EnterpriseBranchExportReqVO();
|
||||||
|
reqVO.setBranchName(null);
|
||||||
|
reqVO.setBranchType(null);
|
||||||
|
reqVO.setAdminName(null);
|
||||||
|
reqVO.setTelephone(null);
|
||||||
|
reqVO.setBranchRemark(null);
|
||||||
|
reqVO.setBranchSuperior(null);
|
||||||
|
reqVO.setLogo(null);
|
||||||
|
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||||
|
|
||||||
|
// 调用
|
||||||
|
List<EnterpriseBranchDO> list = enterpriseBranchService.getEnterpriseBranchList(reqVO);
|
||||||
|
// 断言
|
||||||
|
assertEquals(1, list.size());
|
||||||
|
assertPojoEquals(dbEnterpriseBranch, list.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
import { defHttp } from '@/utils/http/axios'
|
||||||
|
|
||||||
|
|
||||||
|
// export interface EnterpriseBranchPageReqVO extends PageParam {
|
||||||
|
// branchName?: string
|
||||||
|
// branchType?: string
|
||||||
|
// adminName?: string
|
||||||
|
// telephone?: string
|
||||||
|
// branchRemark?: string
|
||||||
|
// createTime?: Date[]
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// 查询分支机构列表
|
||||||
|
export function getEnterpriseBranchPage(params) {
|
||||||
|
return defHttp.get({ url: '/system/enterprise-branch/page', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询分支机构列表
|
||||||
|
export function getEnterpriseBranchPage1(params) {
|
||||||
|
return defHttp.get({ url: '/system/enterprise-branch/page1', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询分支机构详情
|
||||||
|
export function getEnterpriseBranch(id: number) {
|
||||||
|
return defHttp.get({ url: '/system/enterprise-branch/get?id=' + id })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增分支机构
|
||||||
|
export function createEnterpriseBranch(data) {
|
||||||
|
return defHttp.post({ url: '/system/enterprise-branch/create', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改分支机构
|
||||||
|
export function updateEnterpriseBranch(data) {
|
||||||
|
return defHttp.put({ url: '/system/enterprise-branch/update', data })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除分支机构
|
||||||
|
export function deleteEnterpriseBranch(id: number) {
|
||||||
|
return defHttp.delete({ url: '/system/enterprise-branch/delete?id=' + id })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出分支机构 Excel
|
||||||
|
export function exportEnterpriseBranch(params) {
|
||||||
|
return defHttp.download({ url: '/system/enterprise-branch/export-excel', params }, '分支机构.xls')
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { createEnterpriseBranch } from '@/api/system/enterpriseBranch'
|
||||||
|
|
||||||
|
import { reactive, ref } from 'vue'
|
||||||
|
import TransferList from './TransferList.vue'
|
||||||
|
|
||||||
|
interface FormState {
|
||||||
|
k1: string;
|
||||||
|
k2: string;
|
||||||
|
k3: string;
|
||||||
|
k4: string;
|
||||||
|
k5: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formState = reactive<FormState>({
|
||||||
|
k1: '',
|
||||||
|
k2: '济钢城市矿产科技有限公司',
|
||||||
|
k3: '',
|
||||||
|
k4: '',
|
||||||
|
k5: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
isShow: Boolean
|
||||||
|
})
|
||||||
|
const emit = defineEmits(['doCancel'])
|
||||||
|
// 模态显示
|
||||||
|
// const isOpen: any = ref(true);
|
||||||
|
// 确认
|
||||||
|
const doOk = async () => {
|
||||||
|
const result = await createEnterpriseBranch(FormState.userInfo);
|
||||||
|
console.log('ok');
|
||||||
|
emit('doCancel', false)
|
||||||
|
}
|
||||||
|
// 取消
|
||||||
|
const doCancel = () => {
|
||||||
|
emit('doCancel', false)
|
||||||
|
}
|
||||||
|
const onFinish = (values: any) => {
|
||||||
|
console.log('Success:', values);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onFinishFailed = (errorInfo: any) => {
|
||||||
|
console.log('Failed:', errorInfo);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 传输框
|
||||||
|
let isShowTransferList = ref(false);
|
||||||
|
// const doShowModalAdd = (isshow: boolean) => {
|
||||||
|
// isShowModalAdd.value = isshow;
|
||||||
|
// }
|
||||||
|
const onSelect = (formState: any) => {
|
||||||
|
isShowTransferList.value = true;
|
||||||
|
console.log(formState.k3);
|
||||||
|
};
|
||||||
|
// 取消传输选择
|
||||||
|
const doCancelA = (isshow: boolean) => {
|
||||||
|
isShowTransferList.value = isshow
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<template v-if="props.isShow">
|
||||||
|
<a-modal :open="true" title="新建机构" @ok="doOk" @cancel="doCancel">
|
||||||
|
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off"
|
||||||
|
@finish="onFinish" @finishFailed="onFinishFailed">
|
||||||
|
<a-form-item label="机构名称" name="k1" :rules="[{ required: true, message: '请输入机构名称!' }]">
|
||||||
|
<a-input v-model:value="formState.k1" placeholder="输入内容" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="上级机构" name="k2" :rules="[]">
|
||||||
|
<a-input v-model:value="formState.k2" disabled />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label=" 负责人员" name="k3" :rules="[{ required: true, message: '请选择负责人员!' }]">
|
||||||
|
<a-input v-model:value="formState.k3" placeholder="选择人员" @click="onSelect(formState)" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label=" 联系电话" name="k4" :rules="[{ required: true, message: '请输入联系电话!' }]">
|
||||||
|
<a-input v-model:value="formState.k4" placeholder="输入内容" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label=" 机构描述" name="k5" :rules="[]">
|
||||||
|
<a-textarea v-model:value="formState.k5" placeholder="输入内容" :auto-size="{ minRows: 4, maxRows: 6 }" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</a-modal>
|
||||||
|
<TransferList :isShow="isShowTransferList" @do-cancel="doCancelA"></TransferList>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
Loading…
Reference in new issue