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

quangdn

parent d4565414
......@@ -34,6 +34,8 @@ public interface CustomerService {
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 updateCustomerList(CustomerListDTO customerListDTO);
......
......@@ -600,36 +600,39 @@ public class CustomerServiceImpl implements CustomerService {
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
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();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = new CustomerList();
try {
if (customerListDTO != null) {
// insert
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 {
CustomerList cl = customerListRepository.findByCustomerListCode(customerListDTO.getCustomerListCode());
if (cl != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
resultDTO.setDescription("Entity exists");
return resultDTO;
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
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) {
e.printStackTrace();
}
LOGGER.error(e.getMessage());
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription("Error");
return resultDTO;
}
}
@Override
@Transactional(DataSourceQualify.CCMS_FULL)
......
......@@ -109,13 +109,16 @@ public class CustomerController {
@PostMapping("/createCustomerList")
@ResponseBody
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");
UserSession userSession = (UserSession) RedisUtil.getInstance().get(xAuthToken);
result = customerService.createCustomerList(customerListDTO, userSession.getUserName());
return result;
if (userSession == null) {
userSession = new UserSession();
userSession.setSiteId(customerListDTO.getCompanySiteId());
userSession.setUserName("its4");
}
return customerService.createCustomerList(customerListDTO, userSession.getUserName());
}
@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