parent
6f9a28d25e
commit
608f0defaf
|
@ -21,4 +21,5 @@ public class MessageConstant {
|
||||||
public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
||||||
public static final String MENU_IS_NOT_EXIST = "菜单不存在";
|
public static final String MENU_IS_NOT_EXIST = "菜单不存在";
|
||||||
public static final String SAVE_DTO_IS_NULL = "添加参数不能为空";
|
public static final String SAVE_DTO_IS_NULL = "添加参数不能为空";
|
||||||
|
public static final String UPDATE_DTO_IS_NULL = "修改功能";
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,4 +30,18 @@ public class CategoryBrandController {
|
||||||
categoryBrandService.save(categoryBrand);
|
categoryBrandService.save(categoryBrand);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改功能", description = "修改功能")
|
||||||
|
@PutMapping("updateById")
|
||||||
|
public Result<CategoryBrand> updateById(@RequestBody CategoryBrand categoryBrand) {
|
||||||
|
categoryBrandService.updateById(categoryBrand);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除功能", description = "删除功能")
|
||||||
|
@DeleteMapping("deleteById/{id}")
|
||||||
|
public Result<Long> deleteById(@PathVariable Long id) {
|
||||||
|
categoryBrandService.deleteById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -22,4 +22,13 @@ public interface CategoryBrandMapper {
|
||||||
* @param categoryBrand 分类品牌实体类
|
* @param categoryBrand 分类品牌实体类
|
||||||
*/
|
*/
|
||||||
void save(CategoryBrand categoryBrand);
|
void save(CategoryBrand categoryBrand);
|
||||||
|
|
||||||
|
void updateById(CategoryBrand categoryBrand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 删除的ID
|
||||||
|
*/
|
||||||
|
void deleteById(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,4 +21,18 @@ public interface CategoryBrandService {
|
||||||
* @param categoryBrand 分类品牌实体类
|
* @param categoryBrand 分类品牌实体类
|
||||||
*/
|
*/
|
||||||
void save(CategoryBrand categoryBrand);
|
void save(CategoryBrand categoryBrand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改功能
|
||||||
|
*
|
||||||
|
* @param categoryBrand 分类品牌实体类
|
||||||
|
*/
|
||||||
|
void updateById(CategoryBrand categoryBrand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 删除的ID
|
||||||
|
*/
|
||||||
|
void deleteById(Long id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.atguigu.spzx.manger.mapper.CategoryBrandMapper;
|
||||||
import com.atguigu.spzx.manger.service.CategoryBrandService;
|
import com.atguigu.spzx.manger.service.CategoryBrandService;
|
||||||
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
||||||
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import com.atguigu.utils.StringEmptyUtil;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -17,6 +18,8 @@ import java.util.List;
|
||||||
public class CategoryBrandServiceImpl implements CategoryBrandService {
|
public class CategoryBrandServiceImpl implements CategoryBrandService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryBrandMapper categoryBrandMapper;
|
private CategoryBrandMapper categoryBrandMapper;
|
||||||
|
@Autowired
|
||||||
|
private StringEmptyUtil emptyUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分类品牌列表
|
* 分类品牌列表
|
||||||
|
@ -45,4 +48,28 @@ public class CategoryBrandServiceImpl implements CategoryBrandService {
|
||||||
}
|
}
|
||||||
categoryBrandMapper.save(categoryBrand);
|
categoryBrandMapper.save(categoryBrand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改功能
|
||||||
|
*
|
||||||
|
* @param categoryBrand 分类品牌实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateById(CategoryBrand categoryBrand) {
|
||||||
|
if (categoryBrand == null) {
|
||||||
|
throw new BunnyException(MessageConstant.UPDATE_DTO_IS_NULL);
|
||||||
|
}
|
||||||
|
categoryBrandMapper.updateById(categoryBrand);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 删除的ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteById(Long id) {
|
||||||
|
emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
|
||||||
|
categoryBrandMapper.deleteById(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,27 @@
|
||||||
values (#{id}, #{brandId}, #{categoryId}, now(), now(), 0);
|
values (#{id}, #{brandId}, #{categoryId}, now(), now(), 0);
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改功能 -->
|
||||||
|
<update id="updateById">
|
||||||
|
update category_brand
|
||||||
|
set
|
||||||
|
<if test="brandId != null and brandId != ''">
|
||||||
|
brand_id = #{brandId},
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null and categoryId != ''">
|
||||||
|
category_id = #{categoryId},
|
||||||
|
</if>
|
||||||
|
update_time = now()
|
||||||
|
where id = #{id};
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 删除功能 -->
|
||||||
|
<update id="deleteById">
|
||||||
|
update category_brand
|
||||||
|
set is_deleted = 1
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
<!-- 分类品牌列表 -->
|
<!-- 分类品牌列表 -->
|
||||||
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.CategoryBrand">
|
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.CategoryBrand">
|
||||||
select
|
select
|
||||||
|
|
Loading…
Reference in New Issue