本文整理匯總了Java中com.mmall.pojo.Product類的典型用法代碼示例。如果您正苦於以下問題:Java Product類的具體用法?Java Product怎麽用?Java Product使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Product類屬於com.mmall.pojo包,在下文中一共展示了Product類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveOrUpdateProduct
import com.mmall.pojo.Product; //導入依賴的package包/類
/**
* 添加或者更新商品接口
* @param session
* @param product 如果id為null則表示更新商品,如果id不為null,則表示添加商品
* @return
*/
@ResponseBody
@RequestMapping(value = "saveOrUpdateProduct.do",method = RequestMethod.POST)
public ServerResponse<String> saveOrUpdateProduct(HttpSession session, Product product){
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 iProductService.saveOrUpdateProduct(product);
} else {
return ServerResponse.createByError("對不起,您沒有管理員權限");
}
}
示例2: setSaleStatus
import com.mmall.pojo.Product; //導入依賴的package包/類
/**
* 修改商品的銷售狀態
* @param productId
* @param state
* @return
*/
public ServerResponse setSaleStatus(Integer productId, Integer state) {
if (productId == null || state == null) {
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), ResponseCode.ILLEGAL_ARGUMENT.getDesc());
} else {
Product product = new Product();
product.setId(productId);
product.setStatus(state);
int updateResult = productMapper.updateByPrimaryKeySelective(product);
if (updateResult > 0){
return ServerResponse.createBySuccessMessage("修改產品銷售狀態成功");
}else {
return ServerResponse.createByError("修改產品銷售狀態失敗");
}
}
}
示例3: assembleProductDetailVo
import com.mmall.pojo.Product; //導入依賴的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: assembleProductDetailVo
import com.mmall.pojo.Product; //導入依賴的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;
}
示例5: getProductList
import com.mmall.pojo.Product; //導入依賴的package包/類
public ServerResponse<PageInfo> getProductList(int pageNum,int pageSize){
//startPage--start
//填充自己的sql查詢邏輯
//pageHelper-收尾
PageHelper.startPage(pageNum,pageSize);
List<Product> productList = productMapper.selectList();
List<ProductListVo> productListVoList = Lists.newArrayList();
for(Product productItem : productList){
ProductListVo productListVo = assembleProductListVo(productItem);
productListVoList.add(productListVo);
}
PageInfo pageResult = new PageInfo(productList);
pageResult.setList(productListVoList);
return ServerResponse.createBySuccess(pageResult);
}
示例6: saveOrUpdateProduct
import com.mmall.pojo.Product; //導入依賴的package包/類
/**
* 如果id為null則表示更新商品,如果id不為null,則表示添加商品
*
* @param product
* @return
*/
public ServerResponse saveOrUpdateProduct(Product product) {
if (product != null) {
if (StringUtils.isNotBlank(product.getSubImages())) {
String[] imageArray = product.getSubImages().split(",");
if (imageArray.length > 0) {
product.setMainImage(imageArray[0]);
}
}
if (product.getId() == null) {
//添加商品
int insert = productMapper.insert(product);
if (insert > 0) {
return ServerResponse.createBySuccessMessage("添加成功");
} else {
return ServerResponse.createByError("添加失敗");
}
} else {
//更新商品
int updateReslut = productMapper.updateByPrimaryKeySelective(product);
if (updateReslut > 0) {
return ServerResponse.createBySuccessMessage("更新成功");
} else {
return ServerResponse.createByError("更新失敗");
}
}
} else {
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), ResponseCode.ILLEGAL_ARGUMENT.getDesc());
}
}
示例7: manageProductDetail
import com.mmall.pojo.Product; //導入依賴的package包/類
/**
* 通過商品Id得到商品詳情,數據已組裝為vo返回
* @param productId
* @return
*/
public ServerResponse<ProductDetailVo> manageProductDetail(Integer productId){
if (productId == null) {
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(), ResponseCode.ILLEGAL_ARGUMENT.getDesc());
} else {
Product product = productMapper.selectByPrimaryKey(productId);
if (product == null){
return ServerResponse.createByError("商品已刪除或下架");
}else {
return ServerResponse.createBySuccess(assembleProductDetailVo(product));
}
}
}
示例8: manageProductList
import com.mmall.pojo.Product; //導入依賴的package包/類
/**
* 獲取商品集合
* @param pageNum 第幾頁
* @param pageSize 每頁多少個
* @return
*/
public ServerResponse<PageInfo> manageProductList(Integer pageNum,Integer pageSize){
PageHelper.startPage(pageNum,pageSize);
List<Product> products = productMapper.selectList();
List<ProductListVo> productListVos = Lists.newArrayList();
for (Product productItem : products){
productListVos.add(assembleProductListVo(productItem));
}
PageInfo pageInfo = new PageInfo(products);
pageInfo.setList(productListVos);
return ServerResponse.createBySuccess(pageInfo);
}
示例9: productSearch
import com.mmall.pojo.Product; //導入依賴的package包/類
/**
* 根據商品名或者id來搜索商品,返回商品集合
* @param productName
* @param productId
* @param pageNum
* @param pageSize
* @return
*/
public ServerResponse<PageInfo> productSearch(String productName,int productId,int pageNum,int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<Product> products = productMapper.selectByNameAndProductId(productName,productId);
List<ProductListVo> productListVos = Lists.newArrayList();
for (Product productItem : products){
productListVos.add(assembleProductListVo(productItem));
}
PageInfo pageInfo = new PageInfo(products);
pageInfo.setList(productListVos);
return ServerResponse.createBySuccess(pageInfo);
}
示例10: assembleProductListVo
import com.mmall.pojo.Product; //導入依賴的package包/類
/**
* 將Product組合成ProductListVo
* @param product
* @return
*/
public ProductListVo assembleProductListVo(Product product){
ProductListVo productListVo = new ProductListVo();
productListVo.setId(product.getId());
productListVo.setName(product.getName());
productListVo.setPrice(product.getPrice());
productListVo.setMainImage(product.getMainImage());
productListVo.setCategoryId(product.getCategoryId());
productListVo.setSubtitle(product.getSubtitle());
productListVo.setStatus(product.getStatus());
productListVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix","http://img.happymmall.com/"));
return productListVo;
}
示例11: getProductDetail
import com.mmall.pojo.Product; //導入依賴的package包/類
public ServerResponse<ProductDetailVo> getProductDetail(Integer productId){
if(productId == null){
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(),ResponseCode.ILLEGAL_ARGUMENT.getDesc());
}
Product product = productMapper.selectByPrimaryKey(productId);
if(product == null){
return ServerResponse.createByError("產品已下架或者刪除");
}
if(product.getStatus() != Const.ProductStatusEnum.ON_SALE.getCode()){
return ServerResponse.createByError("產品已下架或者刪除");
}
ProductDetailVo productDetailVo = assembleProductDetailVo(product);
return ServerResponse.createBySuccess(productDetailVo);
}
示例12: productSave
import com.mmall.pojo.Product; //導入依賴的package包/類
@RequestMapping("save.do")
public ServerResponse productSave(HttpSession session, Product product){
User user = (User)session.getAttribute(Const.CURRENT_USER);
if(user == null){
return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(),"用戶未登錄,請登錄管理員");
}
if(iUserService.checkAdminRole(user).isSuccess()){
//填充我們增加產品的業務邏輯
return iProductService.saveOrUpdateProduct(product);
}else{
return ServerResponse.createByErrorMessage("無權限操作");
}
}
示例13: setSaleStatus
import com.mmall.pojo.Product; //導入依賴的package包/類
public ServerResponse<String> setSaleStatus(Integer productId,Integer status){
if(productId == null || status == null){
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(),ResponseCode.ILLEGAL_ARGUMENT.getDesc());
}
Product product = new Product();
product.setId(productId);
product.setStatus(status);
int rowCount = productMapper.updateByPrimaryKeySelective(product);
if(rowCount > 0){
return ServerResponse.createBySuccess("修改產品銷售狀態成功");
}
return ServerResponse.createByErrorMessage("修改產品銷售狀態失敗");
}
示例14: manageProductDetail
import com.mmall.pojo.Product; //導入依賴的package包/類
public ServerResponse<ProductDetailVo> manageProductDetail(Integer productId){
if(productId == null){
return ServerResponse.createByErrorCodeMessage(ResponseCode.ILLEGAL_ARGUMENT.getCode(),ResponseCode.ILLEGAL_ARGUMENT.getDesc());
}
Product product = productMapper.selectByPrimaryKey(productId);
if(product == null){
return ServerResponse.createByErrorMessage("產品已下架或者刪除");
}
ProductDetailVo productDetailVo = assembleProductDetailVo(product);
return ServerResponse.createBySuccess(productDetailVo);
}
示例15: assembleProductListVo
import com.mmall.pojo.Product; //導入依賴的package包/類
private ProductListVo assembleProductListVo(Product product){
ProductListVo productListVo = new ProductListVo();
productListVo.setId(product.getId());
productListVo.setName(product.getName());
productListVo.setCategoryId(product.getCategoryId());
productListVo.setImageHost(PropertiesUtil.getProperty("ftp.server.http.prefix","http://img.happymmall.com/"));
productListVo.setMainImage(product.getMainImage());
productListVo.setPrice(product.getPrice());
productListVo.setSubtitle(product.getSubtitle());
productListVo.setStatus(product.getStatus());
return productListVo;
}