|
@@ -35,12 +35,12 @@ public class CompanyInfoController {
|
|
|
|
|
|
@ApiOperation(value="创建空记录")
|
|
@ApiOperation(value="创建空记录")
|
|
@GetMapping("create")
|
|
@GetMapping("create")
|
|
- public MessageResult<CompanyInfo> create(){
|
|
|
|
- MessageResult<CompanyInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
+ public MessageResult<CompanyInfoDTO> create(){
|
|
|
|
+ MessageResult<CompanyInfoDTO> msgResult = new MessageResult<>();
|
|
|
|
|
|
- CompanyInfo companyInfo = new CompanyInfo();
|
|
|
|
|
|
+ CompanyInfoDTO companyInfoDTO = new CompanyInfoDTO();
|
|
|
|
|
|
- msgResult.setData(companyInfo);
|
|
|
|
|
|
+ msgResult.setData(companyInfoDTO);
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
|
|
|
|
return msgResult;
|
|
return msgResult;
|
|
@@ -48,20 +48,37 @@ public class CompanyInfoController {
|
|
|
|
|
|
@ApiOperation(value="添加信息")
|
|
@ApiOperation(value="添加信息")
|
|
@PostMapping("add")
|
|
@PostMapping("add")
|
|
- public MessageResult<CompanyInfo> add(@RequestBody CompanyInfo companyInfo,@RequestAttribute String subject){
|
|
|
|
- MessageResult<CompanyInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
+ public MessageResult<Map> add(@RequestBody CompanyInfoDTO companyInfoDTO,@RequestAttribute String subject){
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
+ CompanyInfo companyInfo = new CompanyInfo();
|
|
|
|
+ PojoUtils.map(companyInfoDTO, companyInfo);
|
|
companyInfo.setId(UUID.randomUUID().toString());
|
|
companyInfo.setId(UUID.randomUUID().toString());
|
|
companyInfo.setDelFlag(false);
|
|
companyInfo.setDelFlag(false);
|
|
companyInfo.setCreateBy(subject);
|
|
companyInfo.setCreateBy(subject);
|
|
companyInfo.setCreateTime(new Date());
|
|
companyInfo.setCreateTime(new Date());
|
|
-
|
|
|
|
- int affectCount = companyInfoService.insert(companyInfo);
|
|
|
|
|
|
+ companyInfoService.insert(companyInfo);
|
|
|
|
+ map.put("companyInfo",companyInfo);
|
|
|
|
+
|
|
|
|
+ CompanyPosition companyPosition = new CompanyPosition();
|
|
|
|
+ companyPosition.setId(UUID.randomUUID().toString());
|
|
|
|
+ companyPosition.setCompanyId(companyInfo.getId());
|
|
|
|
+ companyPosition.setPosition1Name(companyInfoDTO.getPosition1Name());
|
|
|
|
+ companyPosition.setPosition2Name(companyInfoDTO.getPosition2Name());
|
|
|
|
+ companyPosition.setPosition3Name(companyInfoDTO.getPosition3Name());
|
|
|
|
+ companyPosition.setPosition4Name(companyInfoDTO.getPosition4Name());
|
|
|
|
+ companyPosition.setPosition5Name(companyInfoDTO.getPosition5Name());
|
|
|
|
+ companyPosition.setDelFlag(false);
|
|
|
|
+ companyPosition.setCreateBy(subject);
|
|
|
|
+ companyPosition.setCreateTime(new Date());
|
|
|
|
+ int affectCount = companyPositionService.insert(companyPosition);
|
|
|
|
+ map.put("companyPosition",companyPosition);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
- msgResult.setData(companyInfo);
|
|
|
|
|
|
+ msgResult.setData(map);
|
|
} else {
|
|
} else {
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage("数据库添加失败");
|
|
msgResult.setMessage("数据库添加失败");
|
|
@@ -79,15 +96,17 @@ public class CompanyInfoController {
|
|
|
|
|
|
@ApiOperation(value="获取信息")
|
|
@ApiOperation(value="获取信息")
|
|
@GetMapping("edit/{id}")
|
|
@GetMapping("edit/{id}")
|
|
- public MessageResult<CompanyInfo> edit(@PathVariable("id") String id){
|
|
|
|
- MessageResult<CompanyInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
+ public MessageResult<CompanyInfoDTO> edit(@PathVariable("id") String id){
|
|
|
|
+ MessageResult<CompanyInfoDTO> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
try {
|
|
CompanyInfo companyInfo = companyInfoService.get(id);
|
|
CompanyInfo companyInfo = companyInfoService.get(id);
|
|
|
|
+ CompanyInfoDTO companyInfoDTO = new CompanyInfoDTO();
|
|
|
|
|
|
if (companyInfo != null) {
|
|
if (companyInfo != null) {
|
|
|
|
+ PojoUtils.map(companyInfo, companyInfoDTO);
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
- msgResult.setData(companyInfo);
|
|
|
|
|
|
+ msgResult.setData(companyInfoDTO);
|
|
} else {
|
|
} else {
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
msgResult.setMessage("数据库不存在该记录!");
|
|
@@ -105,18 +124,43 @@ public class CompanyInfoController {
|
|
|
|
|
|
@ApiOperation(value="更新")
|
|
@ApiOperation(value="更新")
|
|
@PostMapping("update")
|
|
@PostMapping("update")
|
|
- public MessageResult<CompanyInfo> update(@RequestBody CompanyInfo companyInfo,@RequestAttribute String subject){
|
|
|
|
- MessageResult<CompanyInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
+ public MessageResult<Map> update(@RequestBody CompanyInfoDTO companyInfoDTO,@RequestAttribute String subject){
|
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
+ int affectCount = 0;
|
|
|
|
+ CompanyInfo companyInfo = new CompanyInfo();
|
|
|
|
+ PojoUtils.map(companyInfoDTO, companyInfo);
|
|
companyInfo.setUpdateBy(subject);
|
|
companyInfo.setUpdateBy(subject);
|
|
companyInfo.setUpdateTime(new Date());
|
|
companyInfo.setUpdateTime(new Date());
|
|
-
|
|
|
|
- int affectCount = companyInfoService.update(companyInfo);
|
|
|
|
|
|
+ companyInfoService.update(companyInfo);
|
|
|
|
+ map.put("companyInfo",companyInfo);
|
|
|
|
+ affectCount++;
|
|
|
|
+
|
|
|
|
+ CompanyPosition companyPosition = new CompanyPosition();
|
|
|
|
+ Map<String,Object> searchParams1 = new HashMap<>();
|
|
|
|
+ searchParams1.put("companyId",companyInfo.getId());
|
|
|
|
+ List<Sort> sortList1 = new ArrayList<>();
|
|
|
|
+ sortList1.add(new Sort("id_","asc"));
|
|
|
|
+ Page<CompanyPosition> page1 = companyPositionService.pageSearch(searchParams1,1,1,false,sortList1);
|
|
|
|
+ if(page1.size() > 0) {
|
|
|
|
+ companyPosition = page1.get(0);
|
|
|
|
+ companyPosition.setPosition1Name(companyInfoDTO.getPosition1Name());
|
|
|
|
+ companyPosition.setPosition2Name(companyInfoDTO.getPosition2Name());
|
|
|
|
+ companyPosition.setPosition3Name(companyInfoDTO.getPosition3Name());
|
|
|
|
+ companyPosition.setPosition4Name(companyInfoDTO.getPosition4Name());
|
|
|
|
+ companyPosition.setPosition5Name(companyInfoDTO.getPosition5Name());
|
|
|
|
+ companyPosition.setUpdateBy(subject);
|
|
|
|
+ companyPosition.setUpdateTime(new Date());
|
|
|
|
+ companyPositionService.update(companyPosition);
|
|
|
|
+ affectCount++;
|
|
|
|
+ }
|
|
|
|
+ map.put("companyPosition",companyPosition);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
if (affectCount > 0) {
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
- msgResult.setData(companyInfo);
|
|
|
|
|
|
+ msgResult.setData(map);
|
|
} else {
|
|
} else {
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage("数据库更新失败");
|
|
msgResult.setMessage("数据库更新失败");
|