Java女裝商城系統(tǒng)的實(shí)現(xiàn)流程
一、項(xiàng)目簡(jiǎn)述功能
javaweb 網(wǎng)上商城系統(tǒng),前臺(tái)+后臺(tái)管理,用戶注冊(cè),登錄,上哦展示,分組展示,搜索,收貨地址管理,購(gòu)物車管理,添加,購(gòu)買,個(gè)人信息修改。訂單查詢等等,后臺(tái)商品管理,分類管理,庫(kù)存管理,訂單管理,用戶管理,信息修改等等.
二、項(xiàng)目運(yùn)行
環(huán)境配置: Jdk1.8 + Tomcats . 5 + mysql + Eclispe ( IntelliJ IDEA ,Eclispe , MyEclispe , sts 都支持)
項(xiàng)目技術(shù): JSP + Spring + SpringMVC + MyBatis + html + cSS + Javascript + JQuery + Ajax + layui + maven 等等。





后臺(tái)管理平臺(tái)登錄代碼:
/**
* 后臺(tái)管理-主頁(yè)
*/
@Controller
public class AdminHomeController extends BaseController {
@Resource(name = "adminService")
private AdminService adminService;
@Resource(name = "productOrderService")
private ProductOrderService productOrderService;
@Resource(name = "productService")
private ProductService productService;
@Resource(name = "userService")
private UserService userService;
/**
* 轉(zhuǎn)到后臺(tái)管理-主頁(yè)
* @param session session對(duì)象
* @param map 前臺(tái)傳入的Map
* @return 響應(yīng)數(shù)據(jù)
* @throws ParseException 轉(zhuǎn)換異常
*/
@RequestMapping(value = "admin", method = RequestMethod.GET)
public String goToPage(HttpSession session, Map<String, Object> map) throws ParseException {
logger.info("獲取管理員信息");
Object adminId = checkAdmin(session);
if (adminId == null) {
return "redirect:/admin/login";
}
Admin admin = adminService.get(null, Integer.parseInt(adminId.toString()));
map.put("admin", admin);
logger.info("獲取統(tǒng)計(jì)信息");
//產(chǎn)品總數(shù)
Integer productTotal = productService.getTotal(null, new Byte[]{0, 2});
//用戶總數(shù)
Integer userTotal = userService.getTotal(null);
//訂單總數(shù)
Integer orderTotal = productOrderService.getTotal(null, new Byte[]{3});
logger.info("獲取圖表信息");
map.put("jsonObject", getChartData(null,null,7));
map.put("productTotal", productTotal);
map.put("userTotal", userTotal);
map.put("orderTotal", orderTotal);
logger.info("轉(zhuǎn)到后臺(tái)管理-主頁(yè)");
return "admin/homePage";
}
/**
* 轉(zhuǎn)到后臺(tái)管理-主頁(yè)(ajax方式)
* @param session session對(duì)象
* @param map 前臺(tái)傳入的Map
* @return 響應(yīng)數(shù)據(jù)
* @throws ParseException 轉(zhuǎn)換異常
*/
@RequestMapping(value = "admin/home", method = RequestMethod.GET)
public String goToPageByAjax(HttpSession session, Map<String, Object> map) throws ParseException {
logger.info("獲取管理員信息");
Object adminId = checkAdmin(session);
if (adminId == null) {
return "admin/include/loginMessage";
}
Admin admin = adminService.get(null, Integer.parseInt(adminId.toString()));
map.put("admin", admin);
logger.info("獲取統(tǒng)計(jì)信息");
Integer productTotal = productService.getTotal(null, new Byte[]{0, 2});
Integer userTotal = userService.getTotal(null);
Integer orderTotal = productOrderService.getTotal(null, new Byte[]{3});
logger.info("獲取圖表信息");
map.put("jsonObject", getChartData(null, null,7));
logger.info("獲取圖表信息");
map.put("jsonObject", getChartData(null,null,7));
map.put("productTotal", productTotal);
map.put("userTotal", userTotal);
map.put("orderTotal", orderTotal);
logger.info("轉(zhuǎn)到后臺(tái)管理-主頁(yè)-ajax方式");
return "admin/homeManagePage";
}
/**
* 按日期查詢圖表數(shù)據(jù)(ajax方式)
* @param beginDate 開(kāi)始日期
* @param endDate 結(jié)束日期
* @return 響應(yīng)數(shù)據(jù)
* @throws ParseException 轉(zhuǎn)換異常
*/
@ResponseBody
@RequestMapping(value = "admin/home/charts", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
public String getChartDataByDate(@RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate) throws ParseException {
if (beginDate != null && endDate != null) {
//轉(zhuǎn)換日期格式
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
return getChartData(simpleDateFormat.parse(beginDate), simpleDateFormat.parse(endDate),7).toJSONString();
} else {
return getChartData(null, null,7).toJSONString();
}
}
/**
* 按日期獲取圖表數(shù)據(jù)
* @param beginDate 開(kāi)始日期
* @param endDate 結(jié)束日期
* @param days 天數(shù)
* @return 圖表數(shù)據(jù)的JSON對(duì)象
* @throws ParseException 轉(zhuǎn)換異常
*/
private JSONObject getChartData(Date beginDate,Date endDate,int days) throws ParseException {
JSONObject jsonObject = new JSONObject();
SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd", Locale.UK);
SimpleDateFormat time2 = new SimpleDateFormat("MM/dd", Locale.UK);
SimpleDateFormat timeSpecial = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.UK);
//如果沒(méi)有指定開(kāi)始和結(jié)束日期
if (beginDate == null || endDate == null) {
//指定一周前的日期為開(kāi)始日期
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 1-days);
beginDate = time.parse(time.format(cal.getTime()));
//指定當(dāng)前日期為結(jié)束日期
cal = Calendar.getInstance();
endDate = cal.getTime();
} else {
beginDate = time.parse(time.format(beginDate));
endDate = timeSpecial.parse(time.format(endDate) + " 23:59:59");
}
logger.info("根據(jù)訂單狀態(tài)分類");
//未付款訂單數(shù)統(tǒng)計(jì)數(shù)組
int[] orderUnpaidArray = new int[7];
//未發(fā)貨訂單數(shù)統(tǒng)計(jì)叔祖
int[] orderNotShippedArray = new int[7];
//未確認(rèn)訂單數(shù)統(tǒng)計(jì)數(shù)組
int[] orderUnconfirmedArray = new int[7];
//交易成功訂單數(shù)統(tǒng)計(jì)數(shù)組
int[] orderSuccessArray = new int[7];
//總交易訂單數(shù)統(tǒng)計(jì)數(shù)組
int[] orderTotalArray = new int[7];
logger.info("從數(shù)據(jù)庫(kù)中獲取統(tǒng)計(jì)的訂單集合數(shù)據(jù)");
List<OrderGroup> orderGroupList = productOrderService.getTotalByDate(beginDate, endDate);
//初始化日期數(shù)組
JSONArray dateStr = new JSONArray(days);
//按指定的天數(shù)進(jìn)行循環(huán)
for (int i = 0; i < days; i++) {
//格式化日期串(MM/dd)并放入日期數(shù)組中
Calendar cal = Calendar.getInstance();
cal.setTime(beginDate);
cal.add(Calendar.DATE, i);
String formatDate = time2.format(cal.getTime());
dateStr.add(formatDate);
//該天的訂單總數(shù)
int orderCount = 0;
//循環(huán)訂單集合數(shù)據(jù)的結(jié)果集
for(int j = 0; j < orderGroupList.size(); j++){
OrderGroup orderGroup = orderGroupList.get(j);
//如果該訂單日期與當(dāng)前日期一致
if(orderGroup.getProductOrder_pay_date().equals(formatDate)){
//從結(jié)果集中移除數(shù)據(jù)
orderGroupList.remove(j);
//根據(jù)訂單狀態(tài)將統(tǒng)計(jì)結(jié)果存入對(duì)應(yīng)的訂單狀態(tài)數(shù)組中
switch (orderGroup.getProductOrder_status()) {
case 0:
//未付款訂單
orderUnpaidArray[i] = orderGroup.getProductOrder_count();
break;
case 1:
//未發(fā)貨訂單
orderNotShippedArray[i] = orderGroup.getProductOrder_count();
break;
case 2:
//未確認(rèn)訂單
orderUnconfirmedArray[i] = orderGroup.getProductOrder_count();
break;
case 3:
//交易成功訂單
orderSuccessArray[i] = orderGroup.getProductOrder_count();
break;
}
//累加當(dāng)前日期的訂單總數(shù)
orderCount += orderGroup.getProductOrder_count();
}
}
//將統(tǒng)計(jì)的訂單總數(shù)存入總交易訂單數(shù)統(tǒng)計(jì)數(shù)組
orderTotalArray[i] = orderCount;
}
logger.info("返回結(jié)果集map");
jsonObject.put("orderTotalArray", orderTotalArray);
jsonObject.put("orderUnpaidArray", orderUnpaidArray);
jsonObject.put("orderNotShippedArray", orderNotShippedArray);
jsonObject.put("orderUnconfirmedArray", orderUnconfirmedArray);
jsonObject.put("orderSuccessArray", orderSuccessArray);
jsonObject.put("dateStr",dateStr);
return jsonObject;
}
}
商品信息控制層:
/**
* @author yy
*/
@Controller
@RequestMapping("/admin")
public class NewBeeMallGoodsController {
@Resource
private NewBeeMallGoodsService newBeeMallGoodsService;
@Resource
private NewBeeMallCategoryService newBeeMallCategoryService;
@GetMapping("/goods")
public String goodsPage(HttpServletRequest request) {
request.setAttribute("path", "newbee_mall_goods");
return "admin/newbee_mall_goods";
}
@GetMapping("/goods/edit")
public String edit(HttpServletRequest request) {
request.setAttribute("path", "edit");
//查詢所有的一級(jí)分類
List<GoodsCategory> firstLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(0L), NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel());
if (!CollectionUtils.isEmpty(firstLevelCategories)) {
//查詢一級(jí)分類列表中第一個(gè)實(shí)體的所有二級(jí)分類
List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(firstLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
if (!CollectionUtils.isEmpty(secondLevelCategories)) {
//查詢二級(jí)分類列表中第一個(gè)實(shí)體的所有三級(jí)分類
List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
request.setAttribute("firstLevelCategories", firstLevelCategories);
request.setAttribute("secondLevelCategories", secondLevelCategories);
request.setAttribute("thirdLevelCategories", thirdLevelCategories);
request.setAttribute("path", "goods-edit");
return "admin/newbee_mall_goods_edit";
}
}
return "error/error_5xx";
}
@GetMapping("/goods/edit/{goodsId}")
public String edit(HttpServletRequest request, @PathVariable("goodsId") Long goodsId) {
request.setAttribute("path", "edit");
NewBeeMallGoods newBeeMallGoods = newBeeMallGoodsService.getNewBeeMallGoodsById(goodsId);
if (newBeeMallGoods == null) {
return "error/error_400";
}
if (newBeeMallGoods.getGoodsCategoryId() > 0) {
if (newBeeMallGoods.getGoodsCategoryId() != null || newBeeMallGoods.getGoodsCategoryId() > 0) {
//有分類字段則查詢相關(guān)分類數(shù)據(jù)返回給前端以供分類的三級(jí)聯(lián)動(dòng)顯示
GoodsCategory currentGoodsCategory = newBeeMallCategoryService.getGoodsCategoryById(newBeeMallGoods.getGoodsCategoryId());
//商品表中存儲(chǔ)的分類id字段為三級(jí)分類的id,不為三級(jí)分類則是錯(cuò)誤數(shù)據(jù)
if (currentGoodsCategory != null && currentGoodsCategory.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel()) {
//查詢所有的一級(jí)分類
List<GoodsCategory> firstLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(0L), NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel());
//根據(jù)parentId查詢當(dāng)前parentId下所有的三級(jí)分類
List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(currentGoodsCategory.getParentId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
//查詢當(dāng)前三級(jí)分類的父級(jí)二級(jí)分類
GoodsCategory secondCategory = newBeeMallCategoryService.getGoodsCategoryById(currentGoodsCategory.getParentId());
if (secondCategory != null) {
//根據(jù)parentId查詢當(dāng)前parentId下所有的二級(jí)分類
List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondCategory.getParentId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
//查詢當(dāng)前二級(jí)分類的父級(jí)一級(jí)分類
GoodsCategory firestCategory = newBeeMallCategoryService.getGoodsCategoryById(secondCategory.getParentId());
if (firestCategory != null) {
//所有分類數(shù)據(jù)都得到之后放到request對(duì)象中供前端讀取
request.setAttribute("firstLevelCategories", firstLevelCategories);
request.setAttribute("secondLevelCategories", secondLevelCategories);
request.setAttribute("thirdLevelCategories", thirdLevelCategories);
request.setAttribute("firstLevelCategoryId", firestCategory.getCategoryId());
request.setAttribute("secondLevelCategoryId", secondCategory.getCategoryId());
request.setAttribute("thirdLevelCategoryId", currentGoodsCategory.getCategoryId());
}
}
}
}
}
if (newBeeMallGoods.getGoodsCategoryId() == 0) {
//查詢所有的一級(jí)分類
List<GoodsCategory> firstLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(0L), NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel());
if (!CollectionUtils.isEmpty(firstLevelCategories)) {
//查詢一級(jí)分類列表中第一個(gè)實(shí)體的所有二級(jí)分類
List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(firstLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
if (!CollectionUtils.isEmpty(secondLevelCategories)) {
//查詢二級(jí)分類列表中第一個(gè)實(shí)體的所有三級(jí)分類
List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
request.setAttribute("firstLevelCategories", firstLevelCategories);
request.setAttribute("secondLevelCategories", secondLevelCategories);
request.setAttribute("thirdLevelCategories", thirdLevelCategories);
}
}
}
request.setAttribute("goods", newBeeMallGoods);
request.setAttribute("path", "goods-edit");
return "admin/newbee_mall_goods_edit";
}
/**
* 列表
*/
@RequestMapping(value = "/goods/list", method = RequestMethod.GET)
@ResponseBody
public Result list(@RequestParam Map<String, Object> params) {
if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
PageQueryUtil pageUtil = new PageQueryUtil(params);
return ResultGenerator.genSuccessResult(newBeeMallGoodsService.getNewBeeMallGoodsPage(pageUtil));
}
/**
* 添加
*/
@RequestMapping(value = "/goods/save", method = RequestMethod.POST)
@ResponseBody
public Result save(@RequestBody NewBeeMallGoods newBeeMallGoods) {
if (StringUtils.isEmpty(newBeeMallGoods.getGoodsName())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsIntro())
|| StringUtils.isEmpty(newBeeMallGoods.getTag())
|| Objects.isNull(newBeeMallGoods.getOriginalPrice())
|| Objects.isNull(newBeeMallGoods.getGoodsCategoryId())
|| Objects.isNull(newBeeMallGoods.getSellingPrice())
|| Objects.isNull(newBeeMallGoods.getStockNum())
|| Objects.isNull(newBeeMallGoods.getGoodsSellStatus())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsCoverImg())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsDetailContent())) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
String result = newBeeMallGoodsService.saveNewBeeMallGoods(newBeeMallGoods);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 修改
*/
@RequestMapping(value = "/goods/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody NewBeeMallGoods newBeeMallGoods) {
if (Objects.isNull(newBeeMallGoods.getGoodsId())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsName())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsIntro())
|| StringUtils.isEmpty(newBeeMallGoods.getTag())
|| Objects.isNull(newBeeMallGoods.getOriginalPrice())
|| Objects.isNull(newBeeMallGoods.getSellingPrice())
|| Objects.isNull(newBeeMallGoods.getGoodsCategoryId())
|| Objects.isNull(newBeeMallGoods.getStockNum())
|| Objects.isNull(newBeeMallGoods.getGoodsSellStatus())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsCoverImg())
|| StringUtils.isEmpty(newBeeMallGoods.getGoodsDetailContent())) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
String result = newBeeMallGoodsService.updateNewBeeMallGoods(newBeeMallGoods);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 詳情
*/
@GetMapping("/goods/info/{id}")
@ResponseBody
public Result info(@PathVariable("id") Long id) {
NewBeeMallGoods goods = newBeeMallGoodsService.getNewBeeMallGoodsById(id);
if (goods == null) {
return ResultGenerator.genFailResult(ServiceResultEnum.DATA_NOT_EXIST.getResult());
}
return ResultGenerator.genSuccessResult(goods);
}
/**
* 批量修改銷售狀態(tài)
*/
@RequestMapping(value = "/goods/status/{sellStatus}", method = RequestMethod.PUT)
@ResponseBody
public Result delete(@RequestBody Long[] ids, @PathVariable("sellStatus") int sellStatus) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
if (sellStatus != Constants.SELL_STATUS_UP && sellStatus != Constants.SELL_STATUS_DOWN) {
return ResultGenerator.genFailResult("狀態(tài)異常!");
}
if (newBeeMallGoodsService.batchUpdateSellStatus(ids, sellStatus)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("修改失敗");
}
}
}
商品分類控制器:
/**
* @author yy
*/
@Controller
@RequestMapping("/admin")
public class NewBeeMallGoodsCategoryController {
@Resource
private NewBeeMallCategoryService newBeeMallCategoryService;
@GetMapping("/categories")
public String categoriesPage(HttpServletRequest request, @RequestParam("categoryLevel") Byte categoryLevel, @RequestParam("parentId") Long parentId, @RequestParam("backParentId") Long backParentId) {
if (categoryLevel == null || categoryLevel < 1 || categoryLevel > 3) {
return "error/error_5xx";
}
request.setAttribute("path", "newbee_mall_category");
request.setAttribute("parentId", parentId);
request.setAttribute("backParentId", backParentId);
request.setAttribute("categoryLevel", categoryLevel);
return "admin/newbee_mall_category";
}
/**
* 列表
*/
@RequestMapping(value = "/categories/list", method = RequestMethod.GET)
@ResponseBody
public Result list(@RequestParam Map<String, Object> params) {
if (StringUtils.isEmpty(params.get("page")) || StringUtils.isEmpty(params.get("limit"))) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
PageQueryUtil pageUtil = new PageQueryUtil(params);
return ResultGenerator.genSuccessResult(newBeeMallCategoryService.getCategorisPage(pageUtil));
}
/**
* 列表
*/
@RequestMapping(value = "/categories/listForSelect", method = RequestMethod.GET)
@ResponseBody
public Result listForSelect(@RequestParam("categoryId") Long categoryId) {
if (categoryId == null || categoryId < 1) {
return ResultGenerator.genFailResult("缺少參數(shù)!");
}
GoodsCategory category = newBeeMallCategoryService.getGoodsCategoryById(categoryId);
//既不是一級(jí)分類也不是二級(jí)分類則為不返回?cái)?shù)據(jù)
if (category == null || category.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel()) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
Map categoryResult = new HashMap(2);
if (category.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_ONE.getLevel()) {
//如果是一級(jí)分類則返回當(dāng)前一級(jí)分類下的所有二級(jí)分類,以及二級(jí)分類列表中第一條數(shù)據(jù)下的所有三級(jí)分類列表
//查詢一級(jí)分類列表中第一個(gè)實(shí)體的所有二級(jí)分類
List<GoodsCategory> secondLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(categoryId), NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel());
if (!CollectionUtils.isEmpty(secondLevelCategories)) {
//查詢二級(jí)分類列表中第一個(gè)實(shí)體的所有三級(jí)分類
List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(secondLevelCategories.get(0).getCategoryId()), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
categoryResult.put("secondLevelCategories", secondLevelCategories);
categoryResult.put("thirdLevelCategories", thirdLevelCategories);
}
}
if (category.getCategoryLevel() == NewBeeMallCategoryLevelEnum.LEVEL_TWO.getLevel()) {
//如果是二級(jí)分類則返回當(dāng)前分類下的所有三級(jí)分類列表
List<GoodsCategory> thirdLevelCategories = newBeeMallCategoryService.selectByLevelAndParentIdsAndNumber(Collections.singletonList(categoryId), NewBeeMallCategoryLevelEnum.LEVEL_THREE.getLevel());
categoryResult.put("thirdLevelCategories", thirdLevelCategories);
}
return ResultGenerator.genSuccessResult(categoryResult);
}
/**
* 添加
*/
@RequestMapping(value = "/categories/save", method = RequestMethod.POST)
@ResponseBody
public Result save(@RequestBody GoodsCategory goodsCategory) {
if (Objects.isNull(goodsCategory.getCategoryLevel())
|| StringUtils.isEmpty(goodsCategory.getCategoryName())
|| Objects.isNull(goodsCategory.getParentId())
|| Objects.isNull(goodsCategory.getCategoryRank())) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
String result = newBeeMallCategoryService.saveCategory(goodsCategory);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 修改
*/
@RequestMapping(value = "/categories/update", method = RequestMethod.POST)
@ResponseBody
public Result update(@RequestBody GoodsCategory goodsCategory) {
if (Objects.isNull(goodsCategory.getCategoryId())
|| Objects.isNull(goodsCategory.getCategoryLevel())
|| StringUtils.isEmpty(goodsCategory.getCategoryName())
|| Objects.isNull(goodsCategory.getParentId())
|| Objects.isNull(goodsCategory.getCategoryRank())) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
String result = newBeeMallCategoryService.updateGoodsCategory(goodsCategory);
if (ServiceResultEnum.SUCCESS.getResult().equals(result)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult(result);
}
}
/**
* 詳情
*/
@GetMapping("/categories/info/{id}")
@ResponseBody
public Result info(@PathVariable("id") Long id) {
GoodsCategory goodsCategory = newBeeMallCategoryService.getGoodsCategoryById(id);
if (goodsCategory == null) {
return ResultGenerator.genFailResult("未查詢到數(shù)據(jù)");
}
return ResultGenerator.genSuccessResult(goodsCategory);
}
/**
* 分類刪除
*/
@RequestMapping(value = "/categories/delete", method = RequestMethod.POST)
@ResponseBody
public Result delete(@RequestBody Integer[] ids) {
if (ids.length < 1) {
return ResultGenerator.genFailResult("參數(shù)異常!");
}
if (newBeeMallCategoryService.deleteBatch(ids)) {
return ResultGenerator.genSuccessResult();
} else {
return ResultGenerator.genFailResult("刪除失敗");
}
}
}
到此這篇關(guān)于Java女裝商城系統(tǒng)的實(shí)現(xiàn)流程的文章就介紹到這了,更多相關(guān)Java 女裝商城系統(tǒng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Java 實(shí)戰(zhàn)項(xiàng)目錘煉之在線購(gòu)書商城系統(tǒng)的實(shí)現(xiàn)流程
- Java畢業(yè)設(shè)計(jì)實(shí)戰(zhàn)之在線蛋糕銷售商城的實(shí)現(xiàn)
- Java畢業(yè)設(shè)計(jì)實(shí)戰(zhàn)之線上水果超市商城的實(shí)現(xiàn)
- Java畢業(yè)設(shè)計(jì)實(shí)戰(zhàn)項(xiàng)目之寵物商城系統(tǒng)的實(shí)現(xiàn)流程
- Java畢業(yè)設(shè)計(jì)實(shí)戰(zhàn)項(xiàng)目之在線服裝銷售商城系統(tǒng)的實(shí)現(xiàn)流程
- Java實(shí)戰(zhàn)花店商城系統(tǒng)的實(shí)現(xiàn)流程
- Java實(shí)現(xiàn)茶葉售賣商城系統(tǒng)(java+SSM+JSP+EasyUi+mysql)
- Java 仿天貓服裝商城系統(tǒng)的實(shí)現(xiàn)流程
- Java畢業(yè)設(shè)計(jì)實(shí)戰(zhàn)之二手書商城系統(tǒng)的實(shí)現(xiàn)
相關(guān)文章
springSecurity自定義登錄接口和JWT認(rèn)證過(guò)濾器的流程
這篇文章主要介紹了springSecurity自定義登陸接口和JWT認(rèn)證過(guò)濾器的相關(guān)資料,本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-12-12
Java設(shè)計(jì)模式之命令模式_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
命令模式就是對(duì)命令的封裝,下文中給大家介紹了命令模式類圖中的基本結(jié)構(gòu),對(duì)java設(shè)計(jì)模式之命令模式相關(guān)知識(shí)感興趣的朋友一起看看吧2017-08-08
javaweb圖書商城設(shè)計(jì)之購(gòu)物車模塊(3)
這篇文章主要為大家詳細(xì)介紹了javaweb圖書商城設(shè)計(jì)之購(gòu)物車模塊的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11
Java中的synchronized有幾種加鎖方式(實(shí)例詳解)
在Java中,synchronized關(guān)鍵字提供了內(nèi)置的支持來(lái)實(shí)現(xiàn)同步訪問(wèn)共享資源,以避免并發(fā)問(wèn)題,這篇文章主要介紹了java的synchronized有幾種加鎖方式,需要的朋友可以參考下2024-05-05
Javaweb EL自定義函數(shù)開(kāi)發(fā)及代碼實(shí)例
這篇文章主要介紹了Javaweb EL自定義函數(shù)開(kāi)發(fā)及代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06

