Generic method of introduction:
public <E> void insertOrUpdateHistoryData (Integer year, month The Integer, Integer parkId, type Integer, Integer Number, E E) { // the computed data into the database, whether the next look at the database exists, so do not repeat calculated // here is calculated every time, whether to go to query the database table data of the month, if there are updates, not to add. = Data String JSONObject.toJSONString (E); historyData historyData = historyDataService.isExist (year, month The, parkId,. 1,. 1 ); IF (! HistoryData = null ) { // if there is updated data historyData.setData (data); historyDataService.updateByPrimarykey (historyData); } the else{ // does not exist, add data historyDataService.insert (year, month The, parkId,. 1,. 1 , Data); } }
Such a method is used; generic description: https://www.cnblogs.com/coprince/p/8603492.html