Authored by mali

商品池id配置页面

... ... @@ -15,4 +15,6 @@ public interface ResourcesGoodsPoolMapper {
void insertOrUpdate(@Param("list") List<ResGoodsPoolEditBo> param);
void updateBatchByResGoodsPoolBo(@Param("list") List<ResGoodsPoolEditBo> param);
int updatePoolIdById(@Param("id")Integer id, @Param("poolId")Integer poolId, @Param("updateTime")Integer updateTime);
}
... ...
package com.yoho.ufo.model.resource;
import lombok.ToString;
/**
* Created by shengguo.cai on 2018/11/19.
*/
@ToString
public class ResourcesGoodsPool {
private Integer id;
private Integer createTime;
... ...
... ... @@ -49,4 +49,8 @@
select <include refid="Base_Column_List" /> from resources_goods_pool
limit 10000
</select>
<update id="updatePoolIdById">
update resources_goods_pool set pool_id = #{poolId}, update_time = #{updateTime} where id = #{id}
</update>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.resource.controller;
import com.yoho.ufo.model.resource.ResourcesGoodsPool;
import com.yoho.ufo.resource.service.IResourceService;
import com.yoho.ufo.resource.service.impl.ResourcesGoodsPoolService;
import com.yoho.ufo.service.model.ApiResponse;
import com.yoho.ufo.service.model.PageRequestBO;
import com.yoho.ufo.util.DateUtil;
import com.yohobuy.ufo.resource.resp.ResourceGetBo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Created by shengguo.cai on 2018/11/16.
*/
@RestController
@RequestMapping(value = "/ResourcesGoodsPool")
public class ResourcesGoodsPoolController {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourcesGoodsPoolController.class);
@Autowired
private ResourcesGoodsPoolService resourcesGoodsPoolService;
@RequestMapping(value = "/selectAll")
public ApiResponse selectAll() {
List<ResourcesGoodsPool> result = resourcesGoodsPoolService.selectAll();
return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
}
@RequestMapping(value = "/updatePoolIdById")
public ApiResponse updatePoolIdById(@RequestBody ResourcesGoodsPool resourcesGoodsPool) {
LOGGER.info("ResourcesGoodsPoolController.updatePoolIdById in, ");
int result = resourcesGoodsPoolService.updatePoolIdById(resourcesGoodsPool.getId(), resourcesGoodsPool.getPoolId());
return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
}
}
... ...
package com.yoho.ufo.resource.service.impl;
import com.yoho.ufo.dal.ResourcesGoodsPoolMapper;
import com.yoho.ufo.model.resource.ResourcesGoodsPool;
import com.yoho.ufo.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by li.ma on 2019/8/8.
*/
@Service
public class ResourcesGoodsPoolService {
@Autowired
private ResourcesGoodsPoolMapper resourcesGoodsPoolMapper;
public List<ResourcesGoodsPool> selectAll() {
return resourcesGoodsPoolMapper.selectAll();
}
public int updatePoolIdById(Integer id, Integer poolId) {
if (id == null || null == poolId) {
return 0;
}
int result = resourcesGoodsPoolMapper.updatePoolIdById(id, poolId, DateUtil.getCurrentTimeSeconds());
// TODO 清理缓存
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>
<style>
.btn-download span {
line-height: 40px;
color: #87CEFA;
}
</style>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="height: 160px">
<script>
document.write(addHead('配置管理', ''));
</script>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px;height: 660px">
<table id="configTable"></table>
</div>
</div>
<script type="text/javascript">
var param = {};
$(function () {
$("#configTable").myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/ResourcesGoodsPool/selectAll",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "配置说明",
field: "poolName",
width: 40,
align: "center"
}, {
title: "配置值",
field: "poolId",
width: 80,
align: "center",
formatter: function (value, rowData) {
var v = value==null?"":value;
var str = "<input id='pool_id_"+rowData.id+"' type='text' value='"+v+"'>";
return str;
}
}, {
title: "操作",
field: "operations",
width: 80,
align: "center",
formatter: function (value, rowData) {
var str = "<a role='edit' dataId='" + rowData.id + "' style='margin-left:10px;background-color: #5bc0de'>提交</a>";
return str;
}
}]],
cache: false,
pagination: true,
pageSize: 10,
pageList: [10],
idField: "id",
singleSelect: false,
checkOnSelect: false,
onLoadSuccess: function () {
$.parser.parse($("#configTable").parent());
// 编辑
$(this).myDatagrid("getPanel").find("a[role='edit']").linkbutton({
iconCls: "icon-edit",
onClick: function () {
var id = $(this).attr("dataId");
editRow(id);
}
});
}
});
function editRow(id) {
debugger
var pool_id = document.getElementById("pool_id_"+id).value;
var ajaxData = {};
ajaxData.poolId = pool_id;
ajaxData.id = id;
$.ajax({
url: contextPath + '/ResourcesGoodsPool/updatePoolIdById',
contentType: "application/json",
dataType: "json",
type: "POST",
data: JSON.stringify(ajaxData),
success: function(ret) {
$.messager.progress("close");
if (ret && ret.code == 200 && ret.data == 1) {
$.messager.show({
title:'操作提示',
msg:'提交成功'
});
$("#configTable").myDatagrid("load", param);
} else {
$.messager.alert('操作提示', '提交失败');
}
},
error: function(err) {
$.messager.progress("close");
$.messager.alert('操作提示', err.message || '提交失败');
}
});
}
});
</script>
</body>
</html>
\ No newline at end of file
... ...