# Conflicts: # user-service/src/main/java/com/hp/user/service/impl/AccountServiceImpl.java # user-service/src/test/java/com/hp/user/service/ControllerTest.javadev
@@ -62,10 +62,14 @@ public class AccountVO{ | |||
* 对应企业/服务商Id | |||
*/ | |||
private String companyId; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remarks; | |||
public AccountVO(){} | |||
public AccountVO(String userId, String userName, String wxNumber, String phone, Date sysCreateTime, String sysCreator, Date sysUpdateTime, String sysUpdater, Short status, String roleId, String companyId) { | |||
public AccountVO(String userId, String userName, String wxNumber, String phone, Date sysCreateTime, String sysCreator, Date sysUpdateTime, String sysUpdater, Short status, String roleId, String wxOpeanId, String companyId, String remarks) { | |||
this.userId = userId; | |||
this.userName = userName; | |||
this.wxNumber = wxNumber; | |||
@@ -76,7 +80,9 @@ public class AccountVO{ | |||
this.sysUpdater = sysUpdater; | |||
this.status = status; | |||
this.roleId = roleId; | |||
this.wxOpeanId = wxOpeanId; | |||
this.companyId = companyId; | |||
this.remarks = remarks; | |||
} | |||
public String getUserId() { | |||
@@ -175,4 +181,12 @@ public class AccountVO{ | |||
public void setCompanyId(String companyId) { | |||
this.companyId = companyId; | |||
} | |||
public String getRemarks() { | |||
return remarks; | |||
} | |||
public void setRemarks(String remarks) { | |||
this.remarks = remarks; | |||
} | |||
} |
@@ -22,6 +22,11 @@ public class CustomerServiceProviderEnterpriseVO { | |||
public CustomerServiceProviderEnterpriseVO(){} | |||
public CustomerServiceProviderEnterpriseVO(String serviceProviderId, String enterpriseId) { | |||
this.serviceProviderId = serviceProviderId; | |||
this.enterpriseId = enterpriseId; | |||
} | |||
public CustomerServiceProviderEnterpriseVO(String id, String serviceProviderId, String enterpriseId) { | |||
this.id = id; | |||
this.serviceProviderId = serviceProviderId; | |||
@@ -2,9 +2,6 @@ package com.hp.user.client.entity; | |||
public class DataResult<T> extends Result{ | |||
/** | |||
* | |||
*/ | |||
private static final long serialVersionUID = 1L; | |||
private T data; | |||
@@ -3,7 +3,40 @@ package com.hp.user.client.entity; | |||
import java.util.List; | |||
public class PageResult<T> extends Result{ | |||
private Long current; // 当前页 | |||
private Integer size; // 当前页size | |||
private Long total; //总条数 | |||
private List<T> dataList; | |||
public Long getCurrent() { | |||
return current; | |||
} | |||
public void setCurrent(Long current) { | |||
this.current = current; | |||
} | |||
public Integer getSize() { | |||
return size; | |||
} | |||
public void setSize(Integer size) { | |||
this.size = size; | |||
} | |||
public Long getTotal() { | |||
return total; | |||
} | |||
public void setTotal(Long total) { | |||
this.total = total; | |||
} | |||
public List<T> getDataList() { | |||
return dataList; | |||
} | |||
public void setDataList(List<T> dataList) { | |||
this.dataList = dataList; | |||
} | |||
} |
@@ -3,9 +3,7 @@ package com.hp.user.client.entity; | |||
import java.io.Serializable; | |||
public class Result implements Serializable{ | |||
/** | |||
* | |||
*/ | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 错误码,如果没有错误为null | |||
@@ -1,8 +1,6 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.AccountPage; | |||
import com.hp.user.client.entity.AccountVO; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.*; | |||
import java.util.List; | |||
@@ -15,11 +13,12 @@ import java.util.List; | |||
* @since 2020-11-20 | |||
*/ | |||
public interface AccountService { | |||
public boolean insert(AccountVO account); | |||
public boolean delete(String userId); | |||
public boolean update(AccountVO account); | |||
public AccountPage queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus(String companyId,String userName,String phone,Integer status,Long current,Integer size); | |||
public boolean batchChangeStatusOfUser(String companyId,String[] userIds,Short status); | |||
public Result insert(AccountVO account); | |||
public Result delete(String userId); | |||
public Result update(AccountVO account); | |||
public PageResult<AccountVO> queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus(String companyId, String userName, String phone, Integer status, Long current, Integer size); | |||
public Result batchChangeStatusOfUser(String[] userIds,Short status); | |||
public DataResult<AccountVO> queryAccountByPhone(String phone); | |||
/** | |||
* 登陆 | |||
@@ -2,6 +2,9 @@ package com.hp.user.client.service; | |||
import com.hp.user.client.entity.AddressVO; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.ListResult; | |||
import com.hp.user.client.entity.Result; | |||
import java.util.List; | |||
@@ -14,9 +17,9 @@ import java.util.List; | |||
* @since 2020-11-20 | |||
*/ | |||
public interface AddressService{ | |||
public boolean insert(AddressVO address); | |||
public boolean update(AddressVO address); | |||
public boolean delete(String addressId); | |||
public AddressVO queryAddressByAddressId(String addressId); | |||
public List<AddressVO> queryAllAddress(); | |||
public Result insert(AddressVO address); | |||
public Result update(AddressVO address); | |||
public Result delete(String addressId); | |||
public DataResult<AddressVO> queryAddressByAddressId(String addressId); | |||
public ListResult<AddressVO> queryAllAddress(); | |||
} |
@@ -1,6 +1,7 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.AreaVO; | |||
import com.hp.user.client.entity.ListResult; | |||
import java.util.List; | |||
@@ -13,5 +14,5 @@ import java.util.List; | |||
* @since 2020-11-20 | |||
*/ | |||
public interface AreaService{ | |||
public List<AreaVO> getAllArea(); | |||
public ListResult<AreaVO> getAllArea(); | |||
} |
@@ -1,8 +1,10 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.AuditVO; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.Result; | |||
public interface AuditService { | |||
public boolean insert(AuditVO audit); | |||
public AuditVO queryAuditByAuditId(String auditId); | |||
public Result insert(AuditVO audit); | |||
public DataResult<AuditVO> queryAuditByAuditId(String auditId); | |||
} |
@@ -1,8 +1,6 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.CompanyAuditPage; | |||
import com.hp.user.client.entity.CompanyPage; | |||
import com.hp.user.client.entity.CustomerCompanyVO; | |||
import com.hp.user.client.entity.*; | |||
import java.util.Date; | |||
@@ -15,13 +13,13 @@ import java.util.Date; | |||
* @since 2020-11-20 | |||
*/ | |||
public interface CustomerCompanyService { | |||
public boolean insert(CustomerCompanyVO company); | |||
public boolean delete(String companyId); | |||
public boolean update(CustomerCompanyVO company); | |||
public CustomerCompanyVO queryCompanyByCompanyId(String companyId); | |||
public CompanyPage getCompanysPage(Long current, Integer size,Integer type); | |||
public CompanyPage queryServiceProvidersByName(String name, Long current, Integer size); | |||
public CompanyPage queryCompanysPageByNameAndServiceAndStatus(String name, String serviceProviderName, Integer status, Long current, Integer size); | |||
public CompanyAuditPage getCompanyAuditsPage(Long current, Integer size); | |||
public CompanyAuditPage queryCompanysPageByNameAndStatusAndCreateTime(String name, Integer status, Date startTime,Date endTime, Long current, Integer size); | |||
public Result insert(CustomerCompanyVO company); | |||
public Result delete(String companyId); | |||
public Result update(CustomerCompanyVO company); | |||
public DataResult<CustomerCompanyVO> queryCompanyByCompanyId(String companyId); | |||
public PageResult<CustomerCompanyVO> getCompanysPage(Long current, Integer size,Integer type); | |||
public PageResult<CustomerCompanyVO> queryServiceProvidersByName(String name, Long current, Integer size); | |||
public PageResult<CustomerCompanyVO> queryCompanysPageByNameAndServiceAndStatus(String name, String serviceProviderName, Integer status, Long current, Integer size); | |||
public PageResult<CompanyAuditVO> getCompanyAuditsPage(Long current, Integer size); | |||
public PageResult<CompanyAuditVO> queryCompanysPageByNameAndStatusAndCreateTime(String name, Integer status, Date startTime,Date endTime, Long current, Integer size); | |||
} |
@@ -1,6 +1,8 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.CustomerServiceProviderEnterpriseVO; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.Result; | |||
import java.util.List; | |||
@@ -13,12 +15,12 @@ import java.util.List; | |||
* @since 2020-11-20 | |||
*/ | |||
public interface CustomerServiceProviderEnterpriseService { | |||
public boolean insert(CustomerServiceProviderEnterpriseVO cs); | |||
public boolean update(CustomerServiceProviderEnterpriseVO cs); | |||
public boolean delete(String csId); | |||
public CustomerServiceProviderEnterpriseVO queryCsByCompanyIdAndServiceProviderId(String companyId,String serviceProviderId); | |||
public String queryServiceProviderIdByCompanyId(String companyId); | |||
public boolean insertBatch(List<CustomerServiceProviderEnterpriseVO> csVOList); | |||
public boolean deleteBatch(List<String> enterpriseIdList); | |||
public Result insert(CustomerServiceProviderEnterpriseVO cs); | |||
public Result update(CustomerServiceProviderEnterpriseVO cs); | |||
public Result delete(String csId); | |||
public DataResult<CustomerServiceProviderEnterpriseVO> queryCsByCompanyIdAndServiceProviderId(String companyId, String serviceProviderId); | |||
public DataResult<String> queryServiceProviderIdByCompanyId(String companyId); | |||
public Result insertBatch(List<CustomerServiceProviderEnterpriseVO> csVOList); | |||
public Result deleteBatch(List<String> enterpriseIdList); | |||
} |
@@ -1,7 +1,6 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.StationPage; | |||
import com.hp.user.client.entity.StationVO; | |||
import com.hp.user.client.entity.*; | |||
/** | |||
* <p> | |||
@@ -12,11 +11,11 @@ import com.hp.user.client.entity.StationVO; | |||
* @since 2020-11-20 | |||
*/ | |||
public interface StationService { | |||
public boolean insert(StationVO station); | |||
public boolean delete(String stationId); | |||
public boolean update(StationVO station); | |||
public StationVO queryStationByStationId(String stationId); | |||
public StationVO queryStationByStationName(String name); | |||
public StationPage getStationsPage(Long current, Integer size); | |||
public Result insert(StationVO station); | |||
public Result delete(String stationId); | |||
public Result update(StationVO station); | |||
public DataResult<StationVO> queryStationByStationId(String stationId); | |||
public DataResult<StationVO> queryStationByStationName(String name); | |||
public PageResult<StationVO> getStationsPage(Long current, Integer size); | |||
} |
@@ -1,6 +1,8 @@ | |||
package com.hp.user.client.service; | |||
import com.hp.user.client.entity.AreaVO; | |||
import com.hp.user.client.entity.ListResult; | |||
import com.hp.user.client.entity.Result; | |||
import java.util.List; | |||
@@ -15,5 +17,5 @@ import java.util.List; | |||
* 使用AreaServcie来命名在自动注入bean的时候会保存,不知道和那个类同名了 | |||
*/ | |||
public interface UserAreaService{ | |||
public List<AreaVO> getAllArea(); | |||
public ListResult<AreaVO> getAllArea(); | |||
} |
@@ -1,6 +1,8 @@ | |||
package com.hp.user.service.controller; | |||
import com.hp.user.client.entity.AddressVO; | |||
import com.hp.user.client.entity.ListResult; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.AddressService; | |||
import com.hp.user.service.utils.IdWorker; | |||
import com.hp.user.service.utils.HttpResult; | |||
@@ -21,22 +23,22 @@ public class AddressController { | |||
/** | |||
* 添加地址 | |||
* @param address 地址信息 | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "新增地址") | |||
@PostMapping("/addAddress") | |||
public HttpResult addAddress(@RequestBody AddressVO address){ | |||
public Result addAddress(@RequestBody AddressVO address){ | |||
address.setAddressId(IdWorker.generactorId().toString()); | |||
boolean flag = addressService.insert(address); | |||
if(flag) return HttpResult.success(address.getAddressId()); | |||
else return HttpResult.fail("添加失败"); | |||
return addressService.insert(address); | |||
} | |||
/** | |||
* 查询所有地址信息 | |||
* @return ListResult | |||
*/ | |||
@ApiOperation(value = "查询所有地址信息") | |||
@GetMapping("/queryAllAddress") | |||
public HttpResult queryAllAddress(){ | |||
List<AddressVO> addresses = addressService.queryAllAddress(); | |||
if (addresses != null) return HttpResult.success(addresses); | |||
else return HttpResult.fail("查询失败"); | |||
public ListResult<AddressVO> queryAllAddress(){ | |||
return addressService.queryAllAddress(); | |||
} | |||
} |
@@ -2,6 +2,7 @@ package com.hp.user.service.controller; | |||
import com.hp.user.client.entity.AreaVO; | |||
import com.hp.user.client.entity.ListResult; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import com.hp.user.client.service.UserAreaService; | |||
@@ -27,9 +28,7 @@ public class AreaController { | |||
*/ | |||
@GetMapping("/queryAllArea") | |||
@ApiOperation(value = "获取所有地区信息", notes = "获取所有地区信息", httpMethod = "GET") | |||
public HttpResult queryAllArea() { | |||
List<AreaVO> areas = areaService.getAllArea(); | |||
if (areas != null) return HttpResult.success(areas); | |||
else return HttpResult.fail("查询失败"); | |||
public ListResult<AreaVO> queryAllArea() { | |||
return areaService.getAllArea(); | |||
} | |||
} |
@@ -1,6 +1,7 @@ | |||
package com.hp.user.service.controller; | |||
import com.hp.user.client.entity.AuditVO; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.AuditService; | |||
import com.hp.user.service.utils.IdWorker; | |||
import com.hp.user.service.utils.HttpResult; | |||
@@ -18,10 +19,8 @@ public class AuditController { | |||
@ApiOperation(value = "是否通过企业审核",notes = "若操作成功会返回新的审核记录Id") | |||
@PostMapping("/passCompanyAudit") | |||
public HttpResult passCompanyAudit(@RequestBody AuditVO audit){ | |||
public Result passCompanyAudit(@RequestBody AuditVO audit){ | |||
audit.setAuditId(IdWorker.generactorId().toString()); | |||
boolean flag = auditService.insert(audit); | |||
if(flag) return HttpResult.success(audit.getAuditId()); | |||
else return HttpResult.fail(); | |||
return auditService.insert(audit); | |||
} | |||
} |
@@ -1,9 +1,11 @@ | |||
package com.hp.user.service.controller; | |||
import com.baomidou.mybatisplus.extension.api.R; | |||
import com.hp.user.client.entity.*; | |||
import com.hp.user.client.service.AuditService; | |||
import com.hp.user.client.service.CustomerCompanyService; | |||
import com.hp.user.client.service.CustomerServiceProviderEnterpriseService; | |||
import com.hp.user.service.entity.CustomerCompany; | |||
import com.hp.user.service.entity.CustomerServiceProviderEnterprise; | |||
import com.hp.user.service.utils.HttpResult; | |||
import com.hp.user.service.utils.IdWorker; | |||
@@ -33,21 +35,27 @@ public class CompanyController { | |||
* 添加企业/服务商 | |||
* | |||
* @param company 企业/服务商信息 | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "新增企业/服务商", notes = "提示:要指定审核状态 status;服务商type=0,企业type=1;若新增企业,则需要填serviceProviderIds", httpMethod = "POST") | |||
@PostMapping("/addCompany") | |||
@Transactional | |||
public HttpResult addCompany(@RequestBody CustomerCompanyVO company, @RequestParam String serviceProviderId) { | |||
public Result addCompany(@RequestBody CustomerCompanyVO company, String serviceProviderId) { | |||
company.setCustomerId(IdWorker.generactorId().toString()); | |||
boolean flag1 = true, flag2 = true; | |||
flag1 = customerCompanyService.insert(company); | |||
Result result = new Result(), result1 = new Result(), result2 = new Result(); | |||
result1 = customerCompanyService.insert(company); | |||
if (serviceProviderId != null) { | |||
CustomerServiceProviderEnterpriseVO temp = new CustomerServiceProviderEnterpriseVO(IdWorker.generactorId().toString(), serviceProviderId, company.getCustomerId()); | |||
flag2 = csService.insert(temp); | |||
result2 = csService.insert(temp); | |||
} | |||
if (result1.getCode().equals("0") && result2.getCode().equals("0")) { | |||
result.setCode("0"); | |||
return result; | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("添加失败"); | |||
return result; | |||
} | |||
if (flag1 && flag2) return HttpResult.success(company.getCustomerId()); | |||
else return HttpResult.fail("添加失败"); | |||
} | |||
// public HttpResult addCompany(@RequestBody CustomerCompanyVO company, @RequestBody List<String> serviceProviderIds) { | |||
// company.setCustomerId(IdWorker.generactorId().toString()); | |||
@@ -70,57 +78,92 @@ public class CompanyController { | |||
* 更新企业/服务商信息 | |||
* | |||
* @param company 企业/服务商信息 | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "更新企业/服务商信息", notes = "若更新企业,则需要填serviceProviderId") | |||
@PostMapping("/updateCompany") | |||
@Transactional | |||
public HttpResult updateCompany(@RequestBody CustomerCompanyVO company, @RequestParam String serviceProviderId) { | |||
public Result updateCompany(@RequestBody CustomerCompanyVO company, String serviceProviderId) { | |||
boolean flag1 = true, flag2 = true; | |||
flag1 = customerCompanyService.update(company); | |||
Result result = new Result(), result1 = new Result(), result2 = new Result(); | |||
result1 = customerCompanyService.update(company); | |||
if (serviceProviderId != null) { | |||
CustomerServiceProviderEnterpriseVO cs = csService.queryCsByCompanyIdAndServiceProviderId(company.getCustomerId(), serviceProviderId); | |||
cs.setServiceProviderId(serviceProviderId); | |||
flag2 = csService.update(cs); | |||
DataResult temp = csService.queryCsByCompanyIdAndServiceProviderId(company.getCustomerId(), serviceProviderId); | |||
if (temp.getCode().equals("0")) { | |||
CustomerServiceProviderEnterpriseVO cs = (CustomerServiceProviderEnterpriseVO) temp.getData(); | |||
cs.setServiceProviderId(serviceProviderId); | |||
result2 = csService.update(cs); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage(temp.getMessage()); | |||
return result; | |||
} | |||
} | |||
if (result1.getCode().equals("0") && result2.getCode().equals("0")) { | |||
result.setCode("0"); | |||
return result; | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("更新失败"); | |||
return result; | |||
} | |||
if (flag1 && flag2) return HttpResult.success(); | |||
else return HttpResult.fail("更新失败"); | |||
} | |||
/** | |||
* 根据企业Id删除企业 | |||
* | |||
* @param companyId 企业Id | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "删除企业/服务商", notes = "若删除企业,则需要填serviceProviderId") | |||
@GetMapping("/deleteCompanyByCompanyId") | |||
public HttpResult deleteCompanyByCompanyId(@RequestParam String companyId, @RequestParam String serviceProviderId) { | |||
boolean flag1 = true, flag2 = true; | |||
flag1 = customerCompanyService.delete(companyId); | |||
public Result deleteCompanyByCompanyId(@RequestParam String companyId, String serviceProviderId) { | |||
Result result = new Result(), result1 = new Result(), result2 = new Result(); | |||
result1 = customerCompanyService.delete(companyId); | |||
if (serviceProviderId != null) { | |||
CustomerServiceProviderEnterpriseVO cs = csService.queryCsByCompanyIdAndServiceProviderId(companyId, serviceProviderId); | |||
flag2 = csService.delete(cs.getId()); | |||
DataResult temp = csService.queryCsByCompanyIdAndServiceProviderId(companyId, serviceProviderId); | |||
if (temp.getCode().equals("0")) { | |||
CustomerServiceProviderEnterpriseVO cs = (CustomerServiceProviderEnterpriseVO) temp.getData(); | |||
cs.setServiceProviderId(serviceProviderId); | |||
result2 = csService.delete(cs.getId()); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage(temp.getMessage()); | |||
return result; | |||
} | |||
} | |||
if (result1.getCode().equals("0") && result2.getCode().equals("0")) { | |||
result.setCode("0"); | |||
return result; | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("删除失败"); | |||
return result; | |||
} | |||
if (flag1 && flag2) return HttpResult.success(); | |||
else return HttpResult.fail("删除失败"); | |||
} | |||
/** | |||
* 根据企业Id查询某企业信息 | |||
* | |||
* @param companyId 企业Id | |||
* @return HttpResult | |||
* @return DataResult | |||
*/ | |||
@ApiOperation(value = "根据企业/服务商Id 查询某企业/服务商信息", notes = "服务商type为0,企业type为1") | |||
@GetMapping("/queryCompanyByCompanyId") | |||
public HttpResult queryCompanyByCompanyId(@RequestParam String companyId, @RequestParam Integer type) { | |||
CustomerCompanyVO companyVO = customerCompanyService.queryCompanyByCompanyId(companyId); | |||
if(type==1){ | |||
companyVO.setServiceProviderId(csService.queryServiceProviderIdByCompanyId(companyId)); | |||
public DataResult<CustomerCompanyVO> queryCompanyByCompanyId(@RequestParam String companyId, @RequestParam Integer type) { | |||
DataResult<CustomerCompanyVO> result = customerCompanyService.queryCompanyByCompanyId(companyId); | |||
if (result.getCode().equals("0") && type == 1) { | |||
CustomerCompanyVO temp = result.getData(); | |||
DataResult<String> t = csService.queryServiceProviderIdByCompanyId(companyId); | |||
if (t.getCode().equals("0")) { | |||
temp.setServiceProviderId(t.getData()); | |||
result.setData(temp); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage(t.getMessage()); | |||
} | |||
} | |||
if (companyVO != null) return HttpResult.success(companyVO); | |||
else return HttpResult.fail("查询失败/已被删除"); | |||
return result; | |||
} | |||
// /** | |||
@@ -144,14 +187,12 @@ public class CompanyController { | |||
* @param name 服务商名称 | |||
* @param current 要查询页数 | |||
* @param size 一页的行数 | |||
* @return HttpResult | |||
* @return PageResult | |||
*/ | |||
@ApiOperation(value = "根据服务商姓名分页查询服务商") | |||
@GetMapping("/queryServiceProvidersPageByName") | |||
public HttpResult queryServiceProvidersPageByName(String name, @RequestParam Long current, @RequestParam Integer size) { | |||
CompanyPage companyPage = customerCompanyService.queryServiceProvidersByName(name, current, size); | |||
if (companyPage != null) return HttpResult.success(companyPage); | |||
else return HttpResult.fail("查询失败"); | |||
public PageResult<CustomerCompanyVO> queryServiceProvidersPageByName(String name, @RequestParam Long current, @RequestParam Integer size) { | |||
return customerCompanyService.queryServiceProvidersByName(name, current, size); | |||
} | |||
/** | |||
@@ -162,14 +203,12 @@ public class CompanyController { | |||
* @param status 审核状态 | |||
* @param current 要查询页数 | |||
* @param size 一页的行数 | |||
* @return HttpResult | |||
* @return PageResult | |||
*/ | |||
@ApiOperation(value = "根据企业姓名、关联服务商、审核状态分页查询企业", notes = "审核状态\"全部\"则status=0") | |||
@GetMapping("/queryCompanysPageByNameAndServiceProviderAndStatus") | |||
public HttpResult queryCompanysPageByNameAndServiceProviderAndStatus(String name, String serviceProviderName, @RequestParam Integer status, @RequestParam Long current, @RequestParam Integer size) { | |||
CompanyPage companyPage = customerCompanyService.queryCompanysPageByNameAndServiceAndStatus(name, serviceProviderName, status, current, size); | |||
if (companyPage != null) return HttpResult.success(companyPage); | |||
else return HttpResult.fail("查询失败"); | |||
public PageResult<CustomerCompanyVO> queryCompanysPageByNameAndServiceProviderAndStatus(String name, String serviceProviderName, @RequestParam Integer status, @RequestParam Long current, @RequestParam Integer size) { | |||
return customerCompanyService.queryCompanysPageByNameAndServiceAndStatus(name, serviceProviderName, status, current, size); | |||
} | |||
/** | |||
@@ -177,12 +216,12 @@ public class CompanyController { | |||
* | |||
* @param company 企业信息 | |||
* @param willing 是否有意向成为合同用户 | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "成为合同用户", notes = "添加成功会返回添加的企业Id") | |||
@PostMapping("/becomeContractUser") | |||
@Transactional | |||
public HttpResult becomeContractUser(@RequestBody CustomerCompanyVO company, @RequestBody boolean willing) { | |||
public Result becomeContractUser(@RequestBody CustomerCompanyVO company, @RequestBody boolean willing) { | |||
company.setCustomerId(IdWorker.generactorId().toString()); | |||
company.setType((short) 1); // 企业 | |||
company.setStatus((short) 1); // 未审核 | |||
@@ -194,10 +233,17 @@ public class CompanyController { | |||
// 愿意成为合同用户 | |||
if (willing) audit.setVipLevel((short) 1); // 普通会员 | |||
else audit.setVipLevel((short) 2); // 意向用户 | |||
boolean flag1 = customerCompanyService.insert(company); | |||
boolean flag2 = auditService.insert(audit); | |||
if (flag1 && flag2) return HttpResult.success(company.getCustomerId()); | |||
else return HttpResult.fail("添加失败"); | |||
Result result=new Result(); | |||
Result result1 = customerCompanyService.insert(company); | |||
Result result2 = auditService.insert(audit); | |||
if (result1.getCode().equals("0") && result2.getCode().equals("0")) { | |||
result.setCode("0"); | |||
return result; | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("操作失败"); | |||
return result; | |||
} | |||
} | |||
/** | |||
@@ -205,14 +251,12 @@ public class CompanyController { | |||
* | |||
* @param current 要查询页数 | |||
* @param size 一页的行数 | |||
* @return HttpResult | |||
* @return PageResult | |||
*/ | |||
@ApiOperation(value = "分页查询所有认证企业", notes = "输入的current为要查询的页数,size为一页的行数,返回的total为总行数") | |||
@GetMapping("/queryAllCompanyCertifyPage") | |||
public HttpResult queryAllCompanyCertifyPage(@RequestParam Long current, @RequestParam Integer size) { | |||
CompanyAuditPage companyAuditPage = customerCompanyService.getCompanyAuditsPage(current, size); | |||
if (companyAuditPage != null) return HttpResult.success(companyAuditPage); | |||
else return HttpResult.fail("查询失败"); | |||
public PageResult<CompanyAuditVO> queryAllCompanyCertifyPage(@RequestParam Long current, @RequestParam Integer size) { | |||
return customerCompanyService.getCompanyAuditsPage(current, size); | |||
} | |||
/** | |||
@@ -224,14 +268,12 @@ public class CompanyController { | |||
* @param endTime 提交时间的结束间隔 | |||
* @param current 要查询的页数 | |||
* @param size 一页的行数 | |||
* @return HttpResult | |||
* @return PageResult | |||
*/ | |||
@ApiOperation(value = "根据企业姓名、审核状态、提交时间分页查询认证企业", notes = "若审核状态为全部,则status填0") | |||
@GetMapping("/queryCompanysPageByNameAndStatusAndCreateTime") | |||
public HttpResult queryCompanysPageByNameAndStatusAndCreateTime(String name, @RequestParam Integer status, Date startTime, Date endTime, @RequestParam Long current, @RequestParam Integer size) { | |||
CompanyAuditPage companyAuditPage = customerCompanyService.queryCompanysPageByNameAndStatusAndCreateTime(name, status, startTime, endTime, current, size); | |||
if (companyAuditPage != null) return HttpResult.success(companyAuditPage); | |||
else return HttpResult.fail("查询失败"); | |||
public PageResult<CompanyAuditVO> queryCompanysPageByNameAndStatusAndCreateTime(String name, @RequestParam Integer status, Date startTime, Date endTime, @RequestParam Long current, @RequestParam Integer size) { | |||
return customerCompanyService.queryCompanysPageByNameAndStatusAndCreateTime(name, status, startTime, endTime, current, size); | |||
} | |||
// public HttpResult queryContectUserByBusinessContectAndPhone | |||
@@ -1,7 +1,6 @@ | |||
package com.hp.user.service.controller; | |||
import com.hp.user.client.entity.StationPage; | |||
import com.hp.user.client.entity.StationVO; | |||
import com.hp.user.client.entity.*; | |||
import com.hp.user.client.service.StationService; | |||
import com.hp.user.service.utils.HttpResult; | |||
import com.hp.user.service.utils.IdWorker; | |||
@@ -22,71 +21,61 @@ public class StationController { | |||
* 添加站点 | |||
* | |||
* @param station 站点信息 | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "新增站点") | |||
@PostMapping("/addStation") | |||
public HttpResult addStation(@RequestBody StationVO station) { | |||
public Result addStation(@RequestBody StationVO station) { | |||
station.setStationId(IdWorker.generactorId().toString()); | |||
boolean flag = stationService.insert(station); | |||
if (flag) return HttpResult.success(station.getStationId()); | |||
else return HttpResult.fail("添加失败"); | |||
return stationService.insert(station); | |||
} | |||
/** | |||
* 更新站点信息 | |||
* | |||
* @param station 站点信息 | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "更新站点信息") | |||
@PostMapping("/updateStation") | |||
public HttpResult updateStation(@RequestBody StationVO station) { | |||
boolean flag = stationService.update(station); | |||
if (flag) return HttpResult.success(); | |||
else return HttpResult.fail("更新失败"); | |||
public Result updateStation(@RequestBody StationVO station) { | |||
return stationService.update(station); | |||
} | |||
/** | |||
* 根据站点Id删除站点 | |||
* | |||
* @param stationId 站点Id | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "删除站点") | |||
@GetMapping("/deleteStationByStationId") | |||
public HttpResult deleteStationByStationId(@RequestParam String stationId) { | |||
boolean flag = stationService.delete(stationId); | |||
if (flag) return HttpResult.success(); | |||
else return HttpResult.fail("删除失败"); | |||
public Result deleteStationByStationId(@RequestParam String stationId) { | |||
return stationService.delete(stationId); | |||
} | |||
/** | |||
* 根据站点Id查询某站点信息 | |||
* | |||
* @param stationId 站点Id | |||
* @return HttpResult | |||
* @return DataResult | |||
*/ | |||
@ApiOperation(value = "根据站点Id查询某站点") | |||
@GetMapping("/queryStationByStationId") | |||
public HttpResult queryStationByStationId(String stationId) { | |||
StationVO stationVO = stationService.queryStationByStationId(stationId); | |||
if (stationVO != null) return HttpResult.success(stationVO); | |||
else return HttpResult.fail("查询失败/该站点已被删除"); | |||
public DataResult<StationVO> queryStationByStationId(String stationId) { | |||
return stationService.queryStationByStationId(stationId); | |||
} | |||
/** | |||
* 根据站点名称查询某站点信息 | |||
* | |||
* @param stationName 站点名称 | |||
* @return HttpResult | |||
* @return DataResult | |||
*/ | |||
@ApiOperation(value = "根据站点名称查询某站点") | |||
@GetMapping("/queryStationByStationName") | |||
public HttpResult queryStationByStationName(String stationName) { | |||
StationVO stationVO = stationService.queryStationByStationName(stationName); | |||
if (stationVO != null) return HttpResult.success(stationVO); | |||
else return HttpResult.fail("查询失败"); | |||
public DataResult<StationVO> queryStationByStationName(String stationName) { | |||
return stationService.queryStationByStationName(stationName); | |||
} | |||
/** | |||
@@ -97,13 +86,11 @@ public class StationController { | |||
* | |||
* @param current 要查询页数 | |||
* @param size 一页的行数 | |||
* @return HttpResult | |||
* @return PageResult | |||
*/ | |||
@ApiOperation(value = "分页查询所有站点", notes = "输入的current为要查询的页数,size为一页的行数,返回的total为总行数") | |||
@GetMapping("/queryAllStationByPage") | |||
public HttpResult queryAllStationByPage(@RequestParam Long current, @RequestParam Integer size) { | |||
StationPage stationPage = stationService.getStationsPage(current, size); | |||
if (stationPage != null) return HttpResult.success(stationPage); | |||
else return HttpResult.fail("查询失败"); | |||
public PageResult<StationVO> queryAllStationByPage(@RequestParam Long current, @RequestParam Integer size) { | |||
return stationService.getStationsPage(current, size); | |||
} | |||
} |
@@ -2,6 +2,8 @@ package com.hp.user.service.controller; | |||
import com.hp.user.client.entity.AccountPage; | |||
import com.hp.user.client.entity.AccountVO; | |||
import com.hp.user.client.entity.PageResult; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.AccountService; | |||
import com.hp.user.service.utils.HttpResult; | |||
import com.hp.user.service.utils.IdWorker; | |||
@@ -21,44 +23,38 @@ public class UserController { | |||
* 添加用户 | |||
* | |||
* @param user 用户信息 | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "新增账户", notes = "提示:要指定账号对应的服务商", httpMethod = "POST") | |||
@PostMapping("/addUser") | |||
public HttpResult addUser(@RequestBody AccountVO user) { | |||
public Result addUser(@RequestBody AccountVO user) { | |||
user.setUserId(IdWorker.generactorId().toString()); | |||
boolean flag = accountService.insert(user); | |||
if (flag) return HttpResult.success(user.getUserId()); | |||
else return HttpResult.fail("添加失败"); | |||
return accountService.insert(user); | |||
} | |||
/** | |||
* 更新用户信息 | |||
* | |||
* @param user 用户信息 | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "更新账户信息") | |||
@PostMapping("/updateUser") | |||
public HttpResult updateUser(@RequestBody AccountVO user) { | |||
boolean flag = accountService.update(user); | |||
if (flag) return HttpResult.success(); | |||
else return HttpResult.fail("更新失败"); | |||
public Result updateUser(@RequestBody AccountVO user) { | |||
return accountService.update(user); | |||
} | |||
/** | |||
* 根据用户Id删除用户 | |||
* | |||
* @param userId 用户Id | |||
* @return HttpResult | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "根据用户Id删除用户") | |||
@GetMapping("/deleteUserByUserId") | |||
public HttpResult deleteUserByUserId(String userId) { | |||
boolean flag = accountService.delete(userId); | |||
if (flag) return HttpResult.success(); | |||
else return HttpResult.fail("删除失败"); | |||
public Result deleteUserByUserId(String userId) { | |||
return accountService.delete(userId); | |||
} | |||
/** | |||
@@ -70,29 +66,25 @@ public class UserController { | |||
* @param status 启用状态 | |||
* @param current 要查询页数 | |||
* @param size 一页的行数 | |||
* @return HttpResult | |||
* @return PageResult | |||
*/ | |||
@ApiOperation(value = "根据服务商Id、用户姓名、手机号码、启用状态 分页查询账号", notes = "启用:status=0,禁用:status=1,全部:status为其他数字") | |||
@GetMapping("/queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus") | |||
public HttpResult queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus(@RequestParam String companyId, String userName, String phone, @RequestParam Integer status, @RequestParam Long current, @RequestParam Integer size) { | |||
AccountPage accountPage = accountService.queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus(companyId, userName, phone, status, current, size); | |||
if (accountPage != null) return HttpResult.success(accountPage); | |||
else return HttpResult.fail("查询失败"); | |||
public PageResult<AccountVO> queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus(@RequestParam String companyId, String userName, String phone, @RequestParam Integer status, @RequestParam Long current, @RequestParam Integer size) { | |||
return accountService.queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus(companyId, userName, phone, status, current, size); | |||
} | |||
/** | |||
* 批量启用/禁用账号 | |||
* @param companyId 服务商Id | |||
* | |||
* @param userIds 用户Id数组 | |||
* @param status 启用状态 | |||
* @return HttpResult | |||
* @param status 启用状态 | |||
* @return Result | |||
*/ | |||
@ApiOperation(value = "批量启用/禁用账号", notes = "启用:status=0,禁用:status=1") | |||
@PostMapping("/batchChangeStatusOfUser") | |||
public HttpResult batchChangeStatusOfUser(@RequestParam String companyId,@RequestBody String[] userIds,@RequestParam Short status) { | |||
boolean flag = accountService.batchChangeStatusOfUser(companyId,userIds,status); | |||
if(flag) return HttpResult.success(); | |||
else return HttpResult.fail(); | |||
public Result batchChangeStatusOfUser(@RequestBody String[] userIds, @RequestParam Short status) { | |||
return accountService.batchChangeStatusOfUser(userIds, status); | |||
} | |||
} |
@@ -70,10 +70,14 @@ public class Account implements Serializable { | |||
* 对应企业/服务商Id | |||
*/ | |||
private String companyId; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remarks; | |||
public Account(){} | |||
public Account(String userId, String userName, String wxNumber, String phone, Date sysCreateTime, String sysCreator, Date sysUpdateTime, String sysUpdater, Short sysDeleted, Short status, String roleId, String companyId) { | |||
public Account(String userId, String userName, String wxNumber, String phone, Date sysCreateTime, String sysCreator, Date sysUpdateTime, String sysUpdater, Short sysDeleted, Short status, String roleId, String companyId, String remarks) { | |||
this.userId = userId; | |||
this.userName = userName; | |||
this.wxNumber = wxNumber; | |||
@@ -86,6 +90,7 @@ public class Account implements Serializable { | |||
this.status = status; | |||
this.roleId = roleId; | |||
this.companyId = companyId; | |||
this.remarks = remarks; | |||
} | |||
public String getUserId() { | |||
@@ -183,4 +188,12 @@ public class Account implements Serializable { | |||
public void setSysDeleted(Short sysDeleted) { | |||
this.sysDeleted = sysDeleted; | |||
} | |||
public String getRemarks() { | |||
return remarks; | |||
} | |||
public void setRemarks(String remarks) { | |||
this.remarks = remarks; | |||
} | |||
} |
@@ -1,29 +1,22 @@ | |||
package com.hp.user.service.impl; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.core.toolkit.IdWorker; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; | |||
import com.hp.user.client.entity.AccountPage; | |||
import com.hp.user.client.entity.AccountVO; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.*; | |||
import com.hp.user.client.service.AccountService; | |||
import com.hp.user.client.service.MessageService; | |||
import com.hp.user.service.constants.UserConstants; | |||
import com.hp.user.service.dao.AccountMapper; | |||
import com.hp.user.service.entity.Account; | |||
import com.hp.user.service.utils.WeixinSignUtil; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.apache.commons.lang3.StringUtils; | |||
//import com.hp.user.service.utils.IdWorker; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -38,73 +31,72 @@ import org.springframework.stereotype.Service; | |||
*/ | |||
@Service | |||
public class AccountServiceImpl implements AccountService { | |||
@Autowired | |||
private MessageService messageService; | |||
@Autowired | |||
private AccountMapper accountMapper; | |||
@Override | |||
public void login(String phone, String verificationCode) { | |||
try { | |||
//需要判断phone是否存在 | |||
checkPhone(phone); | |||
String code = messageService.getVerificationCode(phone); | |||
if(StringUtils.equals(verificationCode, code)) { | |||
//登陆成功 | |||
}else { | |||
//登陆失败 | |||
//返回错误信息 | |||
} | |||
}catch(Exception e) { | |||
} | |||
} | |||
@Autowired | |||
private MessageService messageService; | |||
@Override | |||
public Boolean checkPhone(String phone) { | |||
//不存在为true | |||
Boolean flage = true; | |||
try { | |||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("phone", phone); | |||
queryWrapper.eq("sys_deleted", 0); | |||
Integer count = accountMapper.selectCount(queryWrapper); | |||
if(count>0) { | |||
//表示手机以及存在,需要返回错误 | |||
System.out.println("手机号已经存在"); | |||
flage = false; | |||
} | |||
}catch(Exception e) { | |||
} | |||
return flage; | |||
} | |||
@Autowired | |||
private AccountMapper accountMapper; | |||
@Override | |||
public void register(AccountVO accountVo) { | |||
try { | |||
if(checkPhone(accountVo.getPhone())) { | |||
Account account = new Account(); | |||
BeanUtils.copyProperties(accountVo, account); | |||
Long id = IdWorker.getId(); | |||
account.setUserId(id.toString()); | |||
accountMapper.insert(account); | |||
} | |||
}catch(Exception e) { | |||
} | |||
} | |||
@Override | |||
public void login(String phone, String verificationCode) { | |||
try { | |||
//需要判断phone是否存在 | |||
checkPhone(phone); | |||
String code = messageService.getVerificationCode(phone); | |||
if (StringUtils.equals(verificationCode, code)) { | |||
//登陆成功 | |||
} else { | |||
//登陆失败 | |||
//返回错误信息 | |||
} | |||
} catch (Exception e) { | |||
@Override | |||
public void bindWx(String userIdStr, String wxNumber) { | |||
try { | |||
// Long userId = Long.parseLong(userIdStr); | |||
} | |||
} | |||
@Override | |||
public Boolean checkPhone(String phone) { | |||
//不存在为true | |||
Boolean flage = true; | |||
try { | |||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("phone", phone); | |||
queryWrapper.eq("sys_deleted", 0); | |||
Integer count = accountMapper.selectCount(queryWrapper); | |||
if (count > 0) { | |||
//表示手机以及存在,需要返回错误 | |||
System.out.println("手机号已经存在"); | |||
flage = false; | |||
} | |||
} catch (Exception e) { | |||
} | |||
return flage; | |||
} | |||
@Override | |||
public void register(AccountVO accountVo) { | |||
try { | |||
if (checkPhone(accountVo.getPhone())) { | |||
Account account = new Account(); | |||
BeanUtils.copyProperties(accountVo, account); | |||
Long id = IdWorker.getId(); | |||
account.setUserId(id.toString()); | |||
accountMapper.insert(account); | |||
} | |||
} catch (Exception e) { | |||
} | |||
} | |||
@Override | |||
public void bindWx(String userIdStr, String wxNumber) { | |||
try { | |||
Account account = new Account(); | |||
account.setUserId(userIdStr); | |||
account.setWxNumber(wxNumber); | |||
@@ -182,62 +174,155 @@ public class AccountServiceImpl implements AccountService { | |||
return result; | |||
} | |||
@Override | |||
public Result insert(AccountVO account) { | |||
Account temp = new Account(); | |||
int flag = 0; | |||
Result result = new Result(); | |||
try { | |||
BeanUtils.copyProperties(account, temp); | |||
flag = accountMapper.insert(temp); | |||
} catch (Exception e) { | |||
@Override | |||
public boolean insert(AccountVO account) { | |||
Account temp = new Account(); | |||
BeanUtils.copyProperties(account,temp); | |||
return SqlHelper.retBool(accountMapper.insert(temp)); | |||
} | |||
} | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("添加失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean delete(String userId) { | |||
Account temp = accountMapper.selectById(userId); | |||
temp.setSysDeleted((short)1); | |||
return SqlHelper.retBool(accountMapper.updateById(temp)); | |||
} | |||
@Override | |||
public Result delete(String userId) { | |||
Account temp; | |||
int flag = 0; | |||
Result result = new Result(); | |||
try { | |||
temp = accountMapper.selectById(userId); | |||
if (temp == null) { | |||
result.setCode("-1"); | |||
result.setMessage("未查找到此账号"); | |||
return result; | |||
} | |||
temp.setSysDeleted((short) 1); | |||
flag = accountMapper.updateById(temp); | |||
} catch (Exception e) { | |||
@Override | |||
public boolean update(AccountVO account) { | |||
Account temp = new Account(); | |||
BeanUtils.copyProperties(account,temp); | |||
return SqlHelper.retBool(accountMapper.updateById(temp)); | |||
} | |||
} | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("删除失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public AccountPage queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus(String companyId, String userName, String phone, Integer status, Long current, Integer size) { | |||
AccountPage accountPage = new AccountPage(); | |||
IPage<Account> page = new Page<>(current,size); | |||
QueryWrapper<Account> wrapper = new QueryWrapper<>(); | |||
wrapper.eq("company_id",companyId); | |||
wrapper.orderByDesc("sys_create_time"); | |||
if(userName!=null) wrapper.like("user_name",userName); | |||
if(phone!=null) wrapper.like("phone",phone); | |||
if(status==0|| status==1) wrapper.eq("status",status); | |||
accountMapper.selectPage(page,wrapper); | |||
List<Account> accounts = page.getRecords(); | |||
List<AccountVO> accountVOs = new ArrayList<>(); | |||
AccountVO temp; | |||
for(Account account:accounts){ | |||
temp = new AccountVO(); | |||
BeanUtils.copyProperties(account,temp); | |||
accountVOs.add(temp); | |||
} | |||
accountPage.setAccountList(accountVOs); | |||
accountPage.setTotal(page.getTotal()); | |||
accountPage.setCurrent(current); | |||
accountPage.setSize(size); | |||
return accountPage; | |||
} | |||
@Override | |||
public Result update(AccountVO account) { | |||
Result result = new Result(); | |||
Account temp = new Account(); | |||
int flag = 0; | |||
try { | |||
BeanUtils.copyProperties(account, temp); | |||
flag = accountMapper.updateById(temp); | |||
} catch (Exception e) { | |||
@Override | |||
public boolean batchChangeStatusOfUser(String companyId,String[] userIds,Short status){ | |||
Account account; | |||
for(String userId:userIds){ | |||
account = accountMapper.selectById(userId); | |||
account.setStatus(status); | |||
if(!SqlHelper.retBool(accountMapper.updateById(account))) return false; | |||
} | |||
return true; | |||
} | |||
} | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("更新失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public PageResult<AccountVO> queryAccountsPageByCompanyIdAndUserNameAndPhoneAndStatus(String companyId, String userName, String phone, Integer status, Long current, Integer size) { | |||
PageResult<AccountVO> accountPage = new PageResult<>(); | |||
IPage<Account> page = new Page<>(current, size); | |||
QueryWrapper<Account> wrapper = new QueryWrapper<>(); | |||
try { | |||
if (companyId == null) { | |||
accountPage.setCode("-1"); | |||
accountPage.setMessage("服务商/企业Id 不能为空"); | |||
return accountPage; | |||
} | |||
wrapper.eq("company_id", companyId); | |||
wrapper.orderByDesc("sys_create_time"); | |||
if (userName != null) wrapper.like("user_name", userName); | |||
if (phone != null) wrapper.like("phone", phone); | |||
if (status == 0 || status == 1) wrapper.eq("status", status); | |||
accountMapper.selectPage(page, wrapper); | |||
List<Account> accounts = page.getRecords(); | |||
List<AccountVO> accountVOs = new ArrayList<>(); | |||
AccountVO temp; | |||
for (Account account : accounts) { | |||
temp = new AccountVO(); | |||
BeanUtils.copyProperties(account, temp); | |||
accountVOs.add(temp); | |||
} | |||
accountPage.setCode("0"); | |||
accountPage.setDataList(accountVOs); | |||
accountPage.setTotal(page.getTotal()); | |||
accountPage.setCurrent(current); | |||
accountPage.setSize(size); | |||
} catch (Exception e) { | |||
} | |||
return accountPage; | |||
} | |||
@Override | |||
public Result batchChangeStatusOfUser(String[] userIds, Short status) { | |||
Account account; | |||
Result result = new Result(); | |||
int flag = 0; | |||
try { | |||
for (String userId : userIds) { | |||
account = accountMapper.selectById(userId); | |||
if (account == null) { | |||
result.setCode("-1"); | |||
result.setMessage("账号Id为 " + account.getUserId() + " 的账号不存在"); | |||
return result; | |||
} | |||
account.setStatus(status); | |||
flag = accountMapper.updateById(account); | |||
} | |||
} catch (Exception e) { | |||
} | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("更新失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public DataResult<AccountVO> queryAccountByPhone(String phone) { | |||
DataResult<AccountVO> result = new DataResult<>(); | |||
QueryWrapper<Account> wrapper = new QueryWrapper<>(); | |||
try { | |||
wrapper.eq("phone", phone); | |||
Account account = accountMapper.selectOne(wrapper); | |||
if (account == null) { | |||
result.setCode("-1"); | |||
result.setMessage("未找到此手机号对应的用户"); | |||
} else { | |||
AccountVO temp = new AccountVO(); | |||
BeanUtils.copyProperties(account, temp); | |||
result.setCode("0"); | |||
result.setData(temp); | |||
} | |||
} catch (Exception e) { | |||
} | |||
return result; | |||
} | |||
} |
@@ -2,6 +2,9 @@ package com.hp.user.service.impl; | |||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; | |||
import com.hp.user.client.entity.AddressVO; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.ListResult; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.AddressService; | |||
import com.hp.user.service.dao.AddressMapper; | |||
import com.hp.user.service.entity.Address; | |||
@@ -25,50 +28,111 @@ public class AddressServiceImpl implements AddressService { | |||
@Autowired | |||
private AddressMapper addressMapper; | |||
@Override | |||
public boolean insert(AddressVO address) { | |||
public Result insert(AddressVO address) { | |||
Address temp = new Address(); | |||
BeanUtils.copyProperties(address,temp); | |||
Result result = new Result(); | |||
int flag=0; | |||
try{ | |||
BeanUtils.copyProperties(address,temp); | |||
flag = addressMapper.insert(temp); | |||
}catch (Exception e){ | |||
} | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(addressMapper.insert(temp)); | |||
if(SqlHelper.retBool(flag)){ | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("添加失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean update(AddressVO address) { | |||
public Result update(AddressVO address) { | |||
Address temp = new Address(); | |||
BeanUtils.copyProperties(address,temp); | |||
Result result = new Result(); | |||
int flag=0; | |||
try{ | |||
BeanUtils.copyProperties(address,temp); | |||
flag = addressMapper.updateById(temp); | |||
}catch(Exception e){ | |||
} | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(addressMapper.updateById(temp)); | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("更新失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean delete(String addressId) { | |||
Address temp = addressMapper.selectById(addressId); | |||
temp.setSysDeleted((short)1); | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(addressMapper.updateById(temp)); | |||
public Result delete(String addressId) { | |||
Address temp; | |||
int flag=0; | |||
Result result = new Result(); | |||
try{ | |||
temp = addressMapper.selectById(addressId); | |||
if (temp == null) { | |||
result.setCode("-1"); | |||
result.setMessage("未查找到此地址"); | |||
return result; | |||
} | |||
temp.setSysDeleted((short)1); | |||
flag = addressMapper.updateById(temp); | |||
}catch (Exception e){ | |||
} | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("删除失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public AddressVO queryAddressByAddressId(String addressId) { | |||
public DataResult<AddressVO> queryAddressByAddressId(String addressId) { | |||
AddressVO addressVO = new AddressVO(); | |||
Address temp = addressMapper.selectById(addressId); | |||
if (temp==null || temp.getSysDeleted()==1) return null; | |||
else { | |||
BeanUtils.copyProperties(temp,addressVO); | |||
return addressVO; | |||
DataResult<AddressVO> result = new DataResult<>(); | |||
try{ | |||
Address temp = addressMapper.selectById(addressId); | |||
if (temp==null || temp.getSysDeleted()==1) { | |||
result.setCode("-1"); | |||
result.setMessage("地址不存在/已删除"); | |||
return result; | |||
}else{ | |||
BeanUtils.copyProperties(temp,addressVO); | |||
result.setCode("0"); | |||
result.setData(addressVO); | |||
} | |||
}catch (Exception e){ | |||
} | |||
return result; | |||
} | |||
@Override | |||
public List<AddressVO> queryAllAddress() { | |||
public ListResult<AddressVO> queryAllAddress() { | |||
List<AddressVO> addressVOs=new ArrayList<>(); | |||
List<Address> addresses = addressMapper.selectList(null); | |||
AddressVO temp; | |||
for (Address address : addresses){ | |||
temp = new AddressVO(); | |||
BeanUtils.copyProperties(address, temp); | |||
addressVOs.add(temp); | |||
ListResult<AddressVO> result = new ListResult<>(); | |||
try{ | |||
List<Address> addresses = addressMapper.selectList(null); | |||
AddressVO temp; | |||
for (Address address : addresses){ | |||
temp = new AddressVO(); | |||
BeanUtils.copyProperties(address, temp); | |||
addressVOs.add(temp); | |||
} | |||
result.setCode("0"); | |||
result.setDataList(addressVOs); | |||
}catch (Exception e){ | |||
} | |||
return addressVOs; | |||
return result; | |||
} | |||
} |
@@ -1,6 +1,7 @@ | |||
package com.hp.user.service.impl; | |||
import com.hp.user.client.entity.AreaVO; | |||
import com.hp.user.client.entity.ListResult; | |||
import com.hp.user.client.service.UserAreaService; | |||
import com.hp.user.service.entity.Area; | |||
import com.hp.user.service.dao.AreaMapper; | |||
@@ -23,16 +24,24 @@ import java.util.List; | |||
public class AreaServiceImpl implements UserAreaService { | |||
@Autowired | |||
private AreaMapper areaMapper; | |||
@Override | |||
public List<AreaVO> getAllArea() { | |||
public ListResult<AreaVO> getAllArea() { | |||
List<AreaVO> areaVOs=new ArrayList<>(); | |||
List<Area> areas = areaMapper.selectList(null); | |||
AreaVO temp; | |||
for (Area area : areas){ | |||
temp = new AreaVO(); | |||
BeanUtils.copyProperties(area, temp); | |||
areaVOs.add(temp); | |||
ListResult<AreaVO> result = new ListResult<>(); | |||
try{ | |||
List<Area> areas = areaMapper.selectList(null); | |||
AreaVO temp; | |||
for (Area area : areas){ | |||
temp = new AreaVO(); | |||
BeanUtils.copyProperties(area, temp); | |||
areaVOs.add(temp); | |||
} | |||
result.setCode("0"); | |||
result.setDataList(areaVOs); | |||
}catch (Exception e){ | |||
} | |||
return areaVOs; | |||
return result; | |||
} | |||
} |
@@ -2,6 +2,8 @@ package com.hp.user.service.impl; | |||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; | |||
import com.hp.user.client.entity.AuditVO; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.AuditService; | |||
import com.hp.user.service.dao.AuditMapper; | |||
import com.hp.user.service.entity.Audit; | |||
@@ -22,21 +24,44 @@ public class AuditServiceImpl implements AuditService { | |||
@Autowired | |||
private AuditMapper auditMapper; | |||
@Override | |||
public boolean insert(AuditVO audit) { | |||
public Result insert(AuditVO audit) { | |||
Audit temp = new Audit(); | |||
BeanUtils.copyProperties(audit,temp); | |||
Result result = new Result(); | |||
int flag=0; | |||
try{ | |||
BeanUtils.copyProperties(audit,temp); | |||
flag = auditMapper.insert(temp); | |||
}catch (Exception e){ | |||
} | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(auditMapper.insert(temp)); | |||
if(SqlHelper.retBool(flag)){ | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("添加失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public AuditVO queryAuditByAuditId(String auditId) { | |||
public DataResult<AuditVO> queryAuditByAuditId(String auditId) { | |||
AuditVO auditVO = new AuditVO(); | |||
Audit temp = auditMapper.selectById(auditId); | |||
if(temp == null) return null; | |||
else { | |||
BeanUtils.copyProperties(temp, auditVO); | |||
return auditVO; | |||
DataResult<AuditVO> result= new DataResult<>(); | |||
try{ | |||
Audit temp = auditMapper.selectById(auditId); | |||
if(temp == null) { | |||
result.setCode("-1"); | |||
result.setMessage("审核记录不存在"); | |||
return result; | |||
}else{ | |||
BeanUtils.copyProperties(temp, auditVO); | |||
result.setCode("0"); | |||
result.setData(auditVO); | |||
} | |||
}catch (Exception e){ | |||
} | |||
return result; | |||
} | |||
} |
@@ -39,182 +39,252 @@ public class CustomerCompanyServiceImpl implements CustomerCompanyService { | |||
private CustomerServiceProviderEnterpriseService csService; | |||
@Override | |||
public boolean insert(CustomerCompanyVO company) { | |||
public Result insert(CustomerCompanyVO company) { | |||
CustomerCompany temp = new CustomerCompany(); | |||
BeanUtils.copyProperties(company, temp); | |||
Result result = new Result(); | |||
int flag=0; | |||
try{ | |||
BeanUtils.copyProperties(company, temp); | |||
flag = customerCompanyMapper.insert(temp); | |||
}catch (Exception e){ | |||
} | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(customerCompanyMapper.insert(temp)); | |||
if(SqlHelper.retBool(flag)){ | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("添加失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean delete(String companyId) { | |||
CustomerCompany temp = new CustomerCompany(); | |||
public Result delete(String companyId) { | |||
CustomerCompany temp; | |||
Result result = new Result(); | |||
int flag=0; | |||
try { | |||
// 将deleted字段设置为1 | |||
temp = customerCompanyMapper.selectById(companyId); | |||
if(temp==null){ | |||
result.setCode("-1"); | |||
result.setMessage("未查找到此企业/服务商"); | |||
return result; | |||
} | |||
temp.setSysDeleted((short) 1); | |||
flag =customerCompanyMapper.updateById(temp); | |||
} catch (Exception e) { | |||
} | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(customerCompanyMapper.updateById(temp)); | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("删除失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean update(CustomerCompanyVO company) { | |||
public Result update(CustomerCompanyVO company) { | |||
CustomerCompany temp = new CustomerCompany(); | |||
BeanUtils.copyProperties(company, temp); | |||
Result result = new Result(); | |||
int flag=0; | |||
try{ | |||
BeanUtils.copyProperties(company, temp); | |||
flag = customerCompanyMapper.updateById(temp); | |||
}catch(Exception e){ | |||
} | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(customerCompanyMapper.updateById(temp)); | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("更新失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public CustomerCompanyVO queryCompanyByCompanyId(String companyId) { | |||
public DataResult<CustomerCompanyVO> queryCompanyByCompanyId(String companyId) { | |||
CustomerCompanyVO customerCompanyVO = new CustomerCompanyVO(); | |||
CustomerCompany temp = customerCompanyMapper.selectById(companyId); | |||
// 这个已经被删除 | |||
if (temp == null || temp.getSysDeleted() == 1) return null; | |||
else { | |||
BeanUtils.copyProperties(temp, customerCompanyVO); | |||
return customerCompanyVO; | |||
DataResult<CustomerCompanyVO> result = new DataResult<>(); | |||
try{ | |||
CustomerCompany temp = customerCompanyMapper.selectById(companyId); | |||
// 这个已经被删除 | |||
if (temp == null || temp.getSysDeleted() == 1){ | |||
result.setCode("-1"); | |||
result.setMessage("企业不存在/已删除"); | |||
return result; | |||
} | |||
else { | |||
BeanUtils.copyProperties(temp, customerCompanyVO); | |||
result.setCode("0"); | |||
result.setData(customerCompanyVO); | |||
} | |||
}catch(Exception e){ | |||
} | |||
return result; | |||
} | |||
@Override | |||
public CompanyPage getCompanysPage(Long current, Integer size, Integer type) { | |||
CompanyPage companyPage = new CompanyPage(); | |||
public PageResult<CustomerCompanyVO> getCompanysPage(Long current, Integer size, Integer type) { | |||
PageResult<CustomerCompanyVO> result = new PageResult<>(); | |||
List<CustomerCompanyVO> companyVOs = new ArrayList<>(); | |||
IPage<CustomerCompany> page = new Page<>(current, size); | |||
QueryWrapper<CustomerCompany> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.orderByDesc("sys_create_time"); | |||
queryWrapper.eq("sys_deleted", 0); | |||
queryWrapper.eq("type", type); | |||
customerCompanyMapper.selectPage(page, queryWrapper); | |||
List<CustomerCompany> companys = page.getRecords(); | |||
CustomerCompanyVO temp; | |||
for (CustomerCompany company : companys) { | |||
temp = new CustomerCompanyVO(); | |||
BeanUtils.copyProperties(company, temp); | |||
companyVOs.add(temp); | |||
try{ | |||
queryWrapper.orderByDesc("sys_create_time"); | |||
queryWrapper.eq("sys_deleted", 0); | |||
queryWrapper.eq("type", type); | |||
customerCompanyMapper.selectPage(page, queryWrapper); | |||
List<CustomerCompany> companys = page.getRecords(); | |||
CustomerCompanyVO temp; | |||
for (CustomerCompany company : companys) { | |||
temp = new CustomerCompanyVO(); | |||
BeanUtils.copyProperties(company, temp); | |||
companyVOs.add(temp); | |||
} | |||
result.setCode("0"); | |||
result.setDataList(companyVOs); | |||
result.setTotal(page.getTotal()); | |||
result.setCurrent(current); | |||
result.setSize(size); | |||
}catch (Exception e){ | |||
} | |||
companyPage.setCompanyList(companyVOs); | |||
companyPage.setTotal(page.getTotal()); | |||
companyPage.setCurrent(current); | |||
companyPage.setSize(size); | |||
return companyPage; | |||
return result; | |||
} | |||
@Override | |||
public CompanyPage queryServiceProvidersByName(String name, Long current, Integer size) { | |||
CompanyPage companyPage = new CompanyPage(); | |||
public PageResult<CustomerCompanyVO> queryServiceProvidersByName(String name, Long current, Integer size) { | |||
PageResult<CustomerCompanyVO> result = new PageResult<>(); | |||
List<CustomerCompanyVO> companyVOs = new ArrayList<>(); | |||
IPage<CustomerCompany> page = new Page<>(current, size); | |||
QueryWrapper<CustomerCompany> wrapper = new QueryWrapper<>(); | |||
wrapper.orderByDesc("sys_create_time"); | |||
wrapper.eq("sys_deleted", 0); | |||
wrapper.eq("type", 0); | |||
if (name != null) { | |||
wrapper.like("name", name); | |||
} | |||
customerCompanyMapper.selectPage(page, wrapper); | |||
List<CustomerCompany> companys = page.getRecords(); | |||
CustomerCompanyVO temp; | |||
for (CustomerCompany company : companys) { | |||
temp = new CustomerCompanyVO(); | |||
BeanUtils.copyProperties(company, temp); | |||
companyVOs.add(temp); | |||
try{ | |||
wrapper.orderByDesc("sys_create_time"); | |||
wrapper.eq("sys_deleted", 0); | |||
wrapper.eq("type", 0); | |||
if (name != null) { | |||
wrapper.like("name", name); | |||
} | |||
customerCompanyMapper.selectPage(page, wrapper); | |||
List<CustomerCompany> companys = page.getRecords(); | |||
CustomerCompanyVO temp; | |||
for (CustomerCompany company : companys) { | |||
temp = new CustomerCompanyVO(); | |||
BeanUtils.copyProperties(company, temp); | |||
companyVOs.add(temp); | |||
} | |||
result.setDataList(companyVOs); | |||
result.setTotal(page.getTotal()); | |||
result.setCurrent(current); | |||
result.setSize(size); | |||
}catch (Exception e){ | |||
} | |||
companyPage.setCompanyList(companyVOs); | |||
companyPage.setTotal(page.getTotal()); | |||
companyPage.setCurrent(current); | |||
companyPage.setSize(size); | |||
return companyPage; | |||
return result; | |||
} | |||
@Override | |||
public CompanyPage queryCompanysPageByNameAndServiceAndStatus(String name, String serviceProviderName, Integer status, Long current, Integer size) { | |||
CompanyPage companyPage = new CompanyPage(); | |||
public PageResult<CustomerCompanyVO> queryCompanysPageByNameAndServiceAndStatus(String name, String serviceProviderName, Integer status, Long current, Integer size) { | |||
PageResult<CustomerCompanyVO> result = new PageResult<>(); | |||
List<CustomerCompanyVO> companyVOs = new ArrayList<>(); | |||
IPage<CustomerCompany> page = new Page<>(current, size); | |||
QueryWrapper<CustomerCompany> wrapper = new QueryWrapper<>(); | |||
// 关联服务商 | |||
if (!StringUtils.isEmpty(serviceProviderName)) { | |||
QueryWrapper<CustomerCompany> queryWrapper = new QueryWrapper<>(); | |||
// 先查出服务商信息,再根据服务商Id与企业Id的对应情况查企业 | |||
queryWrapper.like("name", serviceProviderName); | |||
String serviceProviderId = customerCompanyMapper.selectOne(queryWrapper).getCustomerId(); | |||
//根据服务商Id与企业Id的对应情况查企业Id | |||
QueryWrapper<CustomerServiceProviderEnterprise> tempWrapper = new QueryWrapper<>(); | |||
tempWrapper.eq("service_provider_id", serviceProviderId); | |||
List<CustomerServiceProviderEnterprise> temp = customerServiceProviderEnterpriseMapper.selectList(tempWrapper); | |||
List<String> companyIds = new ArrayList<>(); | |||
for (CustomerServiceProviderEnterprise tt : temp) { | |||
companyIds.add(tt.getEnterpriseId()); | |||
try{ | |||
// 关联服务商 | |||
if (!StringUtils.isEmpty(serviceProviderName)) { | |||
QueryWrapper<CustomerCompany> queryWrapper = new QueryWrapper<>(); | |||
// 先查出服务商信息,再根据服务商Id与企业Id的对应情况查企业 | |||
queryWrapper.like("name", serviceProviderName); | |||
String serviceProviderId = customerCompanyMapper.selectOne(queryWrapper).getCustomerId(); | |||
//根据服务商Id与企业Id的对应情况查企业Id | |||
QueryWrapper<CustomerServiceProviderEnterprise> tempWrapper = new QueryWrapper<>(); | |||
tempWrapper.eq("service_provider_id", serviceProviderId); | |||
List<CustomerServiceProviderEnterprise> temp = customerServiceProviderEnterpriseMapper.selectList(tempWrapper); | |||
List<String> companyIds = new ArrayList<>(); | |||
for (CustomerServiceProviderEnterprise tt : temp) { | |||
companyIds.add(tt.getEnterpriseId()); | |||
} | |||
wrapper.in("customer_id", companyIds); | |||
} | |||
wrapper.in("customer_id", companyIds); | |||
} | |||
if (status != 0) { | |||
wrapper.eq("status", status); | |||
} | |||
if (!StringUtils.isEmpty(name)) { | |||
wrapper.like("name", name); | |||
} | |||
wrapper.orderByDesc("sys_create_time"); | |||
wrapper.eq("sys_deleted", 0); | |||
wrapper.eq("type", 1); | |||
customerCompanyMapper.selectPage(page, wrapper); | |||
List<CustomerCompany> companys = page.getRecords(); | |||
CustomerCompanyVO t; | |||
for (CustomerCompany company : companys) { | |||
t = new CustomerCompanyVO(); | |||
BeanUtils.copyProperties(company, t); | |||
t.setServiceProviderId(csService.queryServiceProviderIdByCompanyId(company.getCustomerId())); | |||
companyVOs.add(t); | |||
if (status != 0) { | |||
wrapper.eq("status", status); | |||
} | |||
if (!StringUtils.isEmpty(name)) { | |||
wrapper.like("name", name); | |||
} | |||
wrapper.orderByDesc("sys_create_time"); | |||
wrapper.eq("sys_deleted", 0); | |||
wrapper.eq("type", 1); | |||
customerCompanyMapper.selectPage(page, wrapper); | |||
List<CustomerCompany> companys = page.getRecords(); | |||
CustomerCompanyVO t; | |||
for (CustomerCompany company : companys) { | |||
t = new CustomerCompanyVO(); | |||
BeanUtils.copyProperties(company, t); | |||
t.setServiceProviderId(csService.queryServiceProviderIdByCompanyId(company.getCustomerId()).getData()); | |||
companyVOs.add(t); | |||
} | |||
result.setDataList(companyVOs); | |||
result.setTotal(page.getTotal()); | |||
result.setCurrent(current); | |||
result.setSize(size); | |||
}catch (Exception e){ | |||
} | |||
companyPage.setCompanyList(companyVOs); | |||
companyPage.setTotal(page.getTotal()); | |||
companyPage.setCurrent(current); | |||
companyPage.setSize(size); | |||
return companyPage; | |||
return result; | |||
} | |||
@Override | |||
public CompanyAuditPage getCompanyAuditsPage(Long current, Integer size) { | |||
CompanyAuditPage companyAuditPage = new CompanyAuditPage(); | |||
public PageResult<CompanyAuditVO> getCompanyAuditsPage(Long current, Integer size) { | |||
PageResult<CompanyAuditVO> result= new PageResult<>(); | |||
Page<CompanyAudit> page = new Page<>(current, size); | |||
List<CompanyAudit> companyAudits = customerCompanyMapper.selectCompanyAuditPage(page); | |||
List<CompanyAuditVO> companyAuditVOList = new ArrayList<>(); | |||
CompanyAuditVO temp; | |||
for (CompanyAudit companyAudit : companyAudits) { | |||
temp = new CompanyAuditVO(); | |||
BeanUtils.copyProperties(companyAudit, temp); | |||
companyAuditVOList.add(temp); | |||
try{ | |||
List<CompanyAudit> companyAudits = customerCompanyMapper.selectCompanyAuditPage(page); | |||
List<CompanyAuditVO> companyAuditVOList = new ArrayList<>(); | |||
CompanyAuditVO temp; | |||
for (CompanyAudit companyAudit : companyAudits) { | |||
temp = new CompanyAuditVO(); | |||
BeanUtils.copyProperties(companyAudit, temp); | |||
companyAuditVOList.add(temp); | |||
} | |||
result.setDataList(companyAuditVOList); | |||
result.setTotal(page.getTotal()); | |||
result.setCurrent(current); | |||
result.setSize(size); | |||
}catch (Exception e){ | |||
} | |||
companyAuditPage.setCompanyAuditList(companyAuditVOList); | |||
companyAuditPage.setTotal(page.getTotal()); | |||
companyAuditPage.setCurrent(current); | |||
companyAuditPage.setSize(size); | |||
return companyAuditPage; | |||
return result; | |||
} | |||
@Override | |||
public CompanyAuditPage queryCompanysPageByNameAndStatusAndCreateTime(String name, Integer status, Date startTime, Date endTime, Long current, Integer size) { | |||
CompanyAuditPage companyAuditPage = new CompanyAuditPage(); | |||
public PageResult<CompanyAuditVO> queryCompanysPageByNameAndStatusAndCreateTime(String name, Integer status, Date startTime, Date endTime, Long current, Integer size) { | |||
PageResult<CompanyAuditVO> result= new PageResult<>(); | |||
Page<CompanyAudit> page = new Page<>(current, size); | |||
List<CompanyAudit> companyAudits = customerCompanyMapper.queryCompanyAuditPageByNameAndStatusAndCreateTime(page, name, status, startTime, endTime); | |||
List<CompanyAuditVO> companyAuditVOList = new ArrayList<>(); | |||
CompanyAuditVO temp; | |||
for (CompanyAudit companyAudit : companyAudits) { | |||
temp = new CompanyAuditVO(); | |||
BeanUtils.copyProperties(companyAudit, temp); | |||
companyAuditVOList.add(temp); | |||
try{ | |||
List<CompanyAudit> companyAudits = customerCompanyMapper.queryCompanyAuditPageByNameAndStatusAndCreateTime(page, name, status, startTime, endTime); | |||
List<CompanyAuditVO> companyAuditVOList = new ArrayList<>(); | |||
CompanyAuditVO temp; | |||
for (CompanyAudit companyAudit : companyAudits) { | |||
temp = new CompanyAuditVO(); | |||
BeanUtils.copyProperties(companyAudit, temp); | |||
companyAuditVOList.add(temp); | |||
} | |||
result.setDataList(companyAuditVOList); | |||
result.setTotal(page.getTotal()); | |||
result.setCurrent(current); | |||
result.setSize(size); | |||
}catch(Exception e){ | |||
} | |||
companyAuditPage.setCompanyAuditList(companyAuditVOList); | |||
companyAuditPage.setTotal(page.getTotal()); | |||
companyAuditPage.setCurrent(current); | |||
companyAuditPage.setSize(size); | |||
return companyAuditPage; | |||
return result; | |||
} | |||
} |
@@ -1,8 +1,11 @@ | |||
package com.hp.user.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.extension.api.R; | |||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; | |||
import com.hp.user.client.entity.CustomerServiceProviderEnterpriseVO; | |||
import com.hp.user.client.entity.DataResult; | |||
import com.hp.user.client.entity.Result; | |||
import com.hp.user.client.service.CustomerServiceProviderEnterpriseService; | |||
import com.hp.user.service.dao.CustomerServiceProviderEnterpriseMapper; | |||
import com.hp.user.service.entity.CustomerServiceProviderEnterprise; | |||
@@ -26,64 +29,163 @@ import java.util.List; | |||
public class CustomerServiceProviderEnterpriseServiceImpl implements CustomerServiceProviderEnterpriseService { | |||
@Autowired | |||
private CustomerServiceProviderEnterpriseMapper csMapper; | |||
@Override | |||
public boolean insert(CustomerServiceProviderEnterpriseVO cs) { | |||
public Result insert(CustomerServiceProviderEnterpriseVO cs) { | |||
CustomerServiceProviderEnterprise temp = new CustomerServiceProviderEnterprise(); | |||
BeanUtils.copyProperties(cs,temp); | |||
return SqlHelper.retBool(csMapper.insert(temp)); | |||
Result result = new Result(); | |||
int flag = 0; | |||
try { | |||
BeanUtils.copyProperties(cs, temp); | |||
flag = csMapper.insert(temp); | |||
} catch (Exception e) { | |||
} | |||
// 判断数据库操作是否成功 | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("添加失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean update(CustomerServiceProviderEnterpriseVO cs) { | |||
public Result update(CustomerServiceProviderEnterpriseVO cs) { | |||
CustomerServiceProviderEnterprise temp = new CustomerServiceProviderEnterprise(); | |||
BeanUtils.copyProperties(cs,temp); | |||
return SqlHelper.retBool(csMapper.updateById(temp)); | |||
Result result = new Result(); | |||
int flag = 0; | |||
try { | |||
BeanUtils.copyProperties(cs, temp); | |||
flag = csMapper.updateById(temp); | |||
} catch (Exception e) { | |||
} | |||
// 判断数据库操作是否成功 | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("更新失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean delete(String csId) { | |||
return SqlHelper.retBool(csMapper.deleteById(csId)); | |||
public Result delete(String csId) { | |||
Result result = new Result(); | |||
int flag = 0; | |||
try { | |||
flag = csMapper.deleteById(csId); | |||
} catch (Exception e) { | |||
} | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("删除失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public CustomerServiceProviderEnterpriseVO queryCsByCompanyIdAndServiceProviderId(String companyId, String serviceProviderId) { | |||
public DataResult<CustomerServiceProviderEnterpriseVO> queryCsByCompanyIdAndServiceProviderId(String companyId, String serviceProviderId) { | |||
DataResult<CustomerServiceProviderEnterpriseVO> result = new DataResult<>(); | |||
QueryWrapper<CustomerServiceProviderEnterprise> wrapper = new QueryWrapper<>(); | |||
wrapper.eq("service_provider_id",serviceProviderId); | |||
wrapper.eq("enterprise_id",companyId); | |||
CustomerServiceProviderEnterprise cs = csMapper.selectOne(wrapper); | |||
CustomerServiceProviderEnterpriseVO temp = new CustomerServiceProviderEnterpriseVO(); | |||
if(cs == null) return null; | |||
else { | |||
BeanUtils.copyProperties(cs,temp); | |||
return temp; | |||
try { | |||
if (companyId == null || serviceProviderId == null) { | |||
result.setCode("-1"); | |||
result.setMessage("未填写企业Id/服务商Id"); | |||
return result; | |||
} | |||
wrapper.eq("service_provider_id", serviceProviderId); | |||
wrapper.eq("enterprise_id", companyId); | |||
CustomerServiceProviderEnterprise cs = csMapper.selectOne(wrapper); | |||
CustomerServiceProviderEnterpriseVO temp = new CustomerServiceProviderEnterpriseVO(); | |||
if (cs == null) { | |||
result.setCode("-1"); | |||
result.setMessage("该企业不属于此服务商"); | |||
return result; | |||
} else { | |||
BeanUtils.copyProperties(cs, temp); | |||
result.setCode("0"); | |||
result.setData(temp); | |||
} | |||
} catch (Exception e) { | |||
} | |||
return result; | |||
} | |||
@Override | |||
public String queryServiceProviderIdByCompanyId(String companyId) { | |||
public DataResult<String> queryServiceProviderIdByCompanyId(String companyId) { | |||
DataResult<String> result = new DataResult<>(); | |||
QueryWrapper<CustomerServiceProviderEnterprise> wrapper = new QueryWrapper<>(); | |||
wrapper.eq("enterprise_id",companyId); | |||
CustomerServiceProviderEnterprise cs = csMapper.selectOne(wrapper); | |||
if(cs == null) return null; | |||
else { | |||
return cs.getServiceProviderId(); | |||
try { | |||
if (companyId == null){ | |||
result.setCode("-1"); | |||
result.setMessage("企业Id不能为空"); | |||
return result; | |||
} | |||
wrapper.eq("enterprise_id", companyId); | |||
CustomerServiceProviderEnterprise cs = csMapper.selectOne(wrapper); | |||
if (cs == null) { | |||
result.setCode("-1"); | |||
result.setMessage("未查找到企业对应的服务商Id"); | |||
return result; | |||
} | |||
else { | |||
result.setCode("0"); | |||
result.setData(cs.getServiceProviderId()); | |||
} | |||
} catch (Exception e) { | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean insertBatch(List<CustomerServiceProviderEnterpriseVO> csVOList) { | |||
public Result insertBatch(List<CustomerServiceProviderEnterpriseVO> csVOList) { | |||
Result result = new Result(); | |||
int flag = 0; | |||
List<CustomerServiceProviderEnterprise> csList = new ArrayList<>(); | |||
CustomerServiceProviderEnterprise temp; | |||
for(CustomerServiceProviderEnterpriseVO cs:csVOList){ | |||
temp=new CustomerServiceProviderEnterprise(); | |||
BeanUtils.copyProperties(cs,temp); | |||
csList.add(temp); | |||
try{ | |||
for (CustomerServiceProviderEnterpriseVO cs : csVOList) { | |||
temp = new CustomerServiceProviderEnterprise(); | |||
BeanUtils.copyProperties(cs, temp); | |||
csList.add(temp); | |||
} | |||
flag = csMapper.insertBatch(csList); | |||
}catch (Exception e){ | |||
} | |||
return SqlHelper.retBool(csMapper.insertBatch(csList)); | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("添加失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean deleteBatch(List<String> enterpriseIdList) { | |||
return SqlHelper.retBool(csMapper.deleteBatch(enterpriseIdList)); | |||
public Result deleteBatch(List<String> enterpriseIdList) { | |||
Result result = new Result(); | |||
int flag=0; | |||
try{ | |||
flag = csMapper.deleteBatch(enterpriseIdList); | |||
}catch(Exception e){ | |||
} | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("删除失败"); | |||
} | |||
return result; | |||
} | |||
} |
@@ -2,10 +2,10 @@ package com.hp.user.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.api.R; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; | |||
import com.hp.user.client.entity.StationPage; | |||
import com.hp.user.client.entity.StationVO; | |||
import com.hp.user.client.entity.*; | |||
import com.hp.user.client.service.StationService; | |||
import com.hp.user.service.dao.StationMapper; | |||
import com.hp.user.service.entity.Station; | |||
@@ -28,76 +28,148 @@ import java.util.List; | |||
public class StationServiceImpl implements StationService { | |||
@Autowired | |||
private StationMapper stationMapper; | |||
@Override | |||
public boolean insert(StationVO station) { | |||
Station temp=new Station(); | |||
BeanUtils.copyProperties(station,temp); | |||
public Result insert(StationVO station) { | |||
Station temp = new Station(); | |||
Result result = new Result(); | |||
int flag=0; | |||
try{ | |||
BeanUtils.copyProperties(station, temp); | |||
flag = stationMapper.insert(temp); | |||
}catch (Exception e){ | |||
} | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(stationMapper.insert(temp)); | |||
if(SqlHelper.retBool(flag)){ | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("添加失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean delete(String stationId) { | |||
public Result delete(String stationId) { | |||
// 将deleted字段设置为1 | |||
Station temp = stationMapper.selectById(stationId); | |||
temp.setSysDeleted((short) 1); | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(stationMapper.updateById(temp)); | |||
Station temp; | |||
int flag=0; | |||
Result result = new Result(); | |||
try{ | |||
temp = stationMapper.selectById(stationId); | |||
if(temp==null){ | |||
result.setCode("-1"); | |||
result.setMessage("未查找到此站点"); | |||
return result; | |||
} | |||
temp.setSysDeleted((short) 1); | |||
flag = stationMapper.updateById(temp); | |||
}catch (Exception e){ | |||
} | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("删除失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public boolean update(StationVO station) { | |||
Station temp=new Station(); | |||
BeanUtils.copyProperties(station,temp); | |||
public Result update(StationVO station) { | |||
Station temp = new Station(); | |||
Result result = new Result(); | |||
int flag=0; | |||
try{ | |||
BeanUtils.copyProperties(station, temp); | |||
flag = stationMapper.updateById(temp); | |||
}catch (Exception e){ | |||
} | |||
// 判断数据库操作是否成功 | |||
return SqlHelper.retBool(stationMapper.updateById(temp)); | |||
if (SqlHelper.retBool(flag)) { | |||
result.setCode("0"); | |||
} else { | |||
result.setCode("-1"); | |||
result.setMessage("更新失败"); | |||
} | |||
return result; | |||
} | |||
@Override | |||
public StationVO queryStationByStationId(String stationId) { | |||
public DataResult<StationVO> queryStationByStationId(String stationId) { | |||
StationVO stationVO = new StationVO(); | |||
Station temp=stationMapper.selectById(stationId); | |||
if(temp==null || temp.getSysDeleted()==1) return null; | |||
else { | |||
BeanUtils.copyProperties(temp,stationVO); | |||
return stationVO; | |||
DataResult<StationVO> result = new DataResult<>(); | |||
try{ | |||
Station temp = stationMapper.selectById(stationId); | |||
if (temp == null || temp.getSysDeleted() == 1) { | |||
result.setCode("-1"); | |||
result.setMessage("站点不存在/已删除"); | |||
return result; | |||
} | |||
else { | |||
BeanUtils.copyProperties(temp, stationVO); | |||
result.setCode("0"); | |||
result.setData(stationVO); | |||
} | |||
}catch (Exception e){ | |||
} | |||
return result; | |||
} | |||
@Override | |||
public StationVO queryStationByStationName(String name) { | |||
public DataResult<StationVO> queryStationByStationName(String name) { | |||
StationVO stationVO = new StationVO(); | |||
DataResult<StationVO> result= new DataResult<>(); | |||
QueryWrapper<Station> wrapper = new QueryWrapper<>(); | |||
wrapper.like("name",name); | |||
wrapper.eq("sys_deleted",0); | |||
Station station = stationMapper.selectOne(wrapper); | |||
if(station == null) return null; | |||
else { | |||
BeanUtils.copyProperties(station,stationVO); | |||
return stationVO; | |||
try{ | |||
wrapper.like("name", name); | |||
wrapper.eq("sys_deleted", 0); | |||
Station station = stationMapper.selectOne(wrapper); | |||
if (station == null) { | |||
result.setCode("-1"); | |||
result.setMessage("站点不存在/已删除"); | |||
return result; | |||
} | |||
else { | |||
BeanUtils.copyProperties(station, stationVO); | |||
result.setCode("0"); | |||
result.setData(stationVO); | |||
} | |||
}catch (Exception e){ | |||
} | |||
return result; | |||
} | |||
@Override | |||
public StationPage getStationsPage(Long current, Integer size) { | |||
StationPage stationPage = new StationPage(); | |||
public PageResult<StationVO> getStationsPage(Long current, Integer size) { | |||
PageResult<StationVO> result = new PageResult<>(); | |||
List<StationVO> stationVOList = new ArrayList<>(); | |||
IPage<Station> page = new Page<>(current,size); | |||
IPage<Station> page = new Page<>(current, size); | |||
QueryWrapper<Station> wrapper = new QueryWrapper<>(); | |||
wrapper.orderByDesc("sys_create_time"); | |||
wrapper.eq("sys_deleted",0); | |||
stationMapper.selectPage(page,wrapper); | |||
List<Station> stations = page.getRecords(); | |||
StationVO temp; | |||
for(Station station:stations){ | |||
temp=new StationVO(); | |||
BeanUtils.copyProperties(station,temp); | |||
stationVOList.add(temp); | |||
try{ | |||
wrapper.orderByDesc("sys_create_time"); | |||
wrapper.eq("sys_deleted", 0); | |||
stationMapper.selectPage(page, wrapper); | |||
List<Station> stations = page.getRecords(); | |||
StationVO temp; | |||
for (Station station : stations) { | |||
temp = new StationVO(); | |||
BeanUtils.copyProperties(station, temp); | |||
stationVOList.add(temp); | |||
} | |||
result.setDataList(stationVOList); | |||
result.setTotal(page.getTotal()); | |||
result.setCurrent(current); | |||
result.setSize(size); | |||
return result; | |||
}catch (Exception e){ | |||
} | |||
stationPage.setStationList(stationVOList); | |||
stationPage.setTotal(page.getTotal()); | |||
stationPage.setCurrent(current); | |||
stationPage.setSize(size); | |||
return stationPage; | |||
return result; | |||
} | |||
} |
@@ -8,11 +8,10 @@ import org.springframework.boot.test.context.SpringBootTest; | |||
import org.springframework.test.context.junit4.SpringRunner; | |||
import com.hp.user.client.entity.AreaVO; | |||
import com.hp.user.client.entity.ListResult; | |||
import com.hp.user.client.service.MessageService; | |||
import com.hp.user.client.service.UserAreaService; | |||
import java.util.List; | |||
@SpringBootTest | |||
@RunWith(SpringRunner.class) | |||
//这个class的路径要注意,要和需要注入的一些bean文件的最外层,不如会出现文件扫描不到的情况 | |||
@@ -27,8 +26,8 @@ public class ControllerTest { | |||
@Test | |||
public void testQueryAllArea() { | |||
List<AreaVO> users = areaService.getAllArea(); | |||
users.forEach(System.out::println); | |||
ListResult<AreaVO> users = areaService.getAllArea(); | |||
users.getDataList().forEach(System.out::println); | |||
} | |||
@Test | |||