You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.9 KiB
Java

package com.nmgs.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nmgs.annotation.OperationLogDesc;
import com.nmgs.config.ResultData;
import com.nmgs.entity.WhiteAccountText;
import com.nmgs.service.IWhiteAccountSerive;
import com.nmgs.util.PubTools;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Map;
/**
* 单位信息管理
*/
@RestController
@RequestMapping("/whiteAccount")
@Api(tags = "单位信息管理")
public class WhiteAccountTextController {
public IWhiteAccountSerive iWhiteAccountSerive;
@Autowired
public void setiWhiteAccountSerive(IWhiteAccountSerive iWhiteAccountSerive) {
this.iWhiteAccountSerive = iWhiteAccountSerive;
}
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
@PostMapping(value="/getAccountByPage")
@ApiOperation(httpMethod="POST",value="查询单位信息管理数据")
public Object getListByPage(HttpServletRequest request, @RequestBody(required = false) Map<String, Object> req) throws SQLException {
Page<WhiteAccountText> whiteCarnoListList =null;
try{
whiteCarnoListList = iWhiteAccountSerive.getWhiteAccountTextByPage(req);
if (PubTools.isEmpty(whiteCarnoListList)) {
return ResultData.fail(-1,"数据查询失败");
}
}catch (Exception e){
String throwableStr = e.getCause().toString();
if(throwableStr.contains(":")){
throwableStr = throwableStr.substring(throwableStr.indexOf(":") + 1);
}
return ResultData.fail(-1,"数据查询失败==>"+throwableStr);
}
return whiteCarnoListList;
}
@PostMapping(value = "/addData")
@OperationLogDesc(module = "单位信息管理>新增", events = "新增记录")
@ApiOperation(httpMethod="POST",value="新增记录")
public ResultData<String> addData(HttpServletRequest request, @RequestBody(required = false) Map<String, Object> req) throws Exception {
int ret = iWhiteAccountSerive.insertData((WhiteAccountText)PubTools.map2Object(req,WhiteAccountText.class));
if(ret>-1){
return ResultData.success("新增成功","",0);
}else{
if(ret==-2){
return ResultData.fail("单位编码已经存在!");
}
}
return ResultData.fail("新增失败");
}
@PostMapping(value = "/batchDelDatas")
@OperationLogDesc(module = "单位信息管理>批量删除", events = "删除记录")
@ApiOperation(httpMethod="POST",value="删除记录")
public ResultData<String> batchDelDatas(HttpServletRequest request, @RequestBody Object req) throws Exception {
int ret = iWhiteAccountSerive.batchDelDatas(req);
if(ret>-1){
return ResultData.success("删除成功","",0);
}
return ResultData.fail("删除失败");
}
@PostMapping(value = "/updateById")
@OperationLogDesc(module = "单位信息管理>修改", events = "修改记录")
@ApiOperation(httpMethod="POST",value="修改记录")
public ResultData<String> updateById(HttpServletRequest request, @RequestBody(required = false) WhiteAccountText req) throws Exception {
try{
int ret = iWhiteAccountSerive.updateById(req);
if(ret>-1){
return ResultData.success("保存成功");
}
}catch (Exception e){
return ResultData.fail("保存失败:"+e.getMessage());
}
return ResultData.fail("保存失败");
}
}