parent
a2942f7ddb
commit
ad0de10c8d
14 changed files with 258 additions and 17 deletions
@ -0,0 +1,43 @@ |
||||
package com.ccic.safeliab.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic; |
||||
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
||||
import lombok.Data; |
||||
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
||||
import java.util.Date; |
||||
|
||||
@Data |
||||
public class BaseEntity { |
||||
@JsonSerialize( |
||||
using = ToStringSerializer.class |
||||
) |
||||
private Long createdBy; |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
private Date createAt; |
||||
@JsonSerialize( |
||||
using = ToStringSerializer.class |
||||
) |
||||
private Long updateBy; |
||||
@DateTimeFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
@JsonFormat( |
||||
pattern = "yyyy-MM-dd HH:mm:ss" |
||||
) |
||||
private Date updateAt; |
||||
private Integer status; |
||||
@TableLogic |
||||
private Integer isDeleted; |
||||
|
||||
public BaseEntity() { |
||||
} |
||||
|
||||
} |
@ -0,0 +1,33 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* 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 |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* 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 com.ccic.safeliab.service; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.ccic.safeliab.entity.Customer; |
||||
import com.ccic.safeliab.vo.CustomerVO; |
||||
|
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* 服务类 |
||||
* |
||||
* @author edwong |
||||
*/ |
||||
public interface StatisticsService { |
||||
|
||||
Page<Customer> findPage(CustomerVO customer); |
||||
} |
@ -0,0 +1,67 @@ |
||||
/** |
||||
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). |
||||
* <p> |
||||
* 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 |
||||
* <p> |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p> |
||||
* 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 com.ccic.safeliab.service; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.ccic.safeliab.entity.Customer; |
||||
import com.ccic.safeliab.entity.Device; |
||||
import com.ccic.safeliab.entity.User; |
||||
import com.ccic.safeliab.support.Condition; |
||||
import com.ccic.safeliab.util.CcicUtill; |
||||
import com.ccic.safeliab.vo.CustomerVO; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.util.StringUtils; |
||||
|
||||
import java.util.Map; |
||||
|
||||
|
||||
/** |
||||
* 服务实现类 |
||||
* |
||||
* @author edwong |
||||
*/ |
||||
@Service |
||||
public class StatisticsServiceImpl implements StatisticsService { |
||||
|
||||
@Autowired |
||||
private ICustomerService customerService; |
||||
|
||||
@Override |
||||
public Page<Customer> findPage(CustomerVO customer) { |
||||
Page<Customer> page = new Page(customer.getPage(), customer.getNum()); |
||||
QueryWrapper<Customer> wrapper = Condition.getQueryWrapper(customer); |
||||
if (!StringUtils.isEmpty(customer.getKeyword())) { |
||||
// 客户名称与编号过滤
|
||||
wrapper.lambda().like(Customer::getCustomerName, customer.getKeyword()) |
||||
.or() |
||||
.like(Customer::getCustomerNo, customer.getKeyword()); |
||||
} |
||||
if (!StringUtils.isEmpty(customer.getTypePid())) { |
||||
// 归属机构
|
||||
wrapper.lambda().eq(Customer::getTypePid, customer.getTypePid()); |
||||
} |
||||
if (!StringUtils.isEmpty(customer.getTypePid())) { |
||||
// 管理分类
|
||||
wrapper.lambda().eq(Customer::getTypePid, customer.getTypePid()); |
||||
} |
||||
wrapper.orderByDesc("changed_at"); |
||||
customerService.page(page,wrapper); |
||||
|
||||
return page; |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package com.ccic.safeliab.support; |
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface BaseService<T> extends IService<T> { |
||||
boolean deleteLogic(List<Long> ids); |
||||
} |
@ -0,0 +1,50 @@ |
||||
package com.ccic.safeliab.support; |
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import com.ccic.safeliab.entity.BaseEntity; |
||||
import com.ccic.safeliab.entity.Customer; |
||||
import org.springframework.validation.annotation.Validated; |
||||
|
||||
import java.util.Date; |
||||
import java.util.List; |
||||
|
||||
@Validated |
||||
public class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseEntity> extends ServiceImpl<M, T> implements BaseService<T> { |
||||
public BaseServiceImpl() { |
||||
} |
||||
|
||||
public boolean save(T entity) { |
||||
Customer user = new Customer(); |
||||
user.setCustomerId(Long.parseLong("3009473735814009")); |
||||
if (user != null) { |
||||
entity.setCreatedBy(user.getCustomerId()); |
||||
entity.setUpdateBy(user.getCustomerId()); |
||||
} |
||||
|
||||
Date now = new Date(); |
||||
entity.setCreateAt(now); |
||||
entity.setUpdateAt(now); |
||||
if (entity.getStatus() == null) { |
||||
entity.setStatus(1); |
||||
} |
||||
|
||||
entity.setIsDeleted(0); |
||||
return super.save(entity); |
||||
} |
||||
|
||||
public boolean updateById(T entity) { |
||||
Customer user = new Customer(); |
||||
if (user != null) { |
||||
entity.setUpdateBy(user.getCustomerId()); |
||||
} |
||||
|
||||
entity.setUpdateAt(new Date()); |
||||
return super.updateById(entity); |
||||
} |
||||
|
||||
public boolean deleteLogic(List<Long> ids) { |
||||
return super.removeByIds(ids); |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package com.ccic.safeliab.vo; |
||||
|
||||
import com.ccic.safeliab.entity.Customer; |
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class CustomerVO extends Customer { |
||||
|
||||
private String keyword; |
||||
|
||||
private Integer page; |
||||
|
||||
private Integer num; |
||||
} |
@ -0,0 +1,23 @@ |
||||
package com.ccic.safeliab.web; |
||||
|
||||
import com.ccic.safeliab.service.StatisticsService; |
||||
import com.ccic.safeliab.util.R; |
||||
import com.ccic.safeliab.vo.CustomerVO; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
|
||||
@RestController |
||||
@RequestMapping("/ex/statistics") |
||||
public class StatisticsController { |
||||
|
||||
@Autowired |
||||
private StatisticsService statisticsService; |
||||
|
||||
@PostMapping("/page") |
||||
public R page(@RequestBody CustomerVO customer) { |
||||
return R.ok().dataPage(statisticsService.findPage(customer)); |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue