feat(新增): 根据id删除品牌

Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
bunny 2024-03-25 22:31:49 +08:00
parent a7afceb704
commit b77dbadd4a
5 changed files with 40 additions and 0 deletions

View File

@ -36,4 +36,11 @@ public class BrandController {
brandService.updateById(brand); brandService.updateById(brand);
return Result.success(); return Result.success();
} }
@Operation(summary = "删除品牌", description = "删除品牌")
@DeleteMapping("deleteById/{id}")
public Result<Long> deleteById(@PathVariable Long id) {
brandService.deleteById(id);
return Result.success();
}
} }

View File

@ -25,4 +25,11 @@ public interface BrandMapper {
* @param brand 品牌实体类 * @param brand 品牌实体类
*/ */
void updateById(Brand brand); void updateById(Brand brand);
/**
* 根据id删除品牌
*
* @param id 品牌id
*/
void deleteById(Long id);
} }

View File

@ -26,4 +26,11 @@ public interface BrandService {
* @param brand 品牌实体类 * @param brand 品牌实体类
*/ */
void updateById(Brand brand); void updateById(Brand brand);
/**
* 根据id删除品牌
*
* @param id 品牌id
*/
void deleteById(Long id);
} }

View File

@ -57,4 +57,15 @@ public class BrandServiceImpl implements BrandService {
brandMapper.updateById(brand); brandMapper.updateById(brand);
} }
/**
* 根据id删除品牌
*
* @param id 品牌id
*/
@Override
public void deleteById(Long id) {
emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
brandMapper.deleteById(id);
}
} }

View File

@ -26,6 +26,14 @@
where id = #{id} where id = #{id}
</update> </update>
<!-- 根据id删除品牌 -->
<update id="deleteById">
update brand
set is_deleted = 1,
update_time = now()
where id = #{id}
</update>
<!-- 查找分页品牌 --> <!-- 查找分页品牌 -->
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.Brand"> <select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.Brand">
select select