canvas thumbnail CRUD
This commit is contained in:
parent
4b1af2c753
commit
8e746e9d7d
@ -0,0 +1,63 @@
|
||||
package com.interplug.qcast.biz.canvasStatus;
|
||||
|
||||
import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/canvasStatus")
|
||||
@RequiredArgsConstructor
|
||||
public class CanvasStatusController {
|
||||
// @Autowired private CanvasStatusService canvasStatusService;
|
||||
private final CanvasStatusService canvasStatusService;
|
||||
|
||||
@PostMapping("/v1.0/canvasStatus")
|
||||
public void canvasStatus(@RequestBody CanvasStatusDto cs) {
|
||||
log.warn(String.valueOf(log.isDebugEnabled()));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("userId : " + cs.getUserId());
|
||||
log.debug("objectNo : " + cs.getObjectNo());
|
||||
log.debug("imageName : " + cs.getImageName());
|
||||
log.debug("canvasStatus : " + cs.getCanvasStatus());
|
||||
}
|
||||
}
|
||||
|
||||
// 전체 견적서 조회
|
||||
@GetMapping("/{userId}")
|
||||
public CanvasStatusDto selectAllCanvasStatus(@RequestBody CanvasStatusDto cs) {
|
||||
return canvasStatusService.selectAllCanvasStatus(cs);
|
||||
}
|
||||
|
||||
// 견적서 조회
|
||||
@GetMapping("/{objectNo}")
|
||||
public CanvasStatusDto selectObjectNoCanvasStatus(@RequestBody CanvasStatusDto cs) {
|
||||
return canvasStatusService.selectObjectNoCanvasStatus(cs);
|
||||
}
|
||||
|
||||
// 견적서 등록
|
||||
@PostMapping
|
||||
public void insertCanvasStatus(@RequestBody CanvasStatusDto cs) {
|
||||
canvasStatusService.insertCanvasStatus(cs);
|
||||
}
|
||||
|
||||
// 견적서 수정
|
||||
@PutMapping
|
||||
public void updateCanvasStatus(@RequestBody CanvasStatusDto cs) {
|
||||
canvasStatusService.updateCanvasStatus(cs);
|
||||
}
|
||||
|
||||
// 견적서 삭제
|
||||
@DeleteMapping("/{objectNo}")
|
||||
public void deleteObjectNoCanvasStatus(@PathVariable String objectNo) {
|
||||
canvasStatusService.deleteObjectNoCanvasStatus(objectNo);
|
||||
}
|
||||
|
||||
// 이미지(템플릿) 삭제
|
||||
@DeleteMapping
|
||||
public void deleteImageNameCanvasStatus(@RequestBody CanvasStatusDto cs) {
|
||||
canvasStatusService.deleteImageNameCanvasStatus(cs);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.interplug.qcast.biz.canvasStatus;
|
||||
|
||||
import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
interface CanvasStatusMapper {
|
||||
|
||||
// 견적서(objectNo) 존재 확인
|
||||
public CanvasStatusDto getCanvasStatusByObjectNo(String objectNo);
|
||||
|
||||
// 이미지(템플릿) 존재 확인
|
||||
public CanvasStatusDto getCanvasStatusByImageName(String objectNo, String imageName);
|
||||
|
||||
// 전체 견적서 조회
|
||||
public CanvasStatusDto selectAllCanvasStatus(CanvasStatusDto cs);
|
||||
|
||||
// 견적서 조회
|
||||
public CanvasStatusDto selectObjectNoCanvasStatus(CanvasStatusDto cs);
|
||||
|
||||
// 신규 견적서 등록
|
||||
public void insertNewCanvasStatus(CanvasStatusDto cs);
|
||||
|
||||
// 이미지(템플릿) 추가 등록
|
||||
public void insertImageAddCanvasStatus(CanvasStatusDto cs);
|
||||
|
||||
// 견적서 수정
|
||||
public void updateCanvasStatus(CanvasStatusDto cs);
|
||||
|
||||
// 견적서 삭제
|
||||
public void deleteObjectNoCanvasStatus(String objectNo);
|
||||
|
||||
// 이미지(템플릿) 삭제
|
||||
public void deleteImageNameCanvasStatus(CanvasStatusDto cs);
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package com.interplug.qcast.biz.canvasStatus;
|
||||
|
||||
import com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CanvasStatusService {
|
||||
// @Autowired CanvasStatusMapper canvasStatusMapper;
|
||||
private final CanvasStatusMapper canvasStatusMapper;
|
||||
|
||||
// 전체 견적서 조회
|
||||
public CanvasStatusDto selectAllCanvasStatus(CanvasStatusDto cs) {
|
||||
return canvasStatusMapper.selectAllCanvasStatus(cs);
|
||||
}
|
||||
|
||||
// 견적서 조회
|
||||
public CanvasStatusDto selectObjectNoCanvasStatus(CanvasStatusDto cs) {
|
||||
return canvasStatusMapper.selectObjectNoCanvasStatus(cs);
|
||||
}
|
||||
|
||||
// 견적서 등록
|
||||
public void insertCanvasStatus(CanvasStatusDto cs) {
|
||||
|
||||
// 견적서(objectNo) 존재 확인
|
||||
CanvasStatusDto existingStatus = canvasStatusMapper.getCanvasStatusByObjectNo(cs.getObjectNo());
|
||||
|
||||
if (existingStatus == null) {
|
||||
// 견적서(objectNo)가 존재하지 않으면 새로 생성
|
||||
canvasStatusMapper.insertNewCanvasStatus(cs);
|
||||
} else {
|
||||
// 견적서 이미지 추가 등록
|
||||
// 견적서(objectNo)가 존재하면 해당 objectNo Row 추가 후 imageName +1 추가
|
||||
canvasStatusMapper.insertImageAddCanvasStatus(cs);
|
||||
}
|
||||
}
|
||||
|
||||
// 견적서 수정
|
||||
public void updateCanvasStatus(CanvasStatusDto cs) {
|
||||
|
||||
// 이미지(템플릿) 존재 확인
|
||||
CanvasStatusDto existingStatus = canvasStatusMapper.getCanvasStatusByImageName(cs.getObjectNo(), cs.getImageName());
|
||||
|
||||
if (existingStatus == null) {
|
||||
// 이미지(템플릿)가 존재하지 않으면 새로 생성
|
||||
canvasStatusMapper.insertNewCanvasStatus(cs);
|
||||
} else {
|
||||
// 이미지(템플릿)가 존재하면 update 처리
|
||||
canvasStatusMapper.updateCanvasStatus(cs);
|
||||
}
|
||||
}
|
||||
|
||||
// 견적서 삭제
|
||||
public void deleteObjectNoCanvasStatus(String objectNo) {
|
||||
canvasStatusMapper.deleteObjectNoCanvasStatus(objectNo);
|
||||
}
|
||||
|
||||
// 이미지(템플릿) 삭제
|
||||
public void deleteImageNameCanvasStatus(CanvasStatusDto cs) {
|
||||
canvasStatusMapper.deleteImageNameCanvasStatus(cs);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.interplug.qcast.biz.canvasStatus.dto;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
public class CanvasStatusDto {
|
||||
private int id; //PK ID
|
||||
private String userId; //사용자 ID
|
||||
private String objectNo; //견적서 번호
|
||||
private String imageName; //이미지명
|
||||
private String canvasStatus; //캠버스 상태
|
||||
private Date registDatetime; //생성일시
|
||||
private Date lastEditDatetime; //수정일시
|
||||
}
|
||||
116
src/main/resources/mappers/canvasStatus/canvasStatusMapper.xml
Normal file
116
src/main/resources/mappers/canvasStatus/canvasStatusMapper.xml
Normal file
@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.interplug.qcast.biz.canvasStatus.CanvasStatusMapper">
|
||||
|
||||
<select id="getCanvasStatusByObjectNo" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto"
|
||||
resultType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.getCanvasStatusByObjectNo */
|
||||
SELECT 1
|
||||
FROM TB_CANVAS_STATUS
|
||||
WHERE object_no = #{objectNo}
|
||||
</select>
|
||||
|
||||
<select id="getCanvasStatusByImageName" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto"
|
||||
resultType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.getCanvasStatusByImageName */
|
||||
SELECT 1
|
||||
FROM TB_CANVAS_STATUS
|
||||
WHERE object_no = #{objectNo}
|
||||
AND image_name = #{imageName}
|
||||
</select>
|
||||
|
||||
<select id="selectAllCanvasStatus" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto"
|
||||
resultType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.selectAllCanvasStatus 전체 견적서 조회 */
|
||||
SELECT id
|
||||
, user_id
|
||||
, object_no
|
||||
, image_name
|
||||
, canvas_status
|
||||
, regist_datetime
|
||||
, last_edit_datetime
|
||||
FROM TB_CANVAS_STATUS
|
||||
WHERE user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectObjectNoCanvasStatus" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto"
|
||||
resultType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.selectObjectNoCanvasStatus 견적서 조회 */
|
||||
SELECT id
|
||||
, user_id
|
||||
, object_no
|
||||
, image_name
|
||||
, canvas_status
|
||||
, regist_datetime
|
||||
, last_edit_datetime
|
||||
FROM TB_CANVAS_STATUS
|
||||
WHERE user_id = #{userId}
|
||||
AND object_no = #{objectNo}
|
||||
</select>
|
||||
|
||||
<insert id="insertNewCanvasStatus" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.insertNewCanvasStatus 신규 견적서 등록 */
|
||||
INSERT INTO TB_CANVAS_STATUS
|
||||
(
|
||||
user_id
|
||||
, object_no
|
||||
, image_name
|
||||
, canvas_status
|
||||
, regist_datetime
|
||||
)
|
||||
VALUES (
|
||||
#{userId}
|
||||
, ( SELECT #{userId} + FORMAT(GETDATE(), 'yyMMdd') + RIGHT('000' + CAST(ISNULL(MAX(CAST(RIGHT(object_no, 3) AS INT)), 0) + 1 AS VARCHAR(3)), 3)
|
||||
FROM TB_CANVAS_STATUS
|
||||
WHERE object_no LIKE #{userId} + FORMAT(GETDATE(), 'yyMMdd') + '%' )
|
||||
, 'image01'
|
||||
, #{canvasStatus}
|
||||
, GETDATE()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insertImageAddCanvasStatus" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.insertImageAddCanvasStatus 이미지(템플릿) 추가 등록 */
|
||||
INSERT INTO TB_CANVAS_STATUS
|
||||
(
|
||||
user_id
|
||||
, object_no
|
||||
, image_name
|
||||
, canvas_status
|
||||
, regist_datetime
|
||||
)
|
||||
VALUES (
|
||||
#{userId}
|
||||
, #{objectNo}
|
||||
, ( SELECT 'image' + RIGHT('00' + CAST(ISNULL(MAX(CAST(RIGHT(image_name, 2) AS INT)), 0) + 1 AS VARCHAR(2)), 2)
|
||||
FROM TB_CANVAS_STATUS
|
||||
WHERE object_no = #{objectNo} )
|
||||
, #{canvasStatus}
|
||||
, GETDATE()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateCanvasStatus" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.updateCanvasStatus 견적서 수정 */
|
||||
UPDATE TB_CANVAS_STATUS
|
||||
SET canvas_status = #{canvasStatus}
|
||||
, last_edit_datetime = GETDATE()
|
||||
WHERE object_no = #{objectNo}
|
||||
AND image_name = #{imageName}
|
||||
</update>
|
||||
|
||||
<delete id="deleteObjectNoCanvasStatus" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.deleteObjectNoCanvasStatus 견적서 삭제 */
|
||||
DELETE FROM TB_CANVAS_STATUS
|
||||
WHERE object_no = #{objectNo}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteImageNameCanvasStatus" parameterType="com.interplug.qcast.biz.canvasStatus.dto.CanvasStatusDto">
|
||||
/* sqlid : com.interplug.qcast.canvasStatus.deleteImageNameCanvasStatus 이미지(템플릿) 삭제 */
|
||||
DELETE FROM TB_CANVAS_STATUS
|
||||
WHERE object_no = #{objectNo}
|
||||
AND image_name = #{imageName}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user