mybatisplus中BaseMapper和BasePO使用

首先需要定义自己的PO用来操作数据库,并且继承BasePO

用@TableName注解确定用哪个数据库表,@TableField注解确定是标准哪个字段

例:

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "SoftBudgetMainPO",description = "软件项目预算主表")
@JsonInclude(JsonInclude.Include.NON_NULL)
@TableName("soft_budget_main")
public class SoftBudgetMainPO extends BasePO {
    @ApiModelProperty(value = "删除标记 0:未删 1:删除")
    @TableField(value = "dr")
    private Integer dr;
}
@TableName(value ="pco_info")
@Data
public class BmkPcoInfoPO extends BasePO implements Serializable{

        /**
         * id
         */
        @TableField(value = "id")
        private String id;
}

建立自己的mapper,继承BaseMapper或TableBaseMapper

例:

public interface BmkPcoInfoMapper extends TableBaseMapper<BmkPcoInfoPO> {
    List<approveUserDTO> approveUser(String id);}
public interface SoftBudgetMainMapper extends BaseMapper<SoftBudgetMainPO> {
    List<SoftBudgetMainDTO> queryBudgetVersion(@Param("bv") String budVersion);}

在GatewayImpl中继承ServiceImpl或BaseTableServiceImpl

例:

@Repository
@Slf4j
public class BmkPcoInfoGatewayImpl extends BaseTableServiceImpl<BmkPcoInfoMapper, BmkPcoInfoPO> implements BmkPcoInfoGateway {
    @Autowired
    private BmkPcoInfoMapper bmkPcoInfoMapper;}
@Slf4j
@Service
@RequiredArgsConstructor
public class SoftBudgetMainGatewayImpl extends ServiceImpl<SoftBudgetMainMapper, SoftBudgetMainPO>implements SoftBudgetMainGateway {
    private final SoftBudgetMainMapper softBudgetMainMapper;}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值