本文整理汇总了Java中com.mmall.pojo.Category类的典型用法代码示例。如果您正苦于以下问题:Java Category类的具体用法?Java Category怎么用?Java Category使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Category类属于com.mmall.pojo包,在下文中一共展示了Category类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildrenParallelCategory
import com.mmall.pojo.Category; //导入依赖的package包/类
/**
* 获取平级的parentId的类品
* @param session
* @param parentId
* @return
*/
@RequestMapping(value = "getChildrenParallelCategory.do",method = RequestMethod.POST)
@ResponseBody
public ServerResponse<List<Category>> getChildrenParallelCategory(HttpSession session,
@RequestParam(value = "parentId",defaultValue = "0") Integer parentId){
User user = (User) session.getAttribute(Const.CURRENT_USER);
if (user == null){
return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"请先登录");
}
//判断这个用户是不是管理员
ServerResponse<String> checkRoleResult = iUserService.checkUserRole(user);
if (checkRoleResult.isSuccess()){
//添加类品
return iCategoryService.getChildrenParallelCategory(parentId);
} else {
return ServerResponse.createByError("对不起,您没有管理员权限");
}
}
示例2: addCategory
import com.mmall.pojo.Category; //导入依赖的package包/类
@Override
public ServerResponse<String> addCategory(String categoryName, Integer parentId) {
if (StringUtils.isNotBlank(categoryName) && parentId != null) {
Category category = new Category();
category.setParentId(parentId);
category.setName(categoryName);
category.setStatus(true);
int insertResult = categoryMapper.insert(category);
if (insertResult > 0) {
return ServerResponse.createBySuccessMessage("添加成功");
} else {
return ServerResponse.createByError("添加失败");
}
}
return ServerResponse.createByError("您的参数有问题");
}
示例3: assembleProductDetailVo
import com.mmall.pojo.Category; //导入依赖的package包/类
/**
* 将Product组合成ProductDetailVo
* @param product
* @return
*/
public ProductDetailVo assembleProductDetailVo(Product product){
ProductDetailVo productDetailVo = new ProductDetailVo();
productDetailVo.setId(product.getId());
productDetailVo.setCategoryId(product.getCategoryId());
productDetailVo.setName(product.getName());
productDetailVo.setSubtitle(product.getSubtitle());
productDetailVo.setDetail(product.getDetail());
productDetailVo.setMainImage(product.getMainImage());
productDetailVo.setSubImages(product.getSubImages());
productDetailVo.setPrice(product.getPrice());
//查询商品的分类
Category category = categoryMapper.selectByPrimaryKey(product.getCategoryId());
if (category == null || category.getParentId() == null) {
productDetailVo.setParentCategoryId(0);
} else {
productDetailVo.setParentCategoryId(category.getParentId());
}
//设置图片host
productDetailVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix","http://img.happymmall.com/"));
//设置时间,因为我们用mybatis的db来查询数据库的时间值为毫秒值,不利于观看,所以需格式化
productDetailVo.setCreateTime(DateTimeUtil.dateToStr(product.getCreateTime()));
productDetailVo.setUpdateTime(DateTimeUtil.dateToStr(product.getUpdateTime()));
return productDetailVo;
}
示例4: addCategory
import com.mmall.pojo.Category; //导入依赖的package包/类
public ServerResponse addCategory(String categoryName,Integer parentId){
if(parentId == null || StringUtils.isBlank(categoryName)){
return ServerResponse.createByErrorMessage("添加品类参数错误");
}
Category category = new Category();
category.setName(categoryName);
category.setParentId(parentId);
category.setStatus(true);//这个分类是可用的
int rowCount = categoryMapper.insert(category);
if(rowCount > 0){
return ServerResponse.createBySuccess("添加品类成功");
}
return ServerResponse.createByErrorMessage("添加品类失败");
}
示例5: assembleProductDetailVo
import com.mmall.pojo.Category; //导入依赖的package包/类
private ProductDetailVo assembleProductDetailVo(Product product){
ProductDetailVo productDetailVo = new ProductDetailVo();
productDetailVo.setId(product.getId());
productDetailVo.setSubtitle(product.getSubtitle());
productDetailVo.setPrice(product.getPrice());
productDetailVo.setMainImage(product.getMainImage());
productDetailVo.setSubImages(product.getSubImages());
productDetailVo.setCategoryId(product.getCategoryId());
productDetailVo.setDetail(product.getDetail());
productDetailVo.setName(product.getName());
productDetailVo.setStatus(product.getStatus());
productDetailVo.setStock(product.getStock());
productDetailVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix","http://img.happymmall.com/"));
Category category = categoryMapper.selectByPrimaryKey(product.getCategoryId());
if(category == null){
productDetailVo.setParentCategoryId(0);//默认根节点
}else{
productDetailVo.setParentCategoryId(category.getParentId());
}
productDetailVo.setCreateTime(DateTimeUtil.dateToStr(product.getCreateTime()));
productDetailVo.setUpdateTime(DateTimeUtil.dateToStr(product.getUpdateTime()));
return productDetailVo;
}
示例6: updateCategoryInfo
import com.mmall.pojo.Category; //导入依赖的package包/类
@Override
public ServerResponse<String> updateCategoryInfo(String categoryName, Integer categoryId) {
if (StringUtils.isNotBlank(categoryName) && categoryId != null) {
Category category = new Category();
category.setId(categoryId);
category.setName(categoryName);
int updateResult = categoryMapper.updateByPrimaryKeySelective(category);
if (updateResult > 0) {
return ServerResponse.createBySuccessMessage("更新类品成功");
} else {
return ServerResponse.createByError("更新类品失败");
}
}
return ServerResponse.createByError("您的参数有问题");
}
示例7: getChildrenParallelCategory
import com.mmall.pojo.Category; //导入依赖的package包/类
@Override
public ServerResponse<List<Category>> getChildrenParallelCategory(Integer parentId) {
if (parentId != null) {
List<Category> categories = categoryMapper.selectByParentId(parentId);
if (CollectionUtils.isEmpty(categories)) {
logger.info("未找到当前分类的子分类");
} else {
return ServerResponse.createBySuccess(categories);
}
}
return ServerResponse.createByError("您的参数有问题");
}
示例8: selectCategoryAndChildrenById
import com.mmall.pojo.Category; //导入依赖的package包/类
/**
* 递归查询本节点的id及孩子节点的id
* @param categoryId
* @return
*/
public ServerResponse<List<Integer>> selectCategoryAndChildrenById(Integer categoryId){
Set<Category> categorySet = Sets.newHashSet();
findChildCategory(categorySet,categoryId);
List<Integer> categoryIdList = Lists.newArrayList();
if(categoryId != null){
for(Category categoryItem : categorySet){
categoryIdList.add(categoryItem.getId());
}
}
return ServerResponse.createBySuccess(categoryIdList);
}
示例9: findChildCategory
import com.mmall.pojo.Category; //导入依赖的package包/类
private Set<Category> findChildCategory(Set<Category> categorySet ,Integer categoryId){
Category category = categoryMapper.selectByPrimaryKey(categoryId);
if(category != null){
categorySet.add(category);
}
//查找子节点,递归算法一定要有一个退出的条件
List<Category> categoryList = categoryMapper.selectByParentId(categoryId);
for(Category categoryItem : categoryList){
findChildCategory(categorySet,categoryItem.getId());
}
return categorySet;
}
示例10: updateCategoryName
import com.mmall.pojo.Category; //导入依赖的package包/类
public ServerResponse updateCategoryName(Integer categoryId,String categoryName){
if(categoryId == null || StringUtils.isBlank(categoryName)){
return ServerResponse.createByErrorMessage("更新品类参数错误");
}
Category category = new Category();
category.setId(categoryId);
category.setName(categoryName);
int rowCount = categoryMapper.updateByPrimaryKeySelective(category);
if(rowCount > 0){
return ServerResponse.createBySuccess("更新品类名字成功");
}
return ServerResponse.createByErrorMessage("更新品类名字失败");
}
示例11: getChildrenParallelCategory
import com.mmall.pojo.Category; //导入依赖的package包/类
public ServerResponse<List<Category>> getChildrenParallelCategory(Integer categoryId){
List<Category> categoryList = categoryMapper.selectCategoryChildrenByParentId(categoryId);
if(CollectionUtils.isEmpty(categoryList)){
logger.info("未找到当前分类的子分类");
}
return ServerResponse.createBySuccess(categoryList);
}
示例12: findChildCategory
import com.mmall.pojo.Category; //导入依赖的package包/类
private Set<Category> findChildCategory(Set<Category> categorySet ,Integer categoryId){
Category category = categoryMapper.selectByPrimaryKey(categoryId);
if(category != null){
categorySet.add(category);
}
//查找子节点,递归算法一定要有一个退出的条件
List<Category> categoryList = categoryMapper.selectCategoryChildrenByParentId(categoryId);
for(Category categoryItem : categoryList){
findChildCategory(categorySet,categoryItem.getId());
}
return categorySet;
}
示例13: getCategoryChild
import com.mmall.pojo.Category; //导入依赖的package包/类
@Ignore
@Test
public void getCategoryChild(){
Category d = categoryMapper.selectByPrimaryKey(1);
System.out.println(d);
Category d4 = categoryMapper.selectByPrimaryKey(4);
System.out.println(d4);
}
示例14: insert
import com.mmall.pojo.Category; //导入依赖的package包/类
int insert(Category record);
示例15: insertSelective
import com.mmall.pojo.Category; //导入依赖的package包/类
int insertSelective(Category record);