Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 2 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. ### frontend:
  2. - Routes.js (path: 'xxx**Win**' for Window component)
  3. - load js resources:
  4. ```javascript
  5. // option 1
  6. items: [
  7. Ext.create('App.test.TestPanel',{
  8. title: 'Title 1'
  9. }),
  10. {
  11. xtype: 'panel',
  12. title: 'Title 2'
  13. }
  14. ]
  15. // option 2
  16. requires: ['App.xxxx.XxxxPanel'],
  17. items: [{
  18. xtype: 'test.testPanel',
  19. title: 'Title 1'
  20. }]
  21. ```
  22. - get component e.g.
  23. ```javascript
  24. me.down('test\\.testPanel') //alias: 'widget.test.testPanel'
  25. - i18n: static/public/i18n/{locale}.json
  26. ```javascript
  27. // component level
  28. bind: {
  29. text: '{i18n.xx.xx}'
  30. }
  31. // program level
  32. App.getI18n('xx.xx') // or App.getI18n().xx.xx
  33. - security
  34. - App.security.getUser()
  35. - App.security.isGranted(string | string[])
  36. - App.security.isGrantedAll(string[])
  37. ### backend (draft):
  38. - vs code dev: example.launch.json
  39. - db migration: resources/db/changelog/changes/\*\* (support subfolder)
  40. - suggested that one changeset with one DDL
  41. - filename: {yyyyMMdd}\_{number}\_{name}/{number}_{name}.sql
  42. - filename 2(optional): {yyyyMMdd}\_{number}\_{name}/{number}\_{name}/{number}\_{name}.sql
  43. ```sql
  44. --liquibase formatted sql
  45. --changeset {name}:{id}
  46. --comment: remarks (optional)
  47. CREATE TABLE `tableName` (
  48. `id` INT PRIMARY KEY AUTO_INCREMENT,
  49. `created` DATETIME NOT NULL DEFAULT NOW(),
  50. `createdBy` VARCHAR(30),
  51. `version` INT NOT NULL DEFAULT 0,
  52. `modified` DATETIME NOT NULL DEFAULT NOW(),
  53. `modifiedBy` VARCHAR(30),
  54. `deleted` BOOLEAN NOT NULL DEFAULT FALSE,
  55. `column1` INT NOT NULL,
  56. `column2` VARCHAR(255)
  57. );
  58. ```
  59. - controller
  60. - AbstractController
  61. - api: /public/\*\* /protected/\*\*
  62. - RequestBody Class (`@NotNull`, `@NotBlank`, `@Min`, `@Max`, `@Pattern`, etc...)
  63. ```java
  64. @NotNull
  65. @Pattern(regexp = "^Y$|^N$")
  66. private String YesNo;
  67. ```
  68. - authentication check: `@PreAuthorize`
  69. - common response class `DataRes`, `IdRes`, `RecrodsRes`, `SuccessRes`
  70. - RESTfull api (http method, http status)
  71. - http status:
  72. - 404: record not found
  73. - 409: record_line not found or record_line not under the record (relation check)
  74. - 422: something wrong, (e.g. qty not enough)
  75. - suggest /save api (also allowed for POST: new, PUT: update)
  76. 1. POST /xxxx/save
  77. 2. body:
  78. ```json
  79. {
  80. "id": 1, //update
  81. "xx": "xx",
  82. "updateLines": [
  83. {
  84. "id": null, // new
  85. "xx": "xx"
  86. },
  87. {
  88. // need a relation check
  89. "id": 1, //update
  90. "xx": "xx"
  91. }
  92. ],
  93. // need a relation check
  94. "deleteLineIds": [1, 2]
  95. }
  96. ```
  97. ```java
  98. //example
  99. @RestController
  100. @RequestMapping("/xxxx")
  101. public class ExampleController extends AbstractController {
  102. @PostMapping('/xxx') // @GetMapping @DeleteMapping @PutMapping @PatchMapping
  103. //@ResponseStatus(HttpStatus.CREATED)
  104. //@PreAuthorize("hasAuthority('XXX_MAINT')")
  105. public Xxxx api (@RequestBody @Valid ReqClass req) {
  106. }
  107. @GetMapping('/{id}')
  108. public Xxxx getXxx (@PathVariable int id) {
  109. }
  110. }
  111. ```
  112. - service
  113. - AbstractService, AbstractIdEntityService, AbstractBaseEntityService
  114. - `@Transactional(rollbackFor = Exception.class)` for write, read only not need transaction
  115. - dao
  116. - interface
  117. - AbstractDao
  118. - [Query Creation](https://docs.spring.io/spring-data/jpa/docs/2.7.0/reference/html/#jpa.query-methods.query-creation)
  119. - `@Query`
  120. ```java
  121. public Optional<User> findByUsernameAndDeletedFalse(String username);
  122. // same
  123. @Query("FROM #{#entityName} u WHERE u.deleted = FALSE AND u.username = :username")
  124. public Optional<User> findByUsername(@Param("username") String username);
  125. ```
  126. - entity
  127. - IdEntity, BaseEntity
  128. - validation: `@NotNull`, `@NotBlank`, `@Min`, `@Max`, `@Pattern`, etc...
  129. - jdbcDao
  130. - reduce Map: queryForEntity, queryForList("SELECT xxx" , params, XxxRecord.class)
  131. - [Class Object vs Hashmap](https://stackoverflow.com/questions/10258071/class-object-vs-hashmap)
  132. - reduce `@Autowired`
  133. - use constructor
  134. - try separate class (e.g. FileListController, FileDownloadController)
  135. - return Optional instead of null
  136. - return Optional\<T\> : may null
  137. - return T : must not null
  138. - i18n: i18n/messages_{locale(underscore)}.properties
  139. - `messageSource.getMessage("name", null, LocaleUtils.getLocale());`
  140. - reporting:
  141. - excel:
  142. - files:
  143. - excel/{filename}.xlsx
  144. - excel/{filename}_zh-TW.xlsx
  145. - excel/{filename}_zh-CN.xlsx
  146. - load Workbook: `ExcelUtils.loadTemplate("excel/{filename}");`
  147. - send out Workbook: `ExcelUtils.send(response, workbook, "filename"); // will output filename.xlsx`
  148. - jasper
  149. - files:
  150. - reports/{filename}.jrxml
  151. - reports/{filename}_zh-TW.jrxml
  152. - reports/{filename}_zh-CN.jrxml
  153. - compile: `JasperUtils.compile("reports/{filename}", params, new JRBeanCollectionDataSource(xxx), Map.of("subReport1","reports/{filename}"));`
  154. - send out: `JasperUtils.responsePdf(response, jRerpot, "filename"); // will output filename.pdf`
  155. - mobile:
  156. - login: POST /mobile/login
  157. - logout: POST /mobile/logout
  158. - call api: http headers with
  159. 1. `X-ATT-DeviceId`
  160. 2. `X-ATT-Access-Token`