本文整理汇总了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;
}