记得上下班打卡 | git大法好,push需谨慎

Commit 814c120a authored by 张国柄's avatar 张国柄

~admin:标签分类管理+MONGO处理;

parent bc7e20f9
package com.liquidnet.service.goblin.dto.vo;
import com.liquidnet.service.goblin.entity.GoblinSelfGoodsCategory;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -68,4 +69,16 @@ public class GoblinSelfGoodsCategoryVo implements Serializable, Cloneable {
return new GoblinSelfGoodsCategoryVo();
}
}
public GoblinSelfGoodsCategoryVo copy(GoblinSelfGoodsCategory source) {
if (null == source) return this;
this.setCateId(source.getCateId());
this.setName(source.getName());
this.setIcon(source.getIcon());
this.setSort(source.getSort());
this.setGrade(source.getGrade());
this.setCatePid(source.getCatePid());
this.setNeIsbn(source.getNeIsbn());
return this;
}
}
package com.liquidnet.service.goblin.dto.vo;
import com.liquidnet.service.goblin.entity.GoblinSelfTag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -34,4 +35,16 @@ public class GoblinSelfTagVo implements Serializable, Cloneable {
return new GoblinSelfTagVo();
}
}
public GoblinSelfTagVo copy(GoblinSelfTag source) {
if (null == source) return this;
this.setTagId(source.getTagId());
this.setTagName(source.getTagName());
this.setTagDesc(source.getTagDesc());
this.setTagPic(source.getTagPic());
this.setTagType(source.getTagType());
this.setTagBelong(source.getTagBelong());
this.setDelFlg(source.getDelFlg());
return this;
}
}
package com.liquidnet.client.admin.web.controller.zhengzai.goblin;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.liquidnet.client.admin.common.annotation.Log;
import com.liquidnet.client.admin.common.core.controller.BaseController;
......@@ -16,13 +15,11 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
......@@ -64,29 +61,26 @@ public class GoblinSelfCategoryController extends BaseController {
// TODO: 2022/1/14 zhanggb valid
selfGoodsCategory.setCateId(IDGenerator.nextMilliId2());
selfGoodsCategory.setDelFlg("0");
if (null == selfGoodsCategory.getSort()) {
selfGoodsCategory.setSort(1);
}
selfGoodsCategory.setCounts(0);
selfGoodsCategory.setCreatedBy(ShiroUtils.getLoginName());
selfGoodsCategory.setCreatedAt(LocalDateTime.now());
return toAjax(goblinSelfGoodsCategoryService.save(selfGoodsCategory));
return toAjax(goblinSelfGoodsCategoryService.addSave(selfGoodsCategory));
}
@Log(title = "店铺管理:商品分类:删除", businessType = BusinessType.DELETE)
@RequiresPermissions("goblin:category:rmv")
@PostMapping("rmv")
@PostMapping("rmv/{cateId}")
@ResponseBody
public AjaxResult rmv(String cateIds) {
String loginName = ShiroUtils.getLoginName();
LocalDateTime now = LocalDateTime.now();
String[] cateIdArr = Convert.toStrArray(cateIds);
return toAjax(goblinSelfGoodsCategoryService.update(Wrappers.lambdaUpdate(GoblinSelfGoodsCategory.class)
.in(GoblinSelfGoodsCategory::getCateId, cateIdArr)
.in(GoblinSelfGoodsCategory::getCatePid, cateIdArr)
.set(GoblinSelfGoodsCategory::getDelFlg, "1")
.set(GoblinSelfGoodsCategory::getUpdatedBy, loginName)
.set(GoblinSelfGoodsCategory::getUpdatedAt, now)
.set(GoblinSelfGoodsCategory::getDeletedBy, loginName)
.set(GoblinSelfGoodsCategory::getDeletedAt, now)
));
public AjaxResult rmv(@PathVariable("cateId") String cateId) {
if (StringUtils.isBlank(cateId)) {
return AjaxResult.warn("请选择至少一条数据操作");
}
return toAjax(goblinSelfGoodsCategoryService.remove(Convert.toStrArray(cateId)));
}
}
package com.liquidnet.client.admin.web.controller.zhengzai.goblin;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.client.admin.common.annotation.Log;
import com.liquidnet.client.admin.common.core.controller.BaseController;
......@@ -22,7 +21,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
......@@ -33,6 +31,7 @@ import java.util.List;
@RequestMapping("goblin/extag")
public class GoblinSelfExtagController extends BaseController {
private final String prefix = "zhengzai/goblin/extag";
private final String tagBelong = "1";
@Autowired
IGoblinSelfTagService goblinSelfTagService;
......@@ -52,7 +51,7 @@ public class GoblinSelfExtagController extends BaseController {
private List<GoblinSelfTag> listQuery(GoblinSelfTag selfTag) {
LambdaQueryWrapper<GoblinSelfTag> lambdaQueryWrapper = Wrappers.lambdaQuery(GoblinSelfTag.class);
lambdaQueryWrapper.eq(GoblinSelfTag::getDelFlg, "0");
lambdaQueryWrapper.eq(GoblinSelfTag::getTagBelong, "1");
lambdaQueryWrapper.eq(GoblinSelfTag::getTagBelong, tagBelong);
if (StringUtils.isNotBlank(selfTag.getTagName())) {
lambdaQueryWrapper.like(GoblinSelfTag::getTagName, selfTag.getTagName());
}
......@@ -99,19 +98,20 @@ public class GoblinSelfExtagController extends BaseController {
selfTag.setTagName(tagName);
selfTag.setTagPic(tagPic);
selfTag.setTagType(tagType);
selfTag.setTagBelong("1");
selfTag.setTagBelong(tagBelong);
selfTag.setDelFlg("0");
return toAjax(goblinSelfTagService.save(selfTag));
return toAjax(goblinSelfTagService.addSave(selfTag));
}
@Log(title = "店铺管理:音乐人标签库:删除", businessType = BusinessType.DELETE)
@RequiresPermissions("goblin:extag:rmv")
@PostMapping("rmv")
@PostMapping("rmv/{extagId}")
@ResponseBody
public AjaxResult rmv(String extagIds) {
return toAjax(goblinSelfTagService.update(Wrappers.lambdaUpdate(GoblinSelfTag.class)
.in(GoblinSelfTag::getTagId, Convert.toStrArray(extagIds))
.set(GoblinSelfTag::getDelFlg, "1")
));
public AjaxResult rmv(@PathVariable("extagId") String extagId) {
if (StringUtils.isBlank(extagId)) {
return AjaxResult.warn("请选择至少一条数据操作");
}
return toAjax(goblinSelfTagService.remove(Convert.toStrArray(extagId), tagBelong));
}
}
package com.liquidnet.client.admin.web.controller.zhengzai.goblin;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.liquidnet.client.admin.common.annotation.Log;
import com.liquidnet.client.admin.common.core.controller.BaseController;
......@@ -9,14 +8,9 @@ import com.liquidnet.client.admin.common.core.domain.AjaxResult;
import com.liquidnet.client.admin.common.core.page.TableDataInfo;
import com.liquidnet.client.admin.common.core.text.Convert;
import com.liquidnet.client.admin.common.enums.BusinessType;
import com.liquidnet.client.admin.common.utils.poi.ExcelUtil;
import com.liquidnet.client.admin.zhengzai.goblin.dto.GoblinSelfExtagExcelDto;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinSelfGoodsCategoryService;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinSelfTagService;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.goblin.entity.GoblinSelfTag;
import com.liquidnet.service.goblin.entity.GoblinStoreCertification;
import com.liquidnet.service.goblin.entity.GoblinStoreInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -25,10 +19,8 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@Api(tags = "标签库")
......@@ -36,6 +28,7 @@ import java.util.List;
@RequestMapping("goblin/tag")
public class GoblinSelfTagController extends BaseController {
private final String prefix = "zhengzai/goblin/tag";
private final String tagBelong = "0";
@Autowired
IGoblinSelfTagService goblinSelfTagService;
......@@ -55,7 +48,7 @@ public class GoblinSelfTagController extends BaseController {
private List<GoblinSelfTag> listQuery(GoblinSelfTag selfTag) {
LambdaQueryWrapper<GoblinSelfTag> lambdaQueryWrapper = Wrappers.lambdaQuery(GoblinSelfTag.class);
lambdaQueryWrapper.eq(GoblinSelfTag::getDelFlg, "0");
lambdaQueryWrapper.eq(GoblinSelfTag::getTagBelong, "0");
lambdaQueryWrapper.eq(GoblinSelfTag::getTagBelong, tagBelong);
if (StringUtils.isNotBlank(selfTag.getTagName())) {
lambdaQueryWrapper.like(GoblinSelfTag::getTagName, selfTag.getTagName());
}
......@@ -101,9 +94,11 @@ public class GoblinSelfTagController extends BaseController {
selfTag.setTagName(tagName);
selfTag.setTagPic(tagPic);
selfTag.setTagType("0");
selfTag.setTagBelong("0");
selfTag.setDelFlg("0");
selfTag.setCounts(0);
selfTag.setTagBelong(tagBelong);
return toAjax(goblinSelfTagService.save(selfTag));
return toAjax(goblinSelfTagService.addSave(selfTag));
}
@ApiOperation(value = "编辑")
......@@ -112,25 +107,19 @@ public class GoblinSelfTagController extends BaseController {
@PostMapping("editSave")
@ResponseBody
public AjaxResult editSave(GoblinSelfTag selfTag) {
selfTag.setTagBelong(tagBelong);
// TODO: 2022/1/13 zhanggb valid
LambdaUpdateWrapper<GoblinSelfTag> updateWrapper = Wrappers.lambdaUpdate(GoblinSelfTag.class);
updateWrapper.eq(GoblinSelfTag::getTagId, selfTag.getTagId());
updateWrapper.eq(GoblinSelfTag::getTagBelong, "1");
updateWrapper.set(GoblinSelfTag::getTagType, selfTag.getTagType());
updateWrapper.set(GoblinSelfTag::getTagName, selfTag.getTagName());
updateWrapper.set(GoblinSelfTag::getTagPic, selfTag.getTagPic());
return toAjax(goblinSelfTagService.update(updateWrapper));
return toAjax(goblinSelfTagService.editSave(selfTag));
}
@Log(title = "店铺管理:标签库:删除", businessType = BusinessType.DELETE)
@RequiresPermissions("goblin:tag:rmv")
@PostMapping("rmv")
@PostMapping("rmv/{tagId}")
@ResponseBody
public AjaxResult rmv(String tagIds) {
return toAjax(goblinSelfTagService.update(Wrappers.lambdaUpdate(GoblinSelfTag.class)
.in(GoblinSelfTag::getTagId, Convert.toStrArray(tagIds))
.set(GoblinSelfTag::getDelFlg, "1")
));
public AjaxResult rmv(@PathVariable("tagId") String tagId) {
if (StringUtils.isBlank(tagId)) {
return AjaxResult.warn("请选择至少一条数据操作");
}
return toAjax(goblinSelfTagService.remove(Convert.toStrArray(tagId), tagBelong));
}
}
......@@ -35,9 +35,9 @@
<a class="btn btn-success" onclick="" shiro:hasPermission="goblin:extag:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goblin:extag:rmv">
<i class="fa fa-remove"></i> 删除
</a>
<!-- <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goblin:extag:rmv">-->
<!-- <i class="fa fa-remove"></i> 删除-->
<!-- </a>-->
</div>
<div class="col-sm-12 select-table table-striped">
......@@ -48,11 +48,11 @@
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
var rmvFlg = [[${@permission.hasPermi('goblin:category:rmv')}]];
var prefix = ctx + "goblin/extag";
var prefix = ctx + "goblin/category";
$(function () {
var options = {
url: prefix + "/list",
removeUrl: prefix + "/rmv",
removeUrl: prefix + "/rmv/{id}",
sortName: "mid",
modalName: "商品分类",
columns: [{
......
......@@ -194,9 +194,9 @@
<a class="btn btn-success" id="button-open-10" shiro:hasPermission="goblin:extag:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goblin:extag:rmv">
<i class="fa fa-remove"></i> 删除
</a>
<!-- <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goblin:extag:rmv">-->
<!-- <i class="fa fa-remove"></i> 删除-->
<!-- </a>-->
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="goblin:extag:export">
<i class="fa fa-download"></i> 导出
</a>
......@@ -274,7 +274,7 @@
})
var options = {
url: prefix + "/list",
removeUrl: prefix + "/rmv",
removeUrl: prefix + "/rmv/{id}",
exportUrl: prefix + "/export",
sortName: "mid desc",
modalName: "音乐人标签库",
......
......@@ -169,9 +169,9 @@
<a class="btn btn-success" id="button-open-10" shiro:hasPermission="goblin:extag:add">
<i class="fa fa-plus"></i> 新增
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goblin:extag:rmv">
<i class="fa fa-remove"></i> 删除
</a>
<!-- <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="goblin:extag:rmv">-->
<!-- <i class="fa fa-remove"></i> 删除-->
<!-- </a>-->
</div>
<div class="col-sm-12 select-table table-striped">
......@@ -234,7 +234,7 @@
})
var options = {
url: prefix + "/list",
removeUrl: prefix + "/rmv",
removeUrl: prefix + "/rmv/{id}",
sortName: "mid desc",
modalName: "标签库",
columns: [{
......@@ -259,8 +259,10 @@
title: '操作',
align: 'center',
formatter: function (value, row, index) {
var actions = `<a class="btn btn-success btn-xs ' + editFlg + '" href="javascript:void(0)" onclick="openMode('${row.tagId}','${row.tagName}','${row.tagPic}')"><i class="fa fa-edit"></i>编辑</a> <a class="btn btn-danger btn-xs ' + rmvFlg + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tagId + '\')"><i class="fa fa-trash"></i>删除</a>`;
return actions;
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlg + '" href="javascript:void(0)" onclick="openMode(\'' + row.tagId + '\',\'' + row.tagName + '\',\'' + row.tagPic + '\')"><i class="fa fa-edit"></i>编辑</a>');
actions.push('<a class="btn btn-danger btn-xs ' + rmvFlg + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tagId + '\')"><i class="fa fa-trash"></i>删除</a>');
return actions.join('');
}
}]
};
......
......@@ -17,4 +17,8 @@ import java.util.List;
public interface IGoblinSelfGoodsCategoryService extends IService<GoblinSelfGoodsCategory> {
List<GoblinSelfGoodsCategoryDto> listForForMultiGrade();
boolean addSave(GoblinSelfGoodsCategory selfGoodsCategory);
boolean remove(String[] cateIdArr);
}
package com.liquidnet.client.admin.zhengzai.goblin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liquidnet.service.goblin.entity.GoblinSelfGoodsCategory;
import com.liquidnet.service.goblin.entity.GoblinSelfTag;
/**
......@@ -13,4 +14,9 @@ import com.liquidnet.service.goblin.entity.GoblinSelfTag;
*/
public interface IGoblinSelfTagService extends IService<GoblinSelfTag> {
boolean addSave(GoblinSelfTag selfTag);
boolean editSave(GoblinSelfTag selfTag);
boolean remove(String[] tagIdArr, String tagBelong);
}
package com.liquidnet.client.admin.zhengzai.goblin.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.client.admin.common.utils.ShiroUtils;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinSelfGoodsCategoryService;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.dto.GoblinSelfGoodsCategoryDto;
import com.liquidnet.service.goblin.dto.vo.GoblinSelfGoodsCategoryVo;
import com.liquidnet.service.goblin.entity.GoblinSelfGoodsCategory;
import com.liquidnet.service.goblin.mapper.GoblinSelfGoodsCategoryMapper;
import com.mongodb.client.result.UpdateResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.List;
/**
......@@ -18,13 +31,60 @@ import java.util.List;
* @author liquidnet
* @since 2021-12-27
*/
@Slf4j
@Service
public class GoblinSelfGoodsCategoryServiceImpl extends ServiceImpl<GoblinSelfGoodsCategoryMapper, GoblinSelfGoodsCategory> implements IGoblinSelfGoodsCategoryService {
@Autowired
private GoblinSelfGoodsCategoryMapper goblinSelfGoodsCategoryMapper;
@Autowired
private MongoTemplate mongoTemplate;
@Override
public List<GoblinSelfGoodsCategoryDto> listForForMultiGrade() {
return goblinSelfGoodsCategoryMapper.listForForMultiGrade();
}
@Transactional
@Override
public boolean addSave(GoblinSelfGoodsCategory selfGoodsCategory) {
if (this.save(selfGoodsCategory)) {
mongoTemplate.insert(GoblinSelfGoodsCategoryVo.getNew().copy(selfGoodsCategory), GoblinSelfGoodsCategoryVo.class.getSimpleName());
// TODO: 2022/1/14 zhanggb redis
return true;
}
return false;
}
@Transactional
@Override
public boolean remove(String[] cateIdArr) {
List<String> cateIdList = goblinSelfGoodsCategoryMapper.listForMultiGradeCateId(cateIdArr);
if (CollectionUtils.isEmpty(cateIdList)) {
log.warn("店铺管理:商品分类:删除失败[cateIdArr={}]", JsonUtils.toJson(cateIdArr));
return false;
}
String loginName = ShiroUtils.getLoginName();
LocalDateTime now = LocalDateTime.now();
boolean rmvResultFlg = this.update(Wrappers.lambdaUpdate(GoblinSelfGoodsCategory.class)
.in(GoblinSelfGoodsCategory::getCateId, cateIdList.toArray())
.set(GoblinSelfGoodsCategory::getDelFlg, "1")
.set(GoblinSelfGoodsCategory::getUpdatedBy, loginName)
.set(GoblinSelfGoodsCategory::getUpdatedAt, now)
.set(GoblinSelfGoodsCategory::getDeletedBy, loginName)
.set(GoblinSelfGoodsCategory::getDeletedAt, now)
);
if (rmvResultFlg) {
UpdateResult updateResult = mongoTemplate.updateMulti(Query.query(Criteria.where("cateId").in(cateIdList.toArray())),
Update.update("delFlg", "1").set("updatedBy", loginName).set("updatedAt", now).set("deletedBy", loginName).set("deletedAt", now),
GoblinSelfGoodsCategoryVo.class.getSimpleName()
);
log.info("店铺管理:商品分类:删除[cateIdArr={},MONGO.UpdateResult={}]", JsonUtils.toJson(cateIdArr), JsonUtils.toJson(updateResult));
// TODO: 2022/1/14 zhanggb redis
}
return rmvResultFlg;
}
}
package com.liquidnet.client.admin.zhengzai.goblin.service.impl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinSelfTagService;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.dto.vo.GoblinSelfTagVo;
import com.liquidnet.service.goblin.entity.GoblinSelfTag;
import com.liquidnet.service.goblin.mapper.GoblinSelfTagMapper;
import com.mongodb.client.result.UpdateResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* <p>
......@@ -14,7 +26,63 @@ import org.springframework.stereotype.Service;
* @author liquidnet
* @since 2021-12-27
*/
@Slf4j
@Service
public class GoblinSelfGoodsTagServiceImpl extends ServiceImpl<GoblinSelfTagMapper, GoblinSelfTag> implements IGoblinSelfTagService {
@Autowired
private MongoTemplate mongoTemplate;
@Transactional
@Override
public boolean addSave(GoblinSelfTag selfTag) {
if (this.save(selfTag)) {
mongoTemplate.insert(GoblinSelfTagVo.getNew().copy(selfTag), GoblinSelfTagVo.class.getSimpleName());
// TODO: 2022/1/14 zhanggb redis
return true;
}
return false;
}
@Transactional
@Override
public boolean editSave(GoblinSelfTag selfTag) {
LambdaUpdateWrapper<GoblinSelfTag> updateWrapper = Wrappers.lambdaUpdate(GoblinSelfTag.class);
updateWrapper.eq(GoblinSelfTag::getTagId, selfTag.getTagId());
updateWrapper.eq(GoblinSelfTag::getTagBelong, selfTag.getTagBelong());
updateWrapper.eq(GoblinSelfTag::getDelFlg, "0");
updateWrapper.set(GoblinSelfTag::getTagType, selfTag.getTagType());
updateWrapper.set(GoblinSelfTag::getTagName, selfTag.getTagName());
updateWrapper.set(GoblinSelfTag::getTagPic, selfTag.getTagPic());
if (this.update(updateWrapper)) {
UpdateResult updateResult = mongoTemplate.getCollection(GoblinSelfTagVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("tagId").is(selfTag.getTagId()).and("tagBelong").is(selfTag.getTagBelong()).and("delFlg").is("0")).getQueryObject(),
Update.update("tagType", selfTag.getTagType()).set("tagName", selfTag.getTagName()).set("tagPic", selfTag.getTagPic()).getUpdateObject()
);
log.info("店铺管理:标签管理:编辑[selfTag={},MONGO.UpdateResult={}]", JsonUtils.toJson(selfTag), JsonUtils.toJson(updateResult));
// TODO: 2022/1/14 zhanggb redis
}
return false;
}
@Transactional
@Override
public boolean remove(String[] tagIdArr, String tagBelong) {
boolean rmvResultFlg = this.update(Wrappers.lambdaUpdate(GoblinSelfTag.class)
.in(GoblinSelfTag::getTagId, tagIdArr)
.eq(GoblinSelfTag::getTagBelong, tagBelong)
.eq(GoblinSelfTag::getDelFlg, "0")
.set(GoblinSelfTag::getDelFlg, "1")
);
if (rmvResultFlg) {
UpdateResult updateResult = mongoTemplate.updateMulti(Query.query(Criteria.where("tagId").in(tagIdArr).and("delFlg").is("0").and("tagBelong").is(tagBelong)),
Update.update("delFlg", "1"),
GoblinSelfTagVo.class.getSimpleName()
);
log.info("店铺管理:标签管理:删除[tagIdArr={},tagBelong={},MONGO.UpdateResult={}]", JsonUtils.toJson(tagIdArr), tagBelong, JsonUtils.toJson(updateResult));
// TODO: 2022/1/14 zhanggb redis
}
return rmvResultFlg;
}
}
......@@ -3,6 +3,7 @@ package com.liquidnet.service.goblin.mapper;
import com.liquidnet.service.goblin.dto.GoblinSelfGoodsCategoryDto;
import com.liquidnet.service.goblin.entity.GoblinSelfGoodsCategory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
......@@ -16,18 +17,18 @@ import java.util.List;
* @since 2021-12-27
*/
public interface GoblinSelfGoodsCategoryMapper extends BaseMapper<GoblinSelfGoodsCategory> {
// SELECT cf.cate_id AS cateFid, cf.name AS fname, cf.icon AS ficon, cf.ne_isbn AS fneIsbn, cf.counts AS fcounts , cs.cate_id AS cateSid, cs.name AS sname, cs.icon AS sicon, cs.ne_isbn AS sneIsbn, cs.counts AS scounts , ct.cate_id AS cateTid, ct.name AS tname, ct.icon AS ticon, ct.ne_isbn AS tneIsbn, ct.counts AS tcounts FROM goblin_self_goods_category cf LEFT JOIN ( SELECT cate_id, name, icon, grade, ne_isbn , counts, cate_pid FROM goblin_self_goods_category WHERE grade = '2' AND del_flg = '0' ) cs ON cs.cate_pid = cf.cate_id LEFT JOIN ( SELECT cate_id, name, icon, grade, ne_isbn , counts, cate_pid FROM goblin_self_goods_category WHERE grade = '3' AND del_flg = '0' ) ct ON ct.cate_pid = cs.cate_id WHERE cf.grade = '1' AND del_flg = '0'
@Select({"select cf.cate_id cateFid,\n" +
// SELECT cf.cate_id AS fcateId, cf.name AS fname, cf.icon AS ficon, cf.ne_isbn AS fneIsbn, cf.counts AS fcounts , cs.cate_id AS scateId, cs.name AS sname, cs.icon AS sicon, cs.ne_isbn AS sneIsbn, cs.counts AS scounts , ct.cate_id AS tcateId, ct.name AS tname, ct.icon AS ticon, ct.ne_isbn AS tneIsbn, ct.counts AS tcounts FROM goblin_self_goods_category cf LEFT JOIN ( SELECT cate_id, name, icon, grade, ne_isbn , counts, cate_pid FROM goblin_self_goods_category WHERE grade = '2' AND del_flg = '0' ) cs ON cs.cate_pid = cf.cate_id LEFT JOIN ( SELECT cate_id, name, icon, grade, ne_isbn , counts, cate_pid FROM goblin_self_goods_category WHERE grade = '3' AND del_flg = '0' ) ct ON ct.cate_pid = cs.cate_id WHERE cf.grade = '1' AND del_flg = '0'
@Select({"select cf.cate_id fcateId,\n" +
" cf.name fname,\n" +
" cf.icon ficon,\n" +
" cf.ne_isbn fneIsbn,\n" +
" cf.counts fcounts,\n" +
" cs.cate_id cateSid,\n" +
" cs.cate_id scateId,\n" +
" cs.name sname,\n" +
" cs.icon sicon,\n" +
" cs.ne_isbn sneIsbn,\n" +
" cs.counts scounts,\n" +
" ct.cate_id cateTid,\n" +
" ct.cate_id tcateId,\n" +
" ct.name tname,\n" +
" ct.icon ticon,\n" +
" ct.ne_isbn tneIsbn,\n" +
......@@ -41,4 +42,6 @@ public interface GoblinSelfGoodsCategoryMapper extends BaseMapper<GoblinSelfGood
") ct on ct.cate_pid = cs.cate_id\n" +
"where cf.grade = '1' and del_flg = '0'"})
List<GoblinSelfGoodsCategoryDto> listForForMultiGrade();
List<String> listForMultiGradeCateId(@Param("cateIdArr") String[] cateIdArr);
}
......@@ -2,4 +2,26 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.goblin.mapper.GoblinSelfGoodsCategoryMapper">
<select id="listForMultiGradeCateId" resultType="java.lang.String">
select cate_id from goblin_self_goods_category cf where del_flg = '0' and grade = '1'
and cf.cate_id in
<foreach item="cateId" collection="cateIdArr" open="(" separator="," close=")">
#{cateId}
</foreach>
union all
select cate_id from goblin_self_goods_category cf where del_flg = '0' and grade = '2'
and cf.cate_pid in
<foreach item="cateId" collection="cateIdArr" open="(" separator="," close=")">
#{cateId}
</foreach>
union all
select cate_id from goblin_self_goods_category cf where del_flg = '0' and grade = '3'
and cf.cate_pid in (
select cate_id from goblin_self_goods_category cf where del_flg = '0' and grade = '2'
and cf.cate_pid in
<foreach item="cateId" collection="cateIdArr" open="(" separator="," close=")">
#{cateId}
</foreach>
)
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment