Authored by caoyan

Merge branch 'master' of http://git.yoho.cn/ufo/ufo-platform

... ... @@ -57,4 +57,10 @@ public interface UfoBrandSeriesMapper {
*/
List<BrandSeries> getBrandSeriesPageList(@Param("brandSeries") BrandSeries brandSeries, @Param("page") PageModel pageModel);
/**
* 根据品牌iD查询系列集合
* @param brandId
* @return
*/
List<BrandSeries> selectSeriesByBrandId(@Param("brandId")Integer brandId);
}
... ...
... ... @@ -82,4 +82,9 @@
order by series.update_time desc
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="selectSeriesByBrandId" resultMap="brandSeriesMap">
select <include refid="queryColumns"/>
from brand_series where brand_id = #{brandId}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -53,4 +53,11 @@ public class BrandSeriesController {
brandSeriesService.updateBrandSeriesStatus(brandSeriesRequestBo);
return new ApiResponse<>();
}
@RequestMapping(value = "/querySeriesByBrandId", method = RequestMethod.GET)
public ApiResponse<Object> querySeriesByBrandId(Integer brandId) {
LOGGER.info("querySeriesByBrandId param = {}", brandId);
return new ApiResponse<>(brandSeriesService.querySeriesByBrandId(brandId));
}
}
... ...
package com.yoho.ufo.service;
import com.alibaba.fastjson.JSONObject;
import com.yohobuy.ufo.model.common.PageResponseBO;
import com.yohobuy.ufo.model.request.brand.BrandSeriesRequestBo;
import com.yohobuy.ufo.model.request.brand.BrandSeriesResponseBo;
import java.util.List;
/**
* @author kun.wang
* @date 2018/9/11
... ... @@ -37,4 +40,11 @@ public interface IBrandSeriesService {
* @return
*/
int updateBrandSeriesStatus(BrandSeriesRequestBo brandSeriesRequestBo);
/**
* 根据品牌id查询系列列表
* @param brandId
* @return
*/
List<JSONObject> querySeriesByBrandId(Integer brandId);
}
... ...
package com.yoho.ufo.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.ufo.dal.UfoBrandSeriesMapper;
import com.yoho.ufo.model.brand.Brand;
import com.yoho.ufo.model.brand.BrandSeries;
import com.yoho.ufo.service.IBrandSeriesService;
import com.yoho.ufo.util.OrikaUtils;
... ... @@ -82,4 +84,23 @@ public class BrandSeriesServiceImpl implements IBrandSeriesService {
brandSeries.setUpdateTime(DateUtil.currentTimeSeconds());
return ufoBrandSeriesMapper.updateBrandSeriesStatus(brandSeries);
}
/**
* 根据品牌id查询系列列表
* @param brandId
* @return
*/
public List<JSONObject> querySeriesByBrandId(Integer brandId) {
// TODO 可以添加缓存
List<BrandSeries> brandSeries = ufoBrandSeriesMapper.selectSeriesByBrandId(brandId);
List<JSONObject> result = new ArrayList<>();
JSONObject jsonObject;
for (BrandSeries item : brandSeries) {
jsonObject = new JSONObject();
jsonObject.put("id", item.getId());
jsonObject.put("text", item.getSeriesName());
result.add(jsonObject);
}
return result;
}
}
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
<script src="/ufoPlatform/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 230px">
<script>
document.write(addHead('品牌管理', ''));
</script>
<input id="brandName" type="text">
<input id="brandSeries" type="text"/>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
<table id="SkuTable"></table>
</div>
</div>
<script type="text/javascript">
var brandId;
$(function () {
$.ajax({
contentType: "application/json",
dataType: "json",
type: "GET",
url: contextPath + '/brand/getBrandName',
/*data: JSON.stringify({
limit: 0
}),*/
success: function (data) {
if (data.code != 200 || !data.data || data.data.length == 0) {
return;
}
$("#brandName").myCombobox({
prompt: "选择名称",
width: 200,
data: data.data,
valueField: "id",
textField: "text"
});
}
});
$.ajax({
contentType: "application/json",
dataType: "json",
type: "GET",
url: contextPath + '/brandSeries/querySeriesByBrandId?brandId=' + $('#brandName').combobox('getValue'),
//data: brandId : ,
success: function (data) {
if (data.code != 200 || !data.data || data.data.length == 0) {
return;
}
$("#brandSeries").myCombobox({
prompt: "选择名称",
width: 200,
data: data.data,
valueField: "id",
textField: "text"
});
}
});
$("#SkuTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/brand/getBrandPageList",
method: 'POST',
/*queryParams: {
'brandName':'',
'status':''
},*/
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "ID",
field: "id",
width: 40,
align: "center"
}, {
title: "品牌LOGO",
field: "brandLogo",
width: 80,
align: "center",
formatter: function (value) {
if (value == null || value == '' || value == undefined) {
return '';
}
return '<img src="' + value + '" style="width:98px;height:98px"/></a>';
}
}, {
title: "品牌名称",
field: "brandName",
width: 100,
align: "center"
}, {
title: "英文名称",
field: "brandNameEn",
width: 80,
align: "center"
}, {
title: "品牌搜索词",
field: "brandSearch",
width: 170,
align: "center"
}, {
title: "状态",
field: "status",
width: 80,
align: "center",
formatter: function (value, rowData) {
if (value == 1) {
return '开启';
}
return '关闭';
}
}, {
title: "创建时间",
field: "createTime",
width: 170,
align: "center"
}, {
title: "操作",
field: "operations",
width: 80,
align: "center",
formatter: function (value, rowData) {
var str = "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px'>编辑</a>";
if (1 == rowData.status) {
str += "<a role='closeBrand' dataId='" + rowData.id + "' style='margin-left:10px'>关闭品牌</a>";
} else {
str += "<a role='openBrand' dataId='" + rowData.id + "' style='margin-left:10px'>开启品牌</a>";
}
return str;
}
}]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function () {
// 编辑
$(this).myDatagrid("getPanel").find("a[role='edit']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
var id = $(this).attr("dataId");
editRow(id);
}
});
// 关闭品牌
$(this).myDatagrid("getPanel").find("a[role='closeBrand']").linkbutton({
iconCls: "icon-more",
onClick: function () {
updateBrandStatus($(this).attr("dataId"), 2);
}
});
// 开启品牌
$(this).myDatagrid("getPanel").find("a[role='openBrand']").linkbutton({
iconCls: "icon-more",
onClick: function () {
updateBrandStatus($(this).attr("dataId"), 1);
}
});
}
});
// 搜索
$("#searchLinkButton").linkbutton({
onClick: function () {
var param = getParams();
$("#brandTable").myDatagrid("load", param);
}
});
// 搜索全部
$("#searchAllLinkButton").linkbutton({
onClick: function () {
$('#brandStatus').combobox('clear');
$('#brandName').combobox('clear');
var param = {};
$("#brandTable").myDatagrid("load", param);
}
});
/**
* 提取出搜索参数
*/
function getParams() {
var brandName = $('#brandName').combobox('getText');
var status = $('#brandStatus').combobox('getValue');
var param = {};
if (undefined !== brandName && null !== brandName && "" !== brandName) {
param.brandName = brandName;
}
if (undefined !== status && null !== status && "" !== status) {
param.status = status;
}
return param;
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...