Commit b868d9de authored by 覃振观's avatar 覃振观 👶

23-12-8: Class 调整。 调整传输数据格式。

parent 28ea8694
var rawData={};
$(document).ready(function() { $(document).ready(function() {
initializeUI(); initializeUI();
initializeToobarContainer(); initializeToobarContainer();
...@@ -25,7 +25,6 @@ function initializeUI() { ...@@ -25,7 +25,6 @@ function initializeUI() {
}); });
} }
function loadDataTest() { function loadDataTest() {
console.log("loadData") console.log("loadData")
var params = new URLSearchParams(document.location.search); var params = new URLSearchParams(document.location.search);
...@@ -33,6 +32,7 @@ function loadDataTest() { ...@@ -33,6 +32,7 @@ function loadDataTest() {
Public.ajax(web_app.name + "/product/loadProductDetail.ajax", { Public.ajax(web_app.name + "/product/loadProductDetail.ajax", {
productId: paramsData.productId productId: paramsData.productId
}, function (data) { }, function (data) {
rawData = data;
$('#submitForm').formSet(data); $('#submitForm').formSet(data);
var fronData = {}; var fronData = {};
fronData.Rows = data.fronColors; fronData.Rows = data.fronColors;
...@@ -53,7 +53,6 @@ function faceGrid(elId, data) { ...@@ -53,7 +53,6 @@ function faceGrid(elId, data) {
} }
} }
}); });
debugger;
var gridManager = UICtrl.grid(elId, { var gridManager = UICtrl.grid(elId, {
columns: [ columns: [
{ display: "颜色名称", name: "productFaceColorId", width: 140, minWidth: 60, type: "string", align: "left" }, { display: "颜色名称", name: "productFaceColorId", width: 140, minWidth: 60, type: "string", align: "left" },
...@@ -71,12 +70,32 @@ function faceGrid(elId, data) { ...@@ -71,12 +70,32 @@ function faceGrid(elId, data) {
}); });
} }
function save() {
$('#submitForm').ajaxSubmit({
url: web_app.name + '/product/saveProductAndDetail.ajax',
param:{ rawData: JSON.stringify(rawData) },
success: function(data) {
debugger;
}
});
}
function initializeToobarContainer(){ function initializeToobarContainer(){
$('#toolBarCenter').attr('position','bottom'); var toolBarOptions= {
dropup: $('#toolBar').data('dropup') === true,//显示更多按钮时 是否向上打开菜单
items: [{
id: 'save',
remark: '保存',
name: 'common.button.save',
icon: 'fa-save',
delay: true,
relation: 'advance',
event: save
}]
};
$('#toolBar').toolBar(toolBarOptions);
//dropup==true 更多按钮向上展示 //dropup==true 更多按钮向上展示
$('#toolBar').data('dropup',true).removeClass('job-button-fixed-top').addClass('job-button-fixed-bottom'); $('#toolBar').data('dropup',true).removeClass('job-button-fixed-top').addClass('job-button-fixed-bottom');
UICtrl.layout($("#jobPageLayout"), {heightDiff:-2,topHeight:40,bottomHeight:40,onSizeChanged:function(){
}});
} }
// checkbox: true, // checkbox: true,
// enabledSort: false, // enabledSort: false,
......
...@@ -8,24 +8,13 @@ ...@@ -8,24 +8,13 @@
<%@ page language="java" contentType="text/html; charset=utf-8"%> <%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@taglib uri="/WEB-INF/taglib.tld" prefix="x"%> <%@taglib uri="/WEB-INF/taglib.tld" prefix="x"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<head> <html>
<x:base include="layout,dialog,grid,tree,combox,commonTree" />
<x:script src='/javaScript/common.js'/>
<x:script src='/lib/jquery/jquery.contextmenu.js'/>
<x:script src='/system/bpm/BpmUtil.js'/>
<x:script src='/biz/topsun/product/productDetail.js'/>
</head>
<body> <body>
<div class="container-fluid" style="position: relative; display: inline-flex; flex-direction: column; height: 97%; <div class="panelX" id="panelContainer" >
background-color: #f3f3f4 !important;" > <x:hidden name="productDetailId" />
<%-- style="position: relative; display: inline-flex; flex-direction: column;"--%>
<%-- <x:hidden name="productDetailId" />--%>
<%-- <x:hidden name="productId"/>--%>
<%-- <div class="hg-form-cols">--%> <%-- <div class="hg-form-cols">--%>
<%-- <div labelCol="15"> </div>--%> <%-- <div labelCol="15"> </div>--%>
<%-- </div>--%> <%-- </div>--%>
<%-- style="overflow: 98vh;"--%>
<form class="hg-form" method="post" action="" id="submitForm"> <form class="hg-form" method="post" action="" id="submitForm">
<div class="hg-form-row"> <div class="hg-form-row">
<x:title title="基本属性" name="group" hideTable="#info" /> <x:title title="基本属性" name="group" hideTable="#info" />
...@@ -79,17 +68,46 @@ ...@@ -79,17 +68,46 @@
</div> </div>
</form> </form>
<div id="toolBarCenter" class="panel-footerX" >
<div id="toolBarCenter" class="footer" style="background: none repeat scroll 0 0 #fff; border-top: 1px solid #e7eaec; <div id="toolBar"></div>
position: absolute; bottom: 0; width: 100%; display:flex; justify-content:center;">
<%-- style=""--%>
<div id='toolBar' checkAccess="false">
<a> aaa </a>
</div>
</div> </div>
</div> </div>
</body> </body>
<head>
<x:base include="layout,dialog,grid,tree,combox,commonTree" />
<x:script src='/javaScript/common.js'/>
<x:script src='/lib/jquery/jquery.contextmenu.js'/>
<x:script src='/system/bpm/BpmUtil.js'/>
<x:script src='/biz/topsun/product/productDetail.js'/>
<style>
.panelX{
height: 98%;
width: 100%;
padding: 5px;
position: relative;
display: inline-flex;
flex-direction: column;
/*background-color: #f3f3f4 !important;*/
}
.panelX > div:first-child { margin-bottom: 38px; }
.panelX > form { margin-bottom: 38px; }
.panel-footerX {
width: 100%;
left: -1px;
bottom: 0;
padding: 1px 99px;
position: fixed;
display:flex;
justify-content:center;
background: none repeat scroll 0 0 #fff0;
/*border-top: 1px solid #e7eaec;*/
/*background: none repeat scroll 0 0 #fff;*/
}
.panel-footerX > div { margin: 2px; }
</style>
</head>
</html> </html>
...@@ -4,6 +4,7 @@ import com.huigou.topsun.product.domain.Product; ...@@ -4,6 +4,7 @@ import com.huigou.topsun.product.domain.Product;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -20,7 +21,7 @@ public interface ProductApplication { ...@@ -20,7 +21,7 @@ public interface ProductApplication {
* @param size 页大小 * @param size 页大小
* @return org.springframework.data.domain.Page<com.huigou.topsun.product.domain.Product> * @return org.springframework.data.domain.Page<com.huigou.topsun.product.domain.Product>
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/11/29 9:34 * @createDate 2023/11/29 9:34
*/ */
ArrayList<Map<String, Object>> findProductPage(int page, int size); ArrayList<Map<String, Object>> findProductPage(int page, int size);
...@@ -29,7 +30,17 @@ public interface ProductApplication { ...@@ -29,7 +30,17 @@ public interface ProductApplication {
* @param productId 产品ID * @param productId 产品ID
* @return java.util.Map<java.lang.String, java.lang.Object> * @return java.util.Map<java.lang.String, java.lang.Object>
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/11/29 9:33 * @createDate 2023/11/29 9:33
*/ */
Map<String, Object> queryDetailAll(int productId); Map<String, Object> queryDetailAll(int productId);
/**
* description 对比所有对象,并保存更改的数据。
* @param rawMap 原数据
* @param updateMap 提交的数据
* @return java.util.HashMap<java.lang.String, java.lang.Object>
* @author qinzhenguan
* @createDate 2023/12/8 17:19
*/
HashMap<String, Object> saveProductAndDetail(HashMap<String, Object> rawMap, HashMap<String, Object> updateMap);
} }
package com.huigou.topsun.product.application.impl; package com.huigou.topsun.product.application.impl;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.topsun.product.application.BrandApplication;
import com.huigou.topsun.product.application.ProductApplication; import com.huigou.topsun.product.application.ProductApplication;
import com.huigou.topsun.product.domain.*; import com.huigou.topsun.product.domain.*;
import com.huigou.topsun.product.repository.*; import com.huigou.topsun.product.repository.*;
...@@ -29,7 +29,6 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -29,7 +29,6 @@ public class ProductApplicationImpl implements ProductApplication {
private final ProductDetailRepository detailRepository; private final ProductDetailRepository detailRepository;
// 类型 // 类型
private final BrandRepository brandRepository; private final BrandRepository brandRepository;
private final BrandApplication brandService;
private final FactoryRepository factoryRepository; private final FactoryRepository factoryRepository;
private final ColorRepository colorRepository; private final ColorRepository colorRepository;
private final ProductCategoryRepository categoryRepository; private final ProductCategoryRepository categoryRepository;
...@@ -50,12 +49,10 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -50,12 +49,10 @@ public class ProductApplicationImpl implements ProductApplication {
// mapList.getContent().stream().map(Product::toString).forEach(System.out::println); // mapList.getContent().stream().map(Product::toString).forEach(System.out::println);
ArrayList<Product> productPage = (ArrayList<Product>) productRepository.findAll(); ArrayList<Product> productPage = (ArrayList<Product>) productRepository.findAll();
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
ArrayList<Map<String, Object>> mapList = (ArrayList<Map<String, Object>>) mapper.convertValue(productPage, List.class);
// convert = mapList.stream().collect(Collectors.toMap(index -> index, Function.identity(), // convert = mapList.stream().collect(Collectors.toMap(index -> index, Function.identity(),
// (oldV, newV) -> oldV)); // (oldV, newV) -> oldV));
return mapper.convertValue(productPage, new TypeReference<ArrayList<Map<String, Object>>>() {});
return mapList;
} }
/** /**
...@@ -63,13 +60,12 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -63,13 +60,12 @@ public class ProductApplicationImpl implements ProductApplication {
* @param productId 产品ID * @param productId 产品ID
* @return java.util.Map<java.lang.String, java.lang.Object> * @return java.util.Map<java.lang.String, java.lang.Object>
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/11/29 13:19 * createDate 2023/11/29 13:19
*/ */
@Override @Override
public Map<String, Object> queryDetailAll(int productId) { public Map<String, Object> queryDetailAll(int productId) {
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>(200);
ProductDetail productDetail = detailRepository.findByProductIdEquals((long)productId); ProductDetail productDetail = detailRepository.findByProductIdEquals((long)productId);
resultMap.put("detail", productDetail);
// EntityManager manager = JPAUtils.getEntityManger(); // EntityManager manager = JPAUtils.getEntityManger();
// manager.getTransaction().begin(); // manager.getTransaction().begin();
// manager.flush(); // manager.flush();
...@@ -89,10 +85,12 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -89,10 +85,12 @@ public class ProductApplicationImpl implements ProductApplication {
entitys.add(typesetConfRepository.findByProductId(strProductId)); entitys.add(typesetConfRepository.findByProductId(strProductId));
entitys.add(lookedRepository.findByProductId(strProductId)); entitys.add(lookedRepository.findByProductId(strProductId));
entitys.add(publishedConfRepository.findByProductId(strProductId)); entitys.add(publishedConfRepository.findByProductId(strProductId));
entitys.add(productDetail);
HashMap<String, Object> listMaps = new HashMap<>(100);
resultMap.putAll(assembleResultOfForm(entitys)); resultMap.putAll(assembleResultOfForm(entitys));
resultMap.put("loss", loss); listMaps.put("loss", loss);
resultMap.put("material", material); listMaps.put("material", material);
// --------------------------------- 版面查询 --------------------------------- // --------------------------------- 版面查询 ---------------------------------
if(productDetail != null) { if(productDetail != null) {
...@@ -101,27 +99,28 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -101,27 +99,28 @@ public class ProductApplicationImpl implements ProductApplication {
ArrayList <ProductFaceColor> fronColors = ArrayList <ProductFaceColor> fronColors =
(ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getBackProductFaceId()); (ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getBackProductFaceId());
resultMap.put("frontFace", frontFace); resultMap.put("frontFace", frontFace);
resultMap.put("fronColors", fronColors == null ? new ArrayList<>() : fronColors); listMaps.put("fronColors", fronColors == null ? new ArrayList<>() : fronColors);
} else { } else {
ProductFaceColor fc = new ProductFaceColor(); ProductFaceColor fc = new ProductFaceColor();
fc.setProductFaceColorId("111"); fc.setProductFaceColorId("111");
ArrayList fronColors = new ArrayList<>(); ArrayList<ProductFaceColor> fronColors = new ArrayList<>();
fronColors.add(fc); fronColors.add(fc);
resultMap.put("fronColors", fronColors); listMaps.put("fronColors", fronColors);
} }
if(productDetail.getBackProductFaceId() != null) { if(productDetail.getBackProductFaceId() != null) {
ProductFace backFace = faceRepository.findByProductFaceIdEquals(productDetail.getBackProductFaceId()); ProductFace backFace = faceRepository.findByProductFaceIdEquals(productDetail.getBackProductFaceId());
ArrayList <ProductFaceColor> backColors = ArrayList <ProductFaceColor> backColors =
(ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getBackProductFaceId()); (ArrayList<ProductFaceColor>) faceColorRepository.findByProductFaceId(productDetail.getBackProductFaceId());
resultMap.put("backFace", backFace); resultMap.put("backFace", backFace);
resultMap.put("backColors", backColors == null ? new ArrayList<>() : backColors); listMaps.put("backColors", backColors == null ? new ArrayList<>() : backColors);
} }
} }
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
resultMap.put("selectedBrand", mapper.convertValue(brands, List.class)); listMaps.put("selectedBrand", mapper.convertValue(brands, List.class));
resultMap.put("selectedFactory", mapper.convertValue(factorys, List.class)); listMaps.put("selectedFactory", mapper.convertValue(factorys, List.class));
resultMap.put("selectedColor", mapper.convertValue(colors, List.class)); listMaps.put("selectedColor", mapper.convertValue(colors, List.class));
resultMap.put("selectedCategory", mapper.convertValue(categorys, List.class)); listMaps.put("selectedCategory", mapper.convertValue(categorys, List.class));
resultMap.put("listMaps", listMaps);
// resultMap.put("selectedBrand", convertToMap(Brand.class, "brandName", "brandId", brands)); // resultMap.put("selectedBrand", convertToMap(Brand.class, "brandName", "brandId", brands));
// resultMap.put("selectedFactory", convertToMap(Factory.class, "factoryName", "factoryId", factorys)); // resultMap.put("selectedFactory", convertToMap(Factory.class, "factoryName", "factoryId", factorys));
// resultMap.put("selectedColor", convertToMap(Color.class, "colorName", "colorId", colors)); // resultMap.put("selectedColor", convertToMap(Color.class, "colorName", "colorId", colors));
...@@ -130,22 +129,28 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -130,22 +129,28 @@ public class ProductApplicationImpl implements ProductApplication {
return resultMap; return resultMap;
} }
@Override
public HashMap<String, Object> saveProductAndDetail(HashMap<String, Object> rawMap, HashMap<String, Object> updateMap) {
return null;
}
/** /**
* description 返回页面 Form 所需的数据格式 * description 返回页面 Form 所需的数据格式
* @param entitys 所有相关的 实体 (如果需要 update,保留这些实体。提交时候用于比较更新值。) * @param entitys 所有相关的 实体 (如果需要 update,保留这些实体。提交时候用于比较更新值。)
* @return java.util.HashMap<java.lang.String, java.lang.Object> * @return java.util.HashMap<java.lang.String, java.lang.Object>
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/12/5 14:09 * createDate 2023/12/5 14:09
*/ */
public Map<String, Object> assembleResultOfForm(Set<Object> entitys) { public Map<String, Object> assembleResultOfForm(Set<Object> entitys) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>(1024);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
map.put("entitys", entitys); map.put("entitys", entitys);
for(Object item : entitys) { for(Object item : entitys) {
if(item == null) { if(item == null) {
continue; continue;
} }
map.putAll(mapper.convertValue(item, Map.class)); map.putAll(mapper.convertValue(item, new TypeReference<Map<? extends String, ?>>() {}));
} }
return map; return map;
} }
...@@ -158,7 +163,7 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -158,7 +163,7 @@ public class ProductApplicationImpl implements ProductApplication {
* @param list 需要转换的 List * @param list 需要转换的 List
* @return java.util.Map<java.lang.Object, java.lang.Object> * @return java.util.Map<java.lang.Object, java.lang.Object>
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/12/1 16:09 * createDate 2023/12/1 16:09
*/ */
public Map<Object, Object> convertToMap(Class<?> clazz, String displayProperty, String valueProperty, public Map<Object, Object> convertToMap(Class<?> clazz, String displayProperty, String valueProperty,
List<?> list) { List<?> list) {
...@@ -167,7 +172,7 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -167,7 +172,7 @@ public class ProductApplicationImpl implements ProductApplication {
set.add(valueProperty); set.add(valueProperty);
if(checkClassesAndProperties(clazz, set, list.size())) { if(checkClassesAndProperties(clazz, set, list.size())) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
List<Map<String, Object>> mapList = mapper.convertValue(list, List.class); LinkedList<Map<String, Object>> mapList = mapper.convertValue(list, new TypeReference<LinkedList<Map<String, Object>>>() {});
return mapList.stream().collect(Collectors.toMap(map -> map.get(displayProperty), map -> map.get(valueProperty), return mapList.stream().collect(Collectors.toMap(map -> map.get(displayProperty), map -> map.get(valueProperty),
(oldV, newV) -> oldV)); (oldV, newV) -> oldV));
} }
...@@ -181,7 +186,7 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -181,7 +186,7 @@ public class ProductApplicationImpl implements ProductApplication {
* @param listSize 需要检查的 ListSize * @param listSize 需要检查的 ListSize
* @return java.lang.Boolean true of false * @return java.lang.Boolean true of false
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/12/1 15:58 * createDate 2023/12/1 15:58
*/ */
public Boolean checkClassesAndProperties(Class<?> clazz, Set<String> set, int listSize) { public Boolean checkClassesAndProperties(Class<?> clazz, Set<String> set, int listSize) {
if(listSize == 0) { if(listSize == 0) {
...@@ -214,7 +219,7 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -214,7 +219,7 @@ public class ProductApplicationImpl implements ProductApplication {
* @param list 需要转换的 List * @param list 需要转换的 List
* @return java.util.Map<java.lang.Object, java.lang.Object> * @return java.util.Map<java.lang.Object, java.lang.Object>
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/11/29 11:36 * createDate 2023/11/29 11:36
*/ */
public Map<Object, Object> convertToMap(Class<?> clazz, String propertyName, List<?> list) { public Map<Object, Object> convertToMap(Class<?> clazz, String propertyName, List<?> list) {
return convertToMap(clazz, propertyName, list, false); return convertToMap(clazz, propertyName, list, false);
...@@ -228,18 +233,19 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -228,18 +233,19 @@ public class ProductApplicationImpl implements ProductApplication {
* @param isBean 是否需要转换为实体 (当前应用不需要返回实体) * @param isBean 是否需要转换为实体 (当前应用不需要返回实体)
* @return java.util.Map<java.lang.Object, java.lang.Object> * @return java.util.Map<java.lang.Object, java.lang.Object>
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/11/29 11:34 * createDate 2023/11/29 11:34
*/ */
public Map<Object, Object> convertToMap(Class<?> clazz, String propertyName, List<?> list, boolean isBean) { public Map<Object, Object> convertToMap(Class<?> clazz, String propertyName, List<?> list, boolean isBean) {
Map<String, Object> checkMap = checkClassesAndProperties(clazz, propertyName, list.size()); Map<String, Object> checkMap = checkClassesAndProperties(clazz, propertyName, list.size());
if(!(Boolean) checkMap.get("isOk")) { String ok = "isOk";
if(!(Boolean) checkMap.get(ok)) {
return null; return null;
} }
Method method = (Method) checkMap.get("method"); Method method = (Method) checkMap.get("method");
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
List<Map<String, Object>> mapList = mapper.convertValue(list, List.class); LinkedList<Map<String, Object>> mapList = mapper.convertValue(list, new TypeReference<LinkedList<Map<String, Object>>>() {});
Map<Object, Object> resultMap = new HashMap<>(); Map<Object, Object> resultMap = new HashMap<>(10);
Map<Object, Object> convert = new HashMap<>(); Map<Object, Object> convert = new HashMap<>(1024);
if(isBean) { if(isBean) {
// --------------------------------- 实体 --------------------------------- // --------------------------------- 实体 ---------------------------------
try { try {
...@@ -270,10 +276,10 @@ public class ProductApplicationImpl implements ProductApplication { ...@@ -270,10 +276,10 @@ public class ProductApplicationImpl implements ProductApplication {
* @param propertyName property * @param propertyName property
* @return java.util.HashMap<java.lang.String, java.lang.Object> { "isOk" : 是否通过检查, "method":获取得到的 method } * @return java.util.HashMap<java.lang.String, java.lang.Object> { "isOk" : 是否通过检查, "method":获取得到的 method }
* @author qinzhenguan * @author qinzhenguan
* @create: 2023/11/29 11:05 * createDate 2023/11/29 11:05
*/ */
public HashMap<String, Object> checkClassesAndProperties(Class<?> clazz, String propertyName, int listSize) { public HashMap<String, Object> checkClassesAndProperties(Class<?> clazz, String propertyName, int listSize) {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>(33);
if(listSize == 0) { if(listSize == 0) {
System.err.println("[checkClassesAndProperties] : List< "+clazz.getName()+" > 需要转换的列表没有元素。请检查~!"); System.err.println("[checkClassesAndProperties] : List< "+clazz.getName()+" > 需要转换的列表没有元素。请检查~!");
map.put("isOk", false); map.put("isOk", false);
......
package com.huigou.topsun.product.controller; package com.huigou.topsun.product.controller;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.huigou.cache.DictUtil; import com.huigou.cache.DictUtil;
import com.huigou.topsun.base.coderule.domain.model.CodeRuleKind;
import com.huigou.topsun.product.domain.Product;
import com.huigou.topsun.product.application.ProductApplication; import com.huigou.topsun.product.application.ProductApplication;
import com.huigou.topsun.resource.vo.ResourceFiledVo;
import org.springframework.data.domain.Page;
import com.huigou.uasp.annotation.ControllerMapping; import com.huigou.uasp.annotation.ControllerMapping;
import com.huigou.uasp.client.CommonController; import com.huigou.uasp.client.CommonController;
import com.huigou.util.SDO; import com.huigou.util.SDO;
...@@ -16,14 +13,13 @@ import org.springframework.stereotype.Controller; ...@@ -16,14 +13,13 @@ import org.springframework.stereotype.Controller;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* ProductController * ProductController
* *
* @author qinzhenguan * @author qinzhenguan
* @date 2023/11/27 11:19 * @createDate 2023/11/27 11:19
**/ **/
@Controller @Controller
@ControllerMapping("/product") @ControllerMapping("/product")
...@@ -40,15 +36,12 @@ public class ProductController extends CommonController { ...@@ -40,15 +36,12 @@ public class ProductController extends CommonController {
/** /**
* description * description
* @author qinzhenguan * @author qinzhenguan
* @date 2023/11/27 11:49 * @createDate 2023/11/27 11:49
* @return null * @return null
*/ */
public String findProduct() {//需要特定类型返回值 public String findProduct() {//需要特定类型返回值
SDO sdo = this.getSDO();
// int page = sdo.getInteger("page");
// int size = sdo.getInteger("size");
ArrayList<Map<String,Object>> productPage = productService.findProductPage(0, 30); ArrayList<Map<String,Object>> productPage = productService.findProductPage(0, 30);
HashMap<Object, Object> map = new HashMap<>(); HashMap<Object, Object> map = new HashMap<>(3);
map.put("Rows",productPage); map.put("Rows",productPage);
return toResult(map); return toResult(map);
} }
...@@ -63,7 +56,7 @@ public class ProductController extends CommonController { ...@@ -63,7 +56,7 @@ public class ProductController extends CommonController {
public String forwardProduct() { public String forwardProduct() {
// 通过此方法可以查看系统配置的 字典 的数据结构 // 通过此方法可以查看系统配置的 字典 的数据结构
DictUtil.getDictionaryList("technologyType"); DictUtil.getDictionaryList("technologyType");
Map<String, Object> map4 = new HashMap<>(); Map<String, Object> map4 = new HashMap<>(10);
map4.put("六六六", "666"); map4.put("六六六", "666");
map4.put("七七七", "777"); map4.put("七七七", "777");
map4.put("八八八", "888"); map4.put("八八八", "888");
...@@ -74,9 +67,9 @@ public class ProductController extends CommonController { ...@@ -74,9 +67,9 @@ public class ProductController extends CommonController {
public String forwardProductDetail() { public String forwardProductDetail() {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
SDO sdo = this.getSDO(); SDO sdo = this.getSDO();
Map param = null; HashMap<String, Object> param;
try { try {
param = mapper.readValue(sdo.getString("data"), Map.class); param = mapper.readValue(sdo.getString("data"), new TypeReference<HashMap<String, Object>>() {});
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -84,13 +77,24 @@ public class ProductController extends CommonController { ...@@ -84,13 +77,24 @@ public class ProductController extends CommonController {
} }
public String loadProductDetail() { public String loadProductDetail() {
ObjectMapper mapper = new ObjectMapper();
SDO sdo = this.getSDO(); SDO sdo = this.getSDO();
String productId = sdo.getString("productId"); String productId = sdo.getString("productId");
Map<String, Object> resultMap = productService.queryDetailAll(Integer.parseInt(productId)); Map<String, Object> resultMap = productService.queryDetailAll(Integer.parseInt(productId));
return toResult(resultMap); return toResult(resultMap);
} }
public String saveProductAndDetail() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
SDO sdo = this.getSDO();
String updateJson = sdo.toString();
HashMap<String,Object> updateMap = mapper.readValue(updateJson, new TypeReference<HashMap<String,Object>>() {});
HashMap<String,Object> rawMap = mapper.readValue(updateMap.get("rawData") + "", new TypeReference<HashMap<String,Object>>() {});
updateMap.remove("rawData");
HashMap<String,Object> resultMap = productService.saveProductAndDetail(rawMap, updateMap);
return success(resultMap);
}
} }
\ No newline at end of file
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