首先需要定义自己的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;}