Commit 9d63d53e authored by Đào Nhật Quang's avatar Đào Nhật Quang

quangdn

parent d4565414
...@@ -34,6 +34,8 @@ public interface CustomerService { ...@@ -34,6 +34,8 @@ public interface CustomerService {
ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId); ResultDTO getAllCustomerList(int page, int pageSize, String sort, Long companySiteId);
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName); ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName);
ResultDTO updateCustomerList(CustomerListDTO customerListDTO); ResultDTO updateCustomerList(CustomerListDTO customerListDTO);
......
...@@ -600,35 +600,38 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -600,35 +600,38 @@ public class CustomerServiceImpl implements CustomerService {
@Override @Override
@Transactional(DataSourceQualify.CCMS_FULL) @Transactional(DataSourceQualify.CCMS_FULL)
public ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName) { public ResultDTO createCustomerList(CustomerListDTO customerListDTO, String userName) {
// THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = new CustomerList();
try { try {
if (customerListDTO != null) { CustomerList cl = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
// insert if (cl != null) {
CustomerList findCustomer = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (findCustomer == null) {
customerListDTO.setCreateBy(userName);
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription("Entity exists");
return resultDTO;
} else {
cl = new CustomerList();
cl.setCustomerListCode(customerListDTO.getCustomerListCode());
cl.setCustomerListName(customerListDTO.getCustomerListName());
cl.setStatus((short) 1);
cl.setCreateBy(userName);
cl.setCreateAt(new Date());
cl.setUpdateBy(null);
cl.setUpdateAt(null);
cl.setSource(null);
cl.setDeptCreate(null);
cl.setCompanySiteId(customerListDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
resultDTO.setData(customerListRepository.save(cl));
return resultDTO;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); LOGGER.error(e.getMessage());
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription("Error");
return resultDTO;
} }
return resultDTO;
} }
@Override @Override
......
...@@ -109,13 +109,16 @@ public class CustomerController { ...@@ -109,13 +109,16 @@ public class CustomerController {
@PostMapping("/createCustomerList") @PostMapping("/createCustomerList")
@ResponseBody @ResponseBody
public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) { public ResultDTO createCustomerList(@RequestBody @Valid CustomerListDTO customerListDTO, HttpServletRequest request) {
ResultDTO result = new ResultDTO(); // THÍM NÀO MERGE CONFLICT THÌ GIỮ LẠI HỘ E CÁI METHOD NÀY VỚI
// VIẾT ĐI VIẾT LẠI 4 LẦN RỒI ĐẤY
String xAuthToken = request.getHeader("X-Auth-Token"); String xAuthToken = request.getHeader("X-Auth-Token");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken); UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
if (userSession == null) {
result = customerService.createCustomerList(customerListDTO, userSession.getUserName()); userSession = new UserSession();
return result; userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return customerService.createCustomerList(customerListDTO, userSession.getUserName());
} }
@PostMapping("/updateCustomerList") @PostMapping("/updateCustomerList")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment