大神来看一下,老师让在springboot项目中新增一张表,然后z在项目中实现表的增删改查,我都不知道那部分有用

文章展示了在SpringBoot应用中,使用Java实体类(CategoriesEntity)、Service接口及其实现、DAO接口来管理t_categories表的操作,包括更新分类名称、选择分类、添加分类和删除分类的方法实现。
摘要由CSDN通过智能技术生成

sql表:entientity:

@Data
@TableName("t_categories")
@AllArgsConstructor
@NoArgsConstructor
public class CategoriesEntity {
   @TableId(type= IdType.AUTO)
    private Integer id;
   private String cNname;
   private String cDescri;//描述分类信息
    private Date cCreateTime;//生成时间
    private Date cUpdateTime;

}

 service:

public interface CategoriesService extends IService<CategoriesEntity> {
    void updateCategoriesName(Integer id);

    void seleceCategories(Integer id);

    void addCategories(CategoriesEntity categoriesEntity);

    void deleteCagegories(Integer id);
}

ServiceImpl:      

@Service
public class CategoriesImpl extends ServiceImpl<CategoriesDao, CategoriesEntity> implements CategoriesService {
//@Autowired
//private CategoriesEntity categoriesEntity;
    @Override
    public void updateCategoriesName(Integer id) {
        Integer categoriesEntity=baseMapper.updateCategoriesName(id);
    }

    @Override
    public void seleceCategories(Integer id) {
//        CategoriesEntity categoriesEntity = null;
//        QueryWrapper queryWrapper=new QueryWrapper();
//        queryWrapper.eq("id",categoriesEntity.getId());
//        CategoriesEntity categoriesEntity1=baseMapper.selectOne(queryWrapper);
        CategoriesEntity i=baseMapper.selectById(id);

    }

    @Override
    public void addCategories(CategoriesEntity categoriesEntity) {
        //categoriesEntity.setCDescri("describle",categoriesEntity.getCDescri());
     Integer categoriesEntity1=baseMapper.insert(categoriesEntity);
    }

    @Override
    public void deleteCagegories(Integer id) {
        Integer i=baseMapper.deleteById(id);
    }

Dao:

@Mapper
public interface CategoriesDao extends BaseMapper<CategoriesEntity> {
    Integer updateCategoriesName(@Param("id")Integer id);

   /* Integer addCategories(@Param()Integer id,
                          @Param()String name,
                          @Param()Date oldTime,
                          @Param()Date newTime,
                          @Param()String describle);
*/}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值