Merge remote-tracking branch 'origin/master'

This commit is contained in:
sungsu
2024-01-17 16:13:18 +09:00
28 changed files with 945 additions and 82 deletions

View File

@@ -30,6 +30,7 @@ public class AccountController {
int count = accountService.count(searchn, search, startRow, perPage);
int pageNum = 4;//보여질 페이지 번호 수
int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수
@@ -37,7 +38,7 @@ public class AccountController {
//스톡서비스로 재고 리스트 출력 메서트 작성
List<AccountDto> list = accountService.selectAll(searchn, search, searchn, perPage);
List<AccountDto> list = accountService.selectAll(searchn, search, startRow, perPage);
int begin = (page - 1) / pageNum * pageNum + 1;
int end = begin + pageNum - 1;
@@ -48,8 +49,9 @@ public class AccountController {
mav.addObject("end", end);
mav.addObject("searchn", searchn);
mav.addObject("search", search);
mav.addObject("page", startRow);
mav.addObject("pageNum", pageNum);
mav.addObject("begin", begin);
mav.addObject("page", page);
mav.setViewName("account/list");
return mav;
}

View File

@@ -45,7 +45,7 @@ public class AuthAspect {
String[] list = targetController.split("\\.");
String packageName = list[3];
if(packageName.equals("login")) {
if(packageName.equals("login") || packageName.equals("resetpassword")) {
return joinPoint.proceed();
}

View File

@@ -1,5 +1,5 @@
package com.no1.wms.in;
public class InController {
}

View File

@@ -0,0 +1,5 @@
package com.no1.wms.in;
public class InDto {
}

View File

@@ -0,0 +1,5 @@
package com.no1.wms.in;
public class InMapper {
}

View File

@@ -0,0 +1,5 @@
package com.no1.wms.in;
public class InService {
}

View File

@@ -34,6 +34,21 @@ public class LoginController {
}
@PostMapping("/pass_reset_call")
@ResponseBody
public String passResetCall(AccountDto dto, Gson gson)
{
return gson.toJson("s");
}
@GetMapping("/passreset")
public String passReset()
{
return "pass_reset_call";
}
@PostMapping("/login/check_password")
@@ -55,6 +70,7 @@ public class LoginController {
auth.put("vendor",getAuthArrayFromInt(authDto.getVendor()));
auth.put("warehouse",getAuthArrayFromInt(authDto.getWarehouse()));
auth.put("stock",getAuthArrayFromInt(authDto.getStock()));
auth.put("planin",getAuthArrayFromInt(authDto.getPlanIn()));
auth.put("in",getAuthArrayFromInt(authDto.getProductIn())); //prodcut_in
auth.put("out",getAuthArrayFromInt(authDto.getProductOut())); //product_out
auth.put("board",getAuthArrayFromInt(authDto.getBoard()));

View File

@@ -0,0 +1,77 @@
package com.no1.wms.mypage;
import java.io.File;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.no1.wms.excel.EgovWebUtil;
@Service
public class ImgService {
public void imgFileUplode(HttpServletRequest request, MultipartFile imageFile, String fileName) {
String storePathString = "";
try {
ClassPathResource resource = new ClassPathResource("/static/img/mypage/profile");
storePathString = resource.getFile().getAbsolutePath();
//storePathString = System.getProperty("user.dir") + "/src/main/resources/static/img/mypage/profile";
//System.out.println("storePathString : " + storePathString);
//String path = ResourceUtils.getFile("classpath:static/img/mypage/profile/").toPath().toString();
//storePathString = path;
//System.out.println("storePathString : " + storePathString);
} catch (Exception e) {
e.printStackTrace();
}
File saveFolder = new File(EgovWebUtil.filePathBlackList(storePathString));
//폴더 없으면 생성
if (!saveFolder.exists() || saveFolder.isFile()) {
saveFolder.mkdirs();
}
// 원본 파일 이름 가져오기
String originalFileName = imageFile.getOriginalFilename();
// 확장자 추출
int index = originalFileName.lastIndexOf(".");
String fileExt = originalFileName.substring(index + 1);
String newFileName = fileName;
// 저장될 파일 경로 설정
String filePath = storePathString + File.separator + newFileName + "." + fileExt;
try {
// 동일한 파일명이 존재하는지 확인하고 있다면 기존 파일 삭제
String jpg = storePathString + File.separator + newFileName + "." + "jpg";
String png = storePathString + File.separator + newFileName + "." + "png";
String jpeg = storePathString + File.separator + newFileName + "." + "jpeg";
File existingJpgFile = new File(jpg);
File existingPngFile = new File(png);
File existingJpegFile = new File(jpeg);
String imgSrc = "";
if(existingJpgFile.exists()) {
existingJpgFile.delete();
}else if(existingPngFile.exists()) {
existingPngFile.delete();
}else if(existingJpegFile.exists()) {
existingJpegFile.delete();
}
// 이미지를 지정된 경로에 저장
imageFile.transferTo(new File(EgovWebUtil.filePathBlackList(filePath)));
//System.out.println("Image file saved at: " + filePath);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,103 @@
package com.no1.wms.mypage;
import java.io.File;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.no1.wms.account.AccountDto;
import com.no1.wms.account.AccountService;
@Controller
public class MypageController {
@Autowired
AccountService accountService;
@Autowired
ImgService imgService;
@GetMapping("/mypage")
public String mypage(Model m, HttpServletRequest request) {
HttpSession session = request.getSession();
AccountDto dto = (AccountDto) session.getAttribute("userData");
AccountDto list = accountService.selectById(dto);
m.addAttribute("list", list);
String id = list.getId();
ClassPathResource resource = new ClassPathResource("/static/img/mypage/profile");
String storePathString;
try {
storePathString = resource.getFile().getAbsolutePath();
String jpg = storePathString + File.separator + id + "." + "jpg";
String png = storePathString + File.separator + id + "." + "png";
String jpeg = storePathString + File.separator + id + "." + "jpeg";
File existingJpgFile = new File(jpg);
File existingPngFile = new File(png);
File existingJpegFile = new File(jpeg);
String imgSrc = "";
if(existingJpgFile.exists()) {
imgSrc = "/resources/static/img/mypage/profile/"+ id +".jpg";
//System.out.println("jpg");
}else if(existingPngFile.exists()) {
imgSrc = "/resources/static/img/mypage/profile/"+ id +".png";
//System.out.println("png");
}else if(existingJpegFile.exists()) {
imgSrc = "/resources/static/img/mypage/profile/"+ id +".jpeg";
//System.out.println("jpeg");
}else {
imgSrc = "/resources/static/img/mypage/profile/defaultimg.png";
//System.out.println("default");
}
m.addAttribute("imgSrc", imgSrc);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "mypage/mypage";
}
@ResponseBody
@PutMapping("/mypage/updateUserInfo")
public boolean updateUserInfo(AccountDto dto) {
int i = accountService.update(dto);
System.out.println(i);
if (i == 1) {
return true;
} else {
return false;
}
}
@PostMapping("/mypage/uplodeImg")
public String imgFileUplode(HttpServletRequest request, MultipartFile file) {
//System.out.println(file);
HttpSession session = request.getSession();
AccountDto dto = (AccountDto) session.getAttribute("userData");
String fileName = dto.getId();
//System.out.println(fileName);
imgService.imgFileUplode(request, file, fileName);
return "redirect:/mypage";
}
}

View File

@@ -0,0 +1,56 @@
package com.no1.wms.planin;
import com.no1.wms.account.AccountDto;
import com.no1.wms.planin.PlanInService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping("planin")
public class PlanInController {
@Autowired
PlanInService planinservice;
@GetMapping("/list")
public ModelAndView list(ModelAndView mav,@RequestParam(defaultValue = "0") int searchn, @RequestParam(defaultValue = "") String search, @RequestParam(defaultValue = "1") int page){
int perPage = 10;
int startRow = (page - 1) * perPage;
int count = planinservice.count(searchn, search, startRow, perPage);
int pageNum = 4;//보여질 페이지 번호 수
int totalPages = count / perPage + (count % perPage > 0 ? 1 : 0); // 전체 페이지 수
//스톡서비스로 재고 리스트 출력 메서트 작성
List<AccountDto> list = planinservice.selectAll(searchn, search, startRow, perPage);
int begin = (page - 1) / pageNum * pageNum + 1;
int end = begin + pageNum - 1;
if (end > totalPages) {
end = totalPages;
}
mav.addObject("list", list);
mav.addObject("end", end);
mav.addObject("searchn", searchn);
mav.addObject("search", search);
mav.addObject("pageNum", pageNum);
mav.addObject("begin", begin);
mav.addObject("page", page);
mav.setViewName("account/list");
return mav;
}
}

View File

@@ -0,0 +1,5 @@
package com.no1.wms.planin;
public class PlanInDto {
}

View File

@@ -0,0 +1,18 @@
package com.no1.wms.planin;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import com.no1.wms.account.AccountDto;
@Repository
@Mapper
public interface PlanInMapper {
List<AccountDto> selectAll(Map<String, Object> m);
int count(Map<String, Object> m);
}

View File

@@ -0,0 +1,37 @@
package com.no1.wms.planin;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.no1.wms.account.AccountDto;
@Service
public class PlanInService {
@Autowired
PlanInMapper mapper;
public List<AccountDto> selectAll(int searchn, String search, int start, int perPage){
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("search", search);
map.put("start", start);
map.put("perPage", perPage);
map.put("searchn", searchn);
return mapper.selectAll(map);
}
int count(int searchn, String search, int start, int perPage){
HashMap<String, Object> m = new HashMap<>();
m.put("searchn", searchn);
m.put("search", search);
m.put("start", start);
m.put("perPage", perPage);
return mapper.count(m);
}
}

View File

@@ -0,0 +1,36 @@
package com.no1.wms.resetpassword;
import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/resetpassword")
public class ResetPasswordController {
@Autowired
ResetPasswordService resetPasswordService;
@PostMapping("/insert")
@ResponseBody
public String insert(ResetPasswordDto dto, Gson gson){
resetPasswordService.insert(dto);
return gson.toJson("s");
}
@PostMapping("/delete")
@ResponseBody
public String delete(ResetPasswordDto dto, Gson gson){
resetPasswordService.delete(dto);
return gson.toJson("s");
}
}

View File

@@ -0,0 +1,27 @@
package com.no1.wms.resetpassword;
import com.no1.wms.account.AccountDto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Alias("ResetPasswordDto")
public class ResetPasswordDto {
String id;
String accountId;
String note;
@DateTimeFormat(pattern = "yyyy-MM-dd")
Date date;
AccountDto accountDto;
String employeeNumber;
}

View File

@@ -0,0 +1,15 @@
package com.no1.wms.resetpassword;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@Repository
@Mapper
public interface ResetPasswordMapper {
void insert(ResetPasswordDto dto);
void delete(ResetPasswordDto dto);
}

View File

@@ -0,0 +1,19 @@
package com.no1.wms.resetpassword;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ResetPasswordService {
@Autowired
ResetPasswordMapper mapper;
void insert(ResetPasswordDto dto){
mapper.insert(dto);
}
void delete(ResetPasswordDto dto){
mapper.delete(dto);
}
}