56 lines
1.6 KiB
Java
Raw Normal View History

2022-03-01 09:36:56 +08:00
package com.xkrs.controller;
import com.xkrs.dao.SpecDao;
import com.xkrs.encapsulation.PromptMessageEnum;
import com.xkrs.model.entity.SpecEntity;
import com.xkrs.model.qo.SpecQo;
import com.xkrs.service.SpecService;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
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
private SpecDao specDao;
/**
* 添加规格数据
*
* @param specQo
*/
@PostMapping("/insertSpec")
public String insertSpec(SpecQo specQo) {
return specService.insertSpec(specQo);
}
/**
* 查询规格信息
*/
@PostMapping("/selectSpec")
public String selectSpec(@RequestBody SpecQo specQo) {
Locale locale = LocaleContextHolder.getLocale();
String partNo = specQo.getPartNo();
String inspectionItemCode = specQo.getInspectionItemCode();
SpecEntity specEntity = specDao.findByPartNoAndInspectionItemCode(partNo, inspectionItemCode).get();
if (specEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该零件的规格信息!", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, specEntity, locale);
}
}