[TEMP] Code entity
This commit is contained in:
parent
5ee43aca29
commit
126c8e0cb0
@ -0,0 +1,10 @@
|
|||||||
|
package com.displaynone.acss.components.auth.models.code;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CodeDTO {
|
||||||
|
private Long id;
|
||||||
|
private Long value;
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.displaynone.acss.components.auth.models.code;
|
||||||
|
|
||||||
|
import com.displaynone.acss.components.auth.models.role.RoleDTO;
|
||||||
|
import com.displaynone.acss.components.auth.models.role.RoleMapper;
|
||||||
|
import com.displaynone.acss.components.auth.models.role.RoleModel;
|
||||||
|
import com.displaynone.acss.utils.GlobalUtils;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@UtilityClass
|
||||||
|
public class CodeMapper {
|
||||||
|
public CodeDTO convertToDTO(CodeModel model) {
|
||||||
|
CodeDTO dto = new CodeDTO();
|
||||||
|
|
||||||
|
dto.setId(model.getId());
|
||||||
|
dto.setValue(model.getValue());
|
||||||
|
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RoleDTO> convertAllToDTO(Collection<RoleModel> models) {
|
||||||
|
return GlobalUtils.convertAllToDTO(models, RoleMapper::convertToDTO);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.displaynone.acss.components.auth.models.code;
|
||||||
|
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.GeneratedValue;
|
||||||
|
import jakarta.persistence.GenerationType;
|
||||||
|
import jakarta.persistence.Id;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CodeModel {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private long id;
|
||||||
|
private long value;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.displaynone.acss.components.auth.models.code;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
public interface CodeRepository extends JpaRepository<CodeModel, Long> {
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.displaynone.acss.components.auth.models.code.service;
|
||||||
|
|
||||||
|
import com.displaynone.acss.components.auth.models.code.CodeModel;
|
||||||
|
|
||||||
|
public interface CodeService {
|
||||||
|
CodeModel getCodeByValue(Long value);
|
||||||
|
|
||||||
|
boolean isValid(Long code);
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.displaynone.acss.components.auth.models.code.service;
|
||||||
|
|
||||||
|
import com.displaynone.acss.components.auth.models.code.CodeModel;
|
||||||
|
import com.displaynone.acss.components.auth.models.code.CodeRepository;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CodeServiceImpl implements CodeService {
|
||||||
|
private final CodeRepository codeRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CodeModel getCodeByValue(Long value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid(Long code) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.displaynone.acss.controllers.acs;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/acs")
|
||||||
|
public class ACSController {
|
||||||
|
@PostMapping("/open")
|
||||||
|
public ResponseEntity<Void> open() {}
|
||||||
|
}
|
@ -17,4 +17,9 @@ public class UserController {
|
|||||||
UserModel user = (UserModel) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
UserModel user = (UserModel) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||||
return ResponseEntity.ok(UserMapper.convertToDTO(user));
|
return ResponseEntity.ok(UserMapper.convertToDTO(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/login/{login}")
|
||||||
|
public ResponseEntity<UserDTO> getUserByLogin() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
server.port=8080
|
server.port=8085
|
||||||
|
|
||||||
spring.application.name=ACSS
|
spring.application.name=ACSS
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
<changeSet id="1" author="universall">
|
<changeSet id="users" author="universall">
|
||||||
<createTable tableName="users">
|
<createTable tableName="users">
|
||||||
<column name="id" type="INTEGER" autoIncrement="true">
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
<constraints primaryKey="true"/>
|
<constraints primaryKey="true"/>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
<changeSet id="1" author="universall">
|
<changeSet id="roles" author="universall">
|
||||||
<createTable tableName="roles">
|
<createTable tableName="roles">
|
||||||
<column name="id" type="INTEGER" autoIncrement="true">
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
<constraints primaryKey="true"/>
|
<constraints primaryKey="true"/>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
<changeSet id="2" author="universall">
|
<changeSet id="user_roles" author="universall">
|
||||||
<createTable tableName="user_roles">
|
<createTable tableName="user_roles">
|
||||||
<column name="user_id" type="INTEGER">
|
<column name="user_id" type="INTEGER">
|
||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
|
17
src/main/resources/db/changelog/01/0004-codes.xml
Normal file
17
src/main/resources/db/changelog/01/0004-codes.xml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
|
https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
|
||||||
|
<changeSet id="codes" author="universall">
|
||||||
|
<createTable tableName="codes">
|
||||||
|
<column name="id" type="INTEGER" autoIncrement="true">
|
||||||
|
<constraints primaryKey="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="value" type="INTEGER">
|
||||||
|
<constraints unique="true" nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -3,7 +3,7 @@
|
|||||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
||||||
<changeSet id="0001-users-data" author="universall">
|
<changeSet id="users-data" author="universall">
|
||||||
<loadData tableName="users" file="db/changelog/data/csv/0001-users-data.csv" separator=";" quotchar='"'/>
|
<loadData tableName="users" file="db/changelog/data/csv/0001-users-data.csv" separator=";" quotchar='"'/>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
||||||
<changeSet id="0002-roles-data" author="universall">
|
<changeSet id="roles-data" author="universall">
|
||||||
<loadData tableName="roles" file="db/changelog/data/csv/0002-roles-data.csv" separator=";" quotchar='"'/>
|
<loadData tableName="roles" file="db/changelog/data/csv/0002-roles-data.csv" separator=";" quotchar='"'/>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
||||||
<changeSet id="0002-user_roles-data" author="universall">
|
<changeSet id="user_roles-data" author="universall">
|
||||||
<loadData tableName="user_roles" file="db/changelog/data/csv/0003-user_roles-data.csv" separator=";" quotchar='"'/>
|
<loadData tableName="user_roles" file="db/changelog/data/csv/0003-user_roles-data.csv" separator=";" quotchar='"'/>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
9
src/main/resources/db/changelog/data/0004-codes-data.xml
Normal file
9
src/main/resources/db/changelog/data/0004-codes-data.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<databaseChangeLog
|
||||||
|
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
|
||||||
|
<changeSet id="codes-data" author="universall">
|
||||||
|
<loadData tableName="codes" file="db/changelog/data/csv/0004-codes-data.csv" separator=";" quotchar='"'/>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
@ -0,0 +1,5 @@
|
|||||||
|
1;1234567890123456789
|
||||||
|
2;9223372036854775807
|
||||||
|
3;1122334455667788990
|
||||||
|
4;998877665544332211
|
||||||
|
5;5566778899001122334
|
|
Loading…
x
Reference in New Issue
Block a user