1. 修复回滚父子角色功能时错误的代码逻辑,补全单元测试用例
2. 新增支持切换后业务菜单查询需限定只查询该公司业务数据能力
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package cn.iocoder.yudao.module.template;
|
||||
|
||||
import cn.iocoder.yudao.framework.business.framework.BusinessDataPermissionConfiguration;
|
||||
import cn.iocoder.yudao.framework.datapermission.config.YudaoCompanyDataPermissionAutoConfiguration;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* 项目的启动类
|
||||
@@ -9,6 +12,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
* @author 周迪
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@Import(BusinessDataPermissionConfiguration.class)
|
||||
public class TemplateServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package cn.iocoder.yudao.module.template.controller.admin.contract;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import cn.iocoder.yudao.framework.business.interceptor.BusinessControllerMarker;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.contract.vo.DemoContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.contract.vo.DemoContractRespVO;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.contract.vo.DemoContractSaveReqVO;
|
||||
import cn.iocoder.yudao.module.template.dal.dataobject.contract.DemoContractDO;
|
||||
import cn.iocoder.yudao.module.template.service.contract.DemoContractService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* @author chenbowen
|
||||
*/
|
||||
@Tag(name = "管理后台 - 合同")
|
||||
@RestController
|
||||
@RequestMapping("/template/demo-contract")
|
||||
@Validated
|
||||
public class DemoContractController implements BusinessControllerMarker {
|
||||
|
||||
@Resource
|
||||
private DemoContractService demoContractService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建合同")
|
||||
@PreAuthorize("@ss.hasPermission('template:demo-contract:create')")
|
||||
public CommonResult<Long> createDemoContract(@Valid @RequestBody DemoContractSaveReqVO createReqVO) {
|
||||
return success(demoContractService.createDemoContract(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新合同")
|
||||
@PreAuthorize("@ss.hasPermission('template:demo-contract:update')")
|
||||
public CommonResult<Boolean> updateDemoContract(@Valid @RequestBody DemoContractSaveReqVO updateReqVO) {
|
||||
demoContractService.updateDemoContract(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除合同")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('template:demo-contract:delete')")
|
||||
public CommonResult<Boolean> deleteDemoContract(@RequestParam("id") Long id) {
|
||||
demoContractService.deleteDemoContract(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号", required = true)
|
||||
@Operation(summary = "批量删除合同")
|
||||
@PreAuthorize("@ss.hasPermission('template:demo-contract:delete')")
|
||||
public CommonResult<Boolean> deleteDemoContractList(@RequestParam("ids") List<Long> ids) {
|
||||
demoContractService.deleteDemoContractListByIds(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得合同")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('template:demo-contract:query')")
|
||||
public CommonResult<DemoContractRespVO> getDemoContract(@RequestParam("id") Long id) {
|
||||
DemoContractDO demoContract = demoContractService.getDemoContract(id);
|
||||
return success(BeanUtils.toBean(demoContract, DemoContractRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得合同分页")
|
||||
@PreAuthorize("@ss.hasPermission('template:demo-contract:query')")
|
||||
public CommonResult<PageResult<DemoContractRespVO>> getDemoContractPage(@Valid DemoContractPageReqVO pageReqVO) {
|
||||
PageResult<DemoContractDO> pageResult = demoContractService.getDemoContractPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DemoContractRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出合同 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('template:demo-contract:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDemoContractExcel(@Valid DemoContractPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DemoContractDO> list = demoContractService.getDemoContractPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "合同.xls", "数据", DemoContractRespVO.class,
|
||||
BeanUtils.toBean(list, DemoContractRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.iocoder.yudao.module.template.controller.admin.contract.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 合同分页 Request VO")
|
||||
@Data
|
||||
public class DemoContractPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "合同编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "合同名称", example = "李四")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "合同状态", example = "1")
|
||||
private Short status;
|
||||
|
||||
@Schema(description = "流程实例ID", example = "24962")
|
||||
private Long processInstanceId;
|
||||
|
||||
@Schema(description = "签订日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] signDate;
|
||||
|
||||
@Schema(description = "合同开始日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] startDate;
|
||||
|
||||
@Schema(description = "合同结束日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] endDate;
|
||||
|
||||
@Schema(description = "合同金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "公司ID", example = "4180")
|
||||
private Long companyId;
|
||||
|
||||
@Schema(description = "公司名称", example = "张三")
|
||||
private String companyName;
|
||||
|
||||
@Schema(description = "部门ID", example = "1707")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门名称", example = "张三")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "岗位ID", example = "26779")
|
||||
private Long postId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package cn.iocoder.yudao.module.template.controller.admin.contract.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 合同 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DemoContractRespVO {
|
||||
|
||||
@Schema(description = "合同ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9541")
|
||||
@ExcelProperty("合同ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("合同编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@ExcelProperty("合同名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "合同状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@ExcelProperty("合同状态")
|
||||
private Short status;
|
||||
|
||||
@Schema(description = "流程实例ID", example = "24962")
|
||||
@ExcelProperty("流程实例ID")
|
||||
private Long processInstanceId;
|
||||
|
||||
@Schema(description = "签订日期")
|
||||
@ExcelProperty("签订日期")
|
||||
private LocalDateTime signDate;
|
||||
|
||||
@Schema(description = "合同开始日期")
|
||||
@ExcelProperty("合同开始日期")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@Schema(description = "合同结束日期")
|
||||
@ExcelProperty("合同结束日期")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
@Schema(description = "合同金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("合同金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "公司ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4180")
|
||||
@ExcelProperty("公司ID")
|
||||
private Long companyId;
|
||||
|
||||
@Schema(description = "公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("公司名称")
|
||||
private String companyName;
|
||||
|
||||
@Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1707")
|
||||
@ExcelProperty("部门ID")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("部门名称")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "岗位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26779")
|
||||
@ExcelProperty("岗位ID")
|
||||
private Long postId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.template.controller.admin.contract.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 合同新增/修改 Request VO")
|
||||
@Data
|
||||
public class DemoContractSaveReqVO {
|
||||
|
||||
@Schema(description = "合同ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "9541")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@NotEmpty(message = "合同名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "签订日期")
|
||||
private LocalDateTime signDate;
|
||||
|
||||
@Schema(description = "合同开始日期")
|
||||
private LocalDateTime startDate;
|
||||
|
||||
@Schema(description = "合同结束日期")
|
||||
private LocalDateTime endDate;
|
||||
|
||||
@Schema(description = "合同金额", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "合同金额不能为空")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "公司ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4180")
|
||||
@NotNull(message = "公司ID不能为空")
|
||||
private Long companyId;
|
||||
|
||||
@Schema(description = "公司名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotEmpty(message = "公司名称不能为空")
|
||||
private String companyName;
|
||||
|
||||
@Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1707")
|
||||
@NotNull(message = "部门ID不能为空")
|
||||
private Long deptId;
|
||||
|
||||
@Schema(description = "部门名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotEmpty(message = "部门名称不能为空")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description = "岗位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26779")
|
||||
@NotNull(message = "岗位ID不能为空")
|
||||
private Long postId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package cn.iocoder.yudao.module.template.dal.dataobject.contract;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BusinessBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 合同 DO
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@TableName("demo_contract")
|
||||
@KeySequence("demo_contract_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DemoContractDO extends BusinessBaseDO {
|
||||
|
||||
/**
|
||||
* 合同ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
/**
|
||||
* 合同编号
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 合同名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 合同状态
|
||||
*/
|
||||
private Short status;
|
||||
/**
|
||||
* 流程实例ID
|
||||
*/
|
||||
private Long processInstanceId;
|
||||
/**
|
||||
* 签订日期
|
||||
*/
|
||||
private LocalDateTime signDate;
|
||||
/**
|
||||
* 合同开始日期
|
||||
*/
|
||||
private LocalDateTime startDate;
|
||||
/**
|
||||
* 合同结束日期
|
||||
*/
|
||||
private LocalDateTime endDate;
|
||||
/**
|
||||
* 合同金额
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.template.dal.mysql.contract;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.template.dal.dataobject.contract.DemoContractDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.contract.vo.*;
|
||||
|
||||
/**
|
||||
* 合同 Mapper
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Mapper
|
||||
public interface DemoContractMapper extends BaseMapperX<DemoContractDO> {
|
||||
|
||||
default PageResult<DemoContractDO> selectPage(DemoContractPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DemoContractDO>()
|
||||
.eqIfPresent(DemoContractDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(DemoContractDO::getName, reqVO.getName())
|
||||
.eqIfPresent(DemoContractDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(DemoContractDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.betweenIfPresent(DemoContractDO::getSignDate, reqVO.getSignDate())
|
||||
.betweenIfPresent(DemoContractDO::getStartDate, reqVO.getStartDate())
|
||||
.betweenIfPresent(DemoContractDO::getEndDate, reqVO.getEndDate())
|
||||
.eqIfPresent(DemoContractDO::getAmount, reqVO.getAmount())
|
||||
.eqIfPresent(DemoContractDO::getRemark, reqVO.getRemark())
|
||||
.betweenIfPresent(DemoContractDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(DemoContractDO::getCompanyId, reqVO.getCompanyId())
|
||||
.likeIfPresent(DemoContractDO::getCompanyName, reqVO.getCompanyName())
|
||||
.eqIfPresent(DemoContractDO::getDeptId, reqVO.getDeptId())
|
||||
.likeIfPresent(DemoContractDO::getDeptName, reqVO.getDeptName())
|
||||
.eqIfPresent(DemoContractDO::getPostId, reqVO.getPostId())
|
||||
.orderByDesc(DemoContractDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.template.service.contract;
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.validation.*;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.contract.vo.*;
|
||||
import cn.iocoder.yudao.module.template.dal.dataobject.contract.DemoContractDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 合同 Service 接口
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
public interface DemoContractService {
|
||||
|
||||
/**
|
||||
* 创建合同
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDemoContract(@Valid DemoContractSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新合同
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDemoContract(@Valid DemoContractSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除合同
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDemoContract(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除合同
|
||||
*
|
||||
* @param ids 编号
|
||||
*/
|
||||
void deleteDemoContractListByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得合同
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 合同
|
||||
*/
|
||||
DemoContractDO getDemoContract(Long id);
|
||||
|
||||
/**
|
||||
* 获得合同分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 合同分页
|
||||
*/
|
||||
PageResult<DemoContractDO> getDemoContractPage(DemoContractPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package cn.iocoder.yudao.module.template.service.contract;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.template.controller.admin.contract.vo.*;
|
||||
import cn.iocoder.yudao.module.template.dal.dataobject.contract.DemoContractDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.template.dal.mysql.contract.DemoContractMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
|
||||
import static cn.iocoder.yudao.module.template.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 合同 Service 实现类
|
||||
*
|
||||
* @author 后台管理
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class DemoContractServiceImpl implements DemoContractService {
|
||||
|
||||
@Resource
|
||||
private DemoContractMapper demoContractMapper;
|
||||
|
||||
@Override
|
||||
public Long createDemoContract(DemoContractSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DemoContractDO demoContract = BeanUtils.toBean(createReqVO, DemoContractDO.class);
|
||||
demoContract.setCode("0");
|
||||
demoContractMapper.insert(demoContract);
|
||||
// 返回
|
||||
return demoContract.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDemoContract(DemoContractSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateDemoContractExists(updateReqVO.getId());
|
||||
// 更新
|
||||
DemoContractDO updateObj = BeanUtils.toBean(updateReqVO, DemoContractDO.class);
|
||||
demoContractMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemoContract(Long id) {
|
||||
// 校验存在
|
||||
validateDemoContractExists(id);
|
||||
// 删除
|
||||
demoContractMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDemoContractListByIds(List<Long> ids) {
|
||||
// 校验存在
|
||||
validateDemoContractExists(ids);
|
||||
// 删除
|
||||
demoContractMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateDemoContractExists(List<Long> ids) {
|
||||
List<DemoContractDO> list = demoContractMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||
throw exception(DEMO_CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateDemoContractExists(Long id) {
|
||||
if (demoContractMapper.selectById(id) == null) {
|
||||
throw exception(DEMO_CONTRACT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DemoContractDO getDemoContract(Long id) {
|
||||
return demoContractMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DemoContractDO> getDemoContractPage(DemoContractPageReqVO pageReqVO) {
|
||||
return demoContractMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,7 +81,7 @@ spring:
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址
|
||||
addresses: http://172.16.46.63:30082/xxl-job-admin # 调度中心部署跟地址
|
||||
|
||||
--- #################### 服务保障相关配置 ####################
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.template.dal.mysql.contract.DemoContractMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user