開發中遇到的坑

2021-10-20 02:34:42 字數 3251 閱讀 6476

new arraylist(.size())時確定list數量,指明list大小,但是確保()裡的.size()不是null

listresult = new arraylist<>(authprioritydolist.size());

判斷string型別的值是不是空時用stringutils.hastext(string phone)

前端傳過來string型別的值傳給service層或者mybatis時一定要做.trim()

//儲存訂單號

if (stringutils.hastext(rpcselectcancelreasonao.getorderid().trim()))

通過mybatis返回的是物件時做null判空處理,返回的是list時,一定不為空,做.size()為0的判斷

list list = new arraylist();list一定不為null,但list.size()=0

前端傳來list時,一定要做相應的去重處理,list《實體》有必要根據對應的字段去重,去重一般使用set去重或者jdk8的distinct()去重

寫完介面,如有空餘時間,先自己使用spring boot的test做自測,部署到dev上的時候一定要檢視控制台輸出,確定部署的服務正確和部署成功,有事兒一定要找運維

和前端聯調時一定要注意介面型別、欄位名稱、字段型別,保證少乙個失誤

介面中引數是陣列時可以寫成(陣列的寫法 string... phone)實際是string phone

在容易報錯的地方加try catch

新增索引

alter table offlineuser add index `idx_userphone_username_licensenumber_callphonetime` ( `userphone`, `username`, `licensenumber`, `callphonetime` )

select

select from drivingdriver

where driverno = #

example example = new example(drivingorderdo.class);

integer unfinishedstatus = new integer;

example.createcriteria().andequalto("driverid", userid).andin("status", arrays.aslist(unfinishedstatus));

複製實體的值到另乙個物件用clone()或者beanutils.copyproperties(source,target)【如果用的是spring的,則前source後target】,copy時有可能出錯,

noticedo notice = noticedto.clone(noticedo.class);

獲取當前時間用system.currenttimemills()

long currenttime = system.currenttimemillis() / 1000;

notice.setgmtcreate(currenttime);

notice.setgmtmodified(currenttime);

分頁查詢中mybatis動態sql中的模糊查詢拼接

and title like concat('%', #, '%')

動態sql中date時間轉成long型別的時間戳進行時間比較

and starttime > unix_timestamp(now())

and starttime <= unix_timestamp(now())

and expiretime >= unix_timestamp(now())

and expiretime < unix_timestamp(now())

example example = new example(drivingorderdo.class);

if (type == orderattributeconst.carowner) else

example example = new example(drivingorderbilldo.class);

example.createcriteria()

.andbetween("paytime", rpcao.getpaystarttime(), rpcao.getpayendtime());

多用option.ofnullable()判空

string driverorgname = optional.ofnullable(resolvedriverorgname(rpcgetdrivingorderlistvo.getdriverorganization())).orelse("--");

分頁查詢時,判斷pagesize和currentpage是否為空,不為空設定預設的大小

if (currenttime - noticedo.getstarttime() > 0 && currenttime - noticedo.getexpiretime() < 0) 

noticedo.builder()

.id(id)

.expiretime(currenttime)

.starttime(currenttime)

.build());

多用@builder註解建立物件

noticedo.builder()

.id(id)

.build());

return noticedo.clone(noticedto.class);

分頁查詢,如果查詢結果為空,則最好不要返回null,返回.size()=0的arraylist()

long carownerid = getcarowneridbyphone(rpcao.getuserphone());

if (carownerid == null || carownerid <= 0)

iOS 開發中遇到的坑

用 建立了乙個view後能顯示,但無法響應觸控事件 出錯原因 可能是父view的frame為cgzero 使用cocoapods更新庫時,使用pod install無效。出錯原因 命令被牆 解決方法 pod install 換成pod install verbose no repo update這個...

VUE開發中遇到的坑

1.父元件監聽不到子元件向外觸發的事件,原因可能是 emit傳入的事件名稱只能用小寫,不可以使用駝峰式命名書寫。現版本的 vue 似乎可以支援 2.用非同步傳遞過來的資料做元件的初始化時候,直接用,因為存在非同步問題 延時,結果需在等待過程結束之後才返回 會出現not find props或者渲染出...

記錄開發中遇到的坑

原因是伺服器出口ip和外網ip不一致。通過下面方式獲取出口ip即可 採用下面的方式去傳送 rocketmqtemplate.syncsend topic name messagebuilder.withpayload json.tojsonstring profitorder build 我遇到的原...