123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package com.fuzamei.web;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.LinkedHashMap;
- import java.util.List;
- import java.util.Map;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.alibaba.fastjson.JSON;
- import com.fuzamei.constant.HintMSG;
- import com.fuzamei.entity.User;
- import com.fuzamei.service.PlannerService;
- import com.fuzamei.util.JSONUtil;
- import com.fuzamei.util.ValidationUtil;
- @RestController
- @RequestMapping(path="/planner")
- public class PlannerAction {
- @Autowired
- private PlannerService plannerService;
-
- @PostMapping(value="queryPlanner")
- public Map<String, Object> queryPlanner(@RequestBody String data){
- try {
- List<User> list=null;
- @SuppressWarnings("unchecked")
- Map<String, Object> map = JSON.parseObject(data,Map.class);//将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
- int user_id = ValidationUtil.checkAndAssignInt(map.get("user_id"));// ————————》给个用户id 判断用户id是什么权限
-
- String username=ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("username"));//拿到前端传来的账号去service校验
- Map<String, Object> mapToService = new LinkedHashMap<String, Object>();
- mapToService.put("user_id",user_id );
- mapToService.put("username", username);
- list=plannerService.queryPlanner(mapToService);
- return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, list);
- } catch (Exception e) {
- e.printStackTrace();
- //System.out.println(e.getMessage()+"aa");
- return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
- }
-
- }
- /**
- {
- "plannerId":"1002"
- }
- * 配置供应商
- * 通过计划员id 查询已经添加的供应商 和 未添加的供应商
- * @param data
- * @return
- */
- @PostMapping(value="queryYesOrNoSupplierByPlannerId")
- public Map<String, Object> queryYesOrNoSupplierByPlannerId(@RequestBody String data){
- try {
- List<User> SupplierList=null;
- List<User> SupplierList2=null;
- @SuppressWarnings("unchecked")
- Map<String, Object> map = JSON.parseObject(data,Map.class);//将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
- int userId = ValidationUtil.checkAndAssignInt(map.get("plannerId"));// 传的是计划员id 其实就是用户id
-
- SupplierList=plannerService.queryAllSupplierByPlannerId(userId);
- SupplierList2=plannerService.queryAllNoSupplierByPlannerId(userId);
- Map<String, Object> twolist =new HashMap<String, Object>();
- twolist.put("SupplierList", SupplierList);
- twolist.put("SupplierList2", SupplierList2);
- return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, twolist);
- } catch (Exception e) {
- e.printStackTrace();
- return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
- }
-
- }
-
-
- }
|