|
|
@@ -0,0 +1,92 @@
|
|
|
+package com.uas.platform.b2b.controller;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.Sort.Direction;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.servlet.ModelAndView;
|
|
|
+
|
|
|
+import com.uas.platform.b2b.model.Vendor;
|
|
|
+import com.uas.platform.b2b.service.VendorService;
|
|
|
+import com.uas.platform.b2b.support.JxlsExcelView;
|
|
|
+import com.uas.platform.b2b.support.SystemSession;
|
|
|
+import com.uas.platform.core.model.PageInfo;
|
|
|
+import com.uas.platform.core.model.PageParams;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 供应商、客户
|
|
|
+ *
|
|
|
+ * @author suntg
|
|
|
+ *
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/vendor")
|
|
|
+public class VendorController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private VendorService vendorService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取供应商
|
|
|
+ */
|
|
|
+ @RequestMapping(method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Page<Vendor> getVendors(PageParams params){
|
|
|
+ PageInfo info = new PageInfo(params);
|
|
|
+ info.filter("myEnUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ return vendorService.findAllByPageInfo(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取客户
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/customer", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Page<Vendor> getCustomers(PageParams params){
|
|
|
+ PageInfo info = new PageInfo(params);
|
|
|
+ info.filter("vendEnUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ return vendorService.findAllByPageInfo(info);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查找平台使用日志
|
|
|
+ *
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/customer/xls", method = RequestMethod.GET)
|
|
|
+ public ModelAndView exportUsageLogs() {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ PageInfo pageInfo = new PageInfo(1, JxlsExcelView.MAX_SIZE, 0);
|
|
|
+ pageInfo.sorting("myEnUU", Direction.ASC);
|
|
|
+ pageInfo.filter("vendEnUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ map.put("data", vendorService.findAllByPageInfo(pageInfo).getContent());
|
|
|
+ return new ModelAndView(new JxlsExcelView("classpath:jxls-tpl/Customer", "客户列表"), map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供应商个数和客户个数
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/count", method = RequestMethod.GET, headers = "Accept=application/json")
|
|
|
+ @ResponseBody
|
|
|
+ @ResponseStatus(value = HttpStatus.OK)
|
|
|
+ public ModelMap getTodo() {
|
|
|
+ ModelMap modelMap = new ModelMap();
|
|
|
+ modelMap.put("vendor", vendorService.findMyVendors().size());
|
|
|
+ modelMap.put("customer", vendorService.findMyCustomers().size());
|
|
|
+ return modelMap;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|