12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package com.fuzamei.web;
- 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.constant.Roles;
- import com.fuzamei.entity.User;
- import com.fuzamei.service.ReceivingClerkService;
- import com.fuzamei.util.JSONUtil;
- import com.fuzamei.util.ValidationUtil;
- @RestController
- @RequestMapping(value="/receiving_clerk")
- public class ReceivingClerkAction {
- @Autowired
- private ReceivingClerkService receivingClerkService;
- /**
- {
- "user_id":"1001",
- "username":""
- }
- * @param data
- * @return
- */
- @PostMapping(value="queryReceivingClerk")
- public Map<String, Object> queryReceivingClerk(@RequestBody String data){
- try {
- List<User> list=null;
- @SuppressWarnings("unchecked")
- Map<String, Object> map = JSON.parseObject(data,Map.class);//将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
- Integer user_id = ValidationUtil.checkAndAssignInt(map.get("user_id"));// ————————》给个用户id 判断用户id是什么权限
-
- String username=ValidationUtil.checkBlankStringAndAssignEmptyIfIsBlank(map.get("username"));
- Map<String, Object> mapToService = new LinkedHashMap<String, Object>();
- mapToService.put("user_id",user_id );
- mapToService.put("username", username);
- list=receivingClerkService.queryReceivingClerk(mapToService);
- return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, list);
- } catch (Exception e) {
- return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
- }
-
- }
-
-
- //根据用户id 查询角色 test
- /**
- * "user_id":"1001"
- */
- @PostMapping(value="selectRoleByUserId")
- public Map<String, Object> selectRoleByUserId(@RequestBody String data){
- try {
- @SuppressWarnings("unchecked")
- Map<String, Object> map = JSON.parseObject(data,Map.class);//将前端传过来的json数据转化为map对象,并将map对象传入service层进行数据校验
- int userId = ValidationUtil.checkAndAssignInt(map.get("user_id"));
-
- String ss=receivingClerkService.selectRoleByUserId(userId);
- System.out.println(ss+"fffffffffff");
- return JSONUtil.getJsonMap(200, true, HintMSG.QUERY_SUCCESS, ss);
- } catch (Exception e) {
- return JSONUtil.getJsonMap(500, false, HintMSG.QUERY_FAIL+":"+e.getMessage(), null);
- }
- }
-
-
- }
|