package com.chinasoft.clothesmanager.controller;
import com.chinasoft.clothesmanager.entity.Clothes;
import com.chinasoft.clothesmanager.entity.ClothesExWarehousing;
import com.chinasoft.clothesmanager.entity.ClothesVo;
import com.chinasoft.clothesmanager.service.ClothesService;
import com.chinasoft.clothesmanager.service.impl.ClothesServiceImpl;
import com.chinasoft.clothesmanager.util.ClothesCons;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 登录
* @autor songxingsongxing
* @date 20200305
*/
@Controller
@RequestMapping("/clothes")
public class ClothesController {
@Autowired
ClothesService clothesService;
private Logger logger = LoggerFactory.getLogger(ClothesServiceImpl.class);
/**
* 获取衣服信息
* @autor songxingsongxing
* @date 20200305
* @param clothesName
* @param clothesColor
* @return
*/
@ResponseBody
@RequestMapping(value = "/getClothes", method = RequestMethod.GET)
public Map getClothes(@RequestParam(value = "clothesName", required = false)String clothesName,
@RequestParam(value = "clothesColor", required = false)String clothesColor) {
Map<String, Object> map = new HashMap<>();
map.put("STATUS", 1);
map.put("MSG", ClothesCons.QUERY_SUCCESS);
try {
List<ClothesVo> list = clothesService.getClothes(clothesName, clothesColor);
map.put("datas", list);
}
catch (Exception e) {
logger.error("获取衣服信息异常");
map.put("STATUS", 0);
map.put("MSG", ClothesCons.QUERY_FAIL);
return map;
}
return map;
}
/**
* 衣服入库
* @autor songxingsongxing
* @date 20200305
* @param clothes
* @return
*/
@ResponseBody
@RequestMapping(value = "/Clothes", method = RequestMethod.POST)
public Map insertClothes(Clothes clothes) {
Map<String, Object> map = new HashMap<>();
map.put("STATUS", 1);
map.put("MSG", ClothesCons.ADD_SUCCESS);
try {
clothesService.insertClothes(clothes);
}
catch (Exception e) {
e.printStackTrace();
map.put("STATUS", 0);
map.put("MSG", ClothesCons.ADD_FAIL);
return map;
}
return map;
}
/**
* 衣服出库
* @autor songxingsongxing
* @date 20200308
* @param exClothes
* @return
*/
@ResponseBody
@RequestMapping(value = "/exClothes", method = RequestMethod.POST)
public Map exClothes(@RequestBody Map<String, List<ClothesExWarehousing>> exClothes) {
Map<String, Object> map = new HashMap<>();
map.put("STATUS", 1);
map.put("MSG", ClothesCons.EXCLOTHES_SUCCESS);
try {
clothesService.exClothes(exClothes);
}
catch (Exception e) {
e.printStackTrace();
map.put("STATUS", 0);
map.put("MSG", ClothesCons.EXCLOTHES_FAIL);
return map;
}
return map;
}
}
10-19