feat(后台管理): 运营管理

添加栏目菜单列表
master
wayn 4 years ago
parent 61a5f9b619
commit e0aa640a96

@ -1,10 +1,50 @@
package com.wayn.admin.api.controller.shop;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.base.controller.BaseController;
import com.wayn.common.core.domain.shop.Column;
import com.wayn.common.core.service.shop.IColumnService;
import com.wayn.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping("shop/column")
public class ColumnController {
public class ColumnController extends BaseController {
@Autowired
private IColumnService iColumnService;
@GetMapping("/list")
public R list(Column column) {
Page<Column> page = getPage();
return R.success().add("page", iColumnService.listPage(page, column));
}
@PostMapping
public R addBanner(@Validated @RequestBody Column column) {
column.setCreateTime(new Date());
return R.result(iColumnService.save(column));
}
@PutMapping
public R updateBanner(@Validated @RequestBody Column column) {
column.setUpdateTime(new Date());
return R.result(iColumnService.updateById(column));
}
@GetMapping("{columnId}")
public R getBanner(@PathVariable Long columnId) {
return R.success().add("data", iColumnService.getById(columnId));
}
@DeleteMapping("{columnIds}")
public R deleteBanner(@PathVariable List<Long> columnIds) {
return R.result(iColumnService.removeByIds(columnIds));
}
}

@ -37,4 +37,9 @@ public class Column extends ShopBaseEntity implements Serializable {
*/
private String name;
/**
* 0 1
*/
private Boolean delFlag;
}

@ -1,6 +1,8 @@
package com.wayn.common.core.mapper.shop;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wayn.common.core.domain.shop.Column;
/**
@ -13,4 +15,5 @@ import com.wayn.common.core.domain.shop.Column;
*/
public interface ColumnMapper extends BaseMapper<Column> {
IPage<Column> selectColumnListPage(Page<Column> page, Column column);
}

@ -1,5 +1,7 @@
package com.wayn.common.core.service.shop;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wayn.common.core.domain.shop.Column;
@ -13,4 +15,12 @@ import com.wayn.common.core.domain.shop.Column;
*/
public interface IColumnService extends IService<Column> {
/**
*
*
* @param page
* @param column
* @return
*/
IPage<Column> listPage(Page<Column> page, Column column);
}

@ -1,9 +1,12 @@
package com.wayn.common.core.service.shop.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wayn.common.core.domain.shop.Column;
import com.wayn.common.core.mapper.shop.ColumnMapper;
import com.wayn.common.core.service.shop.IColumnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@ -17,4 +20,11 @@ import org.springframework.stereotype.Service;
@Service
public class ColumnServiceImpl extends ServiceImpl<ColumnMapper, Column> implements IColumnService {
@Autowired
private ColumnMapper columnMapper;
@Override
public IPage<Column> listPage(Page<Column> page, Column column) {
return columnMapper.selectColumnListPage(page, column);
}
}

@ -3,18 +3,29 @@
<mapper namespace="com.wayn.common.core.mapper.shop.ColumnMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.wayn.common.core.domain.shop.Column">
<resultMap id="ShopColumnResult" type="com.wayn.common.core.domain.shop.Column">
<result column="id" property="id" />
<result column="sort_order" property="sortOrder" />
<result column="name" property="name" />
<result column="create_time" property="createTime" />
<result column="update_time" property="updateTime" />
<result column="del_flag" property="delFlag" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
<sql id="selectColumnVo">
select id,
sort_order, name, create_time, update_time from column
sort_order, name, create_time, update_time,del_flag from shop_column
</sql>
<select id="selectColumnListPage" resultMap="ShopColumnResult">
<include refid="selectColumnVo"/>
<where>
del_flag = 0
<if test="column.name != null and column.name != ''">
AND name like concat('%', #{column.name}, '%')
</if>
</where>
</select>
</mapper>

@ -15,6 +15,7 @@ import com.wayn.common.util.R;
import com.wayn.mobile.api.domain.SearchHistory;
import com.wayn.mobile.api.service.ISearchHistoryService;
import com.wayn.mobile.framework.security.util.SecurityUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.BoolQueryBuilder;
@ -138,9 +139,19 @@ public class SearchController extends BaseController {
@GetMapping("hotKeywords")
public R hotKeywords() {
List<Keyword> keywords = iKeywordService.list(new QueryWrapper<Keyword>().eq("is_hot", true).orderByDesc("sort_order"));
List<String> strings = keywords.stream().map(Keyword::getKeyword).collect(Collectors.toList());
return R.success().add("data", strings);
List<Keyword> hotKeywords = iKeywordService.list(new QueryWrapper<Keyword>().eq("is_hot", true).orderByAsc("sort_order"));
List<String> hotStrings = hotKeywords.stream().map(Keyword::getKeyword).collect(Collectors.toList());
List<Keyword> defaultKeyword = iKeywordService.list(new QueryWrapper<Keyword>().eq("is_default", true).orderByAsc("sort_order"));
List<String> defaultStrings = defaultKeyword.stream().map(Keyword::getKeyword).collect(Collectors.toList());
R r = R.success();
if (CollectionUtils.isNotEmpty(hotStrings)) {
r.add("data", hotStrings);
}
r.add("data", hotStrings);
if (CollectionUtils.isNotEmpty(defaultStrings)) {
r.add("default", defaultStrings.get(0));
}
return r;
}
}

Loading…
Cancel
Save