Commit 78799d1e by guojuxing

新增企业

parent dfdf31e6
......@@ -23,4 +23,11 @@ public interface EnterpriseApiService {
* @return
*/
ServiceResponse<Integer> editEnterprise(EnterpriseDTO enterpriseDTO);
/**
* 根据主键获取数据
* @param enterpriseId
* @return
*/
ServiceResponse<EnterpriseDTO> getEnterpriseById(Integer enterpriseId);
}
package com.gic.enterprise.service.outer;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.constant.EnterpriseStatusTypeEnum;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.entity.TabEnterprise;
......@@ -55,7 +56,7 @@ public class EnterpriseApiServiceImpl implements EnterpriseApiService {
if (tabEnterprise == null) {
ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "企业ID错误,查询不到数据");
}
if (enterpriseService.isRepeatEnterpriseName(enterpriseDTO.getEnterpriseName(), null)) {
if (enterpriseService.isRepeatEnterpriseName(enterpriseDTO.getEnterpriseName(), enterpriseDTO.getEnterpriseId())) {
ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "商户名称不能重复");
}
......@@ -63,4 +64,13 @@ public class EnterpriseApiServiceImpl implements EnterpriseApiService {
enterpriseService.editEnterprise(enterpriseDTO);
return ServiceResponse.success();
}
@Override
public ServiceResponse<EnterpriseDTO> getEnterpriseById(Integer enterpriseId) {
TabEnterprise tabEnterprise = enterpriseService.getEnterpriseById(enterpriseId);
if (tabEnterprise == null) {
ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "企业ID错误,查询不到数据");
}
return ServiceResponse.success(EntityUtil.changeEntityNew(EnterpriseDTO.class, tabEnterprise));
}
}
package com.gic.enterprise.service.outer;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.service.EnterpriseApiService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
/**
* @author guojx
* @date 2019/7/16 6:31 PM
*/
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class EnterpriseApiServiceImplTest extends AbstractJUnit4SpringContextTests{
@Autowired
private EnterpriseApiService enterpriseApiService;
@Test
public void saveEnterprise() throws Exception {
EnterpriseDTO dto = new EnterpriseDTO();
ServiceResponse response = enterpriseApiService.saveEnterprise(dto);
if (!response.isSuccess()) {
System.out.println(response.getMessage());
}
}
}
\ No newline at end of file
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