요청사항 처리 중 폰트 사이즈를 10으로 해달라고 해서 10px로 진행했는데
이렇게 작게 해도 되나 싶은 생각이 들긴 했었는데 결국 다시 수정해달라는 요청이 왔다.
고객사 측에서는 알고보니 아웃룩에서 제공하는 글자 사이즈를 보고 10으로 해달라고 한 것이었는데
사이즈를 측정해보니 px가 아니고 pt가 거기에 해당했다.
pt는 px보다 25%정도 더 적었는데
7.5pt가 10px이고
10pt가 13.333333px이었다.
자동화는 무난하게 잘 작동했기 때문에
페이지네이션 관련 작업을 다시 진행해봤는데
숫자로 하는 부분은 실제로는 쓸일이 없을 것 같아서
일단 간단하게 api 연동과 데이터 뿌리기, 페이지 이동, 이동불가 페이지 disabled 처리 등을 진행했다.
public without sharing class yohanController {
@AuraEnabled(cacheable=true)
public static Map<String, Object> getPokemonList(Integer pageNumber, Integer pageSize) {
Integer offset = (pageNumber - 1) * pageSize;
HttpRequest req = new HttpRequest();
req.setEndpoint('https://pokeapi.co/api/v2/pokemon?offset=' + offset + '&limit=' + pageSize);
req.setMethod('GET');
Http http = new Http();
HttpResponse res = http.send(req);
if (res.getStatusCode() == 200) {
Map<String, Object> jsonResponse = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
return jsonResponse;
} else {
return new Map<String, Object>();
}
}
}
import { LightningElement, track } from 'lwc';
import getPokemonList from '@salesforce/apex/yohanController.getPokemonList';
// import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class YohanLWC extends LightningElement {
@track data;
@track error;
@track currentPage;
@track pageNumber;
@track totalPages;
@track pageSize;
@track notAddable;
@track notMinusable;
constructor(){
super();
this.pageNumber = 1
this.currentPage = 1
this.pageSize = 20
this.totalPages = 9999
this.notMinusable = true
this.notAddable = true
this.search();
}
search(){
getPokemonList({ pageNumber: this.pageNumber, pageSize: this.pageSize})
.then(result => {
console.log(result)
console.log(result.count, this.pageSize, Math.ceil(result.count/this.pageSize));
this.totalPages = Math.ceil(result.count/this.pageSize);
this.data = JSON.parse(JSON.stringify(result.results));
this.currentPage = this.pageNumber;
this.error = undefined;
if(this.pageNumber > 1){
this.notMinusable = false;
}
else{
this.notMinusable = true;
}
if(this.pageNumber < this.totalPages){
this.notAddable = false;
}
else{
this.notAddable = true;
}
// showSuccessToast('로딩 성공', '데이터가 성공적으로 들어왔습니다.')
})
.catch(error => {
this.error = error;
this.data = undefined;
})
}
handleSizeChange(event){
this.pageSize = event.target.value;
}
handlePageChange(event){
this.pageNumber = Math.max(1, Math.min(event.target.value, this.totalPages));
}
updateValuesAndLoadData(){
this.search();
}
events(e){
if(e.target.label == '<'){
this.pageNumber--;
this.search();
}
else if(e.target.label == '<<'){
this.pageNumber = 1;
this.search();
}
else if(e.target.label == '>'){
this.pageNumber++;
this.search();
}
else if(e.target.label == '>>'){
this.pageNumber = this.totalPages;
this.search();
}
}
<template>
<lightning-card title="정보" class="custom-card">
<table class="data-table">
<thead>
<tr>
<th style="text-align: center;">No.</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Url</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">Name</th>
</tr>
</thead>
<tbody>
<tr for:each={data} for:item="item" for:index="index" key={item.url} class="hoverable-row">
<td style="text-align: center;">{index}</td>
<td>{item.name}</td>
<td>{item.url}</td>
<td>{item.name}</td>
<td>{item.name}</td>
<td>{item.name}</td>
<td>{item.name}</td>
<td>{item.name}</td>
<td>{item.name}</td>
<td>{item.name}</td>
<td>{item.name}</td>
</tr>
</tbody>
</table>
<div class="pagination-container">
<lightning-button variant="neutral" label="<<" onclick={events} disabled={notMinusable}></lightning-button>
<lightning-button variant="neutral" label="<" onclick={events} disabled={notMinusable}></lightning-button>
<input type="number" id="pageNumber" value={pageNumber} oninput={handlePageChange} class="page-input"></input>
<lightning-button variant="brand" label="이동" onclick={search}></lightning-button>
<lightning-button variant="neutral" label=">" onclick={events} disabled={notAddable}></lightning-button>
<lightning-button variant="neutral" label=">>" onclick={events} disabled={notAddable}></lightning-button>
</div>
<div class="pagination-info">
{currentPage} / {totalPages}
</div>
</lightning-card>
</template>
(1).백준 26198번 Chronogram은 특정 문자가 대응하는 숫자가 존재할 때
문자열 내부에서 더할 수 있는 모든 값을 더한 결과를 각각의 테스트케이스마다 출력해야 하는 문제였다.
해당 점수를 빠르게 불러올 수 있게 map에 담아 조회하고
해당 값이 있는 경우에만 sum에 더해 result에 담은 다음
한번에 result.join('\n')으로 출력했다.
const input = `2
VIDE ISTA ECCLESIA CATHEDRALIS SVB PRAESVLE FRANCISCO PAROCHOQVE STANSLAO LAETA EXSISTIT REVIVISCENS
ENTERTAINING REGIONAL CONTEST HELD IN EXTRAVAGANT LJUBLJANA WITH RIDICULOUSLY HARD TASKS`.split('\n')
const point = {I:1, V:5, X:10, L:50, C:100, D:500, M:1000}
const result = []
for(let i = 1 ; i < input.length ; i++){
let sum = 0
for(let j = 0 ; j < input[i].length ; j++){
if(point[input[i][j]]){
sum += point[input[i][j]]
}
}
result.push(sum)
}
console.log(result.join('\n'))
'회고' 카테고리의 다른 글
[개발일지] - 176(주말) (0) | 2023.12.23 |
---|---|
[개발일지] - 175 (1) | 2023.12.22 |
[개발일지] - 173 (1) | 2023.12.20 |
[개발일지] - 172 (0) | 2023.12.19 |
[개발일지] - 171 (0) | 2023.12.18 |