Authored by 张帅

Merge

Showing 26 changed files with 1423 additions and 535 deletions
package com.yohobuy.platform.grass.restapi;
import com.yohobuy.platform.grass.service.IGrassArticleCommentService;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.ArticleCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.ArticleCommentQueryReq;
import com.yohobuy.platform.model.grass.response.ArticleCommentQueryRsp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
... ... @@ -16,4 +23,20 @@ public class GrassArticleCommentController {
private static final Logger logger = LoggerFactory.getLogger(GrassArticleCommentController.class);
@Autowired
private IGrassArticleCommentService grassArticleCommentService;
@RequestMapping("/queryGrassArticleComment")
@ResponseBody
public ApiResponse queryGrassArticleComment(ArticleCommentQueryReq req){
logger.info("enter queryGrassArticleComment.param is {}",req);
PageResponseVO<ArticleCommentQueryRsp> result = grassArticleCommentService.queryComment(req);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
@RequestMapping("/modifyGrassArticleCommentStatus")
@ResponseBody
public ApiResponse modifyGrassArticleCommentStatus(@RequestBody ArticleCommentModifyStatusReq req){
logger.info("enter modifyGrassArticleCommentStatus.param is {}",req);
grassArticleCommentService.modifyStatus(req);
return new ApiResponse.ApiResponseBuilder().message("审核完成").build();
}
}
... ...
package com.yohobuy.platform.grass.restapi;
import com.yohobuy.platform.grass.service.IGrassGoodsCommentService;
import com.yohobuy.platform.model.common.ApiResponse;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GoodsCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.GoodsCommentQueryReq;
import com.yohobuy.platform.model.grass.response.GoodsCommentQueryRsp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
/**
... ... @@ -16,4 +23,20 @@ public class GrassGoodsCommentController {
private static final Logger logger = LoggerFactory.getLogger(GrassGoodsCommentController.class);
@Autowired
private IGrassGoodsCommentService grassGoodsCommentService;
@RequestMapping("/queryGrassGoodsComment")
@ResponseBody
public ApiResponse queryGrassGoodsComment(GoodsCommentQueryReq req){
logger.info("enter queryGrassGoodsComment.param is {}",req);
PageResponseVO<GoodsCommentQueryRsp> result = grassGoodsCommentService.queryComment(req);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
@RequestMapping("/modifyGrassGoodsCommentStatus")
@ResponseBody
public ApiResponse modifyGrassGoodsCommentStatus(@RequestBody GoodsCommentModifyStatusReq req){
logger.info("enter modifyGrassGoodsCommentStatus.param is {}",req);
grassGoodsCommentService.modifyStatus(req);
return new ApiResponse.ApiResponseBuilder().message("审核完成").build();
}
}
... ...
... ... @@ -29,40 +29,48 @@ public class GrassGoodsController {
@RequestMapping("/queryGoods")
@ResponseBody
public ApiResponse queryGoods(GoodsQueryReq req){
logger.info("enter queryGoods.param is {}",req);
public ApiResponse queryGrassGoods(GoodsQueryReq req){
logger.info("enter queryGrassGoods.param is {}",req);
PageResponseVO<GoodsQueryRsp> result = grassGoodsService.queryGoods(req);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
@RequestMapping("/searchProducts")
@ResponseBody
public ApiResponse searchProducts(ProductSearchReq req){
logger.info("enter searchProducts.param is {}",req);
public ApiResponse searchGrassProducts(ProductSearchReq req){
logger.info("enter searchGrassProducts.param is {}",req);
PageResponseVO<JSONObject> result = grassGoodsService.searchProducts(req);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
@RequestMapping("/batchAddGoods")
@ResponseBody
public ApiResponse batchAddGoods(@RequestBody List<BatchAddGoodsReq> reqList){
logger.info("enter batchAddGoods.param is {}",reqList);
public ApiResponse batchAddGrassGoods(@RequestBody List<BatchAddGoodsReq> reqList){
logger.info("enter batchAddGrassGoods.param is {}",reqList);
grassGoodsService.batchAddGoods(reqList);
return new ApiResponse.ApiResponseBuilder().message("批量新增成功").build();
}
@RequestMapping("/getGoods")
@ResponseBody
public ApiResponse getGoods(@RequestParam("id") Integer id){
logger.info("enter getGoods.id is {}",id);
public ApiResponse getGrassGoods(@RequestParam("id") Integer id){
logger.info("enter getGrassGoods.id is {}",id);
GrassGoods result = grassGoodsService.getGoods(id);
return new ApiResponse.ApiResponseBuilder().data(result).build();
}
@RequestMapping("/modifyGoodsStatus")
@ResponseBody
public ApiResponse modifyGrassGoodsStatus(@RequestParam("status") Integer status,@RequestParam("id") Integer id){
logger.info("enter modifyGrassGoodsStatus.status is {}",status);
grassGoodsService.modifyGoodsStatus(status,id);
return new ApiResponse.ApiResponseBuilder().message("修改成功").build();
}
@RequestMapping("/modifyGoods")
@ResponseBody
public ApiResponse modifyGoods(GoodsModifyReq req){
logger.info("enter modifyGoods.param is {}",req);
public ApiResponse modifyGrassGoods(GoodsModifyReq req){
logger.info("enter modifyGrassGoods.param is {}",req);
grassGoodsService.modifyGoods(req);
return new ApiResponse.ApiResponseBuilder().message("修改成功").build();
}
... ...
package com.yohobuy.platform.grass.service;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.ArticleCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.ArticleCommentQueryReq;
import com.yohobuy.platform.model.grass.response.ArticleCommentQueryRsp;
/**
* Created by shengguo.cai on 2019/1/21.
*/
public interface IGrassArticleCommentService {
PageResponseVO<ArticleCommentQueryRsp> queryComment(ArticleCommentQueryReq req);
void modifyStatus(ArticleCommentModifyStatusReq req);
}
... ...
package com.yohobuy.platform.grass.service;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.request.GoodsCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.GoodsCommentQueryReq;
import com.yohobuy.platform.model.grass.response.GoodsCommentQueryRsp;
/**
* Created by shengguo.cai on 2019/1/21.
*/
public interface IGrassGoodsCommentService {
PageResponseVO<GoodsCommentQueryRsp> queryComment(GoodsCommentQueryReq req);
void modifyStatus(GoodsCommentModifyStatusReq req);
}
... ...
... ... @@ -25,4 +25,6 @@ public interface IGrassGoodsService {
GrassGoods getGoods(Integer id);
void modifyGoods(GoodsModifyReq req);
void modifyGoodsStatus(Integer status, Integer id);
}
... ...
package com.yohobuy.platform.grass.service.impl;
import com.yoho.core.common.utils.DateUtil;
import com.yohobuy.platform.common.helper.UserHelper;
import com.yohobuy.platform.dal.common.BeanConvertUtil;
import com.yohobuy.platform.dal.grass.IGrassArticleCommentDao;
import com.yohobuy.platform.grass.service.IGrassArticleCommentService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.ChildCommentTotalBo;
import com.yohobuy.platform.model.grass.request.ArticleCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.ArticleCommentQueryReq;
import com.yohobuy.platform.model.grass.response.ArticleCommentQueryRsp;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by shengguo.cai on 2019/1/21.
*/
@Service
public class GrassArticleCommentServiceImpl implements IGrassArticleCommentService {
private static final Logger logger = LoggerFactory.getLogger(GrassArticleCommentServiceImpl.class);
@Autowired
private IGrassArticleCommentDao grassArticleCommentDao;
@Override
public PageResponseVO<ArticleCommentQueryRsp> queryComment(ArticleCommentQueryReq req) {
PageResponseVO<ArticleCommentQueryRsp> result = new PageResponseVO<>();
logger.info("queryComment:before selectTotalByCommentQueryReq,param is {}",req);
int total = grassArticleCommentDao.selectTotalByCommentQueryReq(req);
result.setTotal(total);
result.setSize(req.getSize());
result.setPage(req.getPage());
if(total == 0){
return result;
}
List<ArticleCommentQueryRsp> commentQueryRspList = BeanConvertUtil.convertList(grassArticleCommentDao.selectByCommentQueryReq(req),ArticleCommentQueryRsp.class);
if(CollectionUtils.isEmpty(commentQueryRspList)){
return result;
}
List<Integer> ids = commentQueryRspList.stream().map(com->com.getId()).collect(Collectors.toList());
Map<Integer,ChildCommentTotalBo> childMap = BeanConvertUtil.convertMap(grassArticleCommentDao.selectChildTotalMapByIds(ids),ChildCommentTotalBo.class);
commentQueryRspList.forEach(com->{
ChildCommentTotalBo bo = childMap.get(com.getId());
if(bo != null){
com.setChildTotal(bo.getTotal());
}
});
result.setList(commentQueryRspList);
return result;
}
@Override
public void modifyStatus(ArticleCommentModifyStatusReq req) {
Integer reviewerId = new UserHelper().getUserId();
grassArticleCommentDao.updateStatus(req.getIds(),req.getStatus(),reviewerId, DateUtil.currentTimeSeconds());
}
}
... ...
package com.yohobuy.platform.grass.service.impl;
import com.yoho.core.common.utils.DateUtil;
import com.yohobuy.platform.common.helper.UserHelper;
import com.yohobuy.platform.dal.common.BeanConvertUtil;
import com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao;
import com.yohobuy.platform.grass.service.IGrassGoodsCommentService;
import com.yohobuy.platform.model.common.PageResponseVO;
import com.yohobuy.platform.model.grass.ChildCommentTotalBo;
import com.yohobuy.platform.model.grass.request.GoodsCommentModifyStatusReq;
import com.yohobuy.platform.model.grass.request.GoodsCommentQueryReq;
import com.yohobuy.platform.model.grass.response.GoodsCommentQueryRsp;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Created by shengguo.cai on 2019/1/21.
*/
@Service
public class GrassGoodsCommentServiceImpl implements IGrassGoodsCommentService {
private static final Logger logger = LoggerFactory.getLogger(GrassGoodsCommentServiceImpl.class);
@Autowired
private IGrassGoodsCommentDao grassGoodsCommentDao;
@Override
public PageResponseVO<GoodsCommentQueryRsp> queryComment(GoodsCommentQueryReq req) {
PageResponseVO<GoodsCommentQueryRsp> result = new PageResponseVO<>();
logger.info("queryComment:before selectTotalByCommentQueryReq,param is {}",req);
int total = grassGoodsCommentDao.selectTotalByCommentQueryReq(req);
result.setTotal(total);
result.setSize(req.getSize());
result.setPage(req.getPage());
if(total == 0){
return result;
}
List<GoodsCommentQueryRsp> commentQueryRspList = BeanConvertUtil.convertList(grassGoodsCommentDao.selectByCommentQueryReq(req),GoodsCommentQueryRsp.class);
if(CollectionUtils.isEmpty(commentQueryRspList)){
return result;
}
List<Integer> ids = commentQueryRspList.stream().map(com->com.getId()).collect(Collectors.toList());
Map<Integer,ChildCommentTotalBo> childMap = BeanConvertUtil.convertMap(grassGoodsCommentDao.selectChildTotalMapByIds(ids),ChildCommentTotalBo.class);
commentQueryRspList.forEach(com->{
ChildCommentTotalBo bo = childMap.get(com.getId());
if(bo != null){
com.setChildTotal(bo.getTotal());
}
});
result.setList(commentQueryRspList);
return result;
}
@Override
public void modifyStatus(GoodsCommentModifyStatusReq req) {
Integer reviewerId = new UserHelper().getUserId();
grassGoodsCommentDao.updateStatus(req.getIds(),req.getStatus(),reviewerId, DateUtil.currentTimeSeconds());
}
}
... ...
... ... @@ -2,9 +2,11 @@ package com.yohobuy.platform.grass.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.helpers.ImagesHelper;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.platform.dal.common.BeanConvertUtil;
import com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao;
import com.yohobuy.platform.dal.grass.IGrassGoodsDao;
import com.yohobuy.platform.dal.grass.model.GrassGoods;
... ... @@ -62,14 +64,14 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
logger.info("queryGoods#selectTotalByGoodsQueryReq total is 0.param is {}",req);
return result;
}
List<GoodsQueryRsp> goodsBoList = grassGoodsDao.selectByGoodsQueryReq(req);
List<GoodsQueryRsp> goodsBoList = BeanConvertUtil.convertList(grassGoodsDao.selectByGoodsQueryReq(req),GoodsQueryRsp.class);
if(CollectionUtils.isEmpty(goodsBoList)){
logger.info("queryGoods#selectByGoodsQueryReq goodsBoList is empty.param is {}",req);
return result;
}
// 查询评论总数
List<Integer> goodsIds = goodsBoList.stream().map(goods->goods.getId()).collect(Collectors.toList());
Map<Integer,GoodsCommentTotalBo> commentMap = grassGoodsCommentDao.selectTotalMapByGoodsIds(goodsIds);
Map<Integer,GoodsCommentTotalBo> commentMap = BeanConvertUtil.convertMap(grassGoodsCommentDao.selectTotalMapByGoodsIds(goodsIds),GoodsCommentTotalBo.class);
// 查询商品信息
String skns = goodsBoList.stream().filter(goods-> StringUtils.isNotBlank(goods.getProductSkn())).map(goods->goods.getProductSkn()).collect(Collectors.joining(","));
Map<String,JSONObject> productMap = buildProductMap(skns,1);
... ... @@ -82,7 +84,7 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
@Override
public PageResponseVO<JSONObject> searchProducts(ProductSearchReq req) {
try {
JSONObject responseObj = searchProduct(req.getSkns(),req.getPage());
JSONObject responseObj = searchProduct(req.getSkns(),req.getPage(),"Y",2);
if(responseObj == null || !responseObj.get("code").equals(200)){
throw new ServiceException(500,"search product failed!");
}
... ... @@ -90,7 +92,18 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
responseVO.setPage(responseObj.getJSONObject("data").getInteger("page"));
responseVO.setSize(responseObj.getJSONObject("data").getInteger("page_size"));
responseVO.setTotal(responseObj.getJSONObject("data").getInteger("total"));
responseVO.setList((List) responseObj.getJSONObject("data").get("product_list"));
List productlist = (List)responseObj.getJSONObject("data").get("product_list");
if(!CollectionUtils.isEmpty(productlist)){
productlist.stream().forEach(obj->{
JSONObject jsonObject = (JSONObject)obj;
String img = jsonObject.getString("default_images");
if(StringUtils.isNotBlank(img)){
img = ImagesHelper.getImageUrl(img, 100, 100, 0, "goodsimg");
jsonObject.put("default_images",img);
}
});
}
responseVO.setList(productlist);
return responseVO;
} catch (Exception e) {
logger.warn("searchProducts exp is {}",e);
... ... @@ -124,6 +137,11 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
grassGoodsDao.updateByGoodsModifyReq(req);
}
@Override
public void modifyGoodsStatus(Integer status, Integer id) {
grassGoodsDao.updateStatus(status,id,DateUtil.getCurrentTimeSecond());
}
private void initAddGoodsContent(List<BatchAddGoodsReq> reqList) {
List<Integer> skns = reqList.stream().map(req->req.getSkn()).collect(Collectors.toList());
logger.info("initAddGoodsContent#before selectProductBySkns,skns is {}",skns);
... ... @@ -157,7 +175,7 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
return null;
}
try {
JSONObject responseObj = searchProduct(skns,page);
JSONObject responseObj = searchProduct(skns,page,null,null);
if(!responseObj.get("code").equals(200)){
return null;
}
... ... @@ -177,15 +195,22 @@ public class GrassGoodsServiceImpl implements IGrassGoodsService{
return null;
}
private JSONObject searchProduct(String skns,int page){
private JSONObject searchProduct(String skns,int page,String sales,Integer attributeNot){
logger.info("enter searchProduct,skns is {},page is {}",skns,page);
String url = searchServerAddress + "search" ;
Map<String,Object> reqMap = new HashMap<>();
if(StringUtils.isNotBlank(skns)){
reqMap.put("query",skns);
}
if(StringUtils.isNotBlank(sales)){
reqMap.put("sales",sales);
}
if(attributeNot != null){
reqMap.put("attribute_not",attributeNot);
}
reqMap.put("page",page);
try {
logger.info("before searchProduct#yohosearch.search,param is {},url is {}",reqMap,url);
String responseStr=serviceCaller.get("yohosearch.search", url, reqMap, String.class, null).get();
logger.info("searchProduct#yohosearch.search result is {},param is {},url is {}",responseStr,reqMap,url);
JSONObject responseObj = JSONObject.parseObject(responseStr);
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>yohobuy-platform-cms</artifactId>
<groupId>com.yoho.dsf</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.yoho.dsf.yhplatform</groupId>
<artifactId>platform-cms-mvc</artifactId>
<packaging>jar</packaging>
<name>platform-cms-mvc</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.yoho.service.platform.model</groupId>
<artifactId>platform-service-model</artifactId>
</dependency>
<dependency>
<groupId>com.yohobuy.platform</groupId>
<artifactId>platform-common</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.core</groupId>
<artifactId>yoho-core-redis-cluster</artifactId>
</dependency>
</dependencies>
</project>
/**
*
*/
package com.yohobuy.platform.mvc.bean;
import java.util.List;
import com.yoho.tools.common.beans.BaseBean;
/**
* @author ping.huang
* 2016年9月24日
*/
public class ERPProfileRequestBO extends BaseBean {
/**
*
*/
private static final long serialVersionUID = -6299334332126635127L;
private String password;
private String account;
private String auth_site;
private String truename;
private String staff_code;
private String email;
private Integer dept_id;
private Integer role_id;
private Integer create_id;
private Integer pid;
private String phone;
private List<Integer> pIds;
private Integer status;
private Integer pageNo;
private Integer pageSize;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getAuth_site() {
return auth_site;
}
public void setAuth_site(String auth_site) {
this.auth_site = auth_site;
}
public String getTruename() {
return truename;
}
public void setTruename(String truename) {
this.truename = truename;
}
public String getStaff_code() {
return staff_code;
}
public void setStaff_code(String staff_code) {
this.staff_code = staff_code;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getDept_id() {
return dept_id;
}
public void setDept_id(Integer dept_id) {
this.dept_id = dept_id;
}
public Integer getRole_id() {
return role_id;
}
public void setRole_id(Integer role_id) {
this.role_id = role_id;
}
public Integer getCreate_id() {
return create_id;
}
public void setCreate_id(Integer create_id) {
this.create_id = create_id;
}
public Integer getPid() {
return pid;
}
public void setPid(Integer pid) {
this.pid = pid;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public List<Integer> getpIds() {
return pIds;
}
public void setpIds(List<Integer> pIds) {
this.pIds = pIds;
}
public Integer getPageNo() {
return pageNo;
}
public void setPageNo(Integer pageNo) {
this.pageNo = pageNo;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
/**
*
*/
package com.yohobuy.platform.mvc.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.netflix.config.DynamicPropertyFactory;
import com.yoho.core.common.utils.MD5;
import com.yoho.tools.common.beans.Response;
import com.yohobuy.platform.common.enums.CodeEnum;
import com.yohobuy.platform.model.users.response.UserInfoResponseBO;
import com.yohobuy.platform.common.helper.mvc.PlatformConstant;
import com.yohobuy.platform.mvc.service.ILoginService;
import com.yohobuy.platform.common.util.SessionUtil;
/**
* 描述:platform回调cms页面时,验证用户的登录状态
*
*/
@Controller
@RequestMapping("/LoginController")
public class LoginController {
static Logger log = LoggerFactory.getLogger(LoginController.class);
@Resource
ILoginService loginService;
private static String SALT= DynamicPropertyFactory.getInstance().getStringProperty("platform.login.salt", "").get();
@RequestMapping("/loginForPid.do")
public void loginForPid(String pid, String pidMd5, String callbackUrl , HttpServletRequest request, HttpServletResponse response) throws Exception {
log.info("enter login with pid={},pidAes is {},callbackUrl is {}", pid, pidMd5, callbackUrl);
if (StringUtils.isEmpty(pid) || StringUtils.isEmpty(pidMd5)) {
log.warn("loginForPid error. with pid={}, pidMd5={}", pid, pidMd5);
return;
}
UserInfoResponseBO userInfoResponseBO = (UserInfoResponseBO) request.getSession().getAttribute(PlatformConstant.USER_SESSION);
if (null != userInfoResponseBO && pid.equals(userInfoResponseBO.getPid())) {
request.setAttribute("pid", pid);
request.getRequestDispatcher(callbackUrl).forward(request, response);
} else if (pidMd5.equals(MD5.md5(pid + SALT))) {
log.info("loginForPid with session is empty. and login start. with pid={}", pid);
Response<UserInfoResponseBO> responseBO = loginService.loginByPid(pid);
if (responseBO != null && responseBO.getCode() == CodeEnum.SUCCESS.getCode()) {
log.info("loginForPid with session is empty. and login success. with pid={}", pid);
// 登录成功,把用户信息存入redis
SessionUtil.getOpera().setUser(responseBO.getData());
request.setAttribute("pid", pid);
request.getSession().setAttribute(PlatformConstant.USER_SESSION, responseBO.getData());
request.getRequestDispatcher(callbackUrl).forward(request, response);
}
}
}
}
package com.yohobuy.platform.mvc.helper;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.netflix.config.DynamicPropertyFactory;
import com.yoho.tools.common.beans.Response;
import com.yohobuy.platform.common.enums.CodeEnum;
import com.yohobuy.platform.common.enums.ErpApiEnum;
import com.yohobuy.platform.model.users.response.UserInfoResponseBO;
import com.yohobuy.platform.mvc.bean.ERPProfileRequestBO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Component
public class ErpApiServiceHelper {
static Logger log = LoggerFactory.getLogger(ErpApiServiceHelper.class);
@Resource
RestTemplate restTemplate;
private static String ERP_DOMAIN = DynamicPropertyFactory.getInstance().getStringProperty("erp.domain", "").get();
private static String ERP_STORAGE = DynamicPropertyFactory.getInstance().getStringProperty("erp.storage", "").get();
/**
* /account/profile/query_by_id http://192.168.102.47:9098/erp-gateway-web
/service/account/v1/Profile/getAllBrandProfileDataAuthorityApi http://serve.yohobuy.com
/account/profile/query_page http://192.168.102.47:9098/erp-gateway-web
/account/profileDataEntitlement/dataList http://192.168.102.47:9098/erp-gateway-web
*
*/
/**
* 根据pid,查询用户
* @param pid
* @return
*/
@SuppressWarnings("unchecked")
public UserInfoResponseBO getUserByPid(String pid) {
log.info("getUserByPid with pid={}", pid);
ERPProfileRequestBO profile = new ERPProfileRequestBO();
profile.setPid(Integer.parseInt(pid));
Response<Map<String, Object>> resp = restTemplate.postForObject(ERP_DOMAIN + ErpApiEnum.GET_USER_BY_PID.getUrl(), profile, Response.class);
if (resp == null || resp.getCode() != CodeEnum.SUCCESS.getCode()) {
log.warn("getuserbypid error with pid={}", pid);
return null;
}
UserInfoResponseBO user = toSysUserResponse(resp.getData());
return user;
}
/**
* 对象转换
*
* @param map
* @return
*/
private UserInfoResponseBO toSysUserResponse(Map<String, Object> map) {
if (MapUtils.isEmpty(map)) {
return null;
}
UserInfoResponseBO bo = new UserInfoResponseBO();
bo.setCreate_time(MapUtils.getString(map, "create_time"));
bo.setEmail(MapUtils.getString(map, "email"));
bo.setAccount(MapUtils.getString(map, "account"));
bo.setPhone(MapUtils.getString(map, "phone"));
bo.setPid(MapUtils.getString(map, "pid"));
bo.setRole_id(MapUtils.getString(map, "role_id"));
bo.setStatus(MapUtils.getString(map, "status"));
bo.setTruename(MapUtils.getString(map, "truename"));
bo.setAuth_site(MapUtils.getString(map, "auth_site"));
bo.setCreate_date(MapUtils.getString(map, "create_date"));
bo.setCreate_id(MapUtils.getString(map, "create_id"));
bo.setDept_id(MapUtils.getString(map, "dept_id"));
bo.setExpires(MapUtils.getString(map, "expires"));
bo.setIdentity(MapUtils.getString(map, "identity"));
bo.setLogin_time(MapUtils.getString(map, "login_time"));
bo.setLogout_time(MapUtils.getString(map, "logout_time"));
bo.setStaff_code(MapUtils.getString(map, "staff_code"));
return bo;
}
/**
* 北京接口返回:is_all=ture 说明是全品牌,list就是空;is_all = false 说明不是全品牌 品牌id会在list
* 根据pid,获取用户有品牌权限品牌ID。
* 如果为-1, 不存在,所有品牌都不展示
* 如果为空集合,有所有品牌权限
* 如果不为空 ,有品牌权限品牌ID
*/
public List<Integer> getBrandIds(String pid) {
String url = ERP_STORAGE + "/service/account/v1/Profile/getAllBrandProfileDataAuthorityApi";
try {
Response<Map<String, Object>> response = restTemplate.postForObject(url, "["+pid+"]", Response.class);
log.info("call erp method, url:{} and response:{}.", url, response);
if (response == null || response.getCode() != 200) {
log.warn("call erp method fail, response:{}.",response);
// 所有品牌都不展示
return Lists.newArrayList(-1);
}
Map<String,Object> data= (Map<String,Object>) response.getData();
if ((boolean)data.get("is_all")) {
//有所有品牌权限
return Lists.newArrayList();
}
Object brandIdData = data.get("list");
if (brandIdData instanceof List && ((List)brandIdData).isEmpty()) {
//有所有品牌权限
return Lists.newArrayList();
}
List<Integer> brandIds=Lists.newArrayList();
List<String> brandIdStrs=(List<String>)brandIdData;
for (String brandId : brandIdStrs) {
brandIds.add(Integer.parseInt(brandId));
}
return brandIds;
} catch (Exception e) {
log.error("call erp method fail, url:{} and error message:{}.", url, e.getMessage());
// 所有品牌都不展示
return Lists.newArrayList(-1);
}
}
//根据pid获取店铺权限
public List<Integer> getShopIds(String pid) {
String url = ERP_DOMAIN + "/account/profileDataEntitlement/dataList";
List<Integer> list = new ArrayList<>();
try{
JSONObject req = new JSONObject();
req.put("pid",Integer.valueOf(pid));
req.put("type",2);
Response<Map<String, Object>> response = restTemplate.postForObject(url, req, Response.class);
log.info("getShopIds erp method, url:{} and response:{}.", url, response);
if(response.getCode() != 200){
log.warn("call erp method fail, response:{}.",response);
return Lists.newArrayList(-1);
}
Map<String,Object> shopsMap = response.getData();
boolean isAll = (boolean) shopsMap.get("isAll");
if(isAll){
//如果是全部权限,这是权限空
return list;
}
List<Map> shopList = (List) shopsMap.get("businessList");
if (CollectionUtils.isEmpty(shopList)) {
return Lists.newArrayList(-1);
}
for (Map m : shopList){
list.add(MapUtils.getInteger(m,"id"));
}
}catch (Exception e){
log.info("get shopids from erp-gateway-wab error e={}",e.getMessage());
return Lists.newArrayList(-1);
}
return list;
}
}
/**
*
*/
package com.yohobuy.platform.mvc.service;
import com.yoho.tools.common.beans.Response;
import com.yohobuy.platform.model.users.response.UserInfoResponseBO;
/**
* @author ping.huang
* 2016年8月1日
*/
public interface ILoginService {
Response<UserInfoResponseBO> loginByPid(String pid);
}
/**
*
*/
package com.yohobuy.platform.mvc.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import com.yoho.tools.common.beans.Response;
import com.yohobuy.platform.model.users.response.UserInfoResponseBO;
import com.yohobuy.platform.mvc.helper.ErpApiServiceHelper;
import com.yohobuy.platform.mvc.service.ILoginService;
/**
* @author ping.huang
* 2016年8月1日
*/
@Service
public class LoginServiceImpl implements ILoginService {
static Logger log = LoggerFactory.getLogger(LoginServiceImpl.class);
@Resource
ErpApiServiceHelper erpApiServiceHelper;
@Override
public Response<UserInfoResponseBO> loginByPid(String pid) {
log.info("loginByPid with pid is {}.", pid);
UserInfoResponseBO user = erpApiServiceHelper.getUserByPid(pid);
if(user == null){
return new Response<>();
}
List<Integer> brandIds = erpApiServiceHelper.getBrandIds(pid);
user.setBrandIds(brandIds);
List<Integer> shopIds = erpApiServiceHelper.getShopIds(pid);
user.setShopIds(shopIds);
log.info("loginByPid userInfoResponseBO is {}.", user);
return new Response<>(user);
}
}
package org.mvc;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
... ... @@ -28,11 +28,6 @@
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
<artifactId>platform-cms-mvc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
<artifactId>platform-cms-cms</artifactId>
<version>${project.version}</version>
</dependency>
... ... @@ -87,7 +82,6 @@
</dependencies>
<modules>
<module>mvc</module>
<module>cms</module>
<module>suggest</module>
<module>operations</module>
... ...
... ... @@ -25,10 +25,6 @@
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
<artifactId>platform-cms-mvc</artifactId>
</dependency>
<dependency>
<groupId>com.yoho.dsf.yhplatform</groupId>
<artifactId>platform-cms-operations</artifactId>
</dependency>
<dependency>
... ...
... ... @@ -344,7 +344,7 @@ datasources:
- com.yohobuy.platform.dal.grass.IGrassTopicDAO
- com.yohobuy.platform.dal.grass.IGrassGoodsDao
- com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao
- com.yohobuy.platform.dal.grass.IGrassArticleCommentDao
yhb_promotion:
... ...
... ... @@ -342,7 +342,7 @@ datasources:
- com.yohobuy.platform.dal.grass.IGrassTopicDAO
- com.yohobuy.platform.dal.grass.IGrassGoodsDao
- com.yohobuy.platform.dal.grass.IGrassGoodsCommentDao
- com.yohobuy.platform.dal.grass.IGrassArticleCommentDao
yhb_promotion:
servers:
- ${jdbc.mysql.yhbpromotion.master}
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yoho!Buy运营平台</title>
<script src="/pfcms/js/include.js"></script>
<script src="/pfcms/js/ajaxfileupload.js"></script>
<style>
.btn-long {
width: 120px;
height: 37px;
line-height: 37px;
font-size: 15px;
color: white;
border-radius: 5px;
display: inline-block;
cursor: pointer;
text-align: center;
}
.btn-long:hover {
opacity: 0.9;
}
</style>
</head>
<body class="easyui-layout" >
<div region="north" style="height: 200px;">
<script>
document.write(addHead('种草管理', '评论管理'));
</script>
<div style="margin-left: 20px;margin-top: 10px">
<input class="easyui-combobox" id="iptStatus" style="width: 140px">
</input>
<input class="easyui-numberbox" type="number" id="iptUid" style="width: 140px">
</input>
<input class="easyui-numberbox" type="number" id="iptArticleId" style="width: 140px">
</input>
<input id="iptStartTime" class="easyui-datetimebox" data-options="prompt:'开始时间'"/>
~ &nbsp;
<input id="iptEndTime" class="easyui-datetimebox" data-options="prompt:'结束时间'"/>
<a id="searchBtn" class="btn-info">查询</a>
<a id="allBtn" class="btn-info">全部</a>
</div>
<div style="margin-left: 20px;margin-top: 10px">
<a id="btnBatchAllow" class="btn-long" style="background-color: #5CB85C;">批量通过</a>
<a id="btnBatchBan" class="btn-long" style="background-color: #ffa951;">批量拒绝</a>
</div>
</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
<table id="labelGroupListTable"></table>
</div>
</body>
<script>
$(function() {
//用于页面刷新后的数据行定位
var index ="";
$("#iptStatus").combobox({
valueField : "value",
textField : "text",
editable:false,
required:false,
prompt: "请选择状态",
data:[{text:"全部",value:"-1"},{text:"待审核",value:"0"},{text:"已通过",value:"1"},{text:"未通过",value:"2"}]
});
$("#iptUid").numberbox({
required:false,
prompt: "UID"
});
$("#iptArticleId").numberbox({
required:false,
prompt: "原内容ID"
});
$("#allBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
$("#labelGroupListTable").datagrid("load", {});
}
});
$("#btnBatchAllow").click(function(){
batchUpdateStatus(1);
});
$("#btnBatchBan").click(function(){
batchUpdateStatus(2);
});
function batchUpdateStatus(status){
var rows = $('#labelGroupListTable').datagrid('getSelections');
if(!rows||rows.length == 0){
$.messager.alert("提示", "请先选择数据!", "warn");
return;
}
var ids = [];
rows.forEach(function(value,i){
ids.push(value.id);
})
updateStatus(ids,status)
}
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
var startTime;
var endTime;
if ($("#iptStartTime").datetimebox('getValue')!='') {
startTime = parseInt(new Date($("#iptStartTime").datetimebox('getValue')).getTime() / 1000);
}
if ($("#iptEndTime").datetimebox('getValue')!='') {
endTime = parseInt(new Date($("#iptEndTime").datetimebox('getValue')).getTime() / 1000);
}
var status ;
if($("#iptStatus").combobox("getValue")!=null && $("#iptStatus").combobox("getValue") !=-1){
status = $("#iptStatus").combobox("getValue");
}
$("#labelGroupListTable").datagrid("load", {
status: status,
uid: $("#iptUid").textbox("getValue"),
articleId: $("#iptArticleId").textbox("getValue"),
beginTime: startTime,
endTime: endTime
});
}
});
// 检索按钮
$("#labelGroupListTable").myDatagrid({
fit: true,
fitColumns: true,
striped: true,
url: serverContextPath + "/grassArticleComment/queryComment",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
tmp.rows = tmp.list?tmp.list:[];
return tmp;
},
columns: [[
{
field: "ck",
checkbox:true,
align: "left"
},
{
title: "评论ID",
field: "id",
width: 15,
align: "center"
},
{
title: "评论内容",
field: "content",
width: 30,
align: "left"
},
{
title: "原文类型",
field: "columnType",
width: 15,
align: "center",
formatter: function (value, rowData, rowIndex) {
if(value == '1000'){
return "文章";
}
if(value == '1001'){
return "晒单";
}
}
},
{
title: "晒单ID",
field: "shareOrderId",
width: 20,
align: "labelAmount"
},
{
title: "UID",
field: "uid",
width: 20,
align: "labelAmount"
},
{
title: "被回复数",
field: "childTotal",
width: 20,
align: "labelAmount"
},
{
title: "被赞",
field: "praiseTotal",
width: 20,
align: "labelAmount"
},
{
title: "评论时间",
field: "createTime",
width: 20,
align: "labelAmount",
formatter: function (value, rowData, rowIndex) {
if(!value){
return;
}
value = new Date(value*1000);
return [value.getFullYear(),value.getMonth()+1,
value.getDate()
].join('-')+' '+
[value.getHours(),
value.getMinutes(),
value.getSeconds()].join(':');
}
}, {
title: "状态",
field: "status",
width: 25,
align: "left",
formatter: function (value, rowData, rowIndex) {
if(value == '0'){
return "待审核";
}
if(value == '1'){
return "通过";
}
if(value == '2'){
return "未通过";
}
}
},
{
title: "操作",
field: "ddg",
width: 40,
align: "center",
formatter: function (value, rowData, rowIndex) {
if(rowData.status != 0){
return ;
}
var str = "<a role='allowStatus' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #31b0d5' index='"+ rowIndex +"'>通过</a>";
str += "<a role='banStatus' style='margin-left:10px;background-color: #ffa951' dataId='"+ rowData.id +"' index='"+ rowIndex +"'>屏蔽</a>";
return str;
}
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
onLoadSuccess: function (data) {
if(index != ""){
$(this).datagrid("scrollTo",index);
index = "";
}
// 编辑
$(this).datagrid("getPanel").find("a[role='allowStatus']").linkbutton({
iconCls : "icon-edit",
onClick : function() {
index = $(this).attr("index");
var row = $("#labelGroupListTable").datagrid('getData').rows[index];
updateStatus([row.id],1);
}
});
$(this).datagrid("getPanel").find("a[role='banStatus']").linkbutton({
iconCls : "icon-edit",
onClick : function() {
index = $(this).attr("index");
var row = $("#labelGroupListTable").datagrid('getData').rows[index];
updateStatus([row.id],2);
}
});
}
});
function updateStatus(ids,status){
var param={
ids:ids,
status:status
};
$.ajax(
{
type : 'post',
url : serverContextPath + "/grassArticleComment/modifyStatus",
dataType : 'json',
data : JSON.stringify(param),
contentType : 'application/json',
dataType : 'json',
success : function(result){
if(result.code==200){
$("#labelGroupListTable").datagrid("reload");
$.messager.show({
title: "提示",
msg: "审核成功!",
height: 120
});
}else{
$.messager.alert("审核失败", result.message, "error");
}
}
}
);
}
});
</script>
</html>
\ No newline at end of file
... ...
<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<div region="north" style="height: 60px;">
<div style="margin-left: 20px;margin-top: 10px">
<input class="easyui-textbox" id="sknsIpt" style="width: 340px">
</input>
<a id="searchProductBtn" class="btn-info" >搜索商品</a>
</div>
</div>
<div region="center" id="productListDiv" style="margin-left: 20px">
<table id="productListTable"></table>
</div>
</div>
<script>
$(function () {
//用于页面刷新后的数据行定位
var index ="";
$("#sknsIpt").textbox({
required:false,
prompt: "输入SKN,多个SKN以逗号隔开"
});
$("#searchProductBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
$("#productListTable").datagrid("load", {
skns: $("#sknsIpt").textbox("getValue")
});
}
});
$("#productListTable").myDatagrid({
fit: true,
fitColumns: true,
striped: true,
url: serverContextPath + "/grassGoods/searchProducts",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
tmp.rows = tmp.list?tmp.list:[];
return tmp;
},
columns: [[
{
field: "ck",
checkbox:true,
align: "left"
},
{
title: "产品图片",
field: "default_images",
width: 15,
align: "center",
formatter: function (value, rowData, rowIndex) {
return "<img style='width: 80px; height: 80px' src='"+value+"'/>";
}
},
{
title: "产品名称",
field: "product_name",
width: 30,
align: "left"
},{
title: "SKN",
field: "product_skn",
width: 20,
align: "labelAmount"
},
{
title: "品牌",
field: "brand_name",
width: 20,
align: "labelAmount"
},
{
title: "现价",
field: "sales_price",
width: 20,
align: "labelAmount"
},
{
title: "吊牌价",
field: "market_price",
width: 20,
align: "labelAmount"
},
{
title: "预售(哪个?)",
field: "sales_num",
width: 20,
align: "labelAmount"
},
{
title: "库存",
field: "storage_num",
width: 20,
align: "labelAmount"
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "product_skn",
singleSelect: false,
onLoadSuccess: function (data) {
if(index != ""){
$(this).datagrid("scrollTo",index);
index = "";
}
}
});
});
</script>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yoho!Buy运营平台</title>
<script src="/pfcms/js/include.js"></script>
<script src="/pfcms/js/ajaxfileupload.js"></script>
<style>
.btn-long {
width: 120px;
height: 37px;
line-height: 37px;
font-size: 15px;
color: white;
border-radius: 5px;
display: inline-block;
cursor: pointer;
text-align: center;
}
.btn-long:hover {
opacity: 0.9;
}
</style>
</head>
<body class="easyui-layout" >
<div region="north" style="height: 200px;">
<script>
document.write(addHead('潮物管理', '潮物评论管理'));
</script>
<div style="margin-left: 20px;margin-top: 10px">
<input class="easyui-combobox" id="iptStatus" style="width: 140px">
</input>
<input class="easyui-numberbox" type="number" id="iptUid" style="width: 140px">
</input>
<input class="easyui-textbox" id="iptSkn" style="width: 140px">
</input>
<input class="easyui-numberbox" type="number" id="iptGoodsId" style="width: 140px">
</input>
<input id="iptStartTime" class="easyui-datetimebox" data-options="prompt:'开始时间'"/>
~ &nbsp;
<input id="iptEndTime" class="easyui-datetimebox" data-options="prompt:'结束时间'"/>
<a id="searchBtn" class="btn-info">查询</a>
<a id="allBtn" class="btn-info">全部</a>
</div>
<div style="margin-left: 20px;margin-top: 10px">
<a id="btnBatchAllow" class="btn-long" style="background-color: #5CB85C;">批量通过</a>
<a id="btnBatchBan" class="btn-long" style="background-color: #ffa951;">批量拒绝</a>
</div>
</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
<table id="labelGroupListTable"></table>
</div>
</body>
<script>
$(function() {
//用于页面刷新后的数据行定位
var index ="";
$("#iptStatus").combobox({
valueField : "value",
textField : "text",
editable:false,
required:false,
prompt: "请选择状态",
data:[{text:"全部",value:"-1"},{text:"待审核",value:"0"},{text:"已通过",value:"1"},{text:"未通过",value:"2"}]
});
$("#iptUid").numberbox({
required:false,
prompt: "UID"
});
$("#iptSkn").textbox({
required:false,
prompt: "商品SKN"
});
$("#iptGoodsId").numberbox({
required:false,
prompt: "原内容ID"
});
$("#allBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
$("#labelGroupListTable").datagrid("load", {});
}
});
$("#btnBatchAllow").click(function(){
batchUpdateStatus(1);
});
$("#btnBatchBan").click(function(){
batchUpdateStatus(2);
});
function batchUpdateStatus(status){
var rows = $('#labelGroupListTable').datagrid('getSelections');
if(!rows||rows.length == 0){
$.messager.alert("提示", "请先选择数据!", "warn");
return;
}
var ids = [];
rows.forEach(function(value,i){
ids.push(value.id);
})
updateStatus(ids,status)
}
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
var startTime;
var endTime;
if ($("#iptStartTime").datetimebox('getValue')!='') {
startTime = parseInt(new Date($("#iptStartTime").datetimebox('getValue')).getTime() / 1000);
}
if ($("#iptEndTime").datetimebox('getValue')!='') {
endTime = parseInt(new Date($("#iptEndTime").datetimebox('getValue')).getTime() / 1000);
}
var status ;
if($("#iptStatus").combobox("getValue")!=null && $("#iptStatus").combobox("getValue") !=-1){
status = $("#iptStatus").combobox("getValue");
}
$("#labelGroupListTable").datagrid("load", {
status: status,
uid: $("#iptUid").textbox("getValue"),
skn: $("#iptSkn").textbox("getValue"),
goodsId: $("#iptGoodsId").textbox("getValue"),
beginTime: startTime,
endTime: endTime
});
}
});
// 检索按钮
$("#labelGroupListTable").myDatagrid({
fit: true,
fitColumns: true,
striped: true,
url: serverContextPath + "/grassGoodsComment/queryComment",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
tmp.rows = tmp.list?tmp.list:[];
return tmp;
},
columns: [[
{
field: "ck",
checkbox:true,
align: "left"
},
{
title: "评论ID",
field: "id",
width: 15,
align: "center"
},
{
title: "评论内容",
field: "content",
width: 30,
align: "left"
},
{
title: "原内容ID",
field: "goodsId",
width: 20,
align: "labelAmount"
},
{
title: "商品SKN",
field: "skn",
width: 20,
align: "labelAmount"
},
{
title: "UID",
field: "uid",
width: 20,
align: "labelAmount"
},
{
title: "被回复数",
field: "childTotal",
width: 20,
align: "labelAmount"
},
{
title: "被赞",
field: "praiseTotal",
width: 20,
align: "labelAmount"
},
{
title: "评论时间",
field: "createTime",
width: 20,
align: "labelAmount",
formatter: function (value, rowData, rowIndex) {
if(!value){
return;
}
value = new Date(value*1000);
return [value.getFullYear(),value.getMonth()+1,
value.getDate()
].join('-')+' '+
[value.getHours(),
value.getMinutes(),
value.getSeconds()].join(':');
}
}, {
title: "状态",
field: "status",
width: 25,
align: "left",
formatter: function (value, rowData, rowIndex) {
if(value == '0'){
return "待审核";
}
if(value == '1'){
return "通过";
}
if(value == '2'){
return "未通过";
}
}
},
{
title: "操作",
field: "ddg",
width: 40,
align: "center",
formatter: function (value, rowData, rowIndex) {
if(rowData.status != 0){
return ;
}
var str = "<a role='allowStatus' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #31b0d5' index='"+ rowIndex +"'>通过</a>";
str += "<a role='banStatus' style='margin-left:10px;background-color: #ffa951' dataId='"+ rowData.id +"' index='"+ rowIndex +"'>屏蔽</a>";
return str;
}
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
onLoadSuccess: function (data) {
if(index != ""){
$(this).datagrid("scrollTo",index);
index = "";
}
// 编辑
$(this).datagrid("getPanel").find("a[role='allowStatus']").linkbutton({
iconCls : "icon-edit",
onClick : function() {
index = $(this).attr("index");
var row = $("#labelGroupListTable").datagrid('getData').rows[index];
updateStatus([row.id],1);
}
});
$(this).datagrid("getPanel").find("a[role='banStatus']").linkbutton({
iconCls : "icon-edit",
onClick : function() {
index = $(this).attr("index");
var row = $("#labelGroupListTable").datagrid('getData').rows[index];
updateStatus([row.id],2);
}
});
}
});
function updateStatus(ids,status){
var param={
ids:ids,
status:status
};
$.ajax(
{
type : 'post',
url : serverContextPath + "/grassGoodsComment/modifyStatus",
dataType : 'json',
data : JSON.stringify(param),
contentType : 'application/json',
dataType : 'json',
success : function(result){
if(result.code==200){
$("#labelGroupListTable").datagrid("reload");
$.messager.show({
title: "提示",
msg: "审核成功!",
height: 120
});
}else{
$.messager.alert("审核失败", result.message, "error");
}
}
}
);
}
});
</script>
</html>
\ No newline at end of file
... ...
<!DOCTYPE html>
<div id="goodsEdit" class="easyui-layout" fit="true" style="overflow-y: scroll;">
<form name="goodsEditForm" id="goodsEditForm" method="post">
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px">
<td >
<label>商品SKN</label> <br>
<input id="iptSKN" name="skn" class="easyui-textbox" style="width:520px;" disabled/>
</td>
</tr>
<tr style="height: 60px">
<td >
<span style="color:red">*</span><label>标题</label> <br>
<input id="iptTitle" name="title" class="easyui-textbox" style="width:520px;"/>
</td>
</tr>
<tr style="height: 60px">
<td >
<span style="color:red">*</span><label>商品描述</label> <br>
<textarea id="taContent" class="easyui-validatebox" data-options="required:true" name="content" style="width:520px;" rows="6"/>
</td>
</tr>
<tr style="height: 60px">
<td id="imgTd">
<div id="imageUpload">
</div>
</td>
</tr>
<tr style="height: 60px">
<td >
<span style="color:red">*</span><label>展示顺序</label> <br>
<input id="iptWeight" name="weight" type="number" class="easyui-textbox" style="width:520px;"/>
</td>
</tr>
</table>
</div>
</form>
</div>
<script>
$(function () {
$("#iptSKN").textbox({
required:false,
});
$("#iptTitle").textbox({
required:true,
prompt: "请输入标题",
validType:'length[0,60]'
});
$("#iptWeight").textbox({
required:true,
prompt: "数据越大越靠前"
});
$("#imageUpload").imageUpload({
width: 171,
height: 120,
realInputName: "url",
url: contextPath + '/fileupload/uploadFile',
queryParams: {
bucket: "goodsimg"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
debugger;
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误",data.message);
return "";
}
return data.data.url;
},
onLoadSuccess: function (data) {
debugger;
$.messager.progress("close");
return false;
}
});
$("#groupName").textbox({
required: true,
missingMessage: "分组名称不能为空",
prompt: "请输入分组名称"
});
var data = paramObject.goodsData;
if (data){
$("#iptSKN").textbox("setValue", data.productSkn);
$("#iptTitle").textbox("setValue", data.title);
$("#taContent").val(data.content);
$("#imageUpload").imageUpload('setValue',data.icon);
$("#iptWeight").textbox("setValue", data.weight);
}
$("#goodsEditForm").form("validate")
});
</script>
\ No newline at end of file
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yoho!Buy运营平台</title>
<script src="/pfcms/js/include.js"></script>
<script src="/pfcms/js/ajaxfileupload.js"></script>
<style>
.btn-long {
width: 120px;
height: 37px;
line-height: 37px;
font-size: 15px;
color: white;
border-radius: 5px;
display: inline-block;
cursor: pointer;
text-align: center;
}
.btn-long:hover {
opacity: 0.9;
}
</style>
</head>
<body class="easyui-layout" >
<div region="north" style="height: 200px;">
<script>
document.write(addHead('潮物管理', '商品管理'));
</script>
<div style="margin-left: 20px;margin-top: 10px">
<input class="easyui-textbox" id="groupNameSearch" style="width: 140px">
</input>
<a id="searchBtn" class="btn-info">查询</a>
<a id="allBtn" class="btn-info">全部</a>
</div>
<div style="margin-left: 20px;margin-top: 10px">
<a id="addBtn" class="btn-long" style="background-color: #5CB85C;">+添加商品</a>
</div>
</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
<table id="labelGroupListTable"></table>
</div>
</body>
<script>
$(function() {
//用于页面刷新后的数据行定位
var index ="";
$("#allBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
$("#labelGroupListTable").datagrid("load", {});
}
});
$("#groupNameSearch").textbox({
required:false,
prompt: "商品SKN"
});
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
$("#labelGroupListTable").datagrid("load", {
skn: $("#groupNameSearch").textbox("getValue")
});
}
});
$("#addBtn").click(function () {
getAddDialog();
});
// 检索按钮
$("#labelGroupListTable").myDatagrid({
fit: true,
fitColumns: true,
striped: true,
url: serverContextPath + "/grassGoods/queryGoods",
method: 'POST',
loadFilter: function (data) {
var tmp = defaultLoadFilter(data);
tmp.rows = tmp.list?tmp.list:[];
return tmp;
},
columns: [[
{
title: "SKN",
field: "productSkn",
width: 15,
align: "center"
},
{
title: "商品描述",
field: "content",
width: 30,
align: "left"
},
{
title: "封面图",
field: "icon",
width: 20,
align: "labelAmount",
formatter: function (value, rowData, rowIndex) {
return "<img style='width: 80px; height: 80px' src='"+value+"'/>";
}
},
{
title: "可售库存",
field: "availTotal",
width: 20,
align: "labelAmount"
},
{
title: "上下架状态",
field: "shelfStatus",
width: 20,
align: "labelAmount",
formatter: function (value, rowData, rowIndex) {
if(value == '0'){
return "下架";
}
if(value == '1'){
return "上架";
}
}
},
{
title: "被种草数",
field: "grassTotal",
width: 20,
align: "labelAmount"
},
{
title: "展示顺序",
field: "weight",
width: 20,
align: "labelAmount"
},
{
title: "评论数",
field: "commentTotal",
width: 20,
align: "labelAmount"
}, {
title: "状态",
field: "status",
width: 25,
align: "left",
formatter: function (value, rowData, rowIndex) {
if(value == '0'){
return "使用中";
}
if(value == '1'){
return "已停用";
}
}
},
{
title: "操作",
field: "ddg",
width: 40,
align: "center",
formatter: function (value, rowData, rowIndex) {
var statusDesc = rowData.status == 0 ? "停用" : "启用";
var str = "<a role='modifyStatus' dataId='"+ rowData.id +"' dataStatus='"+rowData.status+"' style='margin-left:10px;background-color: #31b0d5' index='"+ rowIndex +"'>"+statusDesc+"</a>";
str += "<a role='edit' style='margin-left:10px;background-color: #ffa951' dataId='"+ rowData.id +"' index='"+ rowIndex +"'>编辑</a>";
return str;
}
}
]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: true,
onLoadSuccess: function (data) {
if(index != ""){
$(this).datagrid("scrollTo",index);
index = "";
}
$(this).datagrid("getPanel").find("a[role='modifyStatus']").linkbutton({
iconCls: "icon-redo",
onClick: function () {
var id = $(this).attr("dataId");
var status = $(this).attr("dataStatus")==0?1:0;
$.post(serverContextPath + "/grassGoods/modifyGoodsStatus", {
id : id,
status:status
}, function(data) {
if (data.code == CODE_SUCCESS) {
$("#labelGroupListTable").datagrid("reload");
window.self.$.messager.show({
title : "提示",
msg : "修改成功!"
});
} else {
window.self.$.messager.alert("失败", data.message, "error");
}
});
}
});
// 编辑
$(this).datagrid("getPanel").find("a[role='edit']").linkbutton({
iconCls : "icon-edit",
onClick : function() {
index = $(this).attr("index");
var row = $("#labelGroupListTable").datagrid('getData').rows[index];
window.self.paramObject.goodsData = row;
getEditDialog(row);
}
});
}
});
function getEditDialog(rowData){
var labelGroupList = $("<div id='labelGroupList'>").appendTo($(document.body));
$(labelGroupList).myDialog({
title: "编辑商品",
width: "600px",
height: "80%",
resizable:false,
buttons:[{
id : "saveBtn",
text:"保存",
iconCls : "icon-save",
handler:function(){
$("#goodsEditForm").form("submit", {
url: serverContextPath + "/grassGoods/modifyGoods",
onSubmit: function (param) {
if (!$("#goodsEditForm").form("validate")) {
return false;
}
param.icon = $('form input[name="url"]').val();
param.id = rowData.id;
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
return true;
},
success: function (data) {
data = JSON.parse(data);
if (data.code == 200) {
$(labelGroupList).dialog("close");
$("#labelGroupListTable").datagrid("reload");
$.messager.show({
title: "提示",
msg: "修改成功!",
height: 120
});
} else {
$.messager.alert("失败", data.message, "error");
}
}
});
}
}, {
text: "取消",
iconCls: "icon-cancel",
handler: function () {
$.messager.confirm("确认", "确认关闭吗?", function (flag) {
if(flag){
$(labelGroupList).dialog("close");
}
});
}
}],
modal: true,
href: contextPath + "/html/grass/goods/goodsEdit.html",
});
}
// 新增潮物
function getAddDialog(){
var labelGroupList = $("<div id='labelGroupList'>").appendTo($(document.body));
$(labelGroupList).myDialog({
title: "添加商品",
width: "60%",
height: "80%",
resizable:false,
buttons:[{
id : "saveBtn",
text:"确认",
iconCls : "icon-save",
handler:function(){
var rows = $('#productListTable').datagrid('getSelections');
if(!rows||rows.length == 0){
$.messager.alert("提示", "请先选择数据!", "warn");
return;
}
var param=[];
rows.forEach(function(value,i){
var parm={
skn:value['product_skn'],
name:value['product_name'],
icon:value['default_images']
};
param.push(parm);
});
$.ajax(
{
type : 'post',
url : serverContextPath + "/grassGoods/batchAddGoods",
dataType : 'json',
data : JSON.stringify(param),
contentType : 'application/json',
success : function(result){
if(result.code==200){
$(labelGroupList).dialog("close");
$("#labelGroupListTable").datagrid("reload");
$.messager.show({
title: "提示",
msg: "新增成功!",
height: 120
});
}else{
$.messager.alert("新增失败", result.message, "error");
}
}
}
);
}
}, {
text: "取消",
iconCls: "icon-cancel",
handler: function () {
$.messager.confirm("确认", "确认关闭吗?", function (flag) {
if(flag){
$(labelGroupList).dialog("close");
}
});
}
}],
modal: true,
href: contextPath + "/html/grass/goods/goodsAdd.html",
});
}
});
</script>
</html>
\ No newline at end of file
... ...