code stringlengths 3 1.18M | language stringclasses 1 value |
|---|---|
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.PubService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.Pub;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/pub" })
public class PubAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(PubAdminController.class);
@Autowired
private PubService pubService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Pub pub) {
CriteriaQuery cq = new CriteriaQuery(Pub.class, curPageNO,
"javascript:pager");
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(pub.getUserName()));
cq.addOrder("desc", "date");
cq.add();
PageSupport ps = this.pubService.getPubList(cq);
savePage(ps, request);
request.setAttribute("bean", pub);
return PathResolver.getPath(request, BackPage.PUB_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Pub pub) {
String name = UserManager.getUsername(request.getSession());
pub.setDate(new Date());
pub.setUserId(UserManager.getUserId(request.getSession()));
pub.setUserName(name);
this.pubService.save(pub, name,
CommonServiceUtil.haveViewAllDataFunction(request));
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.PUB_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Pub pub = this.pubService.getPubById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), pub.getUserName());
if (result != null) {
return result;
}
this.log.info("{} delete Pub Title {}", pub.getUserName(),
pub.getTitle());
this.pubService.delete(id);
saveMessage(request, ResourceBundleHelper.getDeleteString());
return PathResolver.getPath(request, FowardPage.PUB_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Pub pub = this.pubService.getPubById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), pub.getUserName());
if (result != null) {
return result;
}
request.setAttribute("bean", pub);
return PathResolver.getPath(request, BackPage.PUB_EDIT_PAGE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.PUB_EDIT_PAGE);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.ShopStatusEnum;
import com.legendshop.business.common.ShopTypeEnum;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.search.facade.ShopDetailSearchFacade;
import com.legendshop.business.service.ShopDetailService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.UserDetail;
import com.legendshop.util.AppUtils;
import com.legendshop.util.SafeHtml;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/admin/shopDetail" })
public class ShopDetailAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(ShopDetailAdminController.class);
@Autowired
private ShopDetailService shopDetailService;
@Autowired
private ShopDetailSearchFacade shopDetailSearchFacade;
@RequestMapping({"query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, ShopDetail shopDetail)
throws Exception {
CriteriaQuery cq = new CriteriaQuery(ShopDetail.class, curPageNO,
"javascript:pager");
hasAllDataFunction(cq, request, "storeName",
StringUtils.trim(shopDetail.getStoreName()));
if (!CommonServiceUtil.isDataForExport(cq, request)) {
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
}
if (!CommonServiceUtil.isDataSortByExternal(cq, request)) {
cq.addOrder("desc", "modifyTime");
}
cq.eq("type", shopDetail.getType());
cq.eq("colorStyle", shopDetail.getColorStyle());
cq.eq("status", shopDetail.getStatus());
cq.add();
PageSupport ps = this.shopDetailService.getShopDetail(cq);
savePage(ps, request);
request.setAttribute("shopDetail", shopDetail);
return PathResolver.getPath(request, BackPage.SHOP_DETAIL_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, ShopDetail shopDetail) {
if ((shopDetail != null) && (!AppUtils.isBlank(shopDetail.getShopId()))) {
return update(request, response, shopDetail);
}
String userName = shopDetail.getStoreName();
String shopPic = null;
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), userName);
if (result != null) {
return result;
}
if (AppUtils.isBlank(userName)) {
throw new NotFoundException("user name can not be null!", "10");
}
UserDetail userDetail = this.shopDetailService
.getShopDetailByName(userName);
if (AppUtils.isBlank(userDetail))
throw new NotFoundException("userDetail can not be null!", "10");
try {
SafeHtml safeHtml = new SafeHtml();
shopDetail.setUserId(userDetail.getUserId());
Date date = new Date();
shopDetail.setModifyTime(date);
shopDetail.setAddtime(date);
shopDetail.setVisitTimes(Integer.valueOf(0));
shopDetail.setOffProductNum(Integer.valueOf(0));
shopDetail.setCommNum(Integer.valueOf(0));
shopDetail.setProductNum(Integer.valueOf(0));
shopDetail.setWeb(safeHtml.makeSafe(shopDetail.getStoreName()));
shopDetail.setType(ShopTypeEnum.BUSINESS.value());
shopDetail.setStatus(ShopStatusEnum.ONLINE.value());
String subPath = userName + "/shop/";
if (shopDetail.getFile().getSize() > 0L) {
shopPic = FileProcessor.uploadFileAndCallback(
shopDetail.getFile(), subPath, "so" + userName);
shopDetail.setShopPic(shopPic);
}
this.shopDetailService.save(shopDetail);
saveMessage(request, ResourceBundleHelper.getSucessfulString());
} catch (Exception e) {
if (shopPic != null) {
FileProcessor.deleteFile(shopPic);
}
throw new BusinessException(e, "error happened when save shop");
}
return PathResolver.getPath(request, FowardPage.SHOP_DETAIL_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
ShopDetail shopDetail = this.shopDetailService.getShopDetailById(id);
if (shopDetail != null) {
this.shopDetailService.delete(shopDetail);
this.shopDetailSearchFacade.delete(shopDetail);
}
saveMessage(request, ResourceBundleHelper.getDeleteString());
return PathResolver.getPath(request, FowardPage.SHOP_DETAIL_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
ShopDetail shopDetail = this.shopDetailService.getShopDetailById(id);
if (shopDetail != null) {
String result = checkPrivilege(request,
UserManager.getUsername(request), shopDetail.getStoreName());
if (result != null) {
return result;
}
}
request.setAttribute("shopDetail", shopDetail);
request.setAttribute("id", request.getParameter("userId"));
return PathResolver.getPath(request, BackPage.SHOP_DETAIL_EDIT_PAGE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.SHOP_DETAIL_EDIT_PAGE);
}
private String update(HttpServletRequest request,
HttpServletResponse response, ShopDetail shopDetail) {
ShopDetail shop = this.shopDetailService.getShopDetailById(shopDetail
.getShopId());
if (shop == null) {
throw new NotFoundException("shop can not be null, getShopId = "
+ shopDetail.getShopId(), "10");
}
String originShopPic = shop.getShopPic();
String shopPic = null;
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
shopDetail.getStoreName());
if (result != null)
return result;
try {
String subPath = shopDetail.getStoreName() + "/shop/";
SafeHtml safeHtml = new SafeHtml();
shop.setSitename(safeHtml.makeSafe(shopDetail.getSitename()));
shop.setMaddr(safeHtml.makeSafe(shopDetail.getMaddr()));
shop.setMsn(safeHtml.makeSafe(shopDetail.getMsn()));
shop.setMname(safeHtml.makeSafe(shopDetail.getMname()));
shop.setCode(safeHtml.makeSafe(shopDetail.getCode()));
shop.setYmaddr(safeHtml.makeSafe(shopDetail.getYmaddr()));
shop.setYmname(safeHtml.makeSafe(shopDetail.getYmname()));
shop.setColorStyle(shopDetail.getColorStyle());
shop.setLangStyle(shopDetail.getLangStyle());
shop.setBriefDesc(safeHtml.makeSafe(shopDetail.getBriefDesc()));
shop.setDetailDesc(safeHtml.makeSafe(shopDetail.getDetailDesc()));
shop.setModifyTime(new Date());
shop.setProvinceid(shopDetail.getProvinceid());
shop.setCityid(shopDetail.getCityid());
shop.setAreaid(shopDetail.getAreaid());
if ((CommonServiceUtil.haveViewAllDataFunction(request))
|| (!ShopStatusEnum.AUDITING.value().equals(shop.getStatus()))) {
if (shopDetail.getStatus() != null) {
shop.setStatus(shopDetail.getStatus());
}
}
if (shopDetail.getFile().getSize() > 0L) {
shopPic = FileProcessor.uploadFileAndCallback(
shopDetail.getFile(), subPath,
"so" + shopDetail.getStoreName());
shop.setShopPic(shopPic);
}
this.shopDetailService.update(shop);
} catch (Exception e) {
if (shopPic != null) {
FileProcessor.deleteFile(shopPic);
}
throw new BusinessException(e, "error happened when update shop");
} finally {
if ((shopPic != null) && (originShopPic != null)) {
FileProcessor.deleteFile(RealPathUtil.getBigPicRealPath() + "/"
+ originShopPic);
}
}
this.shopDetailSearchFacade.update(shop);
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.SHOP_DETAIL_LIST_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.Constants;
import com.legendshop.business.common.page.TilesPage;
import com.legendshop.business.service.BasketService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.helper.PropertiesUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/basket" })
public class BasketController extends BaseController {
private final Logger log = LoggerFactory.getLogger(BasketController.class);
@Autowired
private BasketService basketService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request, HttpServletResponse response) {
String prodId = request.getParameter("prodId");
return getBasket(request, response,
Long.valueOf(Long.parseLong(prodId)));
}
private String getBasket(HttpServletRequest request,
HttpServletResponse response, Long prodId) {
String userName = UserManager.getUsername(request);
String addtoCart = request.getParameter("addtoCart");
String count = request.getParameter("count");
if (count == null) {
count = "1";
}
request.getSession().setAttribute("BASKET_HW_COUNT", count);
String prodattr = request.getParameter("prodattr");
request.getSession().setAttribute("BASKET_HW_ATTR", prodattr);
if (userName == null) {
String destView = "/views/";
if ("added".equals(addtoCart)) {
destView = "/basket/load/";
}
request.setAttribute("returnUrl", PropertiesUtil.getDomainName()
+ destView + prodId + Constants.WEB_SUFFIX);
return PathResolver.getPath(request, TilesPage.NO_LOGIN);
}
String shopName = getShopName(request, response);
this.basketService.saveToCart(prodId, addtoCart, shopName, prodattr,
userName, Integer.valueOf(count));
return PathResolver.getPath(request, TilesPage.PAGE_CASH);
}
@RequestMapping({"/load/{prodId}" })
public String load(HttpServletRequest request,
HttpServletResponse response, Long prodId) {
return getBasket(request, response, prodId);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.core.base.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
@Controller
public class SortController extends BaseController {
private final Logger log = LoggerFactory.getLogger(SortController.class);
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.ProductCommentService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.Product;
import com.legendshop.model.entity.ProductComment;
import com.legendshop.util.AppUtils;
import com.legendshop.util.SafeHtml;
import com.legendshop.util.sql.ConfigCode;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/productcomment" })
public class ProductCommentAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(ProductCommentAdminController.class);
@Autowired
private ProductCommentService productCommentService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO,
ProductComment productComment) {
String userName = UserManager.getUsername(request.getSession());
Map map = new HashMap();
HqlQuery hql = new HqlQuery(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue(), curPageNO);
if (!CommonServiceUtil.haveViewAllDataFunction(request)) {
map.put("ownerName", userName);
hql.addParams(userName);
} else if (AppUtils.isNotBlank(productComment.getOwnerName())) {
map.put("ownerName", productComment.getOwnerName());
hql.addParams(productComment.getOwnerName());
}
if (AppUtils.isNotBlank(productComment.getUserName())) {
map.put("userName", productComment.getUserName());
hql.addParams("%" + productComment.getUserName() + "%");
}
if (AppUtils.isNotBlank(productComment.getProdName())) {
map.put("prodName", productComment.getProdName());
hql.addParams("%" + productComment.getProdName() + "%");
}
if (!CommonServiceUtil.isDataForExport(hql, request)) {
hql.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
}
if (!CommonServiceUtil.isDataSortByExternal(hql, request, map)) {
map.put("orderIndicator", "order by hc.addtime desc");
}
hql.setAllCountString(ConfigCode.getInstance().getCode(
"biz.getProductCommentCount", map));
hql.setQueryString(ConfigCode.getInstance().getCode(
"biz.getProductComment", map));
PageSupport ps = this.productCommentService.getProductCommentList(hql);
savePage(ps, request);
request.setAttribute("bean", productComment);
return PathResolver.getPath(request, BackPage.PROD_COMM_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, ProductComment productComment) {
ProductComment comment = this.productCommentService
.getProductCommentById(productComment.getId());
if (comment == null) {
throw new NotFoundException("ProductComment Not Found", "12");
}
String username = UserManager.getUsername(request.getSession());
String result = checkPrivilege(request, username,
comment.getOwnerName());
if (result != null) {
return result;
}
SafeHtml safe = new SafeHtml();
comment
.setReplyContent(safe.makeSafe(productComment.getReplyContent()));
comment.setReplyName(username);
comment.setReplyTime(new Date());
this.productCommentService.update(comment);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"operation.successful"));
return PathResolver.getPath(request, FowardPage.PROD_COMM_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
String username = UserManager.getUsername(request.getSession());
ProductComment productComment = this.productCommentService
.getProductCommentById(id);
String result = checkPrivilege(request, username,
productComment.getOwnerName());
if (result != null) {
return result;
}
this.log.info(
"{}, delete ProductComment Addtime {}, delete person",
new Object[] {productComment.getUserName(),
productComment.getAddtime(), username });
this.productCommentService.delete(id);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"entity.deleted"));
return PathResolver.getPath(request, FowardPage.PROD_COMM_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
ProductComment productComment = this.productCommentService
.getProductCommentById(id);
if (productComment == null) {
throw new NotFoundException("ProductComment not found with Id "
+ id, "12");
}
Product product = this.productCommentService.getProduct(productComment
.getProdId());
productComment.setProdName(product.getName());
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
productComment.getOwnerName());
if (result != null) {
return result;
}
request.setAttribute("bean", productComment);
return PathResolver.getPath(request, BackPage.PROD_COMM_EDIT_PAGE);
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
@PathVariable ProductComment productComment) {
this.productCommentService.update(productComment);
return PathResolver.getPath(request, FowardPage.PROD_COMM_LIST_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.Constants;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.ImgFileService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.ApplicationException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.ImgFile;
import com.legendshop.model.entity.Product;
import com.legendshop.util.AppUtils;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/admin/imgFile" })
public class ImgFileAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(ImgFileAdminController.class);
@Autowired
private ImgFileService imgFileService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, ImgFile imgFile) {
Long productId = (Long) request.getAttribute("productId");
if (productId == null) {
String productIdStr = request.getParameter("productId");
if (AppUtils.isNotBlank(productIdStr))
productId = Long.valueOf(productIdStr);
}
if (productId == null) {
throw new ApplicationException("miss productId", "26");
}
CriteriaQuery cq = new CriteriaQuery(ImgFile.class, curPageNO,
"javascript:pager");
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(imgFile.getUserName()));
if (productId != null) {
cq.eq("productId", productId);
imgFile.setProductId(productId);
Product product = this.imgFileService.getProd(productId);
request.setAttribute("prod", product);
}
cq.add();
PageSupport ps = this.imgFileService.getImgFileList(cq);
savePage(ps, request);
request.setAttribute("productId", productId);
return PathResolver.getPath(request, BackPage.IMG_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, ImgFile imgFile) {
if (imgFile.getFile() != null) {
String name = UserManager.getUsername(request.getSession());
String subPath = name + "/imgFile/";
String filePath = FileProcessor.uploadFileAndCallback(
imgFile.getFile(), subPath, "imf" + name);
imgFile.setFilePath(filePath);
imgFile.setFileSize(new Integer((int) imgFile.getFile().getSize()));
imgFile.setFileType(filePath.substring(
filePath.lastIndexOf(".") + 1).toLowerCase());
imgFile.setProductType(Short.valueOf("1"));
imgFile.setStatus(Short.valueOf(Constants.ONLINE.shortValue()));
imgFile.setUpoadTime(new Date());
imgFile.setUserName(name);
this.imgFileService.save(imgFile);
saveMessage(request, ResourceBundleHelper.getSucessfulString());
}
request.setAttribute("productId", imgFile.getProductId());
return PathResolver.getPath(request, FowardPage.IMG_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
ImgFile imgFile = this.imgFileService.getImgFileById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
imgFile.getUserName());
if (result != null) {
return result;
}
this.log.info("{}, delete ImgFile filePath {}", imgFile.getUserName(),
imgFile.getFilePath());
this.imgFileService.delete(id);
String url = RealPathUtil.getBigPicRealPath() + "/"
+ imgFile.getFilePath();
FileProcessor.deleteFile(url);
request.setAttribute("productId", imgFile.getProductId());
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.IMG_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
ImgFile imgFile = this.imgFileService.getImgFileById(id);
request.setAttribute("bean", imgFile);
return PathResolver.getPath(request, BackPage.IMG_EDIT_PAGE);
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
@PathVariable ImgFile imgFile) {
this.imgFileService.update(imgFile);
return PathResolver.getPath(request, FowardPage.IMG_LIST_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.event.EventId;
import com.legendshop.business.service.ShopDetailService;
import com.legendshop.business.service.UserDetailService;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.dao.support.SqlQuery;
import com.legendshop.event.EventContext;
import com.legendshop.event.EventHome;
import com.legendshop.event.GenericEvent;
import com.legendshop.model.entity.UserDetail;
import com.legendshop.model.entity.UserDetailView;
import com.legendshop.util.AppUtils;
import com.legendshop.util.sql.ConfigCode;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/system/userDetail" })
public class UserDetailAdminController extends BaseController {
/* 52 */private final Logger log = LoggerFactory
.getLogger(UserDetailAdminController.class);
/* */
/* */@Autowired
/* */private UserDetailService userDetailService;
/* */
/* */@Autowired
/* */private ShopDetailService shopDetailService;
/* */
/* */@Deprecated
/* */public String query_for_HQL(HttpServletRequest request,
HttpServletResponse response, String curPageNO, UserDetail userDetail)
/* */{
/* 77 */String search = request.getParameter("search") == null ? ""
: request.getParameter("search");
/* 78 */String enabled = request.getParameter("enabled") == null ? ""
: request.getParameter("enabled");
/* 79 */String haveShop = request.getParameter("haveShop") == null ? ""
: request.getParameter("haveShop");
/* 80 */String userMail = request.getParameter("userMail") == null ? ""
: request.getParameter("userMail");
/* */
/* 82 */this.log.debug(
"search = {},enabled = {}, haveShop = {}, userMail ={} ",
new Object[] {search, enabled, haveShop, userMail });
/* */
/* 84 */Map map = new HashMap();
/* 85 */HqlQuery hqlQuery = new HqlQuery(60, curPageNO);
/* */
/* 87 */if ("1".equals(haveShop))
/* 88 */map.put("haveShop", "and u.shopId is not null");
/* 89 */else if ("0".equals(haveShop)) {
/* 90 */map.put("haveShop", "and u.shopId is null");
/* */}
/* */
/* 93 */if (!AppUtils.isBlank(search)) {
/* 94 */map.put("userName", search);
/* 95 */hqlQuery.addParams("%" + search + "%");
/* */}
/* */
/* 98 */if (!AppUtils.isBlank(enabled)) {
/* 99 */map.put("enabled", enabled);
/* 100 */hqlQuery.addParams(enabled);
/* */}
/* */
/* 103 */if (!AppUtils.isBlank(userMail)) {
/* 104 */map.put("userMail", userMail);
/* 105 */hqlQuery.addParams("%" + userMail + "%");
/* */}
/* 107 */if ((CommonServiceUtil.isDataForExport(hqlQuery, request))
||
/* 109 */(!CommonServiceUtil.isDataSortByExternal(hqlQuery,
request, map))) {
/* 110 */map.put("orderIndicator", "order by u.userRegtime desc");
/* */}
/* 112 */String QueryNsortCount = ConfigCode.getInstance().getCode(
"biz.QueryUserDetailCount", map);
/* 113 */String QueryNsort = ConfigCode.getInstance().getCode(
"biz.QueryUserDetail", map);
/* 114 */hqlQuery.setAllCountString(QueryNsortCount);
/* 115 */hqlQuery.setQueryString(QueryNsort);
/* */
/* 117 */EventContext eventContext = new EventContext(request);
/* 118 */EventHome.publishEvent(new GenericEvent(eventContext,
EventId.CAN_ADD_SHOPDETAIL_EVENT));
/* 119 */Boolean isSupportOpenShop = eventContext.getBooleanResponse();
/* 120 */request.setAttribute("supportOpenShop", isSupportOpenShop);
/* 121 */PageSupport ps = this.userDetailService
.getUserDetailList(hqlQuery);
/* 122 */request.setAttribute("search", search);
/* 123 */request.setAttribute("userMail", userMail);
/* 124 */request.setAttribute("enabled", enabled);
/* 125 */request.setAttribute("haveShop", haveShop);
/* 126 */savePage(ps, request);
/* */
/* 128 */return PathResolver.getPath(request,
BackPage.USER_DETAIL_LIST_PAGE);
/* */}
/* */
/* */@RequestMapping({"/query" })
/* */public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, UserDetail userDetail)
/* */{
/* 146 */String userName = request.getParameter("userName") == null ? ""
: request.getParameter("userName").trim();
/* 147 */String enabled = request.getParameter("enabled") == null ? ""
: request.getParameter("enabled");
/* 148 */String haveShop = request.getParameter("haveShop") == null ? ""
: request.getParameter("haveShop");
/* 149 */String userMail = request.getParameter("userMail") == null ? ""
: request.getParameter("userMail").trim();
/* */
/* 151 */this.log.debug(
"search = {},enabled = {}, haveShop = {}, userMail ={} ",
new Object[] {userName, enabled, haveShop, userMail });
/* */
/* 153 */Map map = new HashMap();
/* 154 */SqlQuery hqlQuery = new SqlQuery(60, curPageNO);
/* */
/* 156 */if ("1".equals(haveShop))
/* 157 */map.put("haveShop", "and u.shop_id is not null");
/* 158 */else if ("0".equals(haveShop)) {
/* 159 */map.put("haveShop", "and u.shop_id is null");
/* */}
/* */
/* 162 */if (!AppUtils.isBlank(userName)) {
/* 163 */map.put("userName", userName);
/* 164 */hqlQuery.addParams("%" + userName + "%");
/* */}
/* */
/* 167 */if (!AppUtils.isBlank(enabled)) {
/* 168 */map.put("enabled", enabled);
/* 169 */hqlQuery.addParams(enabled);
/* */}
/* */
/* 172 */if (!AppUtils.isBlank(userMail)) {
/* 173 */map.put("userMail", userMail);
/* 174 */hqlQuery.addParams("%" + userMail + "%");
/* */}
/* 176 */if ((CommonServiceUtil.isDataForExport(hqlQuery, request))
||
/* 178 */(!CommonServiceUtil.isDataSortByExternal(hqlQuery,
request, map))) {
/* 179 */map.put("orderIndicator", "order by u.user_regtime desc");
/* */}
/* 181 */String totalUserDetail = ConfigCode.getInstance().getCode(
"biz.QueryUserDetailCount", map);
/* 182 */String userDetailSQL = ConfigCode.getInstance().getCode(
"biz.QueryUserDetail", map);
/* 183 */hqlQuery.setAllCountString(totalUserDetail);
/* 184 */hqlQuery.setQueryString(userDetailSQL);
/* */
/* 186 */EventContext eventContext = new EventContext(request);
/* 187 */EventHome.publishEvent(new GenericEvent(eventContext,
EventId.CAN_ADD_SHOPDETAIL_EVENT));
/* 188 */Boolean isSupportOpenShop = eventContext.getBooleanResponse();
/* */
/* 190 */request.setAttribute("supportOpenShop", isSupportOpenShop);
/* */
/* 193 */PageSupport ps = this.userDetailService
.getUserDetailList(hqlQuery);
/* 194 */ps.setResultList(convert((List<Object>) ps.getResultList()));
/* 195 */request.setAttribute("userName", userName);
/* 196 */request.setAttribute("userMail", userMail);
/* 197 */request.setAttribute("enabled", enabled);
/* 198 */request.setAttribute("haveShop", haveShop);
/* 199 */savePage(ps, request);
/* */
/* 201 */return PathResolver.getPath(request,
BackPage.USER_DETAIL_LIST_PAGE);
/* */}
/* */
/* */private List<UserDetailView> convert(List<Object> objs)
/* */{
/* 212 */if (AppUtils.isBlank(objs)) {
/* 213 */return null;
/* */}
/* 215 */List list = new ArrayList();
/* 216 */for (Iterator i$ = objs.iterator(); i$.hasNext();) {
Object obj = i$.next();
/* 217 */UserDetailView userDetail = new UserDetailView();
/* 218 */Object[] arrayObj = (Object[]) (Object[]) obj;
/* 219 */if (arrayObj[0] != null) {
/* 220 */userDetail.setUserId((String) (String) arrayObj[0]);
/* */}
/* 222 */if (arrayObj[1] != null) {
/* 223 */userDetail.setUserName((String) (String) arrayObj[1]);
/* */}
/* */
/* 226 */if (arrayObj[2] != null) {
/* 227 */userDetail.setNickName((String) (String) arrayObj[2]);
/* */}
/* */
/* 230 */if (arrayObj[3] != null) {
/* 231 */userDetail.setUserMail((String) (String) arrayObj[3]);
/* */}
/* */
/* 234 */if (arrayObj[4] != null) {
/* 235 */userDetail.setUserRegip((String) (String) arrayObj[4]);
/* */}
/* */
/* 238 */if (arrayObj[5] != null) {
/* 239 */userDetail.setModifyTime((Date) (Date) arrayObj[5]);
/* */}
/* */
/* 242 */if (arrayObj[6] != null) {
/* 243 */userDetail.setUserRegtime((Date) (Date) arrayObj[6]);
/* */}
/* */
/* 246 */if (arrayObj[7] != null) {
/* 247 */userDetail.setEnabled((String) (String) arrayObj[7]);
/* */}
/* */
/* 250 */if (arrayObj[8] != null) {
/* 251 */userDetail.setShopId(Long
.valueOf(((Integer) (Integer) arrayObj[8]).longValue()));
/* */}
/* 253 */list.add(userDetail);
/* */}
/* 255 */return list;
/* */}
/* */
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.event.EventId;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.event.EventContext;
import com.legendshop.event.EventHome;
import com.legendshop.event.GenericEvent;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/license" })
public class LicenseController extends BaseController {
private final Logger log = LoggerFactory.getLogger(LicenseController.class);
@RequestMapping({"/upgrade" })
public String upgrade(HttpServletRequest request,
HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.UPGRADE_PAGE);
}
@RequestMapping({"/postUpgrade" })
public String postUpgrade(HttpServletRequest request,
HttpServletResponse response) {
EventContext eventContext = new EventContext(request);
EventHome.publishEvent(new GenericEvent(eventContext,
EventId.LICENSE_STATUS_CHECK_EVENT));
if (eventContext.getBooleanResponse().booleanValue()) {
request.setAttribute("postUpgrade", Boolean.valueOf(true));
}
return PathResolver.getPath(request, BackPage.UPGRADE_PAGE);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.PayTypeService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.AuthorizationException;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.tag.TableCache;
import com.legendshop.model.entity.PayType;
import com.legendshop.util.AppUtils;
import java.util.Map;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/paytype" })
public class PayTypeAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(PayTypeAdminController.class);
@Autowired
private PayTypeService payTypeService;
@Autowired
private TableCache codeTablesCache;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, PayType payType) {
CriteriaQuery cq = new CriteriaQuery(PayType.class, curPageNO,
"javascript:pager");
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataAndOperationFunction(cq, request,
StringUtils.trim(payType.getUserName()));
cq.add();
PageSupport ps = this.payTypeService.getPayTypeList(cq);
savePage(ps, request);
request.setAttribute("bean", payType);
return PathResolver.getPath(request, BackPage.PAY_TYPE_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, PayType payType) {
String name = UserManager.getUsername(request.getSession());
if (AppUtils.isBlank(name)) {
throw new AuthorizationException("you are not logon yet!", "27");
}
payType.setUserName(name);
Map map = this.codeTablesCache.getCodeTable("PAY_TYPE");
if (AppUtils.isNotBlank(map)) {
payType.setPayTypeName((String) map.get(String.valueOf(payType
.getPayTypeId())));
}
if (AppUtils.isNotBlank(payType.getPayId())) {
return update(request, response, payType);
}
PayType origin = this.payTypeService.getPayTypeByIdAndName(
payType.getUserName(), payType.getPayTypeId());
if (AppUtils.isNotBlank(origin)) {
throw new BusinessException("你已经创建一个叫 “" + payType.getPayTypeName()
+ "” 的支付方式", "27");
}
this.payTypeService.save(payType);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"operation.successful"));
return PathResolver.getPath(request, FowardPage.PAY_TYPE_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
this.payTypeService.delete(id);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"entity.deleted"));
return PathResolver.getPath(request, FowardPage.PAY_TYPE_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
PayType payType = this.payTypeService.getPayTypeById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
payType.getUserName());
if (result != null) {
return result;
}
request.setAttribute("bean", payType);
return PathResolver.getPath(request, BackPage.PAY_TYPE_EDIT_PAGE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.PAY_TYPE_EDIT_PAGE);
}
private String update(HttpServletRequest request,
HttpServletResponse response, PayType payType) {
PayType origin = this.payTypeService.getPayTypeById(payType.getPayId());
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), origin.getUserName());
if (result != null) {
return result;
}
this.log
.info(
"{} update paytype, Partner: {}, ValidateKey: {}, SellerEmail: {} ",
new Object[] {origin.getUserName(), origin.getPartner(),
origin.getValidateKey(), origin.getSellerEmail() });
origin.setMemo(payType.getMemo());
origin.setPartner(payType.getPartner());
origin.setPayTypeId(payType.getPayTypeId());
origin.setPayTypeName(payType.getPayTypeName());
origin.setSellerEmail(payType.getSellerEmail());
origin.setValidateKey(payType.getValidateKey());
try {
this.payTypeService.update(origin);
} catch (DataIntegrityViolationException e) {
throw new BusinessException(e, "你已经创建一个叫 “"
+ payType.getPayTypeName() + "” 的支付方式");
}
return PathResolver.getPath(request, FowardPage.PAY_TYPE_LIST_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.VisitLogService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.AuthorizationException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.VisitLog;
import com.legendshop.util.AppUtils;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/visitLog" })
public class VisitLogAdminController extends BaseController
implements AdminController<VisitLog, Long> {
public static String LIST_PAGE = "/visitLog/visitLogList";
@Autowired
private VisitLogService visitLogService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, VisitLog visitLog) {
CriteriaQuery cq = new CriteriaQuery(VisitLog.class, curPageNO,
"javascript:pager");
if (CommonServiceUtil.haveViewAllDataFunction(request)) {
if (!AppUtils.isBlank(visitLog.getShopName()))
cq.like("shopName",
"%" + StringUtils.trim(visitLog.getShopName()) + "%");
} else {
String name = UserManager.getUsername(request.getSession());
if (name == null) {
throw new AuthorizationException("you are not logon yet!", "28");
}
cq.eq("shopName", name);
}
cq.ge("date", visitLog.getStartTime());
cq.le("date", visitLog.getEndTime());
cq.eq("page", visitLog.getPage());
if (AppUtils.isNotBlank(visitLog.getUserName())) {
cq.like("userName", visitLog.getUserName() + "%");
}
if (AppUtils.isNotBlank(visitLog.getProductName())) {
cq.like("productName", "%" + visitLog.getProductName() + "%");
}
if (!CommonServiceUtil.isDataForExport(cq, request)) {
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
}
if (!CommonServiceUtil.isDataSortByExternal(cq, request)) {
cq.addOrder("desc", "date");
}
cq.add();
PageSupport ps = this.visitLogService.getVisitLogList(cq);
savePage(ps, request);
request.setAttribute("bean", visitLog);
return PathResolver.getPath(request, BackPage.VLOG_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, VisitLog visitLog) {
this.visitLogService.save(visitLog);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"operation.successful"));
return PathResolver.getPath(request, FowardPage.VLOG_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
this.visitLogService.delete(id);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"entity.deleted"));
return PathResolver.getPath(request, FowardPage.VLOG_LIST_QUERY);
}
public String load(HttpServletRequest request, HttpServletResponse response) {
return null;
}
public String update(HttpServletRequest request,
HttpServletResponse response, Long id) {
return null;
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.common.page.FrontPage;
import com.legendshop.business.common.page.TilesPage;
import com.legendshop.business.form.SearchForm;
import com.legendshop.business.form.UserForm;
import com.legendshop.business.service.BusinessService;
import com.legendshop.business.service.LoginService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ConfigPropertiesEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.exception.PermissionException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.UserMessages;
import com.legendshop.model.entity.ShopDetail;
import com.legendshop.model.entity.Sub;
import com.legendshop.util.AppUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class BusinessController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(BusinessController.class);
@Autowired
private BusinessService businessService;
@Autowired
private LoginService loginService;
@RequestMapping({"/index" })
public String index(HttpServletRequest request, HttpServletResponse response) {
this.log.debug("Index starting calling");
try {
return this.businessService.getIndex(request, response);
} catch (Exception e) {
this.log.error("invoking index", e);
if (!PropertiesUtil.isSystemInstalled()) {
String version = PropertiesUtil.getProperties(
"config/global.properties",
ConfigPropertiesEnum.LEGENDSHOP_VERSION.name());
UserMessages uem = new UserMessages();
uem.setTitle("系统还没有安装成功");
uem.setDesc("System will be available until install operation is finished!");
uem.setCode("901");
uem.addCallBackList("安装系统", "LegendShop " + version, "install");
request.setAttribute(UserMessages.MESSAGE_KEY, uem);
return "redirect:install/index.jsp";
}
}
return PathResolver.getPath(request, FrontPage.FAIL);
}
@RequestMapping({"/topall" })
public String topall(HttpServletRequest request,
HttpServletResponse response) {
return PathResolver.getPath(request, FrontPage.TOPALL);
}
@RequestMapping({"/topsort" })
public String topsort(HttpServletRequest request,
HttpServletResponse response) {
return this.businessService.getTopSort(request, response);
}
@RequestMapping({"/topnews" })
public String topnews(HttpServletRequest request,
HttpServletResponse response) {
return this.businessService.getTopnews(request, response);
}
@RequestMapping({"/views/{prodId}" })
public String views(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long prodId) {
return this.businessService.getViews(request, response, prodId);
}
@RequestMapping({"/news/{newsId}" })
public String news(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long newsId) {
return this.businessService.getNews(request, response, newsId);
}
@RequestMapping({"/top" })
public String top(HttpServletRequest request, HttpServletResponse response) {
return this.businessService.getTop(request, response);
}
@RequestMapping({"/nsort/{sortId}-{nsortId}" })
public String nsort(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long sortId,
@PathVariable Long nsortId) {
if ((nsortId == null) || (sortId == null)) {
this.log.error("sortId or nsortId is null! ");
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
return this.businessService.getSecSort(request, response, sortId,
nsortId, null);
}
@RequestMapping({"/nsort" })
public String nsort(HttpServletRequest request,
HttpServletResponse response, Long sortId, Long nsortId, Long subNsortId) {
if ((nsortId == null) || (sortId == null)) {
this.log.error("sortId or nsortId is null! ");
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
return this.businessService.getSecSort(request, response, sortId,
nsortId, subNsortId);
}
@RequestMapping({"/shopcontact" })
public String shopcontact(HttpServletRequest request,
HttpServletResponse response) {
return this.businessService.getShopcontact(request, response);
}
@RequestMapping({"/orderDetail/{subNumber}" })
public String orderDetail(HttpServletRequest request,
HttpServletResponse response, @PathVariable String subNumber) {
String userName = UserManager.getUsername(request);
if (AppUtils.isBlank(userName)) {
return PathResolver.getPath(request, TilesPage.LOGIN);
}
Sub sub = this.businessService.getSubBySubNumber(subNumber);
if (sub == null) {
throw new NotFoundException("sub not found with userName: "
+ userName, "17");
}
if ((!userName.equals(sub.getUserName()))
&& (!userName.equals(sub.getShopName()))
&& (!CommonServiceUtil.haveViewAllDataFunction(request))) {
throw new PermissionException(
"can not modify others order detail!", "17");
}
return this.businessService.getOrderDetail(request, sub, userName,
subNumber);
}
@RequestMapping({"/allNews" })
public String allNews(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String newsCategory) {
return this.businessService.getAllNews(request, response, curPageNO,
newsCategory);
}
@RequestMapping({"/hotsale" })
public String hotsale(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String newsCategory) {
return this.businessService.getHotSale(request, response);
}
@RequestMapping({"/hoton" })
public String hoton(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String newsCategory) {
return this.businessService.getHotProduct(request, response);
}
@RequestMapping({"/myaccount" })
public String myaccount(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String newsCategory) {
return this.businessService.getMyAccount(request, response);
}
@RequestMapping({"/ipsearch" })
public String ipsearch(HttpServletRequest request,
HttpServletResponse response, String ipAddress) {
return this.businessService.getIpAddress(request, response, ipAddress);
}
@RequestMapping({"/leaveword" })
public String leaveword(HttpServletRequest request,
HttpServletResponse response, String ipAddress) {
return PathResolver.getPath(request, TilesPage.LEAVEWORD);
}
@RequestMapping({"/copyAll" })
public String copyAll(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String newsCategory) {
return this.businessService.getNewsforCommon(request, response);
}
@RequestMapping({"/search" })
public String search(HttpServletRequest request,
HttpServletResponse response, SearchForm searchForm) {
return this.businessService.search(request, response, searchForm);
}
@RequestMapping({"/searchall" })
public String searchall(HttpServletRequest request,
HttpServletResponse response) {
String keyword = request.getParameter("keyword");
String entityType = request.getParameter("entityType");
int type = 0;
try {
type = Integer.parseInt(entityType);
} catch (Exception e) {
}
return this.businessService.searchall(request, response, keyword,
Integer.valueOf(type));
}
@RequestMapping({"/cash" })
public String cash(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, TilesPage.PAGE_CASH);
}
@RequestMapping({"/userReg" })
public String userReg(HttpServletRequest request,
HttpServletResponse response, UserForm userForm) {
String result = this.businessService.saveUserReg(request, response,
userForm);
return result;
}
@RequestMapping({"/updateAccount" })
public String updateAccount(HttpServletRequest request,
HttpServletResponse response, UserForm userForm) {
return this.businessService.updateAccount(request, response, userForm);
}
@RequestMapping({"/login" })
public String login(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, TilesPage.LOGIN);
}
@RequestMapping({"/reg" })
public String reg(HttpServletRequest request, HttpServletResponse response) {
return this.businessService.saveUserReg(request, response);
}
@RequestMapping({"/all" })
public String all(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, FrontPage.ALL);
}
@RequestMapping({"/league" })
public String league(HttpServletRequest request,
HttpServletResponse response) {
return this.businessService.getLeague(request, response);
}
@RequestMapping({"/friendlink" })
public String friendlink(HttpServletRequest request,
HttpServletResponse response) {
return this.businessService.getFriendlink(request, response);
}
@RequestMapping({"/addShop" })
public String addShop(HttpServletRequest request,
HttpServletResponse response, ShopDetail shopDetail) {
String userName = UserManager.getUsername(request);
if (AppUtils.isBlank(userName)) {
return PathResolver.getPath(request, TilesPage.NO_LOGIN);
}
return this.businessService.saveShop(request, response, shopDetail);
}
@RequestMapping({"/hotview" })
public String hotview(HttpServletRequest request,
HttpServletResponse response) {
return this.businessService.getHotView(request, response);
}
@RequestMapping({"/userRegSuccess" })
public String userRegSuccess(HttpServletRequest request,
HttpServletResponse response, String userName, String registerCode) {
return this.businessService.updateUserReg(request, response, userName,
registerCode);
}
@RequestMapping({"/sort/{sortId}" })
public String sort(HttpServletRequest request,
HttpServletResponse response, String curPageNO,
@PathVariable Long sortId) {
return this.businessService.getSort(request, response, curPageNO,
sortId);
}
@RequestMapping({"/sort" })
public String sortById(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Long sortId) {
return this.businessService.getSort(request, response, curPageNO,
sortId);
}
@RequestMapping({"/shop/{shopName}" })
public String shop(HttpServletRequest request,
HttpServletResponse response, String curPageNO,
@PathVariable String shopName) {
request.setAttribute("shopName", shopName);
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
@RequestMapping({"/afterOperation" })
public String afterOperation(HttpServletRequest request,
HttpServletResponse response) {
return PathResolver.getPath(request, TilesPage.AFTER_OPERATION);
}
@RequestMapping({"/productGallery/{prodId}" })
public String productGallery(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long prodId)
throws Exception {
if (AppUtils.isBlank(prodId)) {
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
return this.businessService
.getProductGallery(request, response, prodId);
}
@RequestMapping({"/resetpassword" })
public String resetpassword(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return PathResolver.getPath(request, FrontPage.RESETPASSWORD);
}
@RequestMapping({"/openShop" })
public String openShop(HttpServletRequest request,
HttpServletResponse response) throws Exception {
return PathResolver.getPath(request, TilesPage.OPENSHOP);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.ExternalLinkService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.exception.PermissionException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.ExternalLink;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/admin/externallink" })
public class ExternalLinkAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(ExternalLinkAdminController.class);
@Autowired
private ExternalLinkService externalLinkService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO,
ExternalLink externalLink) {
CriteriaQuery cq = new CriteriaQuery(ExternalLink.class, curPageNO,
"javascript:pager");
cq = hasAllDataFunction(cq, request,
StringUtils.trim(externalLink.getUserName()));
if (!CommonServiceUtil.isDataForExport(cq, request)) {
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
}
if (!CommonServiceUtil.isDataSortByExternal(cq, request)) {
cq.addOrder("desc", "bs");
}
cq.add();
PageSupport ps = this.externalLinkService.getDataByCriteriaQuery(cq);
savePage(ps, request);
request.setAttribute("bean", externalLink);
return PathResolver.getPath(request, BackPage.LINK_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, ExternalLink externalLink) {
ExternalLink origin = null;
String picUrl = null;
externalLink.setUserId(UserManager.getUserId(request.getSession()));
String userName = UserManager.getUsername(request.getSession());
String subPath = userName + "/frendlink/";
externalLink.setUserName(userName);
if ((externalLink != null) && (externalLink.getId() != null)) {
origin = this.externalLinkService.getExternalLinkById(externalLink
.getId());
if (origin == null) {
throw new NotFoundException("Origin ExternalLink is NULL", "15");
}
if ((!CommonServiceUtil.haveViewAllDataFunction(request))
&& (!userName.equals(origin.getUserName()))) {
throw new PermissionException(
"Can't edit ExternalLink does not own to you!", "15");
}
String originPicUrl = origin.getPicture();
origin.setUrl(externalLink.getUrl());
origin.setWordlink(externalLink.getWordlink());
origin.setContent(externalLink.getContent());
origin.setBs(externalLink.getBs());
if ((externalLink.getFile() != null)
&& (externalLink.getFile().getSize() > 0L)) {
picUrl = FileProcessor.uploadFileAndCallback(
externalLink.getFile(), subPath, "ad" + userName);
origin.setPicture(picUrl);
String url = RealPathUtil.getBigPicRealPath() + "/"
+ originPicUrl;
FileProcessor.deleteFile(url);
}
this.externalLinkService.update(origin);
} else {
if ((externalLink.getFile() != null)
&& (externalLink.getFile().getSize() > 0L)) {
picUrl = FileProcessor.uploadFileAndCallback(
externalLink.getFile(), subPath, "ad" + userName);
externalLink.setPicture(picUrl);
}
this.log.info("{} save ExternalLink Url {} ", userName,
externalLink.getUrl());
this.externalLinkService.save(externalLink);
}
saveMessage(request,
ResourceBundleHelper.getString("operation.successful"));
return PathResolver.getPath(request, FowardPage.LINK_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
ExternalLink externalLink = this.externalLinkService
.getExternalLinkById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
externalLink.getUserName());
if (result != null) {
return result;
}
if (externalLink != null) {
this.log.info("{} delete ExternalLink Url{}",
externalLink.getUserName(), externalLink.getUrl());
this.externalLinkService.delete(id);
String picUrl = RealPathUtil.getBigPicRealPath() + "/"
+ externalLink.getPicture();
this.log.debug("delete ExternalLink Image file {}", picUrl);
FileProcessor.deleteFile(picUrl);
}
saveMessage(request, ResourceBundleHelper.getDeleteString());
return PathResolver.getPath(request, FowardPage.LINK_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
ExternalLink externalLink = this.externalLinkService
.getExternalLinkById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
externalLink.getUserName());
if (result != null) {
return result;
}
request.setAttribute("bean", externalLink);
return PathResolver.getPath(request, BackPage.LINK_EDIT_PAGE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.LINK_EDIT_PAGE);
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable ExternalLink externalLink) {
ExternalLink origin = this.externalLinkService
.getExternalLinkById(externalLink.getId());
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), origin.getUserName());
if (result != null) {
return result;
}
externalLink.setUserId(origin.getUserId());
externalLink.setUserName(origin.getUserName());
this.log.info("{} update ExternalLink Url{}", origin.getUserName(),
externalLink.getUrl());
this.externalLinkService.update(externalLink);
return PathResolver.getPath(request, FowardPage.LINK_LIST_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.BrandService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.AuthorizationException;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.Brand;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/admin/brand" })
public class BrandAdminController extends BaseController
implements AdminController<Brand, Long> {
private final Logger log = LoggerFactory
.getLogger(BrandAdminController.class);
@Autowired
private BrandService brandService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Brand brand) {
CriteriaQuery cq = new CriteriaQuery(Brand.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(brand.getUserName()));
cq.add();
PageSupport ps = this.brandService.getDataByCriteriaQuery(cq);
savePage(ps, request);
request.setAttribute("bean", brand);
return PathResolver.getPath(request, BackPage.BRAND_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Brand brand) {
Brand originbrand = null;
String brandPic = null;
String name = UserManager.getUsername(request.getSession());
String subPath = name + "/brand/";
if ((brand != null) && (brand.getBrandId() != null)) {
originbrand = this.brandService.getBrand(brand.getBrandId());
if (originbrand == null) {
throw new NotFoundException("Origin Brand is NULL", "21");
}
String originBrandPic = originbrand.getBrandPic();
if ((!CommonServiceUtil.haveViewAllDataFunction(request))
&& (!name.equals(originbrand.getUserName()))) {
throw new AuthorizationException(
"Can't edit Brand does not own to you!", "21");
}
originbrand.setMemo(brand.getMemo());
originbrand.setBrandName(brand.getBrandName());
if ((brand.getFile() != null) && (brand.getFile().getSize() > 0L)) {
brandPic = FileProcessor.uploadFileAndCallback(brand.getFile(),
subPath, "bra" + name);
originbrand.setBrandPic(brandPic);
String url = RealPathUtil.getBigPicRealPath() + "/"
+ originBrandPic;
FileProcessor.deleteFile(url);
}
this.brandService.update(originbrand);
} else {
if ((brand.getFile() != null) && (brand.getFile().getSize() > 0L)) {
brandPic = FileProcessor.uploadFileAndCallback(brand.getFile(),
subPath, "bra" + name);
brand.setBrandPic(brandPic);
}
brand.setUserId(UserManager.getUserId(request.getSession()));
brand.setUserName(UserManager.getUsername(request.getSession()));
this.brandService.save(brand);
}
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.BRAND_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Brand brand = this.brandService.getBrand(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), brand.getUserName());
if (result != null) {
return result;
}
this.log.info("{}, delete Brand Picture {}", brand.getUserName(),
brand.getBrandPic());
this.brandService.delete(id);
String url = RealPathUtil.getBigPicRealPath() + "/"
+ brand.getBrandPic();
FileProcessor.deleteFile(url);
saveMessage(request, ResourceBundleHelper.getDeleteString());
return PathResolver.getPath(request, FowardPage.BRAND_LIST_QUERY);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.BRAND_EDIT_PAGE);
}
@RequestMapping({"/update/{id}" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Brand brand = this.brandService.getBrand(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), brand.getUserName());
if (result != null) {
return result;
}
request.setAttribute("bean", brand);
return PathResolver.getPath(request, BackPage.BRAND_EDIT_PAGE);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.Constants;
import com.legendshop.business.common.page.FrontPage;
import com.legendshop.business.common.page.TilesPage;
import com.legendshop.business.form.BasketForm;
import com.legendshop.business.service.AdvertisementService;
import com.legendshop.business.service.BasketService;
import com.legendshop.business.service.OrderService;
import com.legendshop.business.service.UserDetailService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.Sub;
import com.legendshop.model.entity.UserDetail;
import com.legendshop.util.AppUtils;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class OrderController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(OrderController.class);
private final String defaultValue = "0";
@Autowired
private AdvertisementService advertisementService;
@Autowired
private OrderService orderService;
@Autowired
private BasketService basketService;
@Autowired
private UserDetailService userDetailService;
@RequestMapping({"/order" })
public String order(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Sub entity) {
String userName = UserManager.getUsername(request);
if (userName == null) {
request.setAttribute("returnUrl", PropertiesUtil.getDomainName()
+ "/order" + Constants.WEB_SUFFIX);
return PathResolver.getPath(request, TilesPage.NO_LOGIN);
}
if ((entity != null) && (entity.getSubCheck() == null)) {
entity.setSubCheck("N");
}
setOneAdvertisement(getShopName(request, response), "USER_REG_ADV_950",
request);
String subNumber = entity.getSubNumber();
if (AppUtils.isNotBlank(subNumber)) {
subNumber = subNumber.trim();
}
this.log.debug("find order userName {}, subNumber {}", userName,
subNumber);
CriteriaQuery cq = new CriteriaQuery(Sub.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.FRONT_PAGE_SIZE, Integer.class)).intValue());
cq.eq("userName", userName);
if (AppUtils.isNotBlank(subNumber)) {
cq.like("subNumber", subNumber + "%");
}
cq.eq("status", entity.getStatus());
cq.eq("subCheck", entity.getSubCheck());
cq.addOrder("desc", "subDate");
cq.add();
PageSupport ps = this.orderService.getOrderList(cq);
savePage(ps, request);
request.setAttribute("subForm", entity);
return PathResolver.getPath(request, TilesPage.ORDER);
}
@RequestMapping({"/buy" })
public String update(HttpServletRequest request,
HttpServletResponse response, BasketForm basket) {
String userName = UserManager.getUsername(request.getSession());
if (userName == null) {
request.setAttribute("returnUrl", PropertiesUtil.getDomainName()
+ "/buy" + Constants.WEB_SUFFIX);
return PathResolver.getPath(request, TilesPage.NO_LOGIN);
}
if ("buy".equals(basket.getAction())) {
String shopName = getShopName(request, response);
Integer count = basket.getCount();
if (count == null) {
count = Integer.valueOf(1);
}
this.basketService.saveToCart(basket.getProdId(), basket.getPic(),
userName, shopName, basket.getCount(),
basket.getAttribute() == null ? ""
: basket.getAttribute(), basket.getProdName(),
basket.getCash(), basket.getCarriage());
request.getSession().setAttribute("BASKET_HW_COUNT", count);
}
setOneAdvertisement(getShopName(request, response), "USER_REG_ADV_950",
request);
return PathResolver.getPath(request, TilesPage.BUY);
}
@RequestMapping({"/clear" })
public String clear(HttpServletRequest request, HttpServletResponse response) {
String userName = UserManager.getUsername(request);
if (AppUtils.isBlank(userName)) {
return PathResolver.getPath(request, TilesPage.NO_LOGIN);
}
String basketId = request.getParameter("basketId");
if (basketId == null)
this.basketService.deleteBasketByUserName(userName);
else {
try {
Long id = Long.valueOf(basketId);
this.basketService.deleteBasketById(id);
} catch (Exception e) {
e.printStackTrace();
}
}
return PathResolver.getPath(request, TilesPage.BUY);
}
@RequestMapping({"/bought" })
public String bought(HttpServletRequest request,
HttpServletResponse response) {
List baskets = this.basketService.getBasketByuserName(UserManager
.getUsername(request));
if (!AppUtils.isBlank(baskets)) {
Double totalcash = CommonServiceUtil.calculateTotalCash(baskets);
request.setAttribute("baskets", baskets);
request.setAttribute("totalcash", totalcash);
}
return PathResolver.getPath(request, FrontPage.BOUGHT);
}
@RequestMapping({"/cashsave" })
public String cashsave(HttpServletRequest request,
HttpServletResponse response) {
String total = request.getParameter("total");
if (total != null)
request.setAttribute("total", total);
else {
total = "0";
}
String userName = UserManager.getUsername(request);
if (AppUtils.isBlank(userName)) {
return PathResolver.getPath(request, TilesPage.NO_LOGIN);
}
UserDetail member = this.userDetailService.getUserDetail(userName);
if (!AppUtils.isBlank(member)) {
request.setAttribute("member", member);
}
setSessionAttribute(request, "shopName", getShopName(request, response));
return PathResolver.getPath(request, FrontPage.CASH_SAVE);
}
private void setOneAdvertisement(String shopName, String key,
HttpServletRequest request) {
List advertisement = this.advertisementService.getOneAdvertisement(
shopName, key);
if (!AppUtils.isBlank(advertisement))
request.setAttribute(key, advertisement);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.service.UserAddressService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.UserAddress;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/userAddress" })
public class UserAddressController extends BaseController
implements AdminController<UserAddress, Long> {
@Autowired
private UserAddressService userAddressService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, UserAddress userAddress) {
CriteriaQuery cq = new CriteriaQuery(UserAddress.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(userAddress.getUserName()));
cq.add();
PageSupport ps = this.userAddressService.getUserAddress(cq);
savePage(ps, request);
request.setAttribute("userAddress", userAddress);
return "/userAddress/userAddressList";
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, UserAddress userAddress) {
this.userAddressService.saveUserAddress(userAddress);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"operation.successful"));
return "forward:/admin/userAddress/query.htm";
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
UserAddress userAddress = this.userAddressService.getUserAddress(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
userAddress.getUserName());
if (result != null) {
return result;
}
this.userAddressService.deleteUserAddress(userAddress);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"entity.deleted"));
return "forward:/admin/userAddress/query.htm";
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
UserAddress userAddress = this.userAddressService.getUserAddress(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
userAddress.getUserName());
if (result != null) {
return result;
}
request.setAttribute("#entityClassInstance", userAddress);
return "/userAddress/userAddress";
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return "/userAddress/userAddress";
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
UserAddress userAddress = this.userAddressService.getUserAddress(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
userAddress.getUserName());
if (result != null) {
return result;
}
request.setAttribute("userAddress", userAddress);
return "forward:/admin/userAddress/query.htm";
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.AdvertisementService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.LimitationException;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.exception.PermissionException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.Advertisement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/admin/advertisement" })
public class AdvertisementAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(AdvertisementAdminController.class);
@Autowired
private AdvertisementService advertisementService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO,
Advertisement advertisement) {
CriteriaQuery cq = new CriteriaQuery(Advertisement.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(advertisement.getUserName()));
cq.addOrder("asc", "type");
cq.add();
PageSupport ps = this.advertisementService.getDataByCriteriaQuery(cq);
savePage(ps, request);
request.setAttribute("bean", advertisement);
return PathResolver.getPath(request, BackPage.ADV_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Advertisement advertisement) {
Advertisement origin = null;
String picUrl = null;
String name = UserManager.getUsername(request.getSession());
String subPath = name + "/advertisement/";
if ((advertisement != null) && (advertisement.getId() != null)) {
origin = this.advertisementService.getAdvertisement(advertisement
.getId());
if (origin == null) {
throw new NotFoundException("Origin Advertisement is NULL",
"25");
}
String originPicUrl = origin.getPicUrl();
if ((!CommonServiceUtil.haveViewAllDataFunction(request))
&& (!name.equals(origin.getUserName()))) {
throw new PermissionException(
"Can't edit Advertisement does not own to you!", "25");
}
origin.setLinkUrl(advertisement.getLinkUrl());
origin.setType(advertisement.getType());
origin.setSourceInput(advertisement.getSourceInput());
origin.setEnabled(advertisement.getEnabled());
origin.setTitle(advertisement.getTitle());
if (advertisement.getFile().getSize() > 0L) {
picUrl = FileProcessor.uploadFileAndCallback(
advertisement.getFile(), subPath, "adv" + name);
origin.setPicUrl(picUrl);
String url = RealPathUtil.getBigPicRealPath() + "/"
+ originPicUrl;
FileProcessor.deleteFile(url);
}
this.advertisementService.update(origin);
} else {
if (!this.advertisementService.isMaxNum(name,
advertisement.getType())) {
throw new LimitationException("您已经达到广告上限,不能再增加", "25");
}
picUrl = FileProcessor.uploadFileAndCallback(
advertisement.getFile(), subPath, "adv" + name);
advertisement.setPicUrl(picUrl);
advertisement
.setUserId(UserManager.getUserId(request.getSession()));
advertisement.setUserName(UserManager.getUsername(request
.getSession()));
this.advertisementService.save(advertisement);
}
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.ADV_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Advertisement advertisement = this.advertisementService
.getAdvertisement(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
advertisement.getUserName());
if (result != null) {
return result;
}
this.log.info("{}, delete Advertisement Url {}",
advertisement.getUserName(), advertisement.getLinkUrl());
this.advertisementService.delete(id);
String url = RealPathUtil.getBigPicRealPath() + "/"
+ advertisement.getPicUrl();
FileProcessor.deleteFile(url);
saveMessage(request, ResourceBundleHelper.getDeleteString());
return PathResolver.getPath(request, FowardPage.ADV_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Advertisement advertisement = this.advertisementService
.getAdvertisement(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()),
advertisement.getUserName());
if (result != null) {
return result;
}
request.setAttribute("bean", advertisement);
return PathResolver.getPath(request, BackPage.ADV_EDIT_PAGE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.ADV_EDIT_PAGE);
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Advertisement advertisement) {
Advertisement origin = this.advertisementService
.getAdvertisement(advertisement.getId());
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), origin.getUserName());
if (result != null) {
return result;
}
advertisement.setUserId(origin.getUserId());
advertisement.setUserName(origin.getUserName());
this.advertisementService.update(advertisement);
return PathResolver.getPath(request, FowardPage.ADV_LIST_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.service.EventService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.Event;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/event" })
public class EventController extends BaseController
implements AdminController<Event, Long> {
@Autowired
private EventService eventService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Event event) {
CriteriaQuery cq = new CriteriaQuery(Event.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(event.getUserName()));
cq.add();
PageSupport ps = this.eventService.getEvent(cq);
savePage(ps, request);
request.setAttribute("event", event);
return "/event/eventList";
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Event event) {
this.eventService.saveEvent(event);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"operation.successful"));
return "forward:/admin/event/query.htm";
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Event event = this.eventService.getEvent(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), event.getUserName());
if (result != null) {
return result;
}
this.eventService.deleteEvent(event);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"entity.deleted"));
return "forward:/admin/event/query.htm";
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Event event = this.eventService.getEvent(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), event.getUserName());
if (result != null) {
return result;
}
request.setAttribute("#entityClassInstance", event);
return "/event/event";
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return "/event/event";
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Event event = this.eventService.getEvent(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), event.getUserName());
if (result != null) {
return result;
}
request.setAttribute("event", event);
return "forward:/admin/event/query.htm";
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.IndexJpgService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.UserMessages;
import com.legendshop.model.entity.Indexjpg;
import com.legendshop.util.AppUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/admin/indexjpg" })
public class IndexJpgAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(IndexJpgAdminController.class);
@Autowired
private IndexJpgService indexJpgService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Indexjpg indexjpg) {
CriteriaQuery cq = new CriteriaQuery(Indexjpg.class, curPageNO);
if (CommonServiceUtil.haveViewAllDataFunction(request)) {
if (!AppUtils.isBlank(indexjpg.getUserName()))
cq.like("userName", "%" + indexjpg.getUserName() + "%");
} else {
cq.eq("userName", UserManager.getUsername(request));
}
if (!CommonServiceUtil.isDataForExport(cq, request)) {
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
}
if (!CommonServiceUtil.isDataSortByExternal(cq, request)) {
cq.addOrder("desc", "id");
}
cq.add();
PageSupport ps = this.indexJpgService.getIndexJpg(cq);
savePage(ps, request);
request.setAttribute("indexJpg", indexjpg);
return PathResolver.getPath(request, BackPage.IJPG_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Indexjpg indexjpg) {
String name = UserManager.getUsername(request);
Long num = this.indexJpgService.getIndexJpgNum(name);
String result = checkMaxJpgNum(request, num);
if (result != null) {
return result;
}
String subPath = name + "/indexjpg/";
String filename = null;
MultipartFile formFile = indexjpg.getFile();
try {
if (indexjpg.getId() != null) {
String orginImg = null;
Indexjpg origin = this.indexJpgService.getIndexJpgById(indexjpg
.getId());
String checkPrivilegeResult = checkPrivilege(request, name,
origin.getUserName());
if (checkPrivilegeResult != null) {
return checkPrivilegeResult;
}
if ((formFile != null) && (formFile.getSize() > 0L)) {
orginImg = RealPathUtil.getBigPicRealPath() + "/"
+ origin.getImg();
filename = FileProcessor.uploadFileAndCallback(formFile,
subPath, "" + name);
origin.setImg(filename);
}
updateIndexjpg(request, response, indexjpg, origin);
if ((formFile != null) && (formFile.getSize() > 0L)
&& (orginImg != null)) {
FileProcessor.deleteFile(orginImg);
}
} else {
indexjpg.setUserId(UserManager.getUserId(request));
indexjpg.setUserName(name);
if ((formFile != null) && (formFile.getSize() > 0L)) {
filename = FileProcessor.uploadFileAndCallback(formFile,
subPath, "" + name);
indexjpg.setImg(filename);
}
saveIndexjpg(request, response, indexjpg);
}
} catch (Exception e) {
if ((formFile != null) && (formFile.getSize() > 0L)) {
FileProcessor.deleteFile(RealPathUtil.getBigPicRealPath() + "/"
+ subPath + filename);
}
throw new BusinessException(e, "save Indexjpg error", "26", "998");
}
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.IJPG_LIST_QUERY);
}
private void saveIndexjpg(HttpServletRequest request,
HttpServletResponse response, Indexjpg indexjpg) {
this.indexJpgService.saveIndexjpg(indexjpg);
}
private void updateIndexjpg(HttpServletRequest request,
HttpServletResponse response, Indexjpg indexjpg, Indexjpg origin) {
origin.setAlt(indexjpg.getAlt());
origin.setHref(indexjpg.getHref());
origin.setId(indexjpg.getId());
origin.setLink(indexjpg.getLink());
origin.setStitle(indexjpg.getStitle());
origin.setTitle(indexjpg.getTitle());
origin.setTitleLink(indexjpg.getTitleLink());
this.indexJpgService.updateIndexjpg(origin);
}
private String checkMaxJpgNum(HttpServletRequest request, Long num) {
String result = null;
Integer maxNum = (Integer) PropertiesUtil.getObject(
ParameterEnum.MAX_INDEX_JPG, Integer.class);
if ((num != null) && (num.longValue() >= maxNum.intValue())) {
UserMessages uem = new UserMessages();
uem.setTitle("系统设置不能上传多于" + maxNum + "张图片");
uem.setCode("701");
uem.addCallBackList("重新上传", "",
PathResolver.getPath(request, BackPage.IJPG_EDIT_PAGE));
request.setAttribute(UserMessages.MESSAGE_KEY, uem);
result = handleException(request, uem);
}
return result;
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Indexjpg indexjpg = this.indexJpgService.getIndexJpgById(id);
checkNullable("indexjpg", indexjpg);
String userName = UserManager.getUsername(request);
String result = checkPrivilege(request, userName,
indexjpg.getUserName());
if (result != null) {
return result;
}
this.log.debug("{} delete indexjpg {}", userName, id);
this.indexJpgService.deleteIndexJpg(indexjpg);
FileProcessor.deleteFile(RealPathUtil.getBigPicRealPath() + "/"
+ indexjpg.getImg());
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.IJPG_LIST_QUERY);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.IJPG_EDIT_PAGE);
}
@RequestMapping({"/update/{id}" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
if (AppUtils.isBlank(id)) {
throw new BusinessException("indexjpg Id is non nullable", "405");
}
Indexjpg indexjpg = this.indexJpgService.getIndexJpgById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request), indexjpg.getUserName());
if (result != null) {
return result;
}
request.setAttribute("index", indexjpg);
return PathResolver.getPath(request, BackPage.IJPG_EDIT_PAGE);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.DynamicPropertiesHelper;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.AdminService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.model.entity.Product;
import com.legendshop.model.entity.ProductDetail;
import com.legendshop.util.AppUtils;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class XmlController extends BaseController {
private final Logger log = LoggerFactory.getLogger(XmlController.class);
@Autowired
private AdminService adminService;
@RequestMapping({"/dynamic/attribute/{prodId}" })
public String queryAttribute(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long prodId) {
ProductDetail prod = (ProductDetail) request.getAttribute("prod");
String attribute = null;
if (prod != null)
attribute = prod.getAttribute();
else {
attribute = this.adminService.getAttributeprodAttribute(prodId);
}
if (AppUtils.isNotBlank(attribute)) {
List modelList = JSONArray.fromObject(attribute);
request.setAttribute("list", modelList);
}
return PathResolver.getPath(request, BackPage.SHOW_DYNAMIC_ATTRIBUTE);
}
@RequestMapping({"/dynamic/parameter/{prodId}" })
public String queryParameter(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long prodId) {
ProductDetail prod = (ProductDetail) request.getAttribute("prod");
String parameter = null;
if (prod != null)
parameter = prod.getParameter();
else {
parameter = this.adminService.getProdParameter(prodId);
}
if (AppUtils.isNotBlank(parameter)) {
List modelList = JSONArray.fromObject(parameter);
DynamicPropertiesHelper helper = new DynamicPropertiesHelper();
request.setAttribute(
"dynamicProperties",
"<table class='goodsAttributeTable'>"
+ helper.gerenateHTML(modelList) + "</table>");
}
return PathResolver.getPath(request, BackPage.SHOW_DYNAMIC);
}
@RequestMapping({"/dynamic/save" })
public String save(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, FowardPage.DYNAMIC_QUERY);
}
@RequestMapping({"/admin/dynamic/loadAttribute/{prodId}" })
public String loadAttributeprodAttribute(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long prodId) {
String userName = UserManager.getUsername(request.getSession());
Product product = this.adminService.getProd(prodId, userName);
if (AppUtils.isNotBlank(product)) {
request.setAttribute("prod", product);
if (AppUtils.isNotBlank(product.getAttribute())) {
JSONArray jsonArray = JSONArray.fromObject(product
.getAttribute());
request.setAttribute("imgFileJSON", jsonArray);
}
}
request.setAttribute("DYNAMIC_TYPE", Integer.valueOf(1));
return PathResolver.getPath(request, BackPage.DYNAMIC_ATTRIBUTE);
}
@RequestMapping({"/admin/dynamic/loadParameter/{prodId}" })
public String loadParameter(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long prodId) {
String userName = UserManager.getUsername(request.getSession());
Product product = this.adminService.getProd(prodId, userName);
if (AppUtils.isNotBlank(product)) {
request.setAttribute("prod", product);
if (AppUtils.isNotBlank(product.getAttribute())) {
JSONArray jsonArray = JSONArray.fromObject(product
.getParameter());
request.setAttribute("imgFileJSON", jsonArray);
}
}
request.setAttribute("DYNAMIC_TYPE", Integer.valueOf(2));
return PathResolver.getPath(request, BackPage.DYNAMIC_ATTRIBUTE);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.util.AppUtils;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
@Controller
public class LocaleController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(LocaleController.class);
private final String LANGUAGE = "language";
private final String COUNTRY = "country";
private final String PAGE = "page";
@Autowired
private LocaleResolver localeResolver;
@RequestMapping({"/changeLocale" })
public String changeLocale(HttpServletRequest request,
HttpServletResponse response) {
String language = request.getParameter("language");
String country = request.getParameter("country");
Locale locale = null;
this.log.debug("language = {}, country = {}", language, country);
if ((AppUtils.isNotBlank(language)) && (AppUtils.isNotBlank(country)))
locale = new Locale(language, country);
else if (AppUtils.isNotBlank(language)) {
locale = new Locale(language, "");
}
if (locale != null) {
this.localeResolver.setLocale(request, response, locale);
}
String target = request.getParameter("page");
if (AppUtils.isNotBlank(target)) {
return PathResolver.getPath(request, target, BackPage.VARIABLE);
}
return PathResolver.getPath(request, FowardPage.INDEX_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.search.LuceneReindexer;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.search.LuceneReindexArgs;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/system/lucene" })
public class LuceneController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(LuceneController.class);
@Autowired
private LuceneReindexer luceneReindexer;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO) {
return PathResolver.getPath(request, BackPage.LUCENE_PAGE);
}
@RequestMapping({"/reindex" })
public String reindex(HttpServletRequest request,
HttpServletResponse response) {
LuceneReindexArgs args = buildReindexArgs(request);
boolean recreate = "recreate".equals(request
.getParameter("indexOperationType"));
this.log.info("reindex starting, recreate {} ",
Boolean.valueOf(recreate));
this.luceneReindexer.startBackgroundProcess(args, recreate);
this.luceneReindexer.list();
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, BackPage.LUCENE_PAGE);
}
private LuceneReindexArgs buildReindexArgs(HttpServletRequest request) {
Date fromDate = buildDateFromRequest(request, "from");
Date toDate = buildDateFromRequest(request, "to");
int firstPostId = 0;
int lastPostId = 0;
int entityType = 0;
if (!StringUtils.isEmpty(request.getParameter("firstPostId"))) {
firstPostId = Integer.valueOf(request.getParameter("firstPostId"))
.intValue();
}
if (!StringUtils.isEmpty(request.getParameter("lastPostId"))) {
lastPostId = Integer.valueOf(request.getParameter("lastPostId"))
.intValue();
}
if (!StringUtils.isEmpty(request.getParameter("entityType"))) {
entityType = Integer.valueOf(request.getParameter("entityType"))
.intValue();
}
return new LuceneReindexArgs(fromDate, toDate, firstPostId, lastPostId,
"yes".equals(request.getParameter("avoidDuplicatedRecords")),
Integer.valueOf(request.getParameter("type")).intValue(),
entityType);
}
private Date buildDateFromRequest(HttpServletRequest request, String prefix) {
String day = request.getParameter(prefix + "Day");
String month = request.getParameter(prefix + "Month");
String year = request.getParameter(prefix + "Year");
String hour = request.getParameter(prefix + "Hour");
String minutes = request.getParameter(prefix + "Minutes");
Date date = null;
if ((!StringUtils.isEmpty(day)) && (!StringUtils.isEmpty(month))
&& (!StringUtils.isEmpty(year)) && (!StringUtils.isEmpty(hour))
&& (!StringUtils.isEmpty(minutes))) {
date = new GregorianCalendar(Integer.parseInt(year),
Integer.parseInt(month) - 1, Integer.parseInt(year),
Integer.parseInt(hour), Integer.parseInt(minutes), 0).getTime();
}
return date;
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.SortService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.Sort;
import com.legendshop.util.AppUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
@Controller
@RequestMapping({"/admin/sort" })
public class SortAdminController extends BaseController
implements AdminController<Sort, Long> {
private final Logger log = LoggerFactory
.getLogger(SortAdminController.class);
@Autowired
private SortService sortService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Sort sort) {
CriteriaQuery cq = new CriteriaQuery(Sort.class, curPageNO);
if (AppUtils.isNotBlank(sort.getSortName())) {
cq.like("sortName", "%" + sort.getSortName() + "%");
}
hasAllDataFunction(cq, request, "userName", sort.getUserName());
if (!CommonServiceUtil.isDataForExport(cq, request)) {
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
}
if (!CommonServiceUtil.isDataSortByExternal(cq, request)) {
cq.addOrder("asc", "seq");
}
cq.add();
PageSupport ps = this.sortService.getSortList(cq);
savePage(ps, request);
request.setAttribute("sort", sort);
return PathResolver.getPath(request, BackPage.SORT_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Sort entity) {
MultipartFile formFile = entity.getFile();
String userName = UserManager.getUsername(request);
String subPath = userName + "/sort/";
String filename = null;
try {
if (entity.getSortId() != null) {
String orginPicture = null;
Sort origin = this.sortService.getSortById(entity.getSortId());
if ((formFile != null) && (formFile.getSize() > 0L)) {
orginPicture = RealPathUtil.getBigPicRealPath() + "/"
+ origin.getPicture();
filename = FileProcessor.uploadFileAndCallback(formFile,
subPath, "" + userName);
origin.setPicture(filename);
}
updateSort(request, response, entity, origin);
if ((formFile != null) && (formFile.getSize() > 0L)) {
FileProcessor.deleteFile(orginPicture);
FileProcessor.deleteFile(orginPicture);
}
} else {
entity.setUserId(UserManager.getUserId(request));
entity.setUserName(userName);
if ((formFile != null) && (formFile.getSize() > 0L)) {
filename = FileProcessor.uploadFileAndCallback(formFile,
subPath, "" + userName);
entity.setPicture(filename);
}
saveSort(request, response, entity);
}
} catch (Exception e) {
if ((formFile != null) && (formFile.getSize() > 0L)) {
FileProcessor.deleteFile(RealPathUtil.getBigPicRealPath() + "/"
+ subPath + filename);
}
throw new BusinessException(e, "save sort error", "20", "998");
}
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.SORT_LIST_QUERY);
}
private void saveSort(HttpServletRequest request,
HttpServletResponse response, Sort entity) {
this.sortService.save(entity);
}
private void updateSort(HttpServletRequest request,
HttpServletResponse response, Sort entity, Sort origin) {
origin.setSeq(entity.getSeq());
origin.setSortName(entity.getSortName());
this.sortService.updateSort(origin);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Sort sort = this.sortService.getSortById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), sort.getUserName());
if (result != null) {
return result;
}
this.log.info("{} delete SortName {}", new Object[] {
sort.getUserName(), sort.getSortName() });
this.sortService.delete(sort);
FileProcessor.deleteFile(RealPathUtil.getBigPicRealPath() + "/"
+ sort.getPicture());
saveMessage(request, ResourceBundleHelper.getDeleteString());
return PathResolver.getPath(request, FowardPage.SORT_LIST_QUERY);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.SORT_EDIT_PAGE);
}
@RequestMapping({"/update/{id}" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
checkNullable("sortId", id);
Sort sort = this.sortService.getSortById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request), sort.getUserName());
if (result != null) {
return result;
}
request.setAttribute("sort", sort);
return PathResolver.getPath(request, BackPage.SORT_EDIT_PAGE);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.service.PaymentService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.util.AppUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/payment" })
public class PaymentController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(PaymentController.class);
@Autowired
private PaymentService paymentService;
@RequestMapping({"/payto" })
public String payment(HttpServletRequest request,
HttpServletResponse response) {
String userName = UserManager.getUsername(request.getSession());
if (AppUtils.isBlank(userName)) {
throw new RuntimeException("not logined yet!");
}
String shopName = request.getParameter("shopName");
checkNull("shopName", shopName);
String payTypeId = request.getParameter("payTypeId");
checkNull("payTypeId", payTypeId);
String out_trade_no = request.getParameter("subNumber");
checkNull("out_trade_no", out_trade_no);
String subject = request.getParameter("aliorder");
String body = request.getParameter("alibody");
String price = request.getParameter("alimoney");
checkNull("price", price);
String payment_result = this.paymentService.payto(shopName, userName,
Integer.valueOf(payTypeId), out_trade_no, subject, body, price,
request.getRemoteAddr());
this.log.debug("payment result = {}", payment_result);
request.setAttribute("payment_result", payment_result);
return PathResolver.getPath(request, BackPage.PAY_PAGE);
}
private void checkNull(String name, String value) {
if (AppUtils.isBlank(value))
throw new BusinessException(name + " can no be null", "405");
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.event.EventId;
import com.legendshop.business.service.BusinessService;
import com.legendshop.business.service.IndexService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.event.EventContext;
import com.legendshop.event.EventHome;
import com.legendshop.event.GenericEvent;
import com.legendshop.model.UserInfo;
import com.legendshop.model.entity.ShopDetailView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class IndexAdminController extends BaseController {
public String ADMIN_MENU = "/frame/menu";
private final Logger log = LoggerFactory
.getLogger(IndexAdminController.class);
@Autowired
private IndexService indexService;
@Autowired
private BusinessService businessService;
@RequestMapping({"/admin/dashboard" })
public String load(HttpServletRequest request, HttpServletResponse response) {
this.log.debug("adminIndex starting");
String userName = UserManager.getUsername(request.getSession());
ShopDetailView shopDetail = this.businessService
.getSimpleInfoShopDetail(userName);
UserInfo userInfo = this.indexService.getAdminIndex(userName,
shopDetail);
request.setAttribute("userInfo", userInfo);
EventContext eventContext = new EventContext(request);
EventHome.publishEvent(new GenericEvent(eventContext,
EventId.LICENSE_UPGRADE_CHECK_EVENT));
if ((eventContext.getBooleanResponse().booleanValue())
&& (CommonServiceUtil.haveViewAllDataFunction(request))) {
request.setAttribute("needUpgrade", Boolean.valueOf(true));
}
return PathResolver.getPath(request, BackPage.DASH_BOARD);
}
@RequestMapping({"/admin/index" })
public String home(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.ADMIN_HOME);
}
@RequestMapping({"/admin/menu/{id}" })
public String menu(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
String path = this.ADMIN_MENU;
if ((id != null) && (id.longValue() != 0L)) {
path = this.ADMIN_MENU + id;
}
return PathResolver.getPath(request, path, BackPage.VARIABLE);
}
@RequestMapping({"/admin/top" })
public String top(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.ADMIN_TOP);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.service.OrderService;
import com.legendshop.business.service.timer.SubService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.PermissionException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.Sub;
import com.legendshop.util.AppUtils;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/order" })
public class OrderAdminController extends BaseController
implements AdminController<Sub, Long> {
private final Logger log = LoggerFactory
.getLogger(OrderAdminController.class);
public static String LIST_PAGE = "/order/orderList";
public static String EDIT_PAGE = "/order/order";
public static String LIST_QUERY = "/admin/order/query";
@Autowired
private OrderService orderService;
@Autowired
private SubService subService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Sub entity) {
String loginName = UserManager.getUsername(request);
String subNumber = entity.getSubNumber();
if ((entity != null) && (entity.getSubCheck() == null)) {
entity.setSubCheck("N");
}
if (!AppUtils.isBlank(subNumber)) {
subNumber = subNumber.trim();
}
CriteriaQuery cq = new CriteriaQuery(Sub.class, curPageNO);
if (CommonServiceUtil.haveViewAllDataFunction(request)) {
if (!AppUtils.isBlank(entity.getShopName()))
cq.eq("shopName", entity.getShopName());
} else {
cq.eq("shopName", loginName);
}
if (AppUtils.isNotBlank(subNumber)) {
cq.like("subNumber", subNumber + "%");
}
if (AppUtils.isNotBlank(entity.getUserName())) {
cq.like("userName", entity.getUserName() + "%");
}
cq.eq("status", entity.getStatus());
cq.eq("subCheck", entity.getSubCheck());
if (!CommonServiceUtil.isDataForExport(cq, request)) {
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.FRONT_PAGE_SIZE, Integer.class)).intValue());
}
if (!CommonServiceUtil.isDataSortByExternal(cq, request)) {
cq.addOrder("desc", "subDate");
}
cq.add();
PageSupport ps = this.orderService.getOrderList(cq);
savePage(ps, request);
request.setAttribute("subForm", entity);
return PathResolver.getPath(request, BackPage.ORDER_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Sub entity) {
return null;
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, Long id) {
return null;
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return null;
}
@RequestMapping({"/loadBySubnumber/{subNumber}" })
public String loadBySubNember(HttpServletRequest request,
HttpServletResponse response, @PathVariable String subNumber) {
List baskets = this.subService.getBasketBySubNumber(subNumber);
if (!AppUtils.isBlank(baskets)) {
Double totalcash = CommonServiceUtil.calculateTotalCash(baskets);
Sub sub = this.subService.getSubBySubNumber(subNumber);
String loginName = UserManager.getUsername(request);
if ((!CommonServiceUtil.haveViewAllDataFunction(request))
&& (!sub.getShopName().equals(loginName))) {
throw new PermissionException(loginName
+ " cann't view Sub id is " + sub.getSubId(), "17");
}
request.setAttribute("sub", sub);
request.setAttribute("baskets", baskets);
request.setAttribute("totalcash", totalcash);
}
return PathResolver.getPath(request, BackPage.ORDERDETAIL);
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
HttpServletResponse response, Long id) {
return null;
}
@RequestMapping({"/modifyPrice" })
public String modifyPrice(HttpServletRequest request,
HttpServletResponse response, Long id) {
return PathResolver.getPath(request, BackPage.MODIFYPRICE);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.NewsService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.News;
import com.legendshop.util.AppUtils;
import com.legendshop.util.CodeFilter;
import com.legendshop.util.sql.ConfigCode;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/news" })
public class NewsAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(NewsAdminController.class);
public static String LIST_PAGE = "/news/newsList";
public static String EDIT_PAGE = "/news/news";
public static String LIST_QUERY = "/admin/news/query";
@Autowired
private NewsService newsService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, News news) {
String userName = UserManager.getUsername(request.getSession());
Map map = new HashMap();
HqlQuery hql = new HqlQuery(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue(), curPageNO);
if (!CommonServiceUtil.haveViewAllDataFunction(request)) {
map.put("userName", userName);
hql.addParams(userName);
} else if (AppUtils.isNotBlank(news.getUserName())) {
map.put("userName", news.getUserName());
hql.addParams(news.getUserName());
}
if (!AppUtils.isBlank(news.getNewsCategoryId())) {
map.put("newsCategoryId", String.valueOf(news.getNewsCategoryId()));
hql.addParams(news.getNewsCategoryId());
}
if (!AppUtils.isBlank(news.getSortId())) {
map.put("sortId", String.valueOf(news.getSortId()));
hql.addParams(news.getSortId());
}
if (!AppUtils.isBlank(news.getNewsTitle())) {
map.put("newsTitle", news.getNewsTitle());
hql.addParams("%" + news.getNewsTitle() + "%");
}
if (!AppUtils.isBlank(news.getStatus())) {
map.put("status", String.valueOf(news.getStatus()));
hql.addParams(news.getStatus());
}
if (!CommonServiceUtil.isDataForExport(hql, request)) {
hql.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
}
if (!CommonServiceUtil.isDataSortByExternal(hql, request, map)) {
map.put("orderIndicator", "order by n.newsDate desc");
}
String QueryNsortCount = ConfigCode.getInstance().getCode(
"biz.QueryNewsCount", map);
String QueryNsort = ConfigCode.getInstance().getCode("biz.QueryNews",
map);
hql.setAllCountString(QueryNsortCount);
hql.setQueryString(QueryNsort);
PageSupport ps = this.newsService.getNewsList(hql);
savePage(ps, request);
request.setAttribute("bean", news);
return PathResolver.getPath(request, BackPage.NEWS_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, News news) {
if (news.getNewsId() != null) {
return update(request, response, news);
}
news.setNewsDate(new Date());
news.setUserId(UserManager.getUserId(request.getSession()));
news.setUserName(UserManager.getUsername(request.getSession()));
this.newsService.save(news);
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.NEWS_LIST_QUERY);
}
private void setNewsBrief(News news) {
String newsContent = news.getNewsContent();
if ((newsContent != null) && (newsContent.length() > 0)) {
Integer len = Integer.valueOf(newsContent.length());
int maxLength = 100;
boolean max = len.intValue() > maxLength;
if (max)
news.setNewsBrief(CodeFilter.unHtml(news.getNewsContent()
.substring(0, maxLength)) + "...");
else
news.setNewsBrief(CodeFilter.unHtml(newsContent));
}
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
News news = this.newsService.getNewsById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), news.getUserName());
if (result != null) {
return result;
}
this.log.info("{},delete News Title{}", news.getUserName(),
news.getNewsTitle());
this.newsService.delete(id);
saveMessage(request, ResourceBundleHelper.getDeleteString());
return PathResolver.getPath(request, FowardPage.NEWS_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
News news = this.newsService.getNewsById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), news.getUserName());
if (result != null) {
return result;
}
request.setAttribute("news", news);
return PathResolver.getPath(request, BackPage.NEWS_EDIT_PAGE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.NEWS_EDIT_PAGE);
}
public String update(HttpServletRequest request,
HttpServletResponse response, News news) {
News origin = this.newsService.getNewsById(news.getNewsId());
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), origin.getUserName());
if (result != null) {
return result;
}
this.log.info("{} update News Title{}", origin.getUserName(),
origin.getNewsTitle());
news.setUserId(origin.getUserId());
news.setUserName(origin.getUserName());
this.newsService.update(news);
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.NEWS_LIST_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.common.CommonServiceUtil;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.service.LogoService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.NotFoundException;
import com.legendshop.core.exception.PermissionException;
import com.legendshop.core.helper.FileProcessor;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.helper.RealPathUtil;
import com.legendshop.core.helper.ResourceBundleHelper;
import com.legendshop.model.entity.Logo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@Controller
@RequestMapping({"/admin/logo" })
public class LogoAdminController extends BaseController {
private final Logger log = LoggerFactory
.getLogger(LogoAdminController.class);
@Autowired
private LogoService logoService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Logo logo) {
CriteriaQuery cq = new CriteriaQuery(Logo.class, curPageNO,
"javascript:pager");
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(logo.getUserName()));
cq.add();
PageSupport ps = this.logoService.getLogoList(cq);
savePage(ps, request);
request.setAttribute("bean", logo);
return PathResolver.getPath(request, BackPage.LOGO_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(MultipartHttpServletRequest request,
HttpServletResponse response, Logo logo) {
Logo originLogo = null;
String banner = null;
String name = UserManager.getUsername(request.getSession());
String subPath = name + "/logo/";
if ((logo != null) && (logo.getId() != null)) {
originLogo = this.logoService.getLogoById(logo.getId());
if (originLogo == null) {
throw new NotFoundException("Origin Logo is NULL", "22");
}
String originBanner = originLogo.getBanner();
if ((!CommonServiceUtil.haveViewAllDataFunction(request))
&& (!name.equals(originLogo.getUserName()))) {
throw new PermissionException(name
+ " can't edit Logo does not own to you!", "22");
}
originLogo.setUrl(logo.getUrl());
originLogo.setMemo(logo.getMemo());
if (logo.getFile().getSize() > 0L) {
banner = FileProcessor.uploadFileAndCallback(logo.getFile(),
subPath, "lo" + name);
originLogo.setBanner(banner);
String url = RealPathUtil.getBigPicRealPath() + "/"
+ originBanner;
FileProcessor.deleteFile(url);
}
this.logoService.update(originLogo);
} else {
banner = FileProcessor.uploadFileAndCallback(logo.getFile(),
subPath, "lo" + name);
logo.setBanner(banner);
logo.setUserId(UserManager.getUserId(request.getSession()));
logo.setUserName(UserManager.getUsername(request.getSession()));
this.logoService.save(logo);
}
saveMessage(request, ResourceBundleHelper.getSucessfulString());
return PathResolver.getPath(request, FowardPage.LOGO_LIST_QUERY);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Logo logo = this.logoService.getLogoById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), logo.getUserName());
if (result != null) {
return result;
}
this.log.info("{}, delete Logo Url {}", logo.getUserName(),
logo.getUrl());
this.logoService.delete(id);
String url = RealPathUtil.getBigPicRealPath() + "/" + logo.getBanner();
FileProcessor.deleteFile(url);
saveMessage(request, ResourceBundleHelper.getDeleteString());
return PathResolver.getPath(request, FowardPage.LOGO_LIST_QUERY);
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Logo logo = this.logoService.getLogoById(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), logo.getUserName());
if (result != null) {
return result;
}
request.setAttribute("bean", logo);
return PathResolver.getPath(request, BackPage.LOGO_EDIT_PAGE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.LOGO_EDIT_PAGE);
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Logo logo) {
Logo origin = this.logoService.getLogoById(logo.getId());
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), origin.getUserName());
if (result != null) {
return result;
}
logo.setUserId(origin.getUserId());
logo.setUserName(origin.getUserName());
this.logoService.update(logo);
return PathResolver.getPath(request, FowardPage.LOGO_LIST_QUERY);
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.service.CashService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.Cash;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/cash" })
public class CashController extends BaseController
implements AdminController<Cash, Long> {
@Autowired
private CashService cashService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Cash cash) {
CriteriaQuery cq = new CriteriaQuery(Cash.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(cash.getUserName()));
cq.add();
PageSupport ps = this.cashService.getCash(cq);
savePage(ps, request);
request.setAttribute("cash", cash);
return "/cash/cashList";
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Cash cash) {
this.cashService.saveCash(cash);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"operation.successful"));
return "forward:/admin/cash/query.htm";
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Cash cash = this.cashService.getCash(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), cash.getUserName());
if (result != null) {
return result;
}
this.cashService.deleteCash(cash);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"entity.deleted"));
return "forward:/admin/cash/query.htm";
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Cash cash = this.cashService.getCash(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), cash.getUserName());
if (result != null) {
return result;
}
request.setAttribute("#entityClassInstance", cash);
return "/cash/cash";
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return "/cash/cash";
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Cash cash = this.cashService.getCash(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), cash.getUserName());
if (result != null) {
return result;
}
request.setAttribute("cash", cash);
return "forward:/admin/cash/query.htm";
}
}
| Java |
package com.legendshop.business.controller;
import com.legendshop.business.service.AskService;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.Ask;
import java.util.ResourceBundle;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/admin/ask" })
public class AskController extends BaseController
implements AdminController<Ask, Long> {
@Autowired
private AskService askService;
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Ask ask) {
CriteriaQuery cq = new CriteriaQuery(Ask.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
cq = hasAllDataFunction(cq, request,
StringUtils.trim(ask.getUserName()));
cq.add();
PageSupport ps = this.askService.getAsk(cq);
savePage(ps, request);
request.setAttribute("ask", ask);
return "/ask/askList";
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Ask ask) {
this.askService.saveAsk(ask);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"operation.successful"));
return "forward:/admin/ask/query.htm";
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Ask ask = this.askService.getAsk(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), ask.getUserName());
if (result != null) {
return result;
}
this.askService.deleteAsk(ask);
saveMessage(
request,
ResourceBundle.getBundle("i18n/ApplicationResources").getString(
"entity.deleted"));
return "forward:/admin/ask/query.htm";
}
@RequestMapping({"/load/{id}" })
public String load(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Ask ask = this.askService.getAsk(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), ask.getUserName());
if (result != null) {
return result;
}
request.setAttribute("#entityClassInstance", ask);
return "/ask/ask";
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return "/ask/ask";
}
@RequestMapping({"/update" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable Long id) {
Ask ask = this.askService.getAsk(id);
String result = checkPrivilege(request,
UserManager.getUsername(request.getSession()), ask.getUserName());
if (result != null) {
return result;
}
request.setAttribute("ask", ask);
return "forward:/admin/ask/query.htm";
}
}
| Java |
package com.legendshop.business.newservice;
import com.legendshop.business.service.ValidateCodeUsernamePasswordAuthenticationFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
public class LoginServiceImpl
extends ValidateCodeUsernamePasswordAuthenticationFilter {
Logger log = LoggerFactory.getLogger(LoginServiceImpl.class);
public Authentication onAuthentication(HttpServletRequest request,
HttpServletResponse response, String username, String password) {
this.log.debug("userName {} register and login", username);
return super.onAuthentication(request, response, username, password);
}
}
| Java |
package com.legendshop.business.form;
import com.legendshop.model.entity.ShopDetail;
import java.util.Date;
public class UserForm {
private static final long serialVersionUID = -4363234793127853507L;
private String userId;
private String name;
private String password;
private String passwordOld;
private String enabled = "1";
private String note;
private Integer gradeId;
private String userName;
private String nickName;
private String userMail;
private String userAdds;
private String userTel;
private String userPostcode;
private String msn;
private String qq;
private String fax;
private Date modifyTime;
private Date userRegtime;
private String userRegip;
private Date userLasttime;
private String userLastip;
private String userMemo;
private String sex;
private String birthDate;
private String userMobile;
private String userBirthYear;
private String userBirthMonth;
private String userBirthDay;
private ShopDetail shopDetail = new ShopDetail();
public String getEnabled() {
return this.enabled;
}
public void setEnabled(String enabled) {
this.enabled = enabled;
}
public String getFax() {
return this.fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public Integer getGradeId() {
return this.gradeId;
}
public void setGradeId(Integer gradeId) {
this.gradeId = gradeId;
}
public Date getModifyTime() {
return this.modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getMsn() {
return this.msn;
}
public void setMsn(String msn) {
this.msn = msn;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getNickName() {
return this.nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getNote() {
return this.note;
}
public void setNote(String note) {
this.note = note;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public String getQq() {
return this.qq;
}
public void setQq(String qq) {
this.qq = qq;
}
public ShopDetail getShopDetail() {
return this.shopDetail;
}
public void setShopDetail(ShopDetail shopDetail) {
this.shopDetail = shopDetail;
}
public String getUserAdds() {
return this.userAdds;
}
public void setUserAdds(String userAdds) {
this.userAdds = userAdds;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserLastip() {
return this.userLastip;
}
public void setUserLastip(String userLastip) {
this.userLastip = userLastip;
}
public Date getUserLasttime() {
return this.userLasttime;
}
public void setUserLasttime(Date userLasttime) {
this.userLasttime = userLasttime;
}
public String getUserMail() {
return this.userMail;
}
public void setUserMail(String userMail) {
this.userMail = userMail;
}
public String getUserMemo() {
return this.userMemo;
}
public void setUserMemo(String userMemo) {
this.userMemo = userMemo;
}
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPostcode() {
return this.userPostcode;
}
public void setUserPostcode(String userPostcode) {
this.userPostcode = userPostcode;
}
public String getUserRegip() {
return this.userRegip;
}
public void setUserRegip(String userRegip) {
this.userRegip = userRegip;
}
public Date getUserRegtime() {
return this.userRegtime;
}
public void setUserRegtime(Date userRegtime) {
this.userRegtime = userRegtime;
}
public String getUserTel() {
return this.userTel;
}
public void setUserTel(String userTel) {
this.userTel = userTel;
}
public String getPasswordOld() {
return this.passwordOld;
}
public void setPasswordOld(String passwordOld) {
this.passwordOld = passwordOld;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getBirthDate() {
return this.birthDate;
}
public void setBirthDate(String birthDate) {
this.birthDate = birthDate;
}
public String getUserBirthYear() {
return this.userBirthYear;
}
public void setUserBirthYear(String userBirthYear) {
this.userBirthYear = userBirthYear;
}
public String getUserBirthMonth() {
return this.userBirthMonth;
}
public void setUserBirthMonth(String userBirthMonth) {
this.userBirthMonth = userBirthMonth;
}
public String getUserBirthDay() {
return this.userBirthDay;
}
public void setUserBirthDay(String userBirthDay) {
this.userBirthDay = userBirthDay;
}
public String getUserMobile() {
return this.userMobile;
}
public void setUserMobile(String userMobile) {
this.userMobile = userMobile;
}
}
| Java |
package com.legendshop.business.form;
import java.util.Date;
public class BasketForm {
private static final long serialVersionUID = 5076753905519824021L;
private Integer count;
private String action;
private Double carriage;
private String attribute;
private Long basketId;
private Long prodId;
private String pic;
private String userName;
private Integer basketCount;
private Date basketDate;
private String basketCheck;
private String prodName;
private Double cash;
private String subNumber;
private String daili;
public BasketForm() {
}
public BasketForm(Long basketId) {
this.basketId = basketId;
}
public Long getBasketId() {
return this.basketId;
}
public void setBasketId(Long basketId) {
this.basketId = basketId;
}
public Long getProdId() {
return this.prodId;
}
public void setProdId(Long hwId) {
this.prodId = hwId;
}
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getBasketCount() {
return this.basketCount;
}
public void setBasketCount(Integer basketCount) {
this.basketCount = basketCount;
}
public Date getBasketDate() {
return this.basketDate;
}
public void setBasketDate(Date basketDate) {
this.basketDate = basketDate;
}
public String getBasketCheck() {
return this.basketCheck;
}
public void setBasketCheck(String basketCheck) {
this.basketCheck = basketCheck;
}
public String getProdName() {
return this.prodName;
}
public void setProdName(String hwName) {
this.prodName = hwName;
}
public Double getCash() {
return this.cash;
}
public void setCash(Double hwCash) {
this.cash = hwCash;
}
public String getSubNumber() {
return this.subNumber;
}
public void setSubNumber(String subNumber) {
this.subNumber = subNumber;
}
public String getDaili() {
return this.daili;
}
public void setDaili(String daili) {
this.daili = daili;
}
public String getAction() {
return this.action;
}
public void setAction(String action) {
this.action = action;
}
public Integer getCount() {
return this.count;
}
public void setCount(Integer count) {
this.count = count;
}
public Double getCarriage() {
return this.carriage;
}
public void setCarriage(Double carriage) {
this.carriage = carriage;
}
public String getAttribute() {
return this.attribute;
}
public void setAttribute(String attribute) {
this.attribute = attribute;
}
public String getPic() {
return this.pic;
}
public void setPic(String hwPic) {
this.pic = hwPic;
}
}
| Java |
package com.legendshop.business.form;
public class SubForm {
private static final long serialVersionUID = 2769000419985544497L;
private String userName;
private String shopName;
private String subNumber;
private Integer status;
private String subCheck = "N";
private String curPageNO = "1";
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getShopName() {
return this.shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getSubNumber() {
return this.subNumber;
}
public void setSubNumber(String subNumber) {
this.subNumber = subNumber;
}
public Integer getStatus() {
return this.status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getSubCheck() {
return this.subCheck;
}
public void setSubCheck(String subCheck) {
this.subCheck = subCheck;
}
public String getCurPageNO() {
return this.curPageNO;
}
public void setCurPageNO(String curPageNO) {
this.curPageNO = curPageNO;
}
}
| Java |
package com.legendshop.business.form;
import java.util.Date;
public class MemberForm {
private static final long serialVersionUID = -3445526260441415877L;
private Double total;
private Long payType;
private String basketId;
private String other;
private Integer userId;
private String userName;
private String orderName;
private String userPass;
private String userMail;
private String userAdds;
private String payTypeName;
private String userTel;
private Date userRegtime;
private String userRegip;
private Date userLasttime;
private String userLastip;
private String userBuymoney;
private String userPostcode;
private String userNamec;
private String userType;
public String getUserAdds() {
return this.userAdds;
}
public void setUserAdds(String userAdds) {
this.userAdds = userAdds;
}
public String getUserBuymoney() {
return this.userBuymoney;
}
public void setUserBuymoney(String userBuymoney) {
this.userBuymoney = userBuymoney;
}
public Integer getUserId() {
return this.userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserLastip() {
return this.userLastip;
}
public void setUserLastip(String userLastip) {
this.userLastip = userLastip;
}
public Date getUserLasttime() {
return this.userLasttime;
}
public void setUserLasttime(Date userLasttime) {
this.userLasttime = userLasttime;
}
public String getUserMail() {
return this.userMail;
}
public void setUserMail(String userMail) {
this.userMail = userMail;
}
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserNamec() {
return this.userNamec;
}
public void setUserNamec(String userNamec) {
this.userNamec = userNamec;
}
public String getUserPass() {
return this.userPass;
}
public void setUserPass(String userPass) {
this.userPass = userPass;
}
public String getUserPostcode() {
return this.userPostcode;
}
public void setUserPostcode(String userPostcode) {
this.userPostcode = userPostcode;
}
public String getUserRegip() {
return this.userRegip;
}
public void setUserRegip(String userRegip) {
this.userRegip = userRegip;
}
public Date getUserRegtime() {
return this.userRegtime;
}
public void setUserRegtime(Date userRegtime) {
this.userRegtime = userRegtime;
}
public String getUserTel() {
return this.userTel;
}
public void setUserTel(String userTel) {
this.userTel = userTel;
}
public String getUserType() {
return this.userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public Long getPayType() {
return this.payType;
}
public void setPayType(Long payType) {
this.payType = payType;
}
public String getOther() {
return this.other;
}
public void setOther(String other) {
this.other = other;
}
public String getBasketId() {
return this.basketId;
}
public void setBasketId(String basketId) {
this.basketId = basketId;
}
public String getOrderName() {
return this.orderName;
}
public void setOrderName(String orderName) {
this.orderName = orderName;
}
public Double getTotal() {
return this.total;
}
public void setTotal(Double total) {
this.total = total;
}
public String getPayTypeName() {
return this.payTypeName;
}
public void setPayTypeName(String payTypeName) {
this.payTypeName = payTypeName;
}
}
| Java |
package com.legendshop.business.form;
public class SearchForm {
private static final long serialVersionUID = 2489827230218323847L;
private String curPageNOTop = "1";
private String keyword;
private Long sortId;
public String getCurPageNOTop() {
return this.curPageNOTop;
}
public void setCurPageNOTop(String curPageNOTop) {
this.curPageNOTop = curPageNOTop;
}
public String getKeyword() {
return this.keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public Long getSortId() {
return this.sortId;
}
public void setSortId(Long sortId) {
this.sortId = sortId;
}
}
| Java |
package com.legendshop.business.event.impl;
import com.legendshop.business.event.EventId;
import com.legendshop.event.SystemEvent;
public class UserRegEvent extends SystemEvent<String> {
public UserRegEvent(String source) {
super(source, EventId.USER_REG_EVENT);
}
}
| Java |
package com.legendshop.business.event.impl;
import com.legendshop.business.event.EventId;
import com.legendshop.event.SystemEvent;
public class SendMailEvent extends SystemEvent<String> {
public SendMailEvent(String source) {
super(source, EventId.SEND_MAIL_EVENT);
}
}
| Java |
package com.legendshop.business.event;
import com.legendshop.event.BaseEventId;
public enum EventId implements BaseEventId {
USER_REG_EVENT("USER_REG"), SEND_MAIL_EVENT("SEND_MAIL"), SEND_SMS_EVENT(
"SEND_SMS"), ORDER_CHANGE_EVENT("ORDER_CHANGE"), SHOP_CHANGE_EVENT(
"SHOP_CHANGE"), PROD_CHANGE_EVENT("PROD_CHANGE"),
LICENSE_STATUS_CHECK_EVENT("LICENSE_STATUS_CHECK"),
LICENSE_UPGRADE_CHECK_EVENT("LICENSE_UPGRADE_CHECK"),
FUNCTION_CHECK_EVENT("FUNCTION_CHECK"),
CAN_ADD_SHOPDETAIL_EVENT("CAN_ADD_SHOPDETAIL");
private final String value;
public String getEventId() {
return this.value;
}
private EventId(String value) {
this.value = value;
}
public boolean instance(String name) {
EventId[] eventIds = values();
for (EventId eventId : eventIds) {
if (eventId.name().equals(name)) {
return true;
}
}
return false;
}
}
| Java |
package com.legendshop.business.event.listener;
import com.legendshop.event.processor.ThreadProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SendMailProcessor extends ThreadProcessor<String> {
private final Logger log = LoggerFactory.getLogger(SendMailProcessor.class);
public boolean isSupport(String task) {
this.log.info("SendMailProcessor isSupport calling, task= " + task);
return true;
}
public void process(String task) {
this.log.info("SendMailProcessor process calling, task= " + task);
}
}
| Java |
package com.legendshop.business.event.listener;
import com.legendshop.event.processor.BaseProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class UserRegProcessor extends BaseProcessor<String> {
private final Logger log = LoggerFactory.getLogger(UserRegProcessor.class);
public boolean isSupport(String task) {
this.log.info("UserRegProcessor isSupport calling, task= " + task);
return true;
}
public void process(String task) {
this.log.info("UserRegProcessor process calling, task= " + task);
}
}
| Java |
package com.legendshop.business;
import com.legendshop.business.service.SystemParameterService;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.core.plugins.Plugin;
import com.legendshop.core.plugins.PluginConfig;
import com.legendshop.core.tag.TableCache;
import com.legendshop.search.SearchFacade;
import javax.servlet.ServletContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BusinessPlugin implements Plugin {
private static Logger log = LoggerFactory
.getLogger(BusinessPlugin.class);
private SystemParameterService systemParameterService;
private TableCache codeTablesCache;
private SearchFacade searchFacade;
private PluginConfig pluginConfig;
public void bind(ServletContext servletContext) {
this.systemParameterService.initSystemParameter();
this.codeTablesCache.initCodeTablesCache();
String luceneIndexPath = PropertiesUtil.getLucenePath();
log.info("luceneIndexPath is {}", luceneIndexPath);
this.searchFacade.init(luceneIndexPath);
}
public void unbind(ServletContext servletContext) {
}
public PluginConfig getPluginConfig() {
return this.pluginConfig;
}
public void setSystemParameterService(
SystemParameterService systemParameterServiceImpl) {
this.systemParameterService = systemParameterServiceImpl;
}
public void setCodeTablesCache(TableCache codeTablesCache) {
this.codeTablesCache = codeTablesCache;
}
public void setSearchFacade(SearchFacade searchFacade) {
this.searchFacade = searchFacade;
}
public void setPluginConfig(PluginConfig pluginConfig) {
this.pluginConfig = pluginConfig;
}
}
| Java |
package com.legendshop.business.permission.controller;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.helper.FunctionChecker;
import com.legendshop.business.helper.StateChecker;
import com.legendshop.business.permission.form.FunctionForm;
import com.legendshop.business.permission.form.PermissionForm;
import com.legendshop.business.permission.form.RoleForm;
import com.legendshop.business.permission.service.RightDelegate;
import com.legendshop.command.framework.State;
import com.legendshop.command.framework.StateImpl;
import com.legendshop.core.AttributeKeys;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.Function;
import com.legendshop.model.entity.Permission;
import com.legendshop.model.entity.PerssionId;
import com.legendshop.model.entity.Role;
import com.legendshop.util.AppUtils;
import com.legendshop.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/member/right" })
public class FunctionController extends BaseController
implements AdminController<Function, String> {
private final Logger log = LoggerFactory
.getLogger(FunctionController.class);
@Autowired
private RightDelegate rightDelegate;
@Autowired
private FunctionChecker functionChecker;
@Autowired
private StateChecker stateChecker;
@RequestMapping({"/deleteFunctionById" })
public String deleteFunctionById(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String roleId,
FunctionForm functionForm) {
String id = request.getParameter("id");
this.logger.info("Struts Action deleteFunctionById with id " + id);
State state = new StateImpl();
boolean result = this.rightDelegate.deleteFunctionById(id, state);
this.logger.debug("deleteFunctionById result = " + result);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FUNCTION_LIST_QUERY);
}
@RequestMapping({"/findFunctionById" })
public String findFunctionById(HttpServletRequest request,
HttpServletResponse response, String id) {
this.logger.info("Struts Action findFunctionById with id " + id);
State state = new StateImpl();
Function function = this.rightDelegate.findFunctionById(id, state);
this.stateChecker.check(state, request);
request.setAttribute("function", function);
return PathResolver.getPath(request, BackPage.UPDATE_FUNCTION);
}
@RequestMapping({"/findFunctionByRole" })
public String findFunctionByRole(HttpServletRequest request,
HttpServletResponse response, String roleId) {
this.logger
.info("Struts FunctionAction findFunctionByRole with roleId "
+ roleId);
State state = new StateImpl();
Role role = this.rightDelegate.findRoleById(roleId, state);
List list = this.rightDelegate.findFunctionByRoleId(roleId, state);
this.stateChecker.check(state, request);
request.setAttribute("list", list);
request.setAttribute("role", role);
return PathResolver.getPath(request, FowardPage.FIND_FUNCTION_BY_ROLE);
}
@RequestMapping({"/findOtherFunctionByHql" })
public String findOtherFunctionByHql(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String roleId) {
String myAction = "findOtherFunctionByHql" + AttributeKeys.WEB_SUFFIX;
if (roleId != null) {
myAction = "findOtherFunctionByHql.do?roleId=" + roleId;
}
HqlQuery hq = new HqlQuery(myAction);
hq.setCurPage(curPageNO);
hq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
State state = new StateImpl();
Role role = this.rightDelegate.findRoleById(roleId, state);
PageSupport ps = this.rightDelegate.findOtherFunctionByHql(hq, roleId,
state);
this.stateChecker.check(state, request);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("offset", new Integer(ps.getOffset() + 1));
if (ps.hasMutilPage())
request.setAttribute("toolBar", ps.getToolBar());
request.setAttribute("functionList", ps.getResultList());
request.setAttribute("role", role);
return PathResolver.getPath(request, BackPage.FIND_OTHER_FUNCTION_LIST);
}
@RequestMapping({"/listFunction" })
public String listFunction(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String roleId,
FunctionForm functionForm) {
String userName = UserManager.getUsername(request);
if (userName == null) {
throw new BusinessException("not login yet", "998");
}
this.functionChecker.check(userName, request);
String myaction = "listFunction" + AttributeKeys.WEB_SUFFIX;
String search = request.getParameter("search");
if (search == null)
search = "";
else {
myaction = myaction + "?search=" + search;
}
CriteriaQuery cq = new CriteriaQuery(Function.class, curPageNO,
myaction);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
if (!AppUtils.isBlank(search)) {
cq.like("name", "%" + search + "%");
cq.add();
}
State state = new StateImpl();
PageSupport ps = this.rightDelegate.findAllFunction(cq, state);
request.setAttribute("search", search);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("offset", new Integer(ps.getOffset() + 1));
request.setAttribute("list", ps.getResultList());
if (ps.hasMutilPage()) {
request.setAttribute("toolBar", ps.getToolBar());
}
return PathResolver.getPath(request, BackPage.FUNCTION_LIST);
}
@RequestMapping({"/saveFunction" })
public String saveFunction(HttpServletRequest request,
HttpServletResponse response, FunctionForm functionForm) {
State state = new StateImpl();
String id = this.rightDelegate.saveFunction(functionForm.getFunction(),
state);
this.logger.info("success saveFunction,id = " + id);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FUNCTION_LIST_QUERY);
}
@RequestMapping({"/saveFunctionsToRoleList" })
public String saveFunctionsToRoleList(HttpServletRequest request,
HttpServletResponse response, String roleId,
PermissionForm permissionForm) {
List permissions = new ArrayList();
String[] strArray = permissionForm.getStrArray();
for (int i = 0; i < strArray.length; i++) {
Permission permission = new Permission();
PerssionId perssionId = new PerssionId();
perssionId.setRoleId(roleId);
perssionId.setFunctionId(strArray[i]);
permission.setId(perssionId);
permissions.add(permission);
}
State state = new StateImpl();
this.rightDelegate.saveFunctionsToRole(permissions, state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FIND_FUNCTION_BY_ROLE);
}
@RequestMapping({"/updateFunctionById" })
public String updateFunctionById(HttpServletRequest request,
HttpServletResponse response, FunctionForm functionForm) {
this.logger.debug("Struts FunctionAction updateFunctionById");
State state = new StateImpl();
this.rightDelegate.updateFunction(functionForm.getFunction(), state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FUNCTION_LIST_QUERY);
}
@RequestMapping({"/deletePermissionByRoleId" })
public String deletePermissionByRoleId(HttpServletRequest request,
HttpServletResponse response, String curPageNO, String roleId,
FunctionForm functionForm) {
this.log.info("Action deletePermissionByRoleId with roleId {}", roleId);
List permissions = new ArrayList();
String[] strArray = functionForm.getStrArray();
for (int i = 0; i < strArray.length; i++) {
Permission permission = new Permission();
PerssionId perssionId = new PerssionId();
perssionId.setRoleId(roleId);
perssionId.setFunctionId(strArray[i]);
permission.setId(perssionId);
permissions.add(permission);
}
State state = new StateImpl();
this.rightDelegate.deleteFunctionsFromRole(permissions, state);
this.stateChecker.check(state, request);
request.setAttribute("roleId", roleId);
return PathResolver.getPath(request, FowardPage.FIND_FUNCTION_BY_ROLE);
}
@RequestMapping({"/findRoleById" })
public String findRoleById(HttpServletRequest request,
HttpServletResponse response, String id) {
this.logger.info("Action findRoleById with id " + id);
State state = new StateImpl();
Role role = this.rightDelegate.findRoleById(id, state);
this.stateChecker.check(state, request);
request.setAttribute("role", role);
return PathResolver.getPath(request, FowardPage.FIND_ALL_ROLE);
}
@RequestMapping({"/deleteRoleById" })
public String deleteRoleById(HttpServletRequest request,
HttpServletResponse response, String id) {
this.logger.info("Struts Action deleteRoleById with id " + id);
State state = new StateImpl();
this.rightDelegate.deleteRoleById(id, state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FIND_ALL_ROLE);
}
@RequestMapping({"/findAllRole" })
public String findAllRole(HttpServletRequest request,
HttpServletResponse response) {
String userName = UserManager.getUsername(request);
if (userName == null) {
throw new BusinessException("not login yet", "998");
}
this.functionChecker.check(userName, request);
String curPageNO = request.getParameter("curPageNO");
String search = request.getParameter("search");
String action = "findAllRole" + AttributeKeys.WEB_SUFFIX;
String myaction;
if (search == null) {
search = "";
myaction = action;
} else {
myaction = action + "?search=" + search;
}
CriteriaQuery cq = new CriteriaQuery(Role.class, curPageNO, myaction);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
if (!AppUtils.isBlank(search)) {
cq.like("name", "%" + search + "%");
cq.add();
}
State state = new StateImpl();
PageSupport ps = this.rightDelegate.findAllRole(cq, state);
request.setAttribute("search", search);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("offset", new Integer(ps.getOffset() + 1));
request.setAttribute("list", ps.getResultList());
if (ps.hasMutilPage()) {
request.setAttribute("toolBar", ps.getToolBar());
}
return PathResolver.getPath(request, BackPage.ROLE_LIST);
}
@RequestMapping({"/findRoleByFunction" })
public String findRoleByFunction(HttpServletRequest request,
HttpServletResponse response, String functionId) {
this.logger.info("Struts Action findRoleByFunction with function id "
+ functionId);
State state = new StateImpl();
Function function = this.rightDelegate.findFunctionById(functionId,
state);
List list = this.rightDelegate.findRoleByFunction(functionId, state);
this.stateChecker.check(state, request);
request.setAttribute("list", list);
request.setAttribute("function", function);
return PathResolver.getPath(request, BackPage.FIND_ROLE_BY_FUNCTION);
}
@RequestMapping({"/saveRole" })
public String saveRole(HttpServletRequest request,
HttpServletResponse response, RoleForm roleForm) {
State state = new StateImpl();
String id = this.rightDelegate.saveRole(roleForm.getRole(), state);
this.logger.info("success saveRole,id = " + id);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FIND_ALL_ROLE);
}
@RequestMapping({"/updateRoleById" })
public String updateRoleById(HttpServletRequest request,
HttpServletResponse response, RoleForm roleForm) {
this.logger.info("Struts Action updateRoleById");
State state = new StateImpl();
this.rightDelegate.updateRole(roleForm.getRole(), state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FIND_ALL_ROLE);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger.info("Struts Action deleteFunctionById with id " + id);
State state = new StateImpl();
boolean result = this.rightDelegate.deleteFunctionById(id, state);
this.logger.debug("deleteFunctionById result = " + result);
if (!result) {
this.stateChecker.check(state, request);
}
return PathResolver.getPath(request, FowardPage.FUNCTION_LIST_QUERY);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse arg1) {
return PathResolver.getPath(request, BackPage.UPDATE_FUNCTION);
}
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Function function) {
String userName = UserManager.getUsername(request);
if (userName == null) {
throw new BusinessException("not login yet", "998");
}
this.functionChecker.check(userName, request);
CriteriaQuery cq = new CriteriaQuery(Function.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
String name = function.getName();
if (!AppUtils.isBlank(name)) {
cq.like("name", "%" + name + "%");
cq.add();
}
State state = new StateImpl();
PageSupport ps = this.rightDelegate.findAllFunction(cq, state);
request.setAttribute("bean", function);
savePage(ps, request);
return PathResolver.getPath(request, BackPage.FUNCTION_LIST);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Function function) {
State state = new StateImpl();
String id = function.getId();
if (StringUtil.isEmpty(id))
id = this.rightDelegate.saveFunction(function, state);
else {
this.rightDelegate.updateFunction(function, state);
}
this.logger.info("success saveFunction,id = " + id);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FUNCTION_LIST_QUERY);
}
@RequestMapping({"/update/{id}" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger.info("Struts Action findFunctionById with id " + id);
State state = new StateImpl();
Function function = this.rightDelegate.findFunctionById(id, state);
this.stateChecker.check(state, request);
request.setAttribute("bean", function);
return PathResolver.getPath(request, BackPage.UPDATE_FUNCTION);
}
@RequestMapping({"/roles/{id}" })
public String roles(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger.info("Struts Action findRoleByFunction with function id "
+ id);
State state = new StateImpl();
Function function = this.rightDelegate.findFunctionById(id, state);
List list = this.rightDelegate.findRoleByFunction(id, state);
this.stateChecker.check(state, request);
request.setAttribute("list", list);
request.setAttribute("bean", function);
return PathResolver.getPath(request, BackPage.FIND_ROLE_BY_FUNCTION);
}
}
| Java |
package com.legendshop.business.permission.controller;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.common.page.FrontPage;
import com.legendshop.business.helper.FunctionChecker;
import com.legendshop.business.helper.StateChecker;
import com.legendshop.business.permission.form.UserRoleForm;
import com.legendshop.business.permission.form.UsersForm;
import com.legendshop.business.permission.service.RightDelegate;
import com.legendshop.command.framework.State;
import com.legendshop.command.framework.StateImpl;
import com.legendshop.core.AttributeKeys;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.User;
import com.legendshop.model.entity.UserRole;
import com.legendshop.model.entity.UserRoleId;
import com.legendshop.util.AppUtils;
import com.legendshop.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/member/user" })
public class UserController extends BaseController
implements AdminController<User, String> {
private final Logger log = LoggerFactory.getLogger(UserController.class);
@Autowired
private RightDelegate rightDelegate;
@Autowired
private FunctionChecker functionChecker;
@Autowired
private StateChecker stateChecker;
@RequestMapping({"/deleteUserRoleByUserId" })
public String deleteUserRoleByUserId(HttpServletRequest request,
HttpServletResponse response, UserRoleForm userRoleForm) {
String userId = request.getParameter("userId");
this.logger
.info("Action deleteUserRoleByUserId with userId " + userId);
List userRoles = new ArrayList();
String[] strArray = userRoleForm.getStrArray();
for (String element : strArray) {
UserRole userRole = new UserRole();
UserRoleId userRoleId = new UserRoleId();
userRoleId.setUserId(userId);
userRoleId.setRoleId(element);
userRole.setId(userRoleId);
userRoles.add(userRole);
}
State state = new StateImpl();
this.rightDelegate.deleteRoleFromUser(userRoles, state);
this.stateChecker.check(state, request);
request.setAttribute("userId", userId);
return PathResolver.getPath(request, FowardPage.FIND_ROLE_BY_USER);
}
@RequestMapping({"/saveUser" })
public String saveUser(HttpServletRequest request,
HttpServletResponse response, UsersForm usersForm) {
State state = new StateImpl();
User user = usersForm.getUser();
if (this.rightDelegate.isUserExist(user.getName(), state)) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
String id = this.rightDelegate.saveUser(Md5Password(user), state);
this.logger.info("success saveUser,id = " + id);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.USERS_LIST);
}
private User Md5Password(User user) {
Md5PasswordEncoder coder = new Md5PasswordEncoder();
coder.setEncodeHashAsBase64(false);
if (user.getPassword() != null) {
user.setPassword(coder.encodePassword(user.getPassword(),
user.getName()));
return user;
}
return user;
}
@RequestMapping({"/updateUserStatus" })
public String updateUserStatus(HttpServletRequest request,
HttpServletResponse response, UsersForm usersForm) {
this.logger.debug("Struts UserAction updateUserStatus");
User user = usersForm.getUser();
String enabled = user.getEnabled();
String userId = user.getId();
State state = new StateImpl();
User olduser = this.rightDelegate.findUserById(userId, state);
olduser.setEnabled(enabled);
olduser.setNote(user.getNote());
this.rightDelegate.updateUser(olduser, state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.USERS_LIST);
}
@RequestMapping({"/preupdateStatus" })
public String preupdateStatus(HttpServletRequest request,
HttpServletResponse response) {
String id = request.getParameter("id");
this.logger.info("Action preupdateStatus with id " + id);
State state = new StateImpl();
User user = this.rightDelegate.findUserById(id, state);
this.stateChecker.check(state, request);
request.setAttribute("user", user);
return PathResolver.getPath(request, BackPage.UPDATE_USER_STATUS);
}
@RequestMapping({"/updateUserPassowrd" })
public String updateUserPassowrd(HttpServletRequest request,
HttpServletResponse response, UsersForm usersForm) {
this.logger.info("Struts UserAction updateUserById");
User user = usersForm.getUser();
String passwordag = user.getPasswordag();
if ((user.getPassword() == null) || (user.getPassword() == "")) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
if (!passwordag.endsWith(user.getPassword())) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
State state = new StateImpl();
Md5PasswordEncoder coder = new Md5PasswordEncoder();
coder.setEncodeHashAsBase64(false);
this.rightDelegate.updateUserPassowrd(user.getId(),
coder.encodePassword(user.getPassword(), user.getName()), state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.USERS_LIST);
}
@RequestMapping({"/findUserById" })
public String findUserById(HttpServletRequest request,
HttpServletResponse response) {
String id = request.getParameter("id");
this.logger.info("Action findUserById with id " + id);
State state = new StateImpl();
User user = this.rightDelegate.findUserById(id, state);
this.stateChecker.check(state, request);
request.setAttribute("user", user);
return PathResolver.getPath(request, BackPage.UPDATE_USER_PASSWORD);
}
@RequestMapping({"/saveRoleToUser" })
public String saveRoleToUser(HttpServletRequest request,
HttpServletResponse response, UsersForm usersForm) {
String userId = request.getParameter("userId");
List userRoles = new ArrayList();
String[] strArray = usersForm.getStrArray();
for (String element : strArray) {
UserRole userRole = new UserRole();
UserRoleId userRoleId = new UserRoleId();
userRoleId.setRoleId(element);
userRoleId.setUserId(userId);
userRole.setId(userRoleId);
userRoles.add(userRole);
}
State state = new StateImpl();
this.rightDelegate.saveRolesToUser(userRoles, state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FIND_USER_ROLES);
}
@RequestMapping({"/findOtherRoleByUser" })
public String findOtherRoleByUser(HttpServletRequest request,
HttpServletResponse response) {
String curPageNO = request.getParameter("curPageNO");
String userId = request.getParameter("userId");
String myAction = "findOtherRoleByUser" + AttributeKeys.WEB_SUFFIX;
if (userId != null) {
myAction = myAction + "?userId=" + userId;
}
HqlQuery hq = new HqlQuery(myAction);
hq.setCurPage(curPageNO);
hq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
State state = new StateImpl();
User user = this.rightDelegate.findUserById(userId, state);
PageSupport ps = this.rightDelegate.findOtherRoleByUser(hq, userId,
state);
this.stateChecker.check(state, request);
request.setAttribute("curPageNO", new Integer(ps.getCurPageNO()));
request.setAttribute("offset", new Integer(ps.getOffset() + 1));
if (ps.hasMutilPage()) {
request.setAttribute("toolBar", ps.getToolBar());
}
request.setAttribute("roles", ps.getResultList());
request.setAttribute("user", user);
return PathResolver.getPath(request, BackPage.FIND_OTHER_ROLE_BY_USER);
}
@RequestMapping({"/findFunctionByUser" })
public String findFunctionByUser(HttpServletRequest request,
HttpServletResponse response) {
String userId = request.getParameter("userId");
this.logger.info("UserAction findFunctionByUser : " + userId);
State state = new StateImpl();
User user = this.rightDelegate.findUserById(userId, state);
List functions = this.rightDelegate.findFunctionByUser(userId, state);
this.stateChecker.check(state, request);
request.setAttribute("functions", functions);
request.setAttribute("user", user);
return PathResolver.getPath(request, BackPage.FIND_FUNCTION_BY_USER);
}
@RequestMapping({"/usersList" })
public String usersList(HttpServletRequest request,
HttpServletResponse response, String curPageNO) {
String userName = UserManager.getUsername(request);
if (userName == null) {
throw new BusinessException("not login yet", "998");
}
this.functionChecker.check(userName, request);
String search = request.getParameter("search") == null ? ""
: request.getParameter("search");
String enabled = request.getParameter("enabled") == null ? ""
: request.getParameter("enabled");
CriteriaQuery cq = new CriteriaQuery(User.class, curPageNO);
cq.setPageSize(1);
if (AppUtils.isNotBlank(search)) {
cq.like("name", search + "%");
}
if (AppUtils.isNotBlank(enabled)) {
cq.eq("enabled", enabled);
}
cq.add();
State state = new StateImpl();
PageSupport ps = this.rightDelegate.findAllUser(cq, state);
request.setAttribute("search", search);
request.setAttribute("enabled", enabled);
savePage(ps, request);
return PathResolver.getPath(request, BackPage.USER_LIST_PAGE);
}
@RequestMapping({"/findRoleByUser" })
public String findRoleByUser(HttpServletRequest request,
HttpServletResponse response) {
String userId = request.getParameter("userId");
this.logger.info("UserAction findOtherRoleByUser : " + userId);
State state = new StateImpl();
User user = this.rightDelegate.findUserById(userId, state);
List roles = this.rightDelegate.findRoleByUser(userId, state);
this.stateChecker.check(state, request);
request.setAttribute("roles", roles);
request.setAttribute("user", user);
return PathResolver.getPath(request, BackPage.FIND_ROLE_BY_USER_PAGE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.MODIFY_USER);
}
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
return null;
}
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, User user) {
String userName = UserManager.getUsername(request);
if (userName == null) {
throw new BusinessException("not login yet", "704");
}
this.functionChecker.check(userName, request);
String name = user.getName();
String enabled = user.getEnabled();
CriteriaQuery cq = new CriteriaQuery(User.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
if (AppUtils.isNotBlank(name)) {
cq.like("name", name + "%");
}
if (AppUtils.isNotBlank(enabled)) {
cq.eq("enabled", enabled);
}
cq.add();
State state = new StateImpl();
PageSupport ps = this.rightDelegate.findAllUser(cq, state);
request.setAttribute("bean", user);
savePage(ps, request);
return PathResolver.getPath(request, BackPage.USER_LIST_PAGE);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, User user) {
State state = new StateImpl();
if (this.rightDelegate.isUserExist(user.getName(), state)) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
String id = user.getId();
if (StringUtil.isEmpty(id))
id = this.rightDelegate.saveUser(Md5Password(user), state);
else {
this.rightDelegate.updateUser(Md5Password(user), state);
}
this.logger.info("success saveUser,id = " + id);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.USERS_LIST);
}
@RequestMapping({"/updatePassword" })
public String updatePassword(HttpServletRequest request,
HttpServletResponse response, User user) {
this.logger.info("Struts UserAction updateUserById");
String passwordag = user.getPasswordag();
if ((user.getPassword() == null) || (user.getPassword() == "")) {
return PathResolver.getPath(request, FrontPage.ERROR_PAGE);
}
if (!passwordag.endsWith(user.getPassword())) {
return PathResolver.getPath(request, FrontPage.FAIL);
}
State state = new StateImpl();
Md5PasswordEncoder coder = new Md5PasswordEncoder();
coder.setEncodeHashAsBase64(false);
this.rightDelegate.updateUserPassowrd(user.getId(),
coder.encodePassword(user.getPassword(), user.getName()), state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.USERS_LIST);
}
@RequestMapping({"/update/{id}" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger.info("Action findUserById with id " + id);
State state = new StateImpl();
User user = this.rightDelegate.findUserById(id, state);
this.stateChecker.check(state, request);
request.setAttribute("bean", user);
return PathResolver.getPath(request, BackPage.UPDATE_USER_PASSWORD);
}
@RequestMapping({"/roles/{id}" })
public String roles(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger.info("UserAction findOtherRoleByUser : " + id);
State state = new StateImpl();
User user = this.rightDelegate.findUserById(id, state);
List roles = this.rightDelegate.findRoleByUser(id, state);
this.stateChecker.check(state, request);
request.setAttribute("list", roles);
request.setAttribute("bean", user);
return PathResolver.getPath(request, BackPage.FIND_ROLE_BY_USER_PAGE);
}
@RequestMapping({"/otherRoles/{id}" })
public String otherRoles(HttpServletRequest request,
HttpServletResponse response, String curPageNO, @PathVariable String id) {
HqlQuery hq = new HqlQuery();
hq.setCurPage(curPageNO);
hq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
State state = new StateImpl();
User user = this.rightDelegate.findUserById(id, state);
PageSupport ps = this.rightDelegate.findOtherRoleByUser(hq, id, state);
this.stateChecker.check(state, request);
savePage(ps, request);
request.setAttribute("bean", user);
return PathResolver.getPath(request, BackPage.FIND_OTHER_ROLE_BY_USER);
}
@RequestMapping({"/deleteRoles/{id}" })
public String deleteRoles(HttpServletRequest request,
HttpServletResponse response, String[] strArray, @PathVariable String id) {
this.logger.info("Action deleteUserRoleByUserId with userId " + id);
List userRoles = new ArrayList();
for (String element : strArray) {
UserRole userRole = new UserRole();
UserRoleId userRoleId = new UserRoleId();
userRoleId.setUserId(id);
userRoleId.setRoleId(element);
userRole.setId(userRoleId);
userRoles.add(userRole);
}
State state = new StateImpl();
this.rightDelegate.deleteRoleFromUser(userRoles, state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FIND_ROLE_BY_USER);
}
@RequestMapping({"/functions/{id}" })
public String functions(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger.info("UserAction findFunctionByUser : " + id);
State state = new StateImpl();
User user = this.rightDelegate.findUserById(id, state);
List functions = this.rightDelegate.findFunctionByUser(id, state);
this.stateChecker.check(state, request);
request.setAttribute("list", functions);
request.setAttribute("bean", user);
return PathResolver.getPath(request, BackPage.FIND_FUNCTION_BY_USER);
}
}
| Java |
package com.legendshop.business.permission.controller;
import com.legendshop.business.common.page.BackPage;
import com.legendshop.business.common.page.FowardPage;
import com.legendshop.business.helper.FunctionChecker;
import com.legendshop.business.helper.StateChecker;
import com.legendshop.business.permission.form.FunctionForm;
import com.legendshop.business.permission.form.PermissionForm;
import com.legendshop.business.permission.service.RightDelegate;
import com.legendshop.command.framework.State;
import com.legendshop.command.framework.StateImpl;
import com.legendshop.core.UserManager;
import com.legendshop.core.base.AdminController;
import com.legendshop.core.base.BaseController;
import com.legendshop.core.constant.ParameterEnum;
import com.legendshop.core.constant.PathResolver;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.BusinessException;
import com.legendshop.core.helper.PropertiesUtil;
import com.legendshop.model.entity.Permission;
import com.legendshop.model.entity.PerssionId;
import com.legendshop.model.entity.Role;
import com.legendshop.util.AppUtils;
import com.legendshop.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping({"/member/role" })
public class RoleController extends BaseController
implements AdminController<Role, String> {
private final Logger log = LoggerFactory.getLogger(RoleController.class);
@Autowired
private RightDelegate rightDelegate;
@Autowired
private FunctionChecker functionChecker;
@Autowired
private StateChecker stateChecker;
@RequestMapping({"/delete/{id}" })
public String delete(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger.info("Struts Action deleteRoleById with id " + id);
State state = new StateImpl();
this.rightDelegate.deleteRoleById(id, state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.ALL_ROLE);
}
@RequestMapping({"/load" })
public String load(HttpServletRequest request, HttpServletResponse response) {
return PathResolver.getPath(request, BackPage.SAVE_ROLE);
}
@RequestMapping({"/query" })
public String query(HttpServletRequest request,
HttpServletResponse response, String curPageNO, Role role) {
String userName = UserManager.getUsername(request);
if (userName == null) {
throw new BusinessException("not login yet", "998");
}
this.functionChecker.check(userName, request);
CriteriaQuery cq = new CriteriaQuery(Role.class, curPageNO);
cq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
String name = role.getName();
String enabled = role.getEnabled();
if (!AppUtils.isBlank(name)) {
cq.like("name", "%" + name + "%");
}
if (AppUtils.isNotBlank(enabled)) {
cq.eq("enabled", enabled);
}
cq.add();
State state = new StateImpl();
PageSupport ps = this.rightDelegate.findAllRole(cq, state);
request.setAttribute("bean", role);
savePage(ps, request);
return PathResolver.getPath(request, BackPage.ROLE_LIST);
}
@RequestMapping({"/save" })
public String save(HttpServletRequest request,
HttpServletResponse response, Role role) {
State state = new StateImpl();
String id = role.getId();
if (StringUtil.isEmpty(id))
id = this.rightDelegate.saveRole(role, state);
else {
this.rightDelegate.updateRole(role, state);
}
this.logger.info("success saveRole,id = " + id);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.ALL_ROLE);
}
@RequestMapping({"/update/{id}" })
public String update(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger.info("Action update with id " + id);
State state = new StateImpl();
Role role = this.rightDelegate.findRoleById(id, state);
this.stateChecker.check(state, request);
request.setAttribute("bean", role);
return PathResolver.getPath(request, BackPage.SAVE_ROLE);
}
@RequestMapping({"/functions/{id}" })
public String functions(HttpServletRequest request,
HttpServletResponse response, @PathVariable String id) {
this.logger
.info("Struts FunctionAction findFunctionByRole with roleId " + id);
State state = new StateImpl();
Role role = this.rightDelegate.findRoleById(id, state);
List list = this.rightDelegate.findFunctionByRoleId(id, state);
this.stateChecker.check(state, request);
request.setAttribute("list", list);
request.setAttribute("bean", role);
return PathResolver.getPath(request, BackPage.ROLE_FUNCTION);
}
@RequestMapping({"/otherFunctions/{id}" })
public String otherFunctions(HttpServletRequest request,
HttpServletResponse response, String curPageNO, @PathVariable String id) {
HqlQuery hq = new HqlQuery();
hq.setCurPage(curPageNO);
hq.setPageSize(((Integer) PropertiesUtil.getObject(
ParameterEnum.PAGE_SIZE, Integer.class)).intValue());
State state = new StateImpl();
Role role = this.rightDelegate.findRoleById(id, state);
PageSupport ps = this.rightDelegate.findOtherFunctionByHql(hq, id,
state);
this.stateChecker.check(state, request);
savePage(ps, request);
request.setAttribute("bean", role);
return PathResolver.getPath(request, BackPage.FIND_OTHER_FUNCTION_LIST);
}
@RequestMapping({"/saveFunctionsToRole" })
public String saveFunctionsToRole(HttpServletRequest request,
HttpServletResponse response, String roleId,
PermissionForm permissionForm) {
List permissions = new ArrayList();
String[] strArray = permissionForm.getStrArray();
for (int i = 0; i < strArray.length; i++) {
Permission permission = new Permission();
PerssionId perssionId = new PerssionId();
perssionId.setRoleId(roleId);
perssionId.setFunctionId(strArray[i]);
permission.setId(perssionId);
permissions.add(permission);
}
State state = new StateImpl();
this.rightDelegate.saveFunctionsToRole(permissions, state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FIND_FUNCTION_BY_ROLE);
}
@RequestMapping({"/deletePermissionByRoleId" })
public String deletePermissionByRoleId(HttpServletRequest request,
HttpServletResponse response, String roleId, FunctionForm functionForm) {
this.log.info("Action deletePermissionByRoleId with roleId {}", roleId);
List permissions = new ArrayList();
String[] strArray = functionForm.getStrArray();
for (int i = 0; i < strArray.length; i++) {
Permission permission = new Permission();
PerssionId perssionId = new PerssionId();
perssionId.setRoleId(roleId);
perssionId.setFunctionId(strArray[i]);
permission.setId(perssionId);
permissions.add(permission);
}
State state = new StateImpl();
this.rightDelegate.deleteFunctionsFromRole(permissions, state);
this.stateChecker.check(state, request);
return PathResolver.getPath(request, FowardPage.FIND_FUNCTION_BY_ROLE);
}
}
| Java |
package com.legendshop.business.permission.form;
public abstract class BaseValidatorForm {
private String myaction = "";
private int curPageNO = 1;
private String[] strArray = new String[0];
public int getCurPageNO() {
return this.curPageNO;
}
public void setCurPageNO(int curPageNO) {
this.curPageNO = curPageNO;
}
public String[] getStrArray() {
return this.strArray;
}
public void setStrArray(String[] strArray) {
this.strArray = strArray;
}
public String getMyaction() {
return this.myaction;
}
public void setMyaction(String myaction) {
this.myaction = myaction;
}
}
| Java |
package com.legendshop.business.permission.form;
import com.legendshop.model.entity.User;
public class UsersForm extends BaseValidatorForm {
private static final long serialVersionUID = -840523994012455010L;
public User user = new User();
public User getUser() {
return this.user;
}
public void setUser(User user) {
this.user = user;
}
}
| Java |
package com.legendshop.business.permission.form;
public class UserRoleForm extends BaseValidatorForm {
private static final long serialVersionUID = -4714759651188550306L;
private String roleId;
private String userId;
public String getRoleId() {
return this.roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
}
| Java |
package com.legendshop.business.permission.form;
import com.legendshop.model.entity.Role;
public class RoleForm extends BaseValidatorForm {
private static final long serialVersionUID = -7431172360957927548L;
public Role role = new Role();
public Role getRole() {
return this.role;
}
public void setRole(Role role) {
this.role = role;
}
}
| Java |
package com.legendshop.business.permission.form;
public class PermissionForm extends BaseValidatorForm {
private static final long serialVersionUID = -6137922551383167345L;
private String roleId;
private String functionId;
public String getFunctionId() {
return this.functionId;
}
public void setFunctionId(String functionId) {
this.functionId = functionId;
}
public String getRoleId() {
return this.roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
}
| Java |
package com.legendshop.business.permission.form;
import com.legendshop.model.entity.Function;
public class FunctionForm extends BaseValidatorForm {
private static final long serialVersionUID = 7048928553222685963L;
public Function function = new Function();
public Function getFunction() {
return this.function;
}
public void setFunction(Function function) {
this.function = function;
}
}
| Java |
package com.legendshop.business.permission.service.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import com.legendshop.business.permission.service.RightDelegate;
import com.legendshop.command.framework.JCFException;
import com.legendshop.command.framework.Request;
import com.legendshop.command.framework.Response;
import com.legendshop.command.framework.State;
import com.legendshop.command.framework.facade.AbstractBizDelegate;
import com.legendshop.command.framework.facade.DelegateUtil;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.ClientException;
import com.legendshop.model.entity.Function;
import com.legendshop.model.entity.LoginHistory;
import com.legendshop.model.entity.Permission;
import com.legendshop.model.entity.Role;
import com.legendshop.model.entity.User;
import com.legendshop.model.entity.UserRole;
import com.legendshop.util.AppUtils;
public class RightDelegateImpl extends AbstractBizDelegate
implements RightDelegate {
public boolean findWorkflow(State state) {
Request req = new Request();
req.setServiceName("RunByResultProcessor");
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return true;
} catch (Exception e) {
DelegateUtil.handleException(e, "workflow", state);
}
return false;
}
public Role findgrantedAuthorityFromDataBase(String authority, State state) {
try {
return (Role) getDelegate().execute("authority", authority,
"FindgrantedAuthorityFromDataBaseProcessor", "resultObject",
state);
} catch (Exception e) {
DelegateUtil.handleException(e, "findgrantedAuthorityFromDataBase",
state);
}
return null;
}
public Function findFunctionFromDataBase(String protectfunction, State state) {
try {
return (Function) getDelegate().execute("protectfunction",
protectfunction, "FindFunctionFromDataBaseProcessor",
"resultObject", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "findFunctionFromDataBase", state);
}
return null;
}
public List findRoleByFunction(String functionId, State state) {
try {
return (List) getDelegate().execute("functionId", functionId,
"FindRoleByFunctionProcessor", "roles", state);
} catch (Exception e) {
throw new ClientException(e, "findRoleByFunction error");
}
}
public List findRoleByUser(String userId, State state) {
try {
return (List) getDelegate().execute("userId", userId,
"FindRoleByUserProcessor", "roles", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "findRoleByUser", state);
}
return null;
}
public User findUserByNameFromDataBase(String name, State state) {
try {
return (User) getDelegate().execute("name", name,
"FindUserByNameFromDataBaseProcessor", "resultObject", state);
} catch (Exception e) {
DelegateUtil
.handleException(e, "findUserByNameFromDataBase", state);
}
return null;
}
public String saveFunction(Function function, State state) {
try {
return (String) getDelegate().execute("function", function,
"SaveFunctionProcessor", "id", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "saveFunction", state);
}
return null;
}
public boolean saveFunctionToRole(Permission permission, State state) {
try {
getDelegate().execute("permission", permission,
"SaveFunctionToRoleProcessor", "id", state);
return true;
} catch (Exception e) {
DelegateUtil.handleException(e, "saveFunctionToRole", state);
}
return false;
}
public void saveFunctionsToRole(List permissions, State state) {
if (DelegateUtil.isNullParam(permissions, "permissions", state)) {
return;
}
Request req = new Request();
req.setServiceName("SaveFunctionsToRoleProcessor");
req.setValue("permissions", permissions);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "saveFunctionsToRole", state);
}
}
public void updateFunction(Function function, State state) {
if (DelegateUtil.isNullParam(function, "function", state)) {
return;
}
Request req = new Request();
req.setServiceName("UpdateFunctionProcessor");
req.setValue("function", function);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "updateFunction", state);
}
}
public boolean isUserExist(String name, State state) {
if (DelegateUtil.isNullParam(name, "name", state)) {
return false;
}
Request req = new Request();
req.setServiceName("IsUserExistProcessor");
req.setValue("name", name);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return ((Boolean) resp.getValue("resultBoolean")).booleanValue();
} catch (Exception e) {
DelegateUtil.handleException(e, "isUserExist", state);
}
return false;
}
public String saveUser(User user, State state) {
try {
return (String) getDelegate().execute("user", user,
"SaveUserProcessor", "result", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "saveUser", state);
}
return null;
}
public PageSupport findAllUser(CriteriaQuery cq, State state) {
if (DelegateUtil.isNullParam(cq, "CriteriaQuery", state)) {
return null;
}
Request req = new Request();
req.setServiceName("FindAllUserProcessor");
req.setValue("CriteriaQuery", cq);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return (PageSupport) (PageSupport) resp.getValue("PageSupport");
} catch (Exception e) {
DelegateUtil.handleException(e, "findAllUser", state);
}
return null;
}
public boolean deleteFunctionById(String functionId, State state) {
if (DelegateUtil.isNullParam(functionId, "functionId", state)) {
return false;
}
Request req = new Request();
req.setServiceName("DeleteFunctionByIdProcessor");
req.setValue("functionId", functionId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return ((Boolean) resp.getValue("resultBoolean")).booleanValue();
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteFunctionById", state);
}
return false;
}
public void deleteFunction(Function function, State state) {
if (DelegateUtil.isNullParam(function, "function", state)) {
return;
}
Request req = new Request();
req.setServiceName("DeleteFunctionProcessor");
req.setValue("function", function);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteFunction", state);
}
}
public PageSupport findAllFunction(CriteriaQuery cq, State state) {
if (DelegateUtil.isNullParam(cq, "CriteriaQuery", state)) {
return null;
}
Request req = new Request();
req.setServiceName("FindAllFunctionProcessor");
req.setValue("CriteriaQuery", cq);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return (PageSupport) (PageSupport) resp.getValue("PageSupport");
} catch (Exception e) {
DelegateUtil.handleException(e, "findAllFunction", state);
}
return null;
}
public Function findFunctionById(String id, State state) {
if (DelegateUtil.isNullParam(id, "id", state)) {
return null;
}
Request req = new Request();
req.setServiceName("FindFunctionByIdProcessor");
req.setValue("id", id);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
Function function = (Function) resp.getValue("function");
DelegateUtil.setState(state, resp);
return function;
} catch (Exception e) {
DelegateUtil.handleException(e, "findFunctionById", state);
}
return null;
}
public List findFunctionByUser(String userId, State state) {
try {
return (List) getDelegate().execute("userId", userId,
"FindFunctionByUserProcessor", "functions", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "findFunctionByUser", state);
}
return null;
}
public PageSupport findOtherRoleByUser(HqlQuery hqlQuery, String userId,
State state) {
if ((DelegateUtil.isNullParam(hqlQuery, "hqlQuery", state))
|| (DelegateUtil.isNullParam(userId, "userId", state))) {
return null;
}
Request req = new Request();
req.setServiceName("FindOtherRoleByUserProcessor");
req.setValue("hqlQuery", hqlQuery);
req.setValue("userId", userId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return (PageSupport) resp.getValue("roles");
} catch (Exception e) {
DelegateUtil.handleException(e, "findOtherRoleByUser", state);
}
return null;
}
public String saveRole(Role role, State state) {
if (DelegateUtil.isNullParam(role, "role", state)) {
return null;
}
Request req = new Request();
req.setServiceName("SaveRoleProcessor");
req.setValue("role", role);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return (String) resp.getValue("result");
} catch (Exception e) {
DelegateUtil.handleException(e, "saveRole", state);
}
return null;
}
public void deleteRoleById(String roleId, State state) {
if (DelegateUtil.isNullParam(roleId, "roleId", state)) {
return;
}
Request req = new Request();
req.setServiceName("DeleteRoleByIdProcessor");
req.setValue("roleId", roleId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteRoleById", state);
}
}
public void deleteRole(Role role, State state) {
if (DelegateUtil.isNullParam(role, "role", state)) {
return;
}
Request req = new Request();
req.setServiceName("DeleteRoleProcessor");
req.setValue("role", role);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteRole", state);
}
}
public void updateRole(Role role, State state) {
if (DelegateUtil.isNullParam(role, "role", state)) {
return;
}
Request req = new Request();
req.setServiceName("UpdateRoleProcessor");
req.setValue("role", role);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "updateRole", state);
}
}
public void updateUser(User user, State state) {
try {
getDelegate().execute("user", user, "UpdateUserProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "updateUser", state);
}
}
public PageSupport findAllRole(CriteriaQuery cq, State state) {
if (DelegateUtil.isNullParam(cq, "CriteriaQuery", state)) {
return null;
}
Request req = new Request();
req.setServiceName("FindAllRoleProcessor");
req.setValue("CriteriaQuery", cq);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return (PageSupport) (PageSupport) resp.getValue("PageSupport");
} catch (Exception e) {
DelegateUtil.handleException(e, "findAllRole", state);
}
return null;
}
public Role findRoleById(String id, State state) {
if (DelegateUtil.isNullParam(id, "id", state)) {
return null;
}
Request req = new Request();
req.setServiceName("FindRoleByIdProcessor");
req.setValue("id", id);
try {
Response resp = getDelegate().execute(req);
Role role = (Role) resp.getValue("role");
DelegateUtil.setState(state, resp);
return role;
} catch (Exception e) {
DelegateUtil.handleException(e, "findRoleById", state);
}
return null;
}
public List findFunctionByRoleId(String roleId, State state) {
if (DelegateUtil.isNullParam(roleId, "roleId", state)) {
return null;
}
Request req = new Request();
req.setServiceName("FindFunctionByRoleIdProcessor");
req.setValue("roleId", roleId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return (List) resp.getValue("functions");
} catch (Exception e) {
DelegateUtil.handleException(e, "findFunctionByRoleId", state);
}
return null;
}
public List findOtherFunctionByRoleId(String roleId, State state) {
if (DelegateUtil.isNullParam(roleId, "roleId", state)) {
return null;
}
Request req = new Request();
req.setServiceName("FindOtherFunctionByRoleIdProcessor");
req.setValue("roleId", roleId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return (List) resp.getValue("functions");
} catch (Exception e) {
DelegateUtil.handleException(e, "findOtherFunctionByRoleId", state);
}
return null;
}
public PageSupport findOtherFunctionByHql(HqlQuery hqlQuery, String roleId,
State state) {
if (DelegateUtil.isNullParam(hqlQuery, "hqlQuery", state)) {
return null;
}
Request req = new Request();
req.setServiceName("FindOtherFunctionByHqlProcessor");
req.setValue("hqlQuery", hqlQuery);
req.setValue("roleId", roleId);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
return (PageSupport) resp.getValue("functions");
} catch (Exception e) {
DelegateUtil.handleException(e, "findOtherFunctionByHql", state);
}
return null;
}
public void deleteFunctionsFromRole(List<Permission> permissions,
State state) {
try {
getDelegate().execute("permissions", permissions,
"DeleteFunctionsFromRoleProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteFunctionsFromRole", state);
}
}
public void deleteRoleFromUser(List userRoles, State state) {
try {
getDelegate().execute("userRoles", userRoles,
"DeleteRoleFromUserProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteRoleFromUser", state);
}
}
public User findUserById(String userId, State state) {
try {
return (User) getDelegate().execute("userId", userId,
"FindUserByIdProcessor", "user", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "findUserById", state);
}
return null;
}
public void saveRoleToUser(UserRole userRole, State state) {
try {
if ((!AppUtils.isBlank(userRole))
&& (!AppUtils.isBlank(userRole.getId().getUserId()))
&& (!AppUtils.isBlank(userRole.getId().getRoleId()))) {
List userRoles = new ArrayList();
userRoles.add(userRole);
saveRolesToUser(userRoles, state);
} else {
throw new JCFException(state.getErrCode(),
"saveRoleToUser userRole is not validated!");
}
} catch (Exception e) {
DelegateUtil.handleException(e, "saveRoleToUser", state);
}
}
public void updateUserPassowrd(String userId, String password, State state) {
if ((DelegateUtil.isNullParam(userId, "userId", state))
|| (DelegateUtil.isNullParam(password, "password", state))) {
return;
}
Request req = new Request();
req.setServiceName("UpdateUserPassowrdProcessor");
req.setValue("userId", userId);
req.setValue("password", password);
try {
Response resp = getDelegate().execute(req);
DelegateUtil.setState(state, resp);
} catch (Exception e) {
DelegateUtil.handleException(e, "updateUserPassowrd", state);
}
}
public void deletePermissionByFunctionId(String functionId, State state) {
try {
getDelegate().execute("functionId", functionId,
"DeletePermissionByFunctionIdProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deletePermissionByFunctionId",
state);
}
}
public void deleteUserRoleByUserId(String userId, State state) {
try {
getDelegate().execute("userId", userId,
"DeleteUserRoleByUserIdProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteUserRoleByUserId", state);
}
}
public void deleteRoleFromUser(UserRole userRole, State state) {
if (AppUtils.isBlank(userRole))
throw new ClientException("PARAMETER_ERROR", "deleteRoleFromUser");
List userRoles = new ArrayList();
userRoles.add(userRole);
deleteRoleFromUser(userRoles, state);
}
public void deleteUserRoleByRoleId(String roleId, State state) {
try {
getDelegate().execute("roleId", roleId,
"DeleteUserRoleByRoleIdProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteUserRoleByRoleId", state);
}
}
public void deletePermissionByRoleId(String roleId, State state) {
try {
getDelegate().execute("roleId", roleId,
"DeletePermissionByRoleIdProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deletePermissionByRoleId", state);
}
}
public void saveRolesToUser(List userRoles, State state) {
try {
getDelegate().execute("userRoles", userRoles,
"SaveRolesToUserProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "saveRolesToUser", state);
}
}
public String saveFile(File file, State state) {
try {
return (String) getDelegate().execute("file", file,
"SaveFileProcessor", "result", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "saveFile", state);
}
return null;
}
public void deleteFileById(String id, State state) {
try {
getDelegate().execute("id", id, "DeleteFileByIdProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteFileById", state);
}
}
public void deleteFile(File file, State state) {
try {
getDelegate().execute("file", file, "DeleteFileProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "deleteUserRoleByUserId", state);
}
}
public void updateFile(File file, State state) {
try {
getDelegate().execute("file", file, "UpdateFileProcessor", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "updateFile", state);
}
}
public PageSupport findAllFile(CriteriaQuery cq, State state) {
try {
return (PageSupport) getDelegate().execute("CriteriaQuery", cq,
"FindAllFileProcessor", "PageSupport", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "findAllFile", state);
}
return null;
}
public File findFileById(String id, State state) {
try {
return (File) getDelegate().execute("id", id,
"FindFileByIdProcessor", "file", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "findFileById", state);
}
return null;
}
public String saveLoginHistory(LoginHistory loginHistory, State state) {
try {
return (String) getDelegate().execute("loginHistory", loginHistory,
"SaveLoginHistoryProcessor", "result", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "saveLoginHistory", state);
}
return null;
}
public String testCircle(State state) {
try {
return (String) getDelegate().execute("testCircleProcessor",
"next", state);
} catch (Exception e) {
DelegateUtil.handleException(e, "testCircle", state);
}
return null;
}
}
| Java |
package com.legendshop.business.permission.service;
import com.legendshop.command.framework.State;
import com.legendshop.command.framework.facade.BizDelegate;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Function;
import com.legendshop.model.entity.LoginHistory;
import com.legendshop.model.entity.Permission;
import com.legendshop.model.entity.Role;
import com.legendshop.model.entity.User;
import com.legendshop.model.entity.UserRole;
import java.io.File;
import java.util.List;
public abstract interface RightDelegate extends BizDelegate {
public abstract boolean findWorkflow(State paramState);
public abstract String testCircle(State paramState);
public abstract Role findgrantedAuthorityFromDataBase(String paramString,
State paramState);
public abstract Function findFunctionFromDataBase(String paramString,
State paramState);
public abstract List findFunctionByRoleId(String paramString,
State paramState);
public abstract User findUserByNameFromDataBase(String paramString,
State paramState);
public abstract List findRoleByFunction(String paramString, State paramState);
public abstract String saveUser(User paramUser, State paramState);
public abstract boolean isUserExist(String paramString, State paramState);
public abstract User findUserById(String paramString, State paramState);
public abstract List findOtherFunctionByRoleId(String paramString,
State paramState);
public abstract PageSupport findOtherFunctionByHql(HqlQuery paramHqlQuery,
String paramString, State paramState);
public abstract PageSupport findAllUser(CriteriaQuery paramCriteriaQuery,
State paramState);
public abstract void updateUserPassowrd(String paramString1,
String paramString2, State paramState);
public abstract String saveFunction(Function paramFunction, State paramState);
public abstract boolean deleteFunctionById(String paramString,
State paramState);
public abstract void deleteFunction(Function paramFunction, State paramState);
public abstract Function findFunctionById(String paramString,
State paramState);
public abstract PageSupport findAllFunction(
CriteriaQuery paramCriteriaQuery, State paramState);
public abstract void updateFunction(Function paramFunction, State paramState);
public abstract boolean saveFunctionToRole(Permission paramPermission,
State paramState);
public abstract void saveFunctionsToRole(List paramList, State paramState);
public abstract void deleteFunctionsFromRole(List<Permission> paramList,
State paramState);
public abstract void deleteRole(Role paramRole, State paramState);
public abstract Role findRoleById(String paramString, State paramState);
public abstract String saveRole(Role paramRole, State paramState);
public abstract void deleteRoleById(String paramString, State paramState);
public abstract PageSupport findAllRole(CriteriaQuery paramCriteriaQuery,
State paramState);
public abstract void updateRole(Role paramRole, State paramState);
public abstract void saveRoleToUser(UserRole paramUserRole, State paramState);
public abstract void saveRolesToUser(List paramList, State paramState);
public abstract void deleteRoleFromUser(List paramList, State paramState);
public abstract void deletePermissionByRoleId(String paramString,
State paramState);
public abstract void deletePermissionByFunctionId(String paramString,
State paramState);
public abstract void deleteUserRoleByUserId(String paramString,
State paramState);
public abstract void deleteUserRoleByRoleId(String paramString,
State paramState);
public abstract void updateUser(User paramUser, State paramState);
public abstract List findRoleByUser(String paramString, State paramState);
public abstract List findFunctionByUser(String paramString, State paramState);
public abstract void deleteRoleFromUser(UserRole paramUserRole,
State paramState);
public abstract PageSupport findOtherRoleByUser(HqlQuery paramHqlQuery,
String paramString, State paramState);
public abstract String saveFile(File paramFile, State paramState);
public abstract void deleteFileById(String paramString, State paramState);
public abstract void deleteFile(File paramFile, State paramState);
public abstract void updateFile(File paramFile, State paramState);
public abstract PageSupport findAllFile(CriteriaQuery paramCriteriaQuery,
State paramState);
public abstract File findFileById(String paramString, State paramState);
public abstract String saveLoginHistory(LoginHistory paramLoginHistory,
State paramState);
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Role;
import java.util.Map;
public class SaveRole extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("result", this.dao.save((Role) params.get("role")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Function;
import com.legendshop.util.AppUtils;
import java.util.Map;
public class UpdateFunction extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
Function function = (Function) params.get("function");
if (checkFunction(function)) {
String msg = "UpdateFunction PARAM_ERR ,function is not validated!";
throw new JCFException("PARAMETER_ERROR", msg);
}
this.dao.update(function);
}
private boolean checkFunction(Function fuction) {
return (AppUtils.isBlank(fuction)) || (fuction.getId() == null);
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.UserDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class DeleteUserRoleByRoleId extends AbstractCommand {
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
this.dao.DeleteUserRole(this.dao.findUserRoleByRoleId((String) params
.get("roleId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindFunctionByRole extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("functions",
this.dao.FindFunctionByRoleId((String) params.get("roleId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Role;
import java.util.Map;
public class DeleteRole extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
Role role = (Role) params.get("role");
if (checkRole(role)) {
String msg = "DeleteRole PARAM_ERR ,role is not validated!";
throw new JCFException("PARAMETER_ERROR", msg);
}
this.dao.delete(role);
}
private boolean checkRole(Role role) {
return role.getId() == null;
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindAllRole extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("PageSupport",
this.dao.find((CriteriaQuery) params.get("CriteriaQuery"), true));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.UserDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindAllUser extends AbstractCommand {
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("PageSupport",
this.dao.find((CriteriaQuery) params.get("CriteriaQuery"), true));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Function;
import com.legendshop.model.entity.Role;
import com.legendshop.util.AppUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FindFunctionByUser extends AbstractCommand {
private FunctionDao dao;
private RoleDao roleDao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
List roles = this.roleDao.FindRoleByUserId((String) params
.get("userId"));
if (!AppUtils.isBlank(roles))
response.put("functions", findFunctionByRole(roles));
else
response.put("functions", null);
}
public List findFunctionByRole(List roles) {
Map functionMap = new HashMap();
List functionList = new ArrayList();
for (int i = 0; i < roles.size(); i++) {
Role role = (Role) roles.get(i);
if (!AppUtils.isBlank(role.getId())) {
List fs = this.dao.FindFunctionByRoleId(role.getId());
if (!AppUtils.isBlank(fs)) {
for (int j = 0; j < fs.size(); j++) {
Function f = (Function) fs.get(j);
if (!functionMap.containsKey(f.getId())) {
functionMap.put(f.getId(), null);
functionList.add(f);
}
}
}
}
}
return functionList;
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
public void setRoleDao(RoleDao roleDao) {
this.roleDao = roleDao;
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Role;
import java.util.Map;
public class UpdateRole extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
this.dao.update((Role) params.get("role"));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.command.framework.JCFException;
import com.legendshop.model.entity.Function;
import java.util.Map;
public class DeleteFunction extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
Function function = (Function) params.get("function");
if (checkFunction(function)) {
String msg = "DeleteFunction PARAMETER_ERROR ,function is not validated!";
throw new JCFException("PARAMETER_ERROR", msg);
}
this.dao.delete(function);
}
private boolean checkFunction(Function fuction) {
return fuction.getId() == null;
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindOtherFunctionByHql extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put(
"functions",
this.dao.FindOtherFunctionByRoleId(
(HqlQuery) params.get("hqlQuery"),
(String) params.get("roleId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindRoleByFunction extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("roles",
this.dao.FindRoleByFunction((String) params.get("functionId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Permission;
import com.legendshop.model.entity.PerssionId;
import java.util.Map;
public class SaveFunctionToRole extends AbstractCommand {
private static final long serialVersionUID = 5575511149689866328L;
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
Permission permission = (Permission) params.get("permission");
String result = checkPermission(permission);
if (result != null) {
throw new JCFException("PARAMETER_ERROR", result);
}
response.put("id", this.dao.save(permission));
}
private String checkPermission(Permission permission) {
if (permission.getId().getFunctionId() == null)
return "SaveFunctionToRole PARAM_ERR ,FunctionId is NULL";
if (permission.getId().getRoleId() == null) {
return "SaveFunctionToRole PARAM_ERR ,FunctionId is NULL";
}
return null;
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.UserDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.util.AppUtils;
import java.util.Map;
public class IsUserExist extends AbstractCommand {
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
if (AppUtils.isBlank(this.dao.findByName((String) params.get("name"))))
response.put("resultBoolean", Boolean.FALSE);
else
response.put("resultBoolean", Boolean.TRUE);
}
public void fini() throws Exception {
}
public void init(String parameter) throws Exception {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.UserDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.User;
import com.legendshop.util.AppUtils;
import java.util.Map;
public class UpdateUser extends AbstractCommand {
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
User user = (User) params.get("user");
if (checkUser(user)) {
String msg = "UpdateRole PARAM_ERR ,role is not validated!";
throw new JCFException("PARAMETER_ERROR", msg);
}
this.dao.update(user);
}
private boolean checkUser(User user) {
return (AppUtils.isBlank(user))
|| (AppUtils.isBlank(user.getEnabled()))
|| (AppUtils.isBlank(user.getId()))
|| (AppUtils.isBlank(user.getName()))
|| (AppUtils.isBlank(user.getPassword()));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Role;
import java.util.Map;
public class DeleteRoleById extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
this.dao.deleteById(Role.class, (String) params.get("roleId"));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.List;
import java.util.Map;
public class DeleteRoleFromUser extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
this.dao.deleteAll((List) params.get("userRoles"));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindOtherRoleByUser extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("roles", this.dao.FindOtherRoleByUser(
(HqlQuery) params.get("hqlQuery"), (String) params.get("userId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.UserDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.User;
import java.util.Map;
public class FindUserById extends AbstractCommand {
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("user",
(User) this.dao.get(User.class, (String) params.get("userId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindRoleByUserId extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("roles",
this.dao.FindRoleByUserId((String) params.get("userId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.UserDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class DeleteUserRoleByUserId extends AbstractCommand {
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
this.dao.DeleteUserRole(this.dao.findUserRoleByUserId((String) params
.get("userId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.UserDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.User;
import java.util.Map;
public class SaveUser extends AbstractCommand {
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("result", this.dao.save((User) params.get("user")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Function;
import java.util.Map;
public class FindFunctionById extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("function",
(Function) this.dao.get(Function.class, (String) params.get("id")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.List;
import java.util.Map;
public class DeletePermissionByFunctionId extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
String functionId = (String) params.get("functionId");
List functionds = this.dao.find(
"from Permission p where p.id.functionId=?",
new Object[] {functionId });
this.dao.DeletePermissionByFunctionId(functionds);
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Role;
import java.util.Map;
public class FindRoleById extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("role",
(Role) this.dao.get(Role.class, (String) params.get("id")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindOtherFunctionByRoleId extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("functions",
this.dao.FindOtherFunctionByRoleId((String) params.get("roleId")));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.util.AppUtils;
import java.util.List;
import java.util.Map;
public class SaveFunctionsToRole extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
List permissions = (List) params.get("permissions");
if (checkPermissions(permissions)) {
String msg = "SaveFunctionsToRole PARAM_ERR ,permissions is not validated!";
throw new JCFException("PARAMETER_ERROR", msg);
}
this.dao.savePermissions(permissions);
}
private boolean checkPermissions(List permissions) {
return AppUtils.isBlank(permissions);
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.UserDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.User;
import java.util.Map;
public class UpdateUserPassowrd extends AbstractCommand {
private UserDao dao;
public void setDao(UserDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
User user = (User) this.dao.get(User.class,
(String) params.get("userId"));
user.setPassword((String) params.get("password"));
this.dao.update(user);
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.List;
import java.util.Map;
public class DeleteFunctionsFromRole extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
this.dao.DeletePermissionByFunctionId((List) params.get("permissions"));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Function;
import java.util.Map;
public class DeleteFunctionById extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put(
"resultBoolean",
Boolean.valueOf(this.dao.delete(Function.class,
(String) params.get("functionId"))));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class DeletePermissionByRoleId extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
this.dao.DeletePermissionByRoleId(this.dao.find(
"from Permission p where p.id.roleId=?",
new Object[] {(String) params.get("roleId") }));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.exception.JCFException;
import java.util.Map;
public class FindAllFunction extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
response.put("PageSupport",
this.dao.find((CriteriaQuery) params.get("CriteriaQuery"), true));
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.RoleDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.UserRole;
import com.legendshop.util.AppUtils;
import java.util.List;
import java.util.Map;
public class SaveRolesToUser extends AbstractCommand {
private RoleDao dao;
public void setDao(RoleDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
List userRoles = (List) params.get("userRoles");
if (checkPermissions(userRoles)) {
String msg = "SaveFunctionsToRole PARAM_ERR ,userRoles is not validated!";
throw new JCFException("PARAMETER_ERROR", msg);
}
for (int i = 0; i < userRoles.size(); i++) {
UserRole userRole = (UserRole) userRoles.get(i);
this.dao.save(userRole);
if (i % 50 == 0) {
this.dao.flush();
this.dao.clear();
}
}
}
private boolean checkPermissions(List userRoles) {
return AppUtils.isBlank(userRoles);
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.command;
import com.legendshop.business.permission.dao.FunctionDao;
import com.legendshop.command.framework.AbstractCommand;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Function;
import java.util.Map;
public class SaveFunction extends AbstractCommand {
private FunctionDao dao;
public void setDao(FunctionDao dao) {
this.dao = dao;
}
public void execute(Map params, Map response) throws Exception {
Function function = (Function) params.get("function");
if (checkFunction(function)) {
String msg = "SaveFunction PARAM_ERR ,function is not validated!Name or ProtectFunction is Null";
throw new JCFException("PARAMETER_ERROR", msg);
}
response.put("id", this.dao.save(function));
}
private boolean checkFunction(Function fuction) {
return (fuction.getName() == null)
|| (fuction.getProtectFunction() == null);
}
public void fini() throws JCFException {
}
public void init(String arg0) throws JCFException {
}
}
| Java |
package com.legendshop.business.permission.dao;
import com.legendshop.core.dao.impl.BaseDaoImpl;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.JCFException;
import com.legendshop.model.entity.Permission;
import com.legendshop.model.entity.PerssionId;
import com.legendshop.util.StringUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;
public class FunctionDao extends BaseDaoImpl {
private static final Log logger = LogFactory.getLog(FunctionDao.class);
private String findFunctionByRoleId;
private String findOtherFunctionByRoleId;
private String findOtherFunctionByRoleIdHQL;
private String findOtherFunctionByRoleIdHQLCount;
public void setFindFunctionByRoleId(String findFunctionByRoleId) {
this.findFunctionByRoleId = findFunctionByRoleId;
}
public void setFindOtherFunctionByRoleId(String findOtherFunctionByRoleId) {
this.findOtherFunctionByRoleId = findOtherFunctionByRoleId;
}
public void setFindOtherFunctionByRoleIdHQL(
String findOtherFunctionByRoleIdHQL) {
this.findOtherFunctionByRoleIdHQL = findOtherFunctionByRoleIdHQL;
}
public List FindFunctionByRoleId(String roleId) {
logger.info(StringUtil.convert(this.findFunctionByRoleId,
new String[] {roleId }));
return find(this.findFunctionByRoleId, new Object[] {roleId });
}
public List FindOtherFunctionByRoleId(String roleId) {
logger.info(StringUtil.convert(this.findOtherFunctionByRoleId,
new String[] {roleId }));
return find(this.findOtherFunctionByRoleId, new Object[] {roleId });
}
public PageSupport FindOtherFunctionByRoleId(HqlQuery hqlQuery,
String roleId) throws JCFException {
logger.info(StringUtil.convert(this.findOtherFunctionByRoleIdHQL,
new String[] {roleId }));
hqlQuery.setQueryString(this.findOtherFunctionByRoleIdHQL);
hqlQuery.setAllCountString(this.findOtherFunctionByRoleIdHQLCount);
hqlQuery.setParam(new Object[] {roleId });
return find(hqlQuery);
}
public void savePermissions(final List permissions) throws Exception {
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Connection con = session.connection();
PreparedStatement pstmt = null;
for (int i = 0; i < permissions.size(); i++) {
Permission p = (Permission) permissions.get(i);
pstmt = con
.prepareStatement("insert into ls_perm (role_id,function_id) values (?,?)");
FunctionDao.logger.info(StringUtil
.convert(
"insert into ls_perm (role_id,function_id) values (?,?)",
new String[] {p.getId().getRoleId(),
p.getId().getFunctionId() }));
pstmt.setString(1, p.getId().getRoleId());
pstmt.setString(2, p.getId().getFunctionId());
pstmt.executeUpdate();
}
return Boolean.TRUE;
}
});
}
public void DeletePermissionByFunctionId(List permissions) {
logger.info("DeletePermissionByFunctionId with size "
+ permissions.size());
deleteAll(permissions);
}
public void setFindOtherFunctionByRoleIdHQLCount(
String findOtherFunctionByRoleIdHQLCount) {
this.findOtherFunctionByRoleIdHQLCount = findOtherFunctionByRoleIdHQLCount;
}
}
| Java |
package com.legendshop.business.permission.dao;
import com.legendshop.core.dao.impl.BaseDaoImpl;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.core.exception.JCFException;
import com.legendshop.util.StringUtil;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class RoleDao extends BaseDaoImpl {
private static final Log logger = LogFactory.getLog(RoleDao.class);
private String findRoleByFunction;
private String findRoleByUserId;
private String findOtherRoleByUser;
private String findOtherRoleByUserCount;
public void setFindOtherRoleByUser(String findOtherRoleByUser) {
this.findOtherRoleByUser = findOtherRoleByUser;
}
public void setFindRoleByFunction(String findRoleByFunction) {
this.findRoleByFunction = findRoleByFunction;
}
public void setFindRoleByUserId(String findRoleByUserId) {
this.findRoleByUserId = findRoleByUserId;
}
public List FindRoleByFunction(String functionId) throws JCFException {
logger.info(StringUtil.convert(this.findRoleByFunction,
new String[] {functionId }));
return find(this.findRoleByFunction, new Object[] {functionId });
}
public void DeletePermissionByRoleId(List permissions) {
deleteAll(permissions);
}
public List FindRoleByUserId(String userId) throws JCFException {
logger.info(StringUtil.convert(this.findRoleByUserId,
new String[] {userId }));
return find(this.findRoleByUserId, new Object[] {userId });
}
public PageSupport FindOtherRoleByUser(HqlQuery hqlQuery, String userId)
throws JCFException {
logger.info(StringUtil.convert(this.findOtherRoleByUser,
new String[] {userId }));
hqlQuery.setQueryString(this.findOtherRoleByUser);
hqlQuery.setAllCountString(this.findOtherRoleByUserCount);
hqlQuery.addParams(userId);
return find(hqlQuery);
}
public void setFindOtherRoleByUserCount(String findOtherRoleByUserCount) {
this.findOtherRoleByUserCount = findOtherRoleByUserCount;
}
}
| Java |
package com.legendshop.business.permission.dao;
import com.legendshop.core.dao.impl.BaseDaoImpl;
import com.legendshop.util.StringUtil;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class UserDao extends BaseDaoImpl {
private static final Log logger = LogFactory.getLog(UserDao.class);
private String findByName;
private String findUserRoleByRoleId;
private String findUserRoleByUserId;
public void setFindByName(String findByName) {
this.findByName = findByName;
}
public void setFindUserRoleByRoleId(String findUserRoleByRoleId) {
this.findUserRoleByRoleId = findUserRoleByRoleId;
}
public void setFindUserRoleByUserId(String findUserRoleByUserId) {
this.findUserRoleByUserId = findUserRoleByUserId;
}
public void DeleteUserRole(List userRoles) {
logger.info("DeleteUserRole with size " + userRoles.size());
deleteAll(userRoles);
}
public List findByName(String name) {
logger.info(StringUtil.convert(this.findByName, new String[] {name }));
return find(this.findByName, new Object[] {name });
}
public List findUserRoleByRoleId(String roleId) {
logger.info(StringUtil.convert(this.findUserRoleByRoleId,
new String[] {roleId }));
return find(this.findUserRoleByRoleId, new Object[] {roleId });
}
public List findUserRoleByUserId(String userId) {
logger.info(StringUtil.convert(this.findUserRoleByUserId,
new String[] {userId }));
return find(this.findUserRoleByUserId, new Object[] {userId });
}
}
| Java |
package com.legendshop.business.permission.common;
public class ManagerConstants {
public static String BizDelegateManager = "BizDelegateManager";
public static String BizDelegateWithOutMethodControl = "BizDelegateWithOutMethodControl";
public static String BizDelegateTarget = "BizDelegateTarget";
public static String rightFacade = "rightFacade";
public static final String SERVICE_CONFIG = "etc/ServiceConfig.xml";
public static final String CacheSubscriber = "CacheSubscriber";
public static final String UpdateUser = "UpdateUser";
public static final String UpdateFunction = "UpdateFunction";
public static final String UpdateAllCache = "UpdateAllCache";
public static final String userCache = "userCache";
public static final String authorityUserCache = "authorityUserCache";
public static final String authorityFunctionCache = "authorityFunctionCache";
public static final String functionCache = "functionCache";
public static final String functionRoleCache = "functionRoleCache";
public static final String roleCache = "roleCache";
public static final String METHOD_CACHE = "METHOD_CACHE";
}
| Java |
package com.legendshop.business.permission.common;
public class ErrorCode extends com.legendshop.command.framework.ErrorCode {
}
| Java |
package com.legendshop.business.permission.common;
public class ServiceConsts {
public static final String FindgrantedAuthorityFromDataBaseProcessor = "FindgrantedAuthorityFromDataBaseProcessor";
public static final String FindRoleByFunctionProcessor = "FindRoleByFunctionProcessor";
public static final String FindRoleByUserProcessor = "FindRoleByUserProcessor";
public static final String FindFunctionFromDataBaseProcessor = "FindFunctionFromDataBaseProcessor";
public static final String FindUserByNameFromDataBaseProcessor = "FindUserByNameFromDataBaseProcessor";
public static final String DeletePermissionByFunctionIdProcessor = "DeletePermissionByFunctionIdProcessor";
public static final String DeleteFunctionsFromRoleProcessor = "DeleteFunctionsFromRoleProcessor";
public static final String FindUserByIdProcessor = "FindUserByIdProcessor";
public static final String DeleteUserRoleByUserIdProcessor = "DeleteUserRoleByUserIdProcessor";
public static final String DeleteRoleFromUserProcessor = "DeleteRoleFromUserProcessor";
public static final String DeleteUserRoleByRoleIdProcessor = "DeleteUserRoleByRoleIdProcessor";
public static final String DeletePermissionByRoleIdProcessor = "DeletePermissionByRoleIdProcessor";
public static final String FindFunctionByUserProcessor = "FindFunctionByUserProcessor";
public static final String FindOtherRoleByUserProcessor = "FindOtherRoleByUserProcessor";
public static final String SaveRolesToUserProcessor = "SaveRolesToUserProcessor";
public static final String UpdateUserProcessor = "UpdateUserProcessor";
public static final String SaveFunctionProcessor = "SaveFunctionProcessor";
public static final String SaveFunctionToRoleProcessor = "SaveFunctionToRoleProcessor";
public static final String SaveFunctionsToRoleProcessor = "SaveFunctionsToRoleProcessor";
public static final String DeleteFunctionByIdProcessor = "DeleteFunctionByIdProcessor";
public static final String DeleteFunctionProcessor = "DeleteFunctionProcessor";
public static final String UpdateFunctionProcessor = "UpdateFunctionProcessor";
public static final String FindAllFunctionProcessor = "FindAllFunctionProcessor";
public static final String FindFunctionByIdProcessor = "FindFunctionByIdProcessor";
public static final String SaveRoleProcessor = "SaveRoleProcessor";
public static final String DeleteRoleByIdProcessor = "DeleteRoleByIdProcessor";
public static final String DeleteRoleProcessor = "DeleteRoleProcessor";
public static final String UpdateRoleProcessor = "UpdateRoleProcessor";
public static final String FindAllRoleProcessor = "FindAllRoleProcessor";
public static final String FindRoleByIdProcessor = "FindRoleByIdProcessor";
public static final String FindFunctionByRoleIdProcessor = "FindFunctionByRoleIdProcessor";
public static final String FindOtherFunctionByRoleIdProcessor = "FindOtherFunctionByRoleIdProcessor";
public static final String FindOtherFunctionByHqlProcessor = "FindOtherFunctionByHqlProcessor";
public static final String SaveUserProcessor = "SaveUserProcessor";
public static final String IsUserExistProcessor = "IsUserExistProcessor";
public static final String FindAllUserProcessor = "FindAllUserProcessor";
public static final String UpdateUserPassowrdProcessor = "UpdateUserPassowrdProcessor";
public static final String SaveFileProcessor = "SaveFileProcessor";
public static final String DeleteFileByIdProcessor = "DeleteFileByIdProcessor";
public static final String DeleteFileProcessor = "DeleteFileProcessor";
public static final String UpdateFileProcessor = "UpdateFileProcessor";
public static final String FindAllFileProcessor = "FindAllFileProcessor";
public static final String FindFileByIdProcessor = "FindFileByIdProcessor";
public static final String SaveLoginHistoryProcessor = "SaveLoginHistoryProcessor";
}
| Java |
package com.legendshop.business.permission.common;
import com.legendshop.command.framework.ErrorHandler;
import com.legendshop.command.framework.GoOnException;
import com.legendshop.command.framework.JCFException;
import com.legendshop.command.framework.Response;
import com.legendshop.command.framework.State;
import org.apache.log4j.Logger;
public class ProcessorErrorHandler implements ErrorHandler {
private String beanName;
private static Logger logger = Logger
.getLogger(ProcessorErrorHandler.class);
public void handleError(Response resp, Throwable th) throws Exception {
if ((th instanceof GoOnException)) {
logger.error("throw GoOnException 异常", th);
} else {
if ((th instanceof JCFException)) {
logger.error("throw JCFException 异常", th);
resp.setReturnCode(-2);
resp.getState().setErrCode("A JCFException happened");
throw ((JCFException) th);
}
logger.error(th + " error occured, forcing a stop");
resp.setReturnCode(-2);
resp.getState().setErrCode("A Exception happened");
if ((th instanceof Exception))
throw ((Exception) th);
}
}
public void setBeanName(String beanName) {
this.beanName = beanName;
}
}
| Java |
package com.legendshop.business.permission.common;
import com.legendshop.business.permission.service.RightDelegate;
import com.legendshop.core.ContextServiceLocator;
import com.legendshop.util.ServiceLocatorIF;
public class BeanFactory {
private static BeanFactory instance;
public static BeanFactory getInstance() {
if (instance == null)
instance = new BeanFactory();
return instance;
}
public static Object getBean(String beanName) {
return ContextServiceLocator.getInstance().getBean(beanName);
}
public RightDelegate getRightDelegate() {
return (RightDelegate) ContextServiceLocator.getInstance().getBean(
"RightDelegateImpl");
}
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Advertisement;
import java.util.List;
import java.util.Map;
public abstract interface AdvertisementService {
public abstract List<Advertisement> getAdvertisementByUserName(
String paramString);
public abstract Advertisement getAdvertisement(Long paramLong);
public abstract boolean isMaxNum(String paramString1, String paramString2);
public abstract void delete(Long paramLong);
public abstract Long save(Advertisement paramAdvertisement);
public abstract void update(Advertisement paramAdvertisement);
public abstract PageSupport getDataByCriteriaQuery(
CriteriaQuery paramCriteriaQuery);
public abstract List<Advertisement> getOneAdvertisement(
String paramString1, String paramString2);
public abstract Map<String, List<Advertisement>> getAdvertisement(
String paramString);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.ExternalLink;
import java.util.List;
public abstract interface ExternalLinkService {
public abstract List<ExternalLink> getExternalLink(String paramString);
public abstract ExternalLink getExternalLinkById(Long paramLong);
public abstract ExternalLink getExternalLinkList(Long paramLong,
String paramString);
public abstract void delete(Long paramLong);
public abstract Long save(ExternalLink paramExternalLink);
public abstract void update(ExternalLink paramExternalLink);
public abstract PageSupport getDataByCriteriaQuery(
CriteriaQuery paramCriteriaQuery);
}
| Java |
package com.legendshop.business.service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
public abstract interface LoginService {
public abstract Authentication onAuthentication(
HttpServletRequest paramHttpServletRequest,
HttpServletResponse paramHttpServletResponse, String paramString1,
String paramString2);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Product;
import com.legendshop.model.entity.ProductComment;
import java.util.List;
public abstract interface ProductCommentService {
public abstract List<ProductComment> getProductCommentList(
String paramString);
public abstract ProductComment getProductCommentById(Long paramLong);
public abstract Product getProduct(Long paramLong);
public abstract void delete(Long paramLong);
public abstract Long save(ProductComment paramProductComment);
public abstract void update(ProductComment paramProductComment);
public abstract PageSupport getProductCommentList(
CriteriaQuery paramCriteriaQuery);
public abstract PageSupport getProductCommentList(HqlQuery paramHqlQuery);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.UserComment;
public abstract interface UserCommentService {
public abstract PageSupport getUserCommentList(
CriteriaQuery paramCriteriaQuery);
public abstract UserComment getUserComment(Long paramLong);
public abstract void delete(UserComment paramUserComment);
public abstract void updateUserCommentToReaded(UserComment paramUserComment);
public abstract void saveOrUpdateUserComment(UserComment paramUserComment);
}
| Java |
package com.legendshop.business.service;
import com.legendshop.core.dao.support.CriteriaQuery;
import com.legendshop.core.dao.support.HqlQuery;
import com.legendshop.core.dao.support.PageSupport;
import com.legendshop.model.entity.Product;
public abstract interface ProductService {
public abstract PageSupport getProductList(HqlQuery paramHqlQuery);
public abstract PageSupport getProductList(CriteriaQuery paramCriteriaQuery);
public abstract Product getProductById(Long paramLong);
public abstract void updateProduct(Product paramProduct);
public abstract Long saveProduct(Product paramProduct);
}
| Java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.