55 lines
1.6 KiB
Java
Raw Normal View History

2022-03-01 09:36:56 +08:00
package com.xkrs.controller;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.model.entity.SpecEntity;
import com.xkrs.model.qo.SpecQo;
import com.xkrs.service.SpecService;
2022-03-01 15:54:55 +08:00
import com.xkrs.util.SpecQuery;
2022-03-01 09:36:56 +08:00
import org.springframework.context.i18n.LocaleContextHolder;
2022-03-01 11:59:54 +08:00
import org.springframework.web.bind.annotation.*;
2022-03-01 09:36:56 +08:00
import javax.annotation.Resource;
2022-03-01 15:54:55 +08:00
import java.util.List;
2022-03-01 09:36:56 +08:00
import java.util.Locale;
import static com.xkrs.encapsulation.OutputEncapsulation.outputEncapsulationObject;
/**
* @Author: XinYi Song
* @Date: 2022/1/20 16:01
*/
@RestController
public class SpecController {
@Resource
private SpecService specService;
@Resource
2022-03-01 15:54:55 +08:00
private SpecQuery specQuery;
2022-03-01 09:36:56 +08:00
/**
* 添加规格数据
*
* @param specQo
*/
@PostMapping("/insertSpec")
2022-03-01 11:59:54 +08:00
public String insertSpec(@RequestBody SpecQo specQo) {
2022-03-01 09:36:56 +08:00
return specService.insertSpec(specQo);
}
/**
* 查询规格信息
*/
2022-03-01 11:59:54 +08:00
@GetMapping("/selectSpec")
2022-03-01 15:54:55 +08:00
public String selectSpec(@RequestParam(required = false, value = "partNo") String partNo,
@RequestParam(required = false, value = "inspectionItemCode") String inspectionItemCode) {
2022-03-01 09:36:56 +08:00
Locale locale = LocaleContextHolder.getLocale();
2022-03-01 15:54:55 +08:00
List<SpecEntity> specEntities = specQuery.selectSpec(partNo, inspectionItemCode);
if (specEntities.isEmpty()) {
2022-03-01 09:36:56 +08:00
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该零件的规格信息!", locale);
}
2022-03-01 15:54:55 +08:00
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, specEntities.get(0), locale);
2022-03-01 09:36:56 +08:00
}
2022-03-01 15:54:55 +08:00
2022-03-01 09:36:56 +08:00
}