[TEMP] Code entity

This commit is contained in:
Universall 2025-02-18 19:00:29 +03:00
parent 5ee43aca29
commit 126c8e0cb0
18 changed files with 152 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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> {
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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() {}
}

View File

@ -17,4 +17,9 @@ public class UserController {
UserModel user = (UserModel) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
return ResponseEntity.ok(UserMapper.convertToDTO(user));
}
@GetMapping("/login/{login}")
public ResponseEntity<UserDTO> getUserByLogin() {
// TODO
}
}

View File

@ -1,4 +1,4 @@
server.port=8080
server.port=8085
spring.application.name=ACSS

View File

@ -4,7 +4,7 @@
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="1" author="universall">
<changeSet id="users" author="universall">
<createTable tableName="users">
<column name="id" type="INTEGER" autoIncrement="true">
<constraints primaryKey="true"/>

View File

@ -4,7 +4,7 @@
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="1" author="universall">
<changeSet id="roles" author="universall">
<createTable tableName="roles">
<column name="id" type="INTEGER" autoIncrement="true">
<constraints primaryKey="true"/>

View File

@ -4,7 +4,7 @@
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="2" author="universall">
<changeSet id="user_roles" author="universall">
<createTable tableName="user_roles">
<column name="user_id" type="INTEGER">
<constraints nullable="false"/>

View 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>

View File

@ -3,7 +3,7 @@
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="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='"'/>
</changeSet>
</databaseChangeLog>

View File

@ -3,7 +3,7 @@
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="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='"'/>
</changeSet>
</databaseChangeLog>

View File

@ -3,7 +3,7 @@
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="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='"'/>
</changeSet>
</databaseChangeLog>

View 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>

View File

@ -0,0 +1,5 @@
1;1234567890123456789
2;9223372036854775807
3;1122334455667788990
4;998877665544332211
5;5566778899001122334
1 1 1234567890123456789
2 2 9223372036854775807
3 3 1122334455667788990
4 4 998877665544332211
5 5 5566778899001122334