Pārlūkot izejas kodu

앱버전 수정 기능 추가

huiwon.seo 4 gadi atpakaļ
vecāks
revīzija
24366189e2

+ 52 - 0
src/main/java/com/lemon/lifecenter/controller/AppVersionController.java

@@ -0,0 +1,52 @@
+package com.lemon.lifecenter.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.lemon.lifecenter.common.LifeCenterController;
+import com.lemon.lifecenter.common.LifeCenterFunction;
+import com.lemon.lifecenter.dto.AppVersionDTO;
+import com.lemon.lifecenter.service.DeviceService;
+
+@Controller
+public class AppVersionController extends LifeCenterController {
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+    
+    @Autowired
+    private DeviceService deviceService;
+    
+    @RequestMapping( "/app/version/edit" )
+    private ModelAndView edit() {
+        List<AppVersionDTO> versionList = deviceService.selectAppVersionAll();
+        
+        ModelAndView mv = setMV( "/version/edit" );
+        mv.addObject( "versionList", versionList );
+        return mv;
+    }
+    @RequestMapping( "/app/version/edit/update" )
+    private String editUpdate( @ModelAttribute("dto") AppVersionDTO dto, HttpServletResponse response ) {
+        AppVersionDTO appDTO = new AppVersionDTO();
+        appDTO.setDeviceType( dto.getDeviceType().split(",")[0] );
+        appDTO.setVersion( dto.getVersion().split(",")[0] );
+        appDTO.setDownloadUrl( dto.getDownloadUrl().split(",")[0] );
+        deviceService.updateAppVersion(appDTO);
+        
+        appDTO = new AppVersionDTO();
+        appDTO.setDeviceType( dto.getDeviceType().split(",")[1] );
+        appDTO.setVersion( dto.getVersion().split(",")[1] );
+        appDTO.setDownloadUrl( dto.getDownloadUrl().split(",")[1] );
+        deviceService.updateAppVersion(appDTO);
+        
+        LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '수정완료', callBack : function(){ location.href='/app/version/edit'; } });" );
+        return "/common/blank";
+    }
+}

+ 4 - 0
src/main/java/com/lemon/lifecenter/mapper/DeviceMapper.java

@@ -1,5 +1,7 @@
 package com.lemon.lifecenter.mapper;
 
+import java.util.List;
+
 import org.apache.ibatis.annotations.Mapper;
 import org.springframework.stereotype.Repository;
 
@@ -14,4 +16,6 @@ public interface DeviceMapper {
     public void insertDeviceInfo(DeviceInfoDTO dto);
     public int updatedeviceInfo(DeviceInfoDTO dto);
     public int deleteDeviceInfo(int patientIdx);
+    public List<AppVersionDTO> selectAppVersionAll();
+    public void updateAppVersion( AppVersionDTO dto );
 }

+ 10 - 0
src/main/java/com/lemon/lifecenter/service/DeviceService.java

@@ -1,5 +1,7 @@
 package com.lemon.lifecenter.service;
 
+import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -31,4 +33,12 @@ public class DeviceService {
     public int deleteDeviceInfo(int patientIdx) {
         return mapper.deleteDeviceInfo(patientIdx);
     }
+    
+    public List<AppVersionDTO> selectAppVersionAll(){
+        return mapper.selectAppVersionAll();
+    }
+    
+    public void updateAppVersion( AppVersionDTO dto ) {
+        mapper.updateAppVersion(dto);
+    }
 }

+ 19 - 0
src/main/resources/mybatis/mapper/device/device.xml

@@ -50,4 +50,23 @@
              WHERE PATIENT_IDX = #{patientIdx}
         ]]>
     </delete>
+    
+    <select id="selectAppVersionAll" resultType="appVersionDTO">
+        <![CDATA[
+            SELECT idx,
+                   version,
+                   download_url downloadUrl,
+                   device_type deviceType
+              FROM APP_VERSION
+        ]]>
+    </select>
+    
+    <update id="updateAppVersion" parameterType="appVersionDTO">
+        <![CDATA[
+            UPDATE APP_VERSION
+               SET VERSION = #{version},
+                   download_url = #{downloadUrl}
+             WHERE device_type = #{deviceType}
+        ]]>
+    </update>
 </mapper>

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 3 - 3
src/main/webapp/WEB-INF/jsp/login/staff.jsp


+ 67 - 0
src/main/webapp/WEB-INF/jsp/version/edit.jsp

@@ -0,0 +1,67 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
+<%@ page language="java" contentType="text/html; charset=UTF-8"
+    pageEncoding="UTF-8"%>
+<jsp:include page="${data._INCLUDE}/header.jsp"></jsp:include>
+<script>
+
+</script>
+</head>
+<body>
+    <div class="wrapper">
+        <jsp:include page="${data._INCLUDE}/sidebar.jsp"></jsp:include>
+        
+        <div class="main">
+            <jsp:include page="${data._INCLUDE}/top.jsp"></jsp:include>
+
+            <main class="content">
+                <div class="container-fluid p-0">
+                    <div class="row">
+                        <div class="col-12">
+                            <div class="card">
+                                <form id="newForm" action="./edit/update" method="post">
+                                    <div class="card-body">
+                                        <table class="table mobile-table">
+                                            <colgroup>
+                                                <col style="width:10%">
+                                                <col style="width:10%">
+                                                <col style="width:50%">
+                                            </colgroup>
+                                            <c:forEach var="vl" items="${versionList}">
+                                                <tr>
+                                                    <th>
+                                                        <input type="hidden" name="deviceType" value='<c:out value="${vl.deviceType}"/>' />
+                                                        <span class="fix">*</span><c:out value="${vl.deviceType}"/>
+                                                    </th>
+                                                    <td>
+                                                        <input type="text" name="version" class="form-control" value="<c:out value="${vl.version}" />" required>
+                                                    </td>
+                                                    <td>
+                                                        <input type="text" name="downloadUrl" class="form-control" value="<c:out value="${vl.downloadUrl}" />" required>
+                                                    </td>
+                                                </tr>
+                                            </c:forEach>
+                                        </table>
+                                        
+                                        <div class="row mt-3">
+                                            <div class="col-12">
+                                                <div class="text-right">
+                                                    <button type="button" class="btn btn-outline-primary w100" onclick="history.back();">취소</button>
+                                                    <button type="submit" class="btn btn-primary w100">등록</button>
+                                                </div>
+                                            </div>
+                                        </div>
+                                    </div>
+                                </form>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </main>
+
+            <jsp:include page="${data._INCLUDE}/footer.jsp"></jsp:include>
+        </div>
+    </div>
+</body>
+</html>