當前位置: 首頁>>代碼示例>>Java>>正文


Java Category類代碼示例

本文整理匯總了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("對不起,您沒有管理員權限");
    }
}
 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:24,代碼來源:CategoryManageController.java

示例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("您的參數有問題");
}
 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:17,代碼來源:CategoryServiceImpl.java

示例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;
}
 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:31,代碼來源:ProductServiceImpl.java

示例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("添加品類失敗");
}
 
開發者ID:Liweimin0512,項目名稱:MMall_JAVA,代碼行數:17,代碼來源:CategoryServiceImpl.java

示例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;
}
 
開發者ID:Liweimin0512,項目名稱:MMall_JAVA,代碼行數:27,代碼來源:ProductServiceImpl.java

示例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("您的參數有問題");
}
 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:16,代碼來源:CategoryServiceImpl.java

示例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("您的參數有問題");
}
 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:13,代碼來源:CategoryServiceImpl.java

示例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);
}
 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:19,代碼來源:CategoryServiceImpl.java

示例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;
}
 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:13,代碼來源:CategoryServiceImpl.java

示例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("更新品類名字失敗");
}
 
開發者ID:Liweimin0512,項目名稱:MMall_JAVA,代碼行數:15,代碼來源:CategoryServiceImpl.java

示例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);
}
 
開發者ID:Liweimin0512,項目名稱:MMall_JAVA,代碼行數:8,代碼來源:CategoryServiceImpl.java

示例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;
}
 
開發者ID:Liweimin0512,項目名稱:MMall_JAVA,代碼行數:13,代碼來源:CategoryServiceImpl.java

示例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);
}
 
開發者ID:Liweimin0512,項目名稱:MMall_JAVA,代碼行數:9,代碼來源:CategoryDaoTest.java

示例14: insert

import com.mmall.pojo.Category; //導入依賴的package包/類
int insert(Category record); 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:2,代碼來源:CategoryMapper.java

示例15: insertSelective

import com.mmall.pojo.Category; //導入依賴的package包/類
int insertSelective(Category record); 
開發者ID:wangshufu,項目名稱:mmall,代碼行數:2,代碼來源:CategoryMapper.java


注:本文中的com.mmall.pojo.Category類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。