package com.qianwen.mdc.controller.account; import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import com.qianwen.mdc.common.OpResult; import com.qianwen.mdc.dto.IdsDTO; import com.qianwen.mdc.dto.account.MachineAccountEditDTO; import com.qianwen.mdc.service.account.MachineAccountEditService; import com.qianwen.mdc.vallidate.UpdateGroup; /** * 设备台账编辑 控制器 */ @RestController @CrossOrigin @RequestMapping(value = "/account") public class MachineAccountEditController { @Autowired private MachineAccountEditService accountEditService; public static final Logger logger = LoggerFactory.getLogger(MachineAccountEditController.class); @PostMapping(value = "/update") public OpResult update(@RequestHeader(value = "mdc-token", defaultValue = "") String token, @Validated(value = {UpdateGroup.class}) @RequestBody MachineAccountEditDTO dto, HttpServletRequest request) { //TODO checktoken /* JSONObject jsonResult = new JSONObject(); jsonResult.put("result", "SUCCESS"); String id = request.getParameter("id"); String machineName = request.getParameter("machineName"); String uuid = request.getParameter("uuid"); String specification = request.getParameter("specification"); String type = request.getParameter("type"); String category = request.getParameter("category"); String accountingAttribute = request.getParameter("accountingAttribute"); // String location = request.getParameter("location"); String department = request.getParameter("department"); String state = request.getParameter("state"); // String isCritical = request.getParameter("isCritical"); // String isPrecision = request.getParameter("isPrecision"); String elecCompFactor = request.getParameter("elecCompFactor"); String mechCompFactor = request.getParameter("mechCompFactor"); String country = request.getParameter("country"); String manufacturer = request.getParameter("manufacturer"); String productionDate = request.getParameter("productionDate"); String originalValue = request.getParameter("originalValue"); String presentValue = request.getParameter("presentValue"); String weight = request.getParameter("weight"); String pic = request.getParameter("pic"); String remark = request.getParameter("remark"); //班次 String classes = request.getParameter("classes"); //设备管理分类 String managType = request.getParameter("managType"); */ try { //accountTokenService.checkToken(token); accountEditService.modify(dto); }catch(Exception ex) { logger.error("修改台账错误",ex); return OpResult.fail(ex.getMessage()); } return OpResult.success(); } @RequestMapping(value = "/delete", method = RequestMethod.POST) public OpResult delete(@RequestHeader(value = "mdc-token", defaultValue = "") String token, @RequestBody IdsDTO dto,HttpServletRequest request) { try { //accountTokenService.checkToken(token); accountEditService.remove(dto.getIds()); }catch(Exception ex) { logger.error("修改台账错误",ex); return OpResult.fail(ex.getMessage()); } return OpResult.success(); } }