package Ġcom . bra ver idge . experience kit . controller Ċ Ċ import Ġcom . bra ver idge . experience kit . form . Device Create Form Ċ import Ġcom . bra ver idge . experience kit . client . request . Device CreateRequest Ċ import Ġcom . bra ver idge . experience kit . client . request . Device Update Request Ċ import Ġcom . bra ver idge . experience kit . form . Device Update Form Ċ import Ġcom . bra ver idge . experience kit . properties . Br ave gate Properties Ċ import Ġcom . bra ver idge . experience kit . service . Br ave gate Service Ċ import Ġorg . springframework . stereotype . Controller Ċ import Ġorg . springframework . ui . Model Ċ import Ġorg . springframework . validation . annotation . Validated Ċ import Ġorg . springframework . web . bind . annotation .* Ċ import Ġjava . lang . RuntimeException Ċ Ċ @ Controller Ċ @ RequestMapping ("/ device ") Ċ class ĠDevice Controller ( ĊĠĠĠ Ġprivate Ġval Ġservice : ĠBr ave gate Service ) Ġ{ ĊĊĠĠĠ Ġ// Ġä¸Ģ è¦§ ĊĠĠĠ Ġ@ GetMapping ("") ĊĠĠĠ Ġfun Ġlist ( model : ĠModel ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdevice List Ġ= Ġservice . getDevice List () ĊĠĠĠĠĠĠĠ Ġmodel . addAttribute (" device List ", Ġdevice List ) ĊĠĠĠĠĠĠĠ Ġreturn Ġ" device / list " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠæĽ´æĸ° ĊĠĠĠ Ġ@ GetMapping ("/ edit /{ deviceId }") ĊĠĠĠ Ġfun Ġedit ( ĊĠĠĠĠĠĠĠ Ġmodel : ĠModel , ĊĠĠĠĠĠĠĠ Ġ@ PathVariable (" deviceId ") ĠdeviceId : ĠString ĊĠĠĠ Ġ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdevice Ġ= Ġservice . getDevice ( deviceId ) ĊĠĠĠĠĠĠĠ Ġmodel . addAttribute (" device ", Ġdevice ) ĊĠĠĠĠĠĠĠ Ġreturn Ġ" device / edit " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ PostMapping ("/ edit /{ deviceId }") ĊĠĠĠ Ġ@ ResponseBody ĊĠĠĠ Ġfun Ġupdate ( ĊĠĠĠĠĠĠĠ Ġ@ PathVariable (" deviceId ") ĠdeviceId : ĠString , ĊĠĠĠĠĠĠĠ Ġ@ RequestBody Ġ@ Validated Ġform : ĠDevice Update Form ĊĠĠĠ Ġ): ĠBr ave gate Service . Device ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠDevice Update Request ( form . groupId , Ġform . name ) ĊĠĠĠĠĠĠĠ Ġreturn Ġservice . update Device ( deviceId , Ġrequest ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠRuntimeException () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// Ġ çĻ»éĮ² ĊĠĠĠ Ġ@ GetMapping ("/ create ") ĊĠĠĠ Ġfun Ġcreate ( model : ĠModel ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġ" device / create " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ PostMapping ("/ create ") ĊĠĠĠ Ġ@ ResponseBody ĊĠĠĠ Ġfun Ġcreate (@ RequestBody Ġ@ Validated Ġform : ĠDevice Create Form ): ĠBr ave gate Service . Device ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠDevice CreateRequest ("", Ġform . deviceId , Ġform . registration Code , Ġform . name ) ĊĠĠĠĠĠĠĠ Ġreturn Ġservice . create Device ( request ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// Ġ åīĬéĻ¤ ĊĠĠĠ Ġ@ PostMapping ("/ delete /{ deviceId }") ĊĠĠĠ Ġ@ ResponseBody ĊĠĠĠ Ġfun Ġdelete (@ PathVariable (" deviceId ") ĠdeviceId : ĠString ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġservice . delete Device ( deviceId ) ĊĠĠĠ Ġ} Ċ }