diff --git a/hiver-core/src/main/java/cc/hiver/core/entity/Worker.java b/hiver-core/src/main/java/cc/hiver/core/entity/Worker.java index f4d7c584..99fdc0ec 100644 --- a/hiver-core/src/main/java/cc/hiver/core/entity/Worker.java +++ b/hiver-core/src/main/java/cc/hiver/core/entity/Worker.java @@ -120,4 +120,11 @@ public class Worker implements Serializable { /*@OneToMany(targetEntity = Order.class,mappedBy = "orderByWorker",cascade = CascadeType.ALL,fetch = FetchType.EAGER) private List order;*/ + /** + * 区域 + */ + @Column(name = "region") + @ApiModelProperty("办公区域") + private String region; + } diff --git a/hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/LogiticsCompanyController.java b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/LogiticsCompanyController.java new file mode 100644 index 00000000..a3232d9f --- /dev/null +++ b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/LogiticsCompanyController.java @@ -0,0 +1,90 @@ +/* +Copyright [2022] [https://hiver.cc] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ +package cc.hiver.app.controller.admin; + +import cc.hiver.app.entity.Company; +import cc.hiver.app.entity.LogiticsCompany; +import cc.hiver.app.service.CompanyService; +import cc.hiver.app.service.LogiticsCompanyService; +import cc.hiver.core.common.utils.PageUtil; +import cc.hiver.core.common.utils.ResultUtil; +import cc.hiver.core.common.vo.PageVo; +import cc.hiver.core.common.vo.Result; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @author houpn + */ +@Slf4j +@RestController +@Api(tags = "物流管理公司接口") +@RequestMapping(value = "/hiver/app/logitics") +public class LogiticsCompanyController { + @Autowired + private LogiticsCompanyService companyService; + + @RequestMapping(value = "/getAll", method = RequestMethod.GET) + @ApiOperation(value = "获取全部数据") + public Result> getAll() { + List list = companyService.getAll(); + return new ResultUtil>().setData(list); + } + + @RequestMapping(value = "/add", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "添加") + public Result add(LogiticsCompany company) { + if (companyService.findByCompanyName(company.getCompanyName()) != null) { + return ResultUtil.error("公司名称已经存在"); + } + companyService.save(company); + return ResultUtil.success("添加成功"); + } + + @RequestMapping(value = "/edit", method = RequestMethod.PUT) + @ResponseBody + @ApiOperation(value = "编辑") + public Result edit(LogiticsCompany company) { + companyService.update(company); + return ResultUtil.success("编辑成功"); + } + + @RequestMapping(value = "/delByIds", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "通过id删除") + public Result delAllByIds(@RequestParam String[] ids) { + for (String id : ids) { + LogiticsCompany company = companyService.get(id); + companyService.delete(id); + } + return ResultUtil.success("删除成功"); + } + + @RequestMapping(value = "/getByCondition", method = RequestMethod.GET) + @ApiOperation(value = "多条件分页获取公司列表") + public Result> getByCondition(LogiticsCompany company, + PageVo pageVo) { + Page page = companyService.findByCondition(company, PageUtil.initPage(pageVo)); + return new ResultUtil>().setData(page); + } +} diff --git a/hiver-modules/hiver-app/src/main/java/cc/hiver/app/dao/LogiticsCompanyDao.java b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/dao/LogiticsCompanyDao.java new file mode 100644 index 00000000..6b5a80e5 --- /dev/null +++ b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/dao/LogiticsCompanyDao.java @@ -0,0 +1,33 @@ +/* +Copyright [2022] [https://hiver.cc] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ +package cc.hiver.app.dao; + +import cc.hiver.app.entity.Company; +import cc.hiver.app.entity.LogiticsCompany; +import cc.hiver.core.base.HiverBaseDao; + +/** + * @author houpn + */ +public interface LogiticsCompanyDao extends HiverBaseDao { + /** + * 通过公司名称获得记录 + * + * @param companyName + * @return + */ + LogiticsCompany findByCompanyName(String companyName); +} diff --git a/hiver-modules/hiver-app/src/main/java/cc/hiver/app/entity/LogiticsCompany.java b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/entity/LogiticsCompany.java new file mode 100644 index 00000000..6e43e888 --- /dev/null +++ b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/entity/LogiticsCompany.java @@ -0,0 +1,67 @@ +/* +Copyright [2022] [https://hiver.cc] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ +package cc.hiver.app.entity; + +import cc.hiver.core.base.HiverBaseEntity; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +import javax.persistence.Entity; +import javax.persistence.Table; + +/** + * 公司实体类 + * + * @author Yazhi Li + */ +@Data +@Entity +@DynamicInsert +@DynamicUpdate +@Table(name = "t_lcompany") +@TableName("t_lcompany") +@ApiModel(value = "公司信息") +public class LogiticsCompany extends HiverBaseEntity { + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "公司名称") + private String companyName; + + @ApiModelProperty(value = "公司电话") + private String companyTel; + + @ApiModelProperty(value = "公司邮箱") + private String companyEmail; + + @ApiModelProperty(value = "所在地区") + private String companyAddress; + + @ApiModelProperty(value = "详细地址") + private String companyStreet; + + @ApiModelProperty(value = "联系人") + private String contacts; + + @ApiModelProperty(value = "联系人手机号") + private String mobile; + + @ApiModelProperty(value = "办公区域") + private String region; +} diff --git a/hiver-modules/hiver-app/src/main/java/cc/hiver/app/service/LogiticsCompanyService.java b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/service/LogiticsCompanyService.java new file mode 100644 index 00000000..78826e7e --- /dev/null +++ b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/service/LogiticsCompanyService.java @@ -0,0 +1,44 @@ +/* +Copyright [2022] [https://hiver.cc] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ +package cc.hiver.app.service; + +import cc.hiver.app.entity.Company; +import cc.hiver.app.entity.LogiticsCompany; +import cc.hiver.core.base.HiverBaseService; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +/** + * @author Yazhi Li + */ +public interface LogiticsCompanyService extends HiverBaseService { + /** + * 多条件获取 + * + * @param company + * @param pageable + * @return + */ + Page findByCondition(LogiticsCompany company, Pageable pageable); + + /** + * 通过公司名称获得记录 + * + * @param companyName + * @return + */ + LogiticsCompany findByCompanyName(String companyName); +} diff --git a/hiver-modules/hiver-app/src/main/java/cc/hiver/app/serviceimpl/LogiticsCompanyServiceImpl.java b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/serviceimpl/LogiticsCompanyServiceImpl.java new file mode 100644 index 00000000..da942bbf --- /dev/null +++ b/hiver-modules/hiver-app/src/main/java/cc/hiver/app/serviceimpl/LogiticsCompanyServiceImpl.java @@ -0,0 +1,89 @@ +/* +Copyright [2022] [https://hiver.cc] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + */ +package cc.hiver.app.serviceimpl; + +import cc.hiver.app.dao.CompanyDao; +import cc.hiver.app.dao.LogiticsCompanyDao; +import cc.hiver.app.entity.Company; +import cc.hiver.app.entity.LogiticsCompany; +import cc.hiver.app.service.CompanyService; +import cc.hiver.app.service.LogiticsCompanyService; +import cc.hiver.core.base.HiverBaseDao; +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.lang.Nullable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.criteria.*; +import java.util.ArrayList; +import java.util.List; + +/** + * @author houpn + */ +@Slf4j +@Service +@Transactional +public class LogiticsCompanyServiceImpl implements LogiticsCompanyService { + @Autowired + private LogiticsCompanyDao companyDao; + + @Override + public HiverBaseDao getRepository() { + return companyDao; + } + + @Override + public Page findByCondition(LogiticsCompany company, Pageable pageable) { + return companyDao.findAll(new Specification() { + @Nullable + @Override + public Predicate toPredicate(Root root, CriteriaQuery cq, CriteriaBuilder cb) { + Path companyNameField = root.get("companyName"); + Path contactsField = root.get("contacts"); + Path mobileField = root.get("mobile"); + + List list = new ArrayList<>(); + + if (StrUtil.isNotBlank(company.getCompanyName())) { + list.add(cb.like(companyNameField, '%' + company.getCompanyName() + '%')); + } + + if (StrUtil.isNotBlank(company.getContacts())) { + list.add(cb.like(contactsField, '%' + company.getContacts() + '%')); + } + + if (StrUtil.isNotBlank(company.getMobile())) { + list.add(cb.like(mobileField, '%' + company.getMobile() + '%')); + } + + Predicate[] arr = new Predicate[list.size()]; + cq.where(list.toArray(arr)); + return null; + } + }, pageable); + } + + @Override + public LogiticsCompany findByCompanyName(String companyName) { + return companyDao.findByCompanyName(companyName); + } +} diff --git a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/handler/OrderXdHandler.java b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/handler/OrderXdHandler.java index 09f43e2d..5150232c 100644 --- a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/handler/OrderXdHandler.java +++ b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/handler/OrderXdHandler.java @@ -5,8 +5,6 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; -import top.javatool.canal.client.annotation.CanalTable; -import top.javatool.canal.client.handler.EntryHandler; /** * @author benjamin_5 @@ -17,9 +15,11 @@ import top.javatool.canal.client.handler.EntryHandler; //@Component //@AllArgsConstructor //@Slf4j +/* public class OrderXdHandler implements EntryHandler { - /*//private final RedisTemplate redisTemplate; + + //private final RedisTemplate redisTemplate; @Override public void insert(OrderXd orderXd) { @@ -37,5 +37,5 @@ public class OrderXdHandler implements EntryHandler { public void delete(OrderXd orderXd) { log.info("[删除]"+orderXd); redisTemplate.delete("ORDER:"+orderXd.getOrderId()); - }*/ -} + } +}*/ \ No newline at end of file