딱히 없음
This commit is contained in:
33
pom.xml
33
pom.xml
@@ -44,8 +44,23 @@
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>${org.aspectj-version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>${org.aspectj-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.10</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@@ -138,6 +153,20 @@
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.opencsv/opencsv -->
|
||||
<dependency>
|
||||
<groupId>com.opencsv</groupId>
|
||||
<artifactId>opencsv</artifactId>
|
||||
<version>5.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
|
||||
<dependency>
|
||||
<groupId>commons-fileupload</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package co.nook.app.DefaultTodo.dao;
|
||||
|
||||
import co.nook.app.DefaultTodo.service.DefaultTodoMapper;
|
||||
import co.nook.app.DefaultTodo.service.DefaultTodoService;
|
||||
import co.nook.app.DefaultTodo.vo.DefaultTodoVo;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Repository("defaultTodoDao")
|
||||
public class DefaultTodoDao implements DefaultTodoService{
|
||||
|
||||
JdbcTemplate jdbcTemplate;
|
||||
|
||||
public DefaultTodoDao( JdbcTemplate jdbcTemplate){
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
private final String SELECT_ALL = "SELECT * from defaultTodo";
|
||||
@Override
|
||||
public ArrayList<DefaultTodoVo> selectAll(){
|
||||
return (ArrayList<DefaultTodoVo>)jdbcTemplate.query(SELECT_ALL , new DefaultTodoMapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultTodoVo select(int key){
|
||||
return null;
|
||||
}
|
||||
|
||||
private final String INSERT = "INSERT INTO defaultTodo " +
|
||||
"values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
@Override
|
||||
public int insert(DefaultTodoVo vo){
|
||||
return jdbcTemplate.update(INSERT,
|
||||
vo.getdTodoNo(),
|
||||
vo.getdIsAlways(),
|
||||
vo.getdContent(),
|
||||
vo.getdDay(),
|
||||
vo.getdMinCount(),
|
||||
vo.getdMaxCount(),
|
||||
vo.getdNpcName(),
|
||||
vo.getdIsEvent(),
|
||||
vo.getdEventStartDate(),
|
||||
vo.getdEventStartHour(),
|
||||
vo.getdEventEndDate(),
|
||||
vo.getdEventEndHour(),
|
||||
vo.getdSpecialFunction(),
|
||||
vo.getdSpecialData1(),
|
||||
vo.getdSpecialData2(),
|
||||
vo.getdSpecialData3(),
|
||||
vo.getdSpecialData4()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(DefaultTodoVo vo){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(int key){
|
||||
return 0;
|
||||
}
|
||||
|
||||
private final String TRUNCATE = "TRUNCATE TABLE defaultTodo";
|
||||
@Override
|
||||
public void truncate(){
|
||||
jdbcTemplate.update(TRUNCATE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package co.nook.app.DefaultTodo.service;
|
||||
|
||||
import co.nook.app.DefaultTodo.vo.DefaultTodoVo;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class DefaultTodoMapper implements RowMapper<DefaultTodoVo>{
|
||||
@Override
|
||||
public DefaultTodoVo mapRow(ResultSet rs, int rowNum) throws SQLException{
|
||||
DefaultTodoVo vo = new DefaultTodoVo();
|
||||
|
||||
vo.setdTodoNo(rs.getInt("dTodoNo"));
|
||||
vo.setdIsAlways(rs.getString("dIsAlways"));
|
||||
vo.setdContent(rs.getString("dContent"));
|
||||
vo.setdDay(rs.getString("dDay"));
|
||||
vo.setdMinCount(rs.getInt("dMinCount"));
|
||||
vo.setdMaxCount(rs.getInt("dMaxCount"));
|
||||
vo.setdNpcName(rs.getString("dNpcName"));
|
||||
vo.setdIsEvent(rs.getString("dIsEvent"));
|
||||
vo.setdEventStartDate(rs.getString("dEventStartDate"));
|
||||
vo.setdEventStartHour(rs.getInt("dEventStartHour"));
|
||||
vo.setdEventEndDate(rs.getString("dEventEndDate"));
|
||||
vo.setdEventEndHour(rs.getInt("dEventEndHour"));
|
||||
vo.setdSpecialFunction(rs.getString("dSpecialFunction"));
|
||||
vo.setdSpecialData1(rs.getString("dSpecialData1"));
|
||||
vo.setdSpecialData2(rs.getString("dSpecialData2"));
|
||||
vo.setdSpecialData3(rs.getString("dSpecialData3"));
|
||||
vo.setdSpecialData4(rs.getString("dSpecialData4"));
|
||||
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package co.nook.app.DefaultTodo.service;
|
||||
|
||||
import co.nook.app.DefaultTodo.vo.DefaultTodoVo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface DefaultTodoService{
|
||||
public ArrayList<DefaultTodoVo> selectAll();
|
||||
public DefaultTodoVo select(int key);
|
||||
public int insert(DefaultTodoVo vo);
|
||||
public int update(DefaultTodoVo vo);
|
||||
public int delete(int key);
|
||||
public void truncate();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package co.nook.app.DefaultTodo.service;
|
||||
|
||||
import co.nook.app.DefaultTodo.dao.DefaultTodoDao;
|
||||
import co.nook.app.DefaultTodo.vo.DefaultTodoVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Service("defaultTodoService")
|
||||
public class DefaultTodoServiceImpl implements DefaultTodoService{
|
||||
|
||||
public DefaultTodoDao defaultTodoDao;
|
||||
|
||||
@Autowired
|
||||
public DefaultTodoServiceImpl(DefaultTodoDao defaultTodoDao){
|
||||
this.defaultTodoDao = defaultTodoDao;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<DefaultTodoVo> selectAll(){
|
||||
return defaultTodoDao.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultTodoVo select(int key){
|
||||
return defaultTodoDao.select(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(DefaultTodoVo vo){
|
||||
return defaultTodoDao.insert(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(DefaultTodoVo vo){
|
||||
return defaultTodoDao.update(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(int key){
|
||||
return defaultTodoDao.delete(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void truncate(){
|
||||
defaultTodoDao.truncate();
|
||||
}
|
||||
}
|
||||
157
src/main/java/co/nook/app/DefaultTodo/vo/DefaultTodoVo.java
Normal file
157
src/main/java/co/nook/app/DefaultTodo/vo/DefaultTodoVo.java
Normal file
@@ -0,0 +1,157 @@
|
||||
package co.nook.app.DefaultTodo.vo;
|
||||
|
||||
public class DefaultTodoVo{
|
||||
private int dTodoNo;
|
||||
private String dIsAlways;
|
||||
private String dContent;
|
||||
private String dDay;
|
||||
private Integer dMinCount;
|
||||
private Integer dMaxCount;
|
||||
private String dNpcName;
|
||||
private String dIsEvent;
|
||||
private String dEventStartDate;
|
||||
private Integer dEventStartHour;
|
||||
private String dEventEndDate;
|
||||
private Integer dEventEndHour;
|
||||
private String dSpecialFunction;
|
||||
private String dSpecialData1;
|
||||
private String dSpecialData2;
|
||||
private String dSpecialData3;
|
||||
private String dSpecialData4;
|
||||
|
||||
public int getdTodoNo(){
|
||||
return dTodoNo;
|
||||
}
|
||||
|
||||
public void setdTodoNo(int dTodoNo){
|
||||
this.dTodoNo = dTodoNo;
|
||||
}
|
||||
|
||||
public String getdIsAlways(){
|
||||
return dIsAlways;
|
||||
}
|
||||
|
||||
public void setdIsAlways(String dIsAlways){
|
||||
this.dIsAlways = dIsAlways;
|
||||
}
|
||||
|
||||
public String getdContent(){
|
||||
return dContent;
|
||||
}
|
||||
|
||||
public void setdContent(String dContent){
|
||||
this.dContent = dContent;
|
||||
}
|
||||
|
||||
public String getdDay(){
|
||||
return dDay;
|
||||
}
|
||||
|
||||
public void setdDay(String dDay){
|
||||
this.dDay = dDay;
|
||||
}
|
||||
|
||||
public Integer getdMinCount(){
|
||||
return dMinCount;
|
||||
}
|
||||
|
||||
public void setdMinCount(Integer dMinCount){
|
||||
this.dMinCount = dMinCount;
|
||||
}
|
||||
|
||||
public Integer getdMaxCount(){
|
||||
return dMaxCount;
|
||||
}
|
||||
|
||||
public void setdMaxCount(Integer dMaxCount){
|
||||
this.dMaxCount = dMaxCount;
|
||||
}
|
||||
|
||||
public String getdNpcName(){
|
||||
return dNpcName;
|
||||
}
|
||||
|
||||
public void setdNpcName(String dNpcName){
|
||||
this.dNpcName = dNpcName;
|
||||
}
|
||||
|
||||
public String getdIsEvent(){
|
||||
return dIsEvent;
|
||||
}
|
||||
|
||||
public void setdIsEvent(String dIsEvent){
|
||||
this.dIsEvent = dIsEvent;
|
||||
}
|
||||
|
||||
public String getdEventStartDate(){
|
||||
return dEventStartDate;
|
||||
}
|
||||
|
||||
public void setdEventStartDate(String dEventStartDate){
|
||||
this.dEventStartDate = dEventStartDate;
|
||||
}
|
||||
|
||||
public Integer getdEventStartHour(){
|
||||
return dEventStartHour;
|
||||
}
|
||||
|
||||
public void setdEventStartHour(Integer dEventStartHour){
|
||||
this.dEventStartHour = dEventStartHour;
|
||||
}
|
||||
|
||||
public String getdEventEndDate(){
|
||||
return dEventEndDate;
|
||||
}
|
||||
|
||||
public void setdEventEndDate(String dEventEndDate){
|
||||
this.dEventEndDate = dEventEndDate;
|
||||
}
|
||||
|
||||
public Integer getdEventEndHour(){
|
||||
return dEventEndHour;
|
||||
}
|
||||
|
||||
public void setdEventEndHour(Integer dEventEndHour){
|
||||
this.dEventEndHour = dEventEndHour;
|
||||
}
|
||||
|
||||
public String getdSpecialFunction(){
|
||||
return dSpecialFunction;
|
||||
}
|
||||
|
||||
public void setdSpecialFunction(String dSpecialFunction){
|
||||
this.dSpecialFunction = dSpecialFunction;
|
||||
}
|
||||
|
||||
public String getdSpecialData1(){
|
||||
return dSpecialData1;
|
||||
}
|
||||
|
||||
public void setdSpecialData1(String dSpecialData1){
|
||||
this.dSpecialData1 = dSpecialData1;
|
||||
}
|
||||
|
||||
public String getdSpecialData2(){
|
||||
return dSpecialData2;
|
||||
}
|
||||
|
||||
public void setdSpecialData2(String dSpecialData2){
|
||||
this.dSpecialData2 = dSpecialData2;
|
||||
}
|
||||
|
||||
public String getdSpecialData3(){
|
||||
return dSpecialData3;
|
||||
}
|
||||
|
||||
public void setdSpecialData3(String dSpecialData3){
|
||||
this.dSpecialData3 = dSpecialData3;
|
||||
}
|
||||
|
||||
public String getdSpecialData4(){
|
||||
return dSpecialData4;
|
||||
}
|
||||
|
||||
public void setdSpecialData4(String dSpecialData4){
|
||||
this.dSpecialData4 = dSpecialData4;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package co.nook.app.DefaultTodo.web;
|
||||
|
||||
import co.nook.app.DefaultTodo.service.DefaultTodoService;
|
||||
import co.nook.app.DefaultTodo.vo.DefaultTodoVo;
|
||||
import com.opencsv.CSVReader;
|
||||
import com.opencsv.exceptions.CsvValidationException;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Controller
|
||||
public class DefaultTodoController{
|
||||
|
||||
private DefaultTodoService defaultTodoService;
|
||||
|
||||
public DefaultTodoController(DefaultTodoService defaultTodoService){
|
||||
this.defaultTodoService = defaultTodoService;
|
||||
}
|
||||
|
||||
@RequestMapping("/adminDataInsertPage.do")
|
||||
public String adminDataInsertPage(Model model){
|
||||
ArrayList<DefaultTodoVo> list = defaultTodoService.selectAll();
|
||||
System.out.println("Size : " +list.size());
|
||||
model.addAttribute("list", list);
|
||||
|
||||
return "admin/admin_data";
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/defaultDataInsert.do", method = RequestMethod.POST)
|
||||
public String defaultDataInsert(HttpServletRequest request, MultipartFile file, Model model){
|
||||
if(!verifyDefaultTodoFile(file))
|
||||
return "invalid";
|
||||
|
||||
String path = request.getServletContext().getRealPath("\\WEB-INF\\uploaded\\");
|
||||
System.out.println(path);
|
||||
String saveName = file.getOriginalFilename();
|
||||
File saveFile = new File(path, saveName);
|
||||
boolean isSaved = false;
|
||||
try{
|
||||
file.transferTo(saveFile);
|
||||
isSaved = true;
|
||||
}catch( IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
try{
|
||||
if(isSaved){
|
||||
//TODO : 파일이 제대로된 데이터인지 검증하는 단계 필요
|
||||
InputStreamReader iReader =new InputStreamReader(file.getInputStream(), "UTF-8");
|
||||
//CSVReader reader = new CSVReader(new FileReader( path+"\\"+saveName));
|
||||
CSVReader reader = new CSVReader(iReader);
|
||||
|
||||
defaultTodoService.truncate();
|
||||
String [] nextLine;
|
||||
int line = 1;
|
||||
while((nextLine = reader.readNext()) != null){
|
||||
|
||||
if(line > 3){
|
||||
DefaultTodoVo vo = csvLineToVo(nextLine);
|
||||
defaultTodoService.insert(vo);
|
||||
}
|
||||
++line;
|
||||
}
|
||||
iReader.close();
|
||||
}
|
||||
}catch(CsvValidationException | IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ArrayList<DefaultTodoVo> list = defaultTodoService.selectAll();
|
||||
model.addAttribute("list", list);
|
||||
|
||||
return String.valueOf(isSaved);
|
||||
}
|
||||
private DefaultTodoVo csvLineToVo(String[] line){
|
||||
DefaultTodoVo vo = new DefaultTodoVo();
|
||||
vo.setdTodoNo(Integer.valueOf(line[0]));
|
||||
vo.setdIsAlways(line[1].toUpperCase().trim());
|
||||
vo.setdContent(line[2].trim());
|
||||
vo.setdDay(line[3].trim());
|
||||
vo.setdMinCount( line[4].isEmpty()? null: Integer.valueOf(line[4]) );
|
||||
vo.setdMaxCount( line[5].isEmpty()? null : Integer.valueOf(line[5]) );
|
||||
vo.setdNpcName(line[6].trim());
|
||||
vo.setdIsEvent(line[7].toUpperCase().trim());
|
||||
vo.setdEventStartDate(line[8].isEmpty()? null : line[8].trim());
|
||||
vo.setdEventStartHour(line[9].isEmpty()? null: Integer.valueOf(line[9]));
|
||||
vo.setdEventEndDate(line[10].isEmpty()? null: line[10].trim());
|
||||
vo.setdEventEndHour(line[11].isEmpty()? null: Integer.valueOf(line[11]));
|
||||
vo.setdSpecialFunction(line[12].isEmpty()? null: line[12].trim());
|
||||
vo.setdSpecialData1(line[13].isEmpty()? null: line[13].trim());
|
||||
vo.setdSpecialData2(line[14].isEmpty()? null: line[14].trim());
|
||||
vo.setdSpecialData3(line[15].isEmpty()? null: line[15].trim());
|
||||
vo.setdSpecialData4(line[16].isEmpty()? null: line[16].trim());
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
private boolean verifyDefaultTodoFile(MultipartFile file){
|
||||
|
||||
try{
|
||||
InputStreamReader iReader =new InputStreamReader(file.getInputStream(), "UTF-8");
|
||||
CSVReader reader = new CSVReader(iReader);
|
||||
String[] lines;
|
||||
|
||||
int line = 1;
|
||||
while((lines = reader.readNext()) != null){
|
||||
if( line > 3){
|
||||
if((! lines[0].isEmpty() && NumberUtils.isCreatable(lines[0])) == false){
|
||||
System.out.println(1);
|
||||
System.out.println(lines[0]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
if((! lines[1].isEmpty() && isStringBoolean(lines[1])) == false){
|
||||
System.out.println(2);
|
||||
System.out.println(lines[1]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
if((! lines[2].isEmpty()) == false){
|
||||
System.out.println(3);
|
||||
System.out.println(lines[2]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
if((! lines[3].isEmpty() && isStringDay(lines[3])) == false){
|
||||
System.out.println(4);
|
||||
System.out.println(lines[3]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
if(! lines[4].isEmpty()){
|
||||
if(NumberUtils.isCreatable(lines[4]) == false){
|
||||
System.out.println(5);
|
||||
System.out.println(lines[4]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(! lines[5].isEmpty()){
|
||||
if(NumberUtils.isCreatable(lines[5]) == false){
|
||||
System.out.println(6);
|
||||
System.out.println(lines[5]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if((! lines[7].isEmpty() && isStringBoolean(lines[7])) == false){
|
||||
System.out.println(7);
|
||||
System.out.println(lines[7]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(! lines[8].isEmpty()){
|
||||
if(! isValidDate(lines[8])){
|
||||
System.out.println(8);
|
||||
System.out.println(lines[8]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(! lines[9].isEmpty()){
|
||||
if(! NumberUtils.isCreatable(lines[9])){
|
||||
System.out.println(9);
|
||||
System.out.println(lines[9]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(! lines[10].isEmpty()){
|
||||
if(! isValidDate(lines[10])){
|
||||
System.out.println(10);
|
||||
System.out.println(lines[10]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(! lines[11].isEmpty()){
|
||||
if(! NumberUtils.isCreatable(lines[11])){
|
||||
System.out.println(11);
|
||||
System.out.println(lines[11]);
|
||||
reader.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
++line;
|
||||
}
|
||||
|
||||
reader.close();
|
||||
return true;
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isStringBoolean(String str){
|
||||
String temp = str.toLowerCase();
|
||||
|
||||
if( temp.equals("true") || temp.equals("false")){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
final String[] days = {"월","화","수","목","금","토","일"};
|
||||
private boolean isStringDay(String str){
|
||||
String[] strings = str.split(",");
|
||||
for( int i = 0 ; i < strings.length; ++i){
|
||||
strings[i] = strings[i].trim();
|
||||
if ( !StringUtils.containsAny(strings[i], days) )
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isValidDate(String str){
|
||||
|
||||
|
||||
str = str.replace(" ","" );
|
||||
String[] strings = str.split(",");
|
||||
if(strings.length != 2)
|
||||
return false;
|
||||
|
||||
|
||||
String[] temp = strings[0].split("/");
|
||||
if( temp.length != 2)
|
||||
return false;
|
||||
|
||||
if(!NumberUtils.isCreatable(temp[0]) || !NumberUtils.isCreatable(temp[1]))
|
||||
return false;
|
||||
int left = Integer.parseInt(temp[0]);
|
||||
int right = Integer.parseInt(temp[1]);
|
||||
if(left > 99 || left < 1 || right > 99 || right < 1)
|
||||
return false;
|
||||
|
||||
temp = strings[1].split("/");
|
||||
if( temp.length != 2)
|
||||
return false;
|
||||
|
||||
if(!NumberUtils.isCreatable(temp[0]) || !NumberUtils.isCreatable(temp[1]))
|
||||
return false;
|
||||
left = Integer.parseInt(temp[0]);
|
||||
right = Integer.parseInt(temp[1]);
|
||||
if(left > 99 || left < 1 || right > 99 || right < 1)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class HomeController {
|
||||
|
||||
model.addAttribute("serverTime", formattedDate );
|
||||
|
||||
return "login/login_form";
|
||||
return "home";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class UserDao implements UserService{
|
||||
final String SELECT_BY_ID = "select * from user where id = ?";
|
||||
@Override
|
||||
public UserVo select( String id ){
|
||||
|
||||
try {
|
||||
return jdbcTemplate.queryForObject(SELECT_BY_ID, new UserMapper(), id );
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<beans:property name="prefix" value="/WEB-INF/views/" />
|
||||
<beans:property name="suffix" value=".jsp" />
|
||||
</beans:bean>
|
||||
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
|
||||
|
||||
<context:component-scan base-package="co.nook.app" />
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean name="commonMav" class="org.springframework.web.servlet.ModelAndView" />
|
||||
<bean id="userVO" class="co.nook.app.user.vo.UserVo" />
|
||||
|
||||
|
||||
</beans>
|
||||
@@ -1,7 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
https://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/tx
|
||||
http://www.springframework.org/schema/tx/spring-tx.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
https://www.springframework.org/schema/aop/spring-aop.xsd">
|
||||
|
||||
|
||||
<!-- Root Context: defines shared resources visible to all other web components -->
|
||||
@@ -12,7 +20,6 @@
|
||||
<property name="url" value="jdbc:mariadb://coon.myds.me:3307/NookSearch" />
|
||||
<property name="username" value="minechost" />
|
||||
<property name="password" value="Ahstmxj5zos1!" />
|
||||
|
||||
</bean>
|
||||
|
||||
<!-- Spring JDBC 설정 -->
|
||||
@@ -21,4 +28,22 @@
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
||||
<property name="dataSource" ref="dataSource" />
|
||||
</bean>
|
||||
<!--
|
||||
<tx:advice id="txAdvice" transaction-manager="txManager">
|
||||
<tx:attributes>
|
||||
<tx:method name="get*" read-only="true"/>
|
||||
<tx:method name="*" />
|
||||
</tx:attributes>
|
||||
</tx:advice>
|
||||
|
||||
<aop:config>
|
||||
<aop:pointcut id="txPointcut" expression="execution(* co.nook.app..*(..))" />
|
||||
<aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice" />
|
||||
</aop:config> -->
|
||||
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
0
src/main/webapp/WEB-INF/uploaded/ignore
Normal file
0
src/main/webapp/WEB-INF/uploaded/ignore
Normal file
127
src/main/webapp/WEB-INF/views/admin/admin_data.jsp
Normal file
127
src/main/webapp/WEB-INF/views/admin/admin_data.jsp
Normal file
@@ -0,0 +1,127 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Suh
|
||||
Date: 2020-04-30
|
||||
Time: 오후 6:18
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>Title</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Cute+Font" rel="stylesheet">
|
||||
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/bootstrap.min.css">
|
||||
<script src="${pageContext.request.contextPath}/resources/js/jquery-3.5.0.min.js"></script>
|
||||
<script src="${pageContext.request.contextPath}/resources/js/popper.min.js"></script>
|
||||
<script src="${pageContext.request.contextPath}/resources/js/bootstrap.min.js"></script>
|
||||
<script src="${pageContext.request.contextPath}/resources/js/all.min.js"></script>
|
||||
<script>
|
||||
$(function(){
|
||||
$("#btn_default_file").on("click", insertDefaultData);
|
||||
|
||||
});
|
||||
|
||||
function insertDefaultData(){
|
||||
console.log("전송함");
|
||||
let form = $("#dDataFrm");
|
||||
let formData = new FormData();
|
||||
formData.append("file", $("#default_file")[0].files[0]);
|
||||
$.ajax({
|
||||
url: "/defaultDataInsert.do",
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: formData,
|
||||
type: 'POST',
|
||||
success: function(result){
|
||||
console.log(result);
|
||||
if(result == "invalid"){
|
||||
alert("업로드한 데이터가 정확하지 않습니다");
|
||||
}else {
|
||||
if (result == "true") {
|
||||
alert("데이터를 성공적으로 업로드 하였습니다");
|
||||
location.href="adminDataInsertPage.do";
|
||||
} else if (result == "false") {
|
||||
alert("데이터베이스에 업로드하다 문제가 생겼습니다");
|
||||
} else {
|
||||
alert("알수없는 에러가 발생하였습니다");
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function(){
|
||||
alert("데이터를 전송하는데 실패하였습니다");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function makeDefaultTodoTable(){
|
||||
let $table = $("tb_default_todo_data");
|
||||
|
||||
$table.remove(".dataTr");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1>기본 할일 테이블 입력</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<form id="dDataFrm" name="dDataFrm" enctype="multipart/form-data">
|
||||
<input type="file" class="form-control-file" id="default_file" name="default_file">
|
||||
<button type="button" class="form-control" id="btn_default_file" >전송</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table" id="tb_default_todo_data" class="table">
|
||||
<tr>
|
||||
<td>TodoNo</td>
|
||||
<td>IsAlways</td>
|
||||
<td>Content</td>
|
||||
<td>Day</td>
|
||||
<td>MinCount</td>
|
||||
<td>MaxCount</td>
|
||||
<td>NPCName</td>
|
||||
<td>IsEvent</td>
|
||||
<td>EventStartDate</td>
|
||||
<td>EventStartHour</td>
|
||||
<td>EventEndDate</td>
|
||||
<td>EventEndHour</td>
|
||||
<td>SpecialFunction</td>
|
||||
<td>SpecialData1</td>
|
||||
<td>SpecialData2</td>
|
||||
<td>SpecialData3</td>
|
||||
<td>SpecialData4</td>
|
||||
</tr>
|
||||
<c:forEach var="item" items="${list}">
|
||||
<tr class="dataTr">
|
||||
<td>${item.dTodoNo}</td>
|
||||
<td>${item.dIsAlways}</td>
|
||||
<td>${item.dContent}</td>
|
||||
<td>${item.dDay}</td>
|
||||
<td>${item.dMinCount}</td>
|
||||
<td>${item.dMaxCount}</td>
|
||||
<td>${item.dNpcName}</td>
|
||||
<td>${item.dIsEvent}</td>
|
||||
<td>${item.dEventStartDate}</td>
|
||||
<td>${item.dEventStartHour}</td>
|
||||
<td>${item.dEventEndDate}</td>
|
||||
<td>${item.dEventEndHour}</td>
|
||||
<td>${item.dSpecialFunction}</td>
|
||||
<td>${item.dSpecialData1}</td>
|
||||
<td>${item.dSpecialData2}</td>
|
||||
<td>${item.dSpecialData3}</td>
|
||||
<td>${item.dSpecialData4}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -10,6 +10,5 @@
|
||||
<script src="${pageContext.request.contextPath}/resources/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
<script src="${pageContext.request.contextPath}/resources/js/popper.min.js"></script>
|
||||
<script src="${pageContext.request.contextPath}/resources/js/bootstrap.min.js"></script>
|
||||
<script src="${pageContext.request.contextPath}/resources/js/all.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/todo.css">
|
||||
|
||||
<script>
|
||||
gaulhoExg = /\( *[0-9]+ *\/ *[0-9]+ *\)/;
|
||||
let dataList;
|
||||
$(function(){
|
||||
makeTable();
|
||||
@@ -28,12 +28,11 @@
|
||||
});
|
||||
|
||||
function getContentType(content){
|
||||
let exg = /\( *[1-9]+[0-9]* *\/ *[1-9]+[0-9]* *\)/;
|
||||
|
||||
if( exg.test(content)){
|
||||
console.log(gaulhoExg.test(content));
|
||||
if( gaulhoExg.test(content) ){
|
||||
return 'stack';
|
||||
}else{
|
||||
return 'normal'
|
||||
return 'normal';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +52,7 @@
|
||||
function removeDel($input){
|
||||
$input.unwrap("del");
|
||||
}
|
||||
|
||||
function showHideCheck($button, bool){
|
||||
let $img = $button.find("i");
|
||||
if(!bool){
|
||||
@@ -107,6 +107,8 @@
|
||||
let $button = $(this).find("button");
|
||||
let content = $input.val();
|
||||
let type = getContentType(content);
|
||||
console.log("content : " + content);
|
||||
console.log(type);
|
||||
let sub1;
|
||||
let sub2;
|
||||
if (type == 'normal') {
|
||||
@@ -146,11 +148,17 @@
|
||||
sub2 = maxCount;
|
||||
}
|
||||
let json = {};
|
||||
|
||||
let originStr = $input.val();
|
||||
if( type == 'stack'){
|
||||
let gaulhoStr = gaulhoExg.exec(originStr)[0];
|
||||
originStr = originStr.replace(gaulhoStr, '');
|
||||
}
|
||||
|
||||
json.todoNo = $(this).find(".hiddenClass").attr("name");
|
||||
json.content = $input.val();
|
||||
json.content = originStr;
|
||||
json.check = $button.find("svg").hasClass("leafCheck")+"";
|
||||
json.sub1 = sub1;
|
||||
|
||||
json.sub2 = sub2;
|
||||
|
||||
let parsed = JSON.stringify(json);
|
||||
@@ -172,7 +180,6 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function findGualho(str, point, direction){
|
||||
@@ -292,14 +299,14 @@
|
||||
$hiddenInput.val(item.uNo);
|
||||
|
||||
let newContent = item.uContent;
|
||||
let type = getContentType(newContent);
|
||||
if( type == "stack") {
|
||||
let cIndex = newContent.indexOf('/');
|
||||
let type = item.uSub2;
|
||||
if( type) {
|
||||
|
||||
let curCount = item.uSub1;
|
||||
let maxCount = item.uSub2;
|
||||
let beforeContent = newContent.substring(0, findGualho(newContent, cIndex, -1));
|
||||
let afterContent = newContent.substring(findGualho(newContent, cIndex, 1) - 1);
|
||||
newContent = beforeContent + " " + curCount + " / " + maxCount + " " + afterContent;
|
||||
|
||||
|
||||
newContent = "( " + curCount + " / " + maxCount + " ) " + newContent ;
|
||||
$todoInput.val(newContent);
|
||||
}else{
|
||||
$todoInput.val(newContent);
|
||||
@@ -376,6 +383,12 @@
|
||||
let check = $tr.find("svg").hasClass("leafCheck");
|
||||
let lineNo = $tr.find("td:first").html();
|
||||
|
||||
let exp = /[/()]+/;
|
||||
if( exp.test(content) ){
|
||||
showMessage("'/', '(', ')' 이 세 문자는 쓸수 없다 구리");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let json= {};
|
||||
json.content= content;
|
||||
@@ -407,12 +420,15 @@
|
||||
|
||||
let key = event.which;
|
||||
let isShift = event.shiftKey;
|
||||
if((isShift && key == 86) || (isShift && key == 57) || (isShift && key == 48) || key == 191){
|
||||
if((isShift && key == 57) || (isShift && key == 48) || (!isShift && key == 191)){
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function showMessage(message){
|
||||
alert(message);
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
16
src/main/webapp/WEB-INF/views/todo/todo_form_test.jsp
Normal file
16
src/main/webapp/WEB-INF/views/todo/todo_form_test.jsp
Normal file
@@ -0,0 +1,16 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Suh
|
||||
Date: 2020-05-04
|
||||
Time: 오전 5:24
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -31,4 +31,21 @@
|
||||
<url-pattern>*.do</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<filter>
|
||||
<filter-name>encodingFilter</filter-name>
|
||||
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>encoding</param-name>
|
||||
<param-value>UTF-8</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>forceEncoding</param-name>
|
||||
<param-value>true</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>encodingFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
</web-app>
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<jsp:forward page="home.do" />
|
||||
<jsp:forward page="adminDataInsertPage.do"></jsp:forward>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user