account read update 관련

This commit is contained in:
Suh
2024-01-12 12:37:56 +09:00
parent 9249fb4b50
commit 96b9dbcd8a
14 changed files with 522 additions and 56 deletions

View File

@@ -1,15 +1,16 @@
package com.no1.wms.account;
import com.google.gson.Gson;
import com.no1.wms.authority.AuthorityDto;
import com.no1.wms.authority.AuthorityService;
import com.no1.wms.utils.ConstantValues;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
import java.util.UUID;
@Controller
@RequestMapping("/account")
@@ -17,6 +18,8 @@ public class AccountController {
@Autowired
AccountService accountService;
@Autowired
AuthorityService authorityService;
@GetMapping("/list")
public ModelAndView list(ModelAndView mav, @RequestParam(defaultValue = "") String search, @RequestParam(defaultValue = "0") int start){
@@ -34,11 +37,63 @@ public class AccountController {
return mav;
}
@PostMapping("/show_modal")
public ModelAndView showModal(ModelAndView mav, @RequestParam String name){
//db에서 데이터 가져오는거 필요
@PostMapping("/create_process")
@ResponseBody
public String createProcess(AccountDto dto, Gson gson){
String uuid = UUID.randomUUID().toString();
AuthorityDto authorityDto = new AuthorityDto();
authorityDto.setId(dto.getGroupAuthorityId());
authorityDto = authorityService.selectById(authorityDto);
authorityDto.setId(uuid);
authorityDto.setIsGroupAuthority(false);
authorityDto.setName(dto.getEmployeeNumber());
accountService.insertToAuthority(authorityDto);
dto.setPersonalAuthorityId(uuid);
accountService.insert(dto);
return gson.toJson("s");
}
@PostMapping("/read")
public ModelAndView read(AccountDto dto, ModelAndView mav){
dto = accountService.selectById(dto);
mav.addObject("dto", dto);
mav.setViewName("/account/read");
return mav;
}
@PostMapping("/update")
public ModelAndView update(AccountDto dto, ModelAndView mav){
dto = accountService.selectById(dto);
mav.addObject("dto", dto);
mav.setViewName("/account/update");
return mav;
}
@PostMapping("/update_process")
@ResponseBody
public String updateProcess(AccountDto dto, Gson gson){
accountService.update(dto);
return gson.toJson("s");
}
@PostMapping("/show_modal")
public ModelAndView showModal(ModelAndView mav, @RequestParam(defaultValue = "") String search,
@RequestParam(defaultValue = "0") int start, @RequestParam String name){
//db에서 데이터 가져오는거 필요
List list = null;
if(name.equals("auth")){
list = authorityService.selectAll(search, start, ConstantValues.PER_PAGE);
}else if(name.equals("dept")){
list = accountService.selectDeptAll(search, start, ConstantValues.PER_PAGE);
}else if(name.equals("pos")){
list = accountService.selectPosAll(search, start, ConstantValues.PER_PAGE);
}
//
mav.addObject("list", list);
mav.setViewName(name);
return mav;
}

View File

@@ -8,6 +8,7 @@ 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;
@@ -25,6 +26,7 @@ public class AccountDto {
private String personalAuthorityId;
private String name;
private String gender;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birth;
private String telephone;
private String address;

View File

@@ -1,5 +1,8 @@
package com.no1.wms.account;
import com.no1.wms.authority.AuthorityDto;
import com.no1.wms.department.DepartmentDto;
import com.no1.wms.position.PositionDto;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
@@ -11,9 +14,15 @@ import java.util.Map;
public interface AccountMapper {
int insert(AccountDto dto);
int insertToAuthority(AuthorityDto dto);
int update(AccountDto dto);
int selectById(AccountDto dto);
AccountDto selectById(AccountDto dto);
List<AccountDto> selectAll(Map<String, Object> m);
List<DepartmentDto> selectDeptAll(Map<String, Object> m);
List<PositionDto> selectPosAll(Map<String, Object> m);
}

View File

@@ -1,5 +1,8 @@
package com.no1.wms.account;
import com.no1.wms.authority.AuthorityDto;
import com.no1.wms.department.DepartmentDto;
import com.no1.wms.position.PositionDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -15,11 +18,14 @@ public class AccountService {
public int insert(AccountDto dto){
return mapper.insert(dto);
}
int insertToAuthority(AuthorityDto dto){
return mapper.insertToAuthority(dto);
}
public int update(AccountDto dto){
return mapper.update(dto);
}
public int selectById(AccountDto dto){
public AccountDto selectById(AccountDto dto){
return mapper.selectById(dto);
}
@@ -34,4 +40,22 @@ public class AccountService {
return mapper.selectAll(map);
}
List<DepartmentDto> selectDeptAll(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);
return mapper.selectDeptAll(map);
}
List<PositionDto> selectPosAll(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);
return mapper.selectPosAll(map);
}
}

View File

@@ -1,17 +0,0 @@
package com.no1.wms.account;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Alias("DeptPositionDto")
public class DeptAndPositionDto {
private String id;
private String name;
}