工具STS,maven ssh框架,前端EasyUI
1、 修改页面 onAfterEdit 事件
$(function(){
$("body").css({visibility:"visible"});
$('#grid').datagrid( {
iconCls : 'icon-forward',
fit : true,
border : true,
rownumbers : true,
striped : true,
pageList: [30,50,100],
pagination : true,
toolbar : toolbar,
url : "",
idField : 'id',
columns : columns,
onDblClickRow : doDblClickRow,
onAfterEdit : function(rowIndex, rowData, changes){
$.post("../../waybill_save.action",rowData,function(data){
if(data.success){
$.messager.show({
title:'提示窗口',
msg:data.msg,
});
}
});
console.info(rowData);
editIndex = undefined;
}
});
});
2、 在 bos_management 服务器,创建 WayBillAction 添加 save 方法
@ParentPackage("json-default")
@Namespace("/")
@Controller
@Scope("prototype")
public class WayBillAction extends BaseAction<WayBill> {
private static final Logger LOGGER = Logger.getLogger(WayBillAction.class);
@Autowired
private WayBillService wayBillService;
@Action(value = "waybill_save", results = { @Result(name = "success", type = "json") })
public String save() {
Map<String, Object> result = new HashMap<String, Object>();
try {
wayBillService.save(model);
result.put("success", true);
result.put("msg", "保存运单成功");
LOGGER.info("保存运单号成功,运单号是" + model.getWayBillNum());
} catch (Exception e) {
e.printStackTrace();
result.put("success", false);
result.put("msg", "保存运单失败");
LOGGER.info("保存运单失败,运单号是"+model.getWayBillNum(),e);
}
return SUCCESS;
}
}
3.编写业务层
public interface WayBillService {
public void save(WayBill model);
}
@Service
@Transactional
public class WayBillServiceImpl implements WayBillService{
@Autowired
private WayBillRepository wayBillRepository;
@Override
public void save(WayBill wayBill) {
wayBillRepository.save(wayBill);
}
}
4.编写dao层
public interface WayBillRepository extends JpaRepository<WayBill, Integer> {
}