嗨森逛服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hai-server/hai-bweb/src/main/java/com/bweb/controller/SecSinopecConfigController....

126 lines
4.1 KiB

package com.bweb.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighUser;
import com.hai.entity.SecSinopecConfig;
import com.hai.model.ResponseData;
import com.hai.service.SecSinopecConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Sum1Dream
*/
@RestController
@RequestMapping(value = "/secSinopecConfig")
@Api(value = "中石化配置管理")
public class SecSinopecConfigController {
private static Logger log = LoggerFactory.getLogger(HighUserController.class);
@Resource
private SecSinopecConfigService secSinopecConfigService;
@RequestMapping(value = "/getListSinopecConfig", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询用户列表")
public ResponseData getListSinopecConfig(
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize
) {
try {
Map<String, String> map = new HashMap<>();
PageHelper.startPage(pageNum, pageSize);
List<SecSinopecConfig> secSinopecConfigs = secSinopecConfigService.getListSinopecConfig(map);
return ResponseMsgUtil.success(new PageInfo<>(secSinopecConfigs));
} catch (Exception e) {
log.error("HighUserController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/insertSinopec", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增")
public ResponseData insertSinopec(@RequestBody SecSinopecConfig reqBody) {
try {
reqBody.setCreateTime(new Date());
secSinopecConfigService.insertSinopec(reqBody);
return ResponseMsgUtil.success("成功");
} catch (Exception e) {
log.error("BsPositionController --> insertSinopec() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/updateSinopec", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改")
public ResponseData updateSinopec(@RequestBody SecSinopecConfig reqBody) {
try {
if (
reqBody.getId() == null
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
SecSinopecConfig secSinopecConfig = secSinopecConfigService.findById(reqBody.getId());
if (secSinopecConfig == null) {
log.error("BsPositionController --> updateUser() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_USER_ERROR, "");
}
reqBody.setCreateTime(secSinopecConfig.getCreateTime());
secSinopecConfigService.updateSinopec(reqBody);
return ResponseMsgUtil.success("修改成功");
} catch (Exception e) {
log.error("BsPositionController --> addPosition() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/findById", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询详情")
public ResponseData findById(@RequestParam(value = "sinopecId", required = true) Integer sinopecId) {
try {
return ResponseMsgUtil.success(secSinopecConfigService.findById(sinopecId));
} catch (Exception e) {
log.error("HighUserController --> findByUserId() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}