增加了app 版本更新接口, 店铺分类接口
This commit is contained in:
parent
f7241da8ed
commit
fa087d32ad
@ -26,7 +26,7 @@ import javax.annotation.Resource;
|
||||
@Api(tags = "店铺分类(类目),此类决定商家分成比例")
|
||||
@RestController
|
||||
@RequestMapping("/admin/shop/store/biz-category")
|
||||
public class ShopStoreBizCategoryController extends BaseControllerImpl {
|
||||
public class ShopStoreBizCategoryAdminController extends BaseControllerImpl {
|
||||
|
||||
@Resource
|
||||
private ShopStoreBizCategoryService shopStoreBizCategoryService;
|
||||
@ -43,12 +43,20 @@ public class ShopStoreBizCategoryController extends BaseControllerImpl {
|
||||
|
||||
@ApiOperation(value = "新增店铺分类(类目)", notes = "新增店铺分类(类目)")
|
||||
@RequestMapping(value = "/add/new", method = RequestMethod.POST)
|
||||
public CommonResult shopStoreBusinessCategoryList(@RequestBody(required = false) JSONObject params) {
|
||||
String keyword = "";
|
||||
if (params != null && StrUtil.isNotBlank(params.getStr("keyword"))) {
|
||||
keyword = params.getStr("keyword");
|
||||
}
|
||||
return CommonResult.success(shopStoreBizCategoryService.selectParentListWithChildren(keyword));
|
||||
public CommonResult shopStoreBusinessCategoryAddNew(@RequestBody JSONObject params) {
|
||||
return shopStoreBizCategoryService.addNew(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改店铺分类(类目)", notes = "修改店铺分类(类目)")
|
||||
@RequestMapping(value = "/modify", method = RequestMethod.POST)
|
||||
public CommonResult shopStoreBusinessCategoryModify(@RequestBody JSONObject params) {
|
||||
return shopStoreBizCategoryService.modify(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "屏蔽店铺分类(类目)", notes = "屏蔽店铺分类(类目)")
|
||||
@RequestMapping(value = "/status/modify", method = RequestMethod.POST)
|
||||
public CommonResult shopStoreBusinessCategoryDisable(@RequestBody JSONObject params) {
|
||||
return shopStoreBizCategoryService.modifyStatus(params);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package com.suisung.mall.shop.store.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreBizCategory;
|
||||
import com.suisung.mall.common.modules.store.dto.ShopStoreBizCategoryDTO;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
@ -24,4 +26,36 @@ public interface ShopStoreBizCategoryService extends IBaseService<ShopStoreBizCa
|
||||
* @return
|
||||
*/
|
||||
List<ShopStoreBizCategoryDTO> selectParentListWithChildren(String keyword);
|
||||
|
||||
/**
|
||||
* 新增店铺营业分类信息
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
CommonResult addNew(JSONObject params);
|
||||
|
||||
/**
|
||||
* 修改店铺营业分类信息
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
CommonResult modify(JSONObject params);
|
||||
|
||||
/**
|
||||
* 删除店铺营业分类信息
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
CommonResult modifyStatus(JSONObject params);
|
||||
|
||||
/**
|
||||
* 根据分类编号查询店铺营业分类信息是否存在
|
||||
*
|
||||
* @param categoryCode
|
||||
* @return
|
||||
*/
|
||||
Boolean isExists(String categoryCode);
|
||||
}
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
package com.suisung.mall.shop.store.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreBizCategory;
|
||||
import com.suisung.mall.common.modules.store.dto.ShopStoreBizCategoryDTO;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.store.mapper.ShopStoreBizCategoryMapper;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBizCategoryService;
|
||||
@ -35,4 +42,155 @@ public class ShopStoreBizCategoryServiceImpl extends BaseServiceImpl<ShopStoreBi
|
||||
public List<ShopStoreBizCategoryDTO> selectParentListWithChildren(String keyword) {
|
||||
return shopStoreBizCategoryMapper.selectParentListWithChildren(keyword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增店铺营业分类信息
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult addNew(JSONObject params) {
|
||||
String userId = "0";
|
||||
|
||||
// UserDto user = getCurrentUser();
|
||||
// if (!user.isAdmin()) {
|
||||
// return CommonResult.failed("权限不足!");
|
||||
// }
|
||||
// userId = user.getId().toString();
|
||||
|
||||
if (params == null) {
|
||||
return CommonResult.failed(I18nUtil._("参数不能为空"));
|
||||
}
|
||||
|
||||
if (!params.containsKey("category_code") || !params.containsKey("category_name")) {
|
||||
return CommonResult.failed(I18nUtil._("缺少必要参数"));
|
||||
}
|
||||
|
||||
ShopStoreBizCategory record = JSONUtil.toBean(params, ShopStoreBizCategory.class);
|
||||
if (record == null) {
|
||||
return CommonResult.failed(I18nUtil._("参数转化错误"));
|
||||
}
|
||||
|
||||
if (!params.containsKey("parent_category_code") || StrUtil.isBlank(params.getStr("parent_category_code"))) {
|
||||
record.setParent_category_code("0");
|
||||
}
|
||||
|
||||
// 判断 category_code 是不是存在?
|
||||
if (isExists(record.getCategory_code())) {
|
||||
return CommonResult.failed(I18nUtil._("分类编号已存在!"));
|
||||
}
|
||||
|
||||
record.setCreated_by(userId);
|
||||
record.setUpdated_by(userId);
|
||||
|
||||
boolean success = save(record);
|
||||
if (!success) {
|
||||
return CommonResult.failed(I18nUtil._("保存失败!"));
|
||||
}
|
||||
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改店铺营业分类信息
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult modify(JSONObject params) {
|
||||
String userId = "0";
|
||||
|
||||
// UserDto user = getCurrentUser();
|
||||
// if (!user.isAdmin()) {
|
||||
// return CommonResult.failed("权限不足!");
|
||||
// }
|
||||
// userId = user.getId().toString();
|
||||
|
||||
if (params == null) {
|
||||
return CommonResult.failed(I18nUtil._("参数不能为空"));
|
||||
}
|
||||
|
||||
if (!params.containsKey("id")) {
|
||||
return CommonResult.failed(I18nUtil._("缺少必要参数"));
|
||||
}
|
||||
|
||||
ShopStoreBizCategory record = JSONUtil.toBean(params, ShopStoreBizCategory.class);
|
||||
if (record == null) {
|
||||
return CommonResult.failed(I18nUtil._("参数转化错误"));
|
||||
}
|
||||
|
||||
record.setUpdated_by(userId);
|
||||
if (record.getStatus().equals(CommonConstant.Enable)) {
|
||||
record.setStatus(CommonConstant.Disable2);
|
||||
}
|
||||
|
||||
boolean success = updateById(record);
|
||||
if (!success) {
|
||||
return CommonResult.failed(I18nUtil._("保存失败!"));
|
||||
}
|
||||
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除店铺营业分类信息
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult modifyStatus(JSONObject params) {
|
||||
String userId = "0";
|
||||
|
||||
// UserDto user = getCurrentUser();
|
||||
// if (!user.isAdmin()) {
|
||||
// return CommonResult.failed("权限不足!");
|
||||
// }
|
||||
// userId = user.getId().toString();
|
||||
|
||||
if (params == null) {
|
||||
return CommonResult.failed(I18nUtil._("参数不能为空"));
|
||||
}
|
||||
|
||||
if (!params.containsKey("id") || !params.containsKey("status")) {
|
||||
return CommonResult.failed(I18nUtil._("缺少必要参数"));
|
||||
}
|
||||
|
||||
Long id = params.getLong("id");
|
||||
Integer status = params.getInt("status");
|
||||
if (!CommonConstant.Enable.equals(status)) {
|
||||
status = CommonConstant.Disable2;
|
||||
}
|
||||
|
||||
ShopStoreBizCategory record = new ShopStoreBizCategory();
|
||||
record.setStatus(status);
|
||||
record.setUpdated_by(userId);
|
||||
record.setId(id);
|
||||
|
||||
boolean success = updateById(record);
|
||||
if (!success) {
|
||||
return CommonResult.failed(I18nUtil._("保存失败!"));
|
||||
}
|
||||
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类编号查询店铺营业分类信息是否存在
|
||||
*
|
||||
* @param categoryCode
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean isExists(String categoryCode) {
|
||||
if (StrUtil.isBlank(categoryCode)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
QueryWrapper<ShopStoreBizCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("category_code", categoryCode).select("id");
|
||||
return count(queryWrapper) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,8 +64,8 @@
|
||||
c.updated_at AS child_updated_at
|
||||
FROM shop_store_biz_category p
|
||||
LEFT JOIN
|
||||
shop_store_biz_category c ON p.category_code = c.parent_category_code
|
||||
WHERE p.parent_category_code = 0
|
||||
shop_store_biz_category c ON p.category_code = c.parent_category_code and c.status = 1
|
||||
WHERE p.parent_category_code = 0 and p.status = 1
|
||||
<if test="keyword != null and keyword != ''">
|
||||
AND (p.category_code LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR p.category_name LIKE CONCAT('%', #{keyword}, '%')
|
||||
@ -74,6 +74,6 @@
|
||||
OR c.category_name LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR c.description LIKE CONCAT('%', #{keyword}, '%'))
|
||||
</if>
|
||||
ORDER BY p.seq asc, c.seq asc
|
||||
ORDER BY p.seq asc, c.seq asc, p.id asc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user