修改了修改火情状态的代码模块

This commit is contained in:
XinYi Song 2022-02-25 16:49:05 +08:00
parent 233420973b
commit 7706e24809
3 changed files with 31 additions and 10 deletions

View File

@ -104,19 +104,11 @@ public class FireController {
* @param map
* @return
*/
@Transactional(rollbackOn = Exception.class)
@PostMapping("/updateFireState")
public String updateFireState(@RequestBody Map map){
String alarmCode = (String) map.get("alarmCode");
Fire byAlarmCode = fireDao.findByAlarmCode(alarmCode);
if(byAlarmCode == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火情编码错误,请检查!",locale);
}
if("1".equals(byAlarmCode.getFireState())){
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"该火情已处理!",locale);
}
fireDao.updateFireState(alarmCode);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功!",locale);
return fireService.updateFireState(alarmCode);
}
/**

View File

@ -29,4 +29,11 @@ public interface FireService {
* @return
*/
String findThreeHundredData();
/**
* 修改火点状态
* @param alarmCode
* @return
*/
String updateFireState(String alarmCode);
}

View File

@ -6,11 +6,13 @@ import com.xkrs.model.entity.Fire;
import com.xkrs.service.FireService;
import com.xkrs.util.Query;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Locale;
@ -78,4 +80,24 @@ public class FireServerImpl implements FireService {
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,threeHundredData,locale);
}
/**
* 修改火点状态
* @param alarmCode
* @return
*/
@CacheEvict(value = "FireServiceCache",allEntries = true)
@Transactional(rollbackOn = Exception.class)
@Override
public String updateFireState(String alarmCode) {
Fire byAlarmCode = fireDao.findByAlarmCode(alarmCode);
if(byAlarmCode == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火情编码错误,请检查!",locale);
}
if("1".equals(byAlarmCode.getFireState())){
return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"该火情已处理!",locale);
}
fireDao.updateFireState(alarmCode);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功!",locale);
}
}