41 changed files with 1350 additions and 67 deletions
@ -0,0 +1,30 @@ |
|||
package com.epmet.user.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/6/22 1:54 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class PatrolCountFormDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -4365871122000986115L; |
|||
|
|||
public interface PatrolCountForm{} |
|||
|
|||
/** |
|||
* 组织ID |
|||
*/ |
|||
@NotBlank(message = "组织ID不能为空",groups = PatrolCountForm.class) |
|||
private String agencyId; |
|||
|
|||
/** |
|||
* 行政地区编码 |
|||
*/ |
|||
private String areaCode; |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.epmet.user.result; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2021/6/22 1:50 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class PatrolCountResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -5686401629775910576L; |
|||
|
|||
/** |
|||
* 当前巡查中人数 |
|||
*/ |
|||
private Integer patrollingCount; |
|||
|
|||
/** |
|||
* 当前未巡查中人数 |
|||
*/ |
|||
private Integer elseCount; |
|||
|
|||
public PatrolCountResultDTO() { |
|||
this.patrollingCount = NumConstant.ZERO; |
|||
this.elseCount = NumConstant.ZERO; |
|||
} |
|||
} |
@ -0,0 +1,96 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* 客户小程序启动页配置 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-06-21 |
|||
*/ |
|||
@Data |
|||
public class CustomerStartPageDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 唯一标识 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 小程序所属端类型【居民端: resi 工作端: work】 |
|||
*/ |
|||
private String clientType; |
|||
|
|||
/** |
|||
* 启动页文件url路径 |
|||
*/ |
|||
private String url; |
|||
|
|||
/** |
|||
* 启动页展示时间,单位秒 |
|||
*/ |
|||
private Integer time; |
|||
|
|||
/** |
|||
* 启动页文件类型(图片 - image、 视频 - video) |
|||
*/ |
|||
private String type; |
|||
|
|||
/** |
|||
* 删除标识:0.未删除 1.已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 小程序-启动页查询-接口入参 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class HomeStartPageFromDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -6163303184086480522L; |
|||
/** |
|||
* extAppId |
|||
*/ |
|||
@NotBlank(message = "小程序Id不能为空", groups = {Start.class}) |
|||
private String appId; |
|||
|
|||
public interface Start extends CustomerClientShowGroup {} |
|||
|
|||
} |
@ -0,0 +1,49 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.Max; |
|||
import javax.validation.constraints.Min; |
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 运营端-启动页查询-接口入参 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class SaveStartPageFromDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -6163303184086480522L; |
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
@NotBlank(message = "客户Id不能为空", groups = {Save.class}) |
|||
private String customerId; |
|||
/** |
|||
* 启动页文件url路径 |
|||
*/ |
|||
@NotBlank(message = "url路径不能为空", groups = {Save.class}) |
|||
private String url; |
|||
/** |
|||
* 小程序所属端类型【居民端: resi 工作端: work】 |
|||
*/ |
|||
@NotBlank(message = "所属端类型不能为空", groups = {Save.class}) |
|||
private String clientType; |
|||
/** |
|||
* 启动页展示时间,单位秒 |
|||
*/ |
|||
@NotNull(message = "展示时长不能为空", groups = {Save.class}) |
|||
@Min(value = 3, groups = {Save.class}) |
|||
@Max(value = 10, groups = {Save.class}) |
|||
private Integer time; |
|||
/** |
|||
* 启动页文件类型(图片 - image、 视频 - video) |
|||
*/ |
|||
@NotBlank(message = "文件类型不能为空", groups = {Save.class}) |
|||
private String type; |
|||
public interface Save extends CustomerClientShowGroup {} |
|||
|
|||
} |
@ -0,0 +1,26 @@ |
|||
package com.epmet.dto.form; |
|||
|
|||
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 运营端-启动页查询-接口入参 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class StartPageFromDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -6163303184086480522L; |
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
@NotBlank(message = "客户Id不能为空", groups = {Start.class}) |
|||
private String customerId; |
|||
|
|||
public interface Start extends CustomerClientShowGroup {} |
|||
|
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 小程序-启动页查询-接口入参 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class HomeStartPageResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 2971689193155710437L; |
|||
|
|||
/** |
|||
* 居民端启动页文件url路径 |
|||
*/ |
|||
private String resiUrl; |
|||
/** |
|||
* 居民端启动页展示时间,单位秒 |
|||
*/ |
|||
private Integer resiTime; |
|||
/** |
|||
* 工作端启动页文件url路径 |
|||
*/ |
|||
private String workUrl; |
|||
/** |
|||
* 工作端启动页展示时间,单位秒 |
|||
*/ |
|||
private Integer workTime; |
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 运营端-启动页查询-接口入参 |
|||
* @Author sun |
|||
*/ |
|||
@Data |
|||
public class StartPageResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 2971689193155710437L; |
|||
|
|||
/** |
|||
* 启动页文件url路径 |
|||
*/ |
|||
private String url; |
|||
/** |
|||
* 小程序所属端类型【居民端: resi 工作端: work】 |
|||
*/ |
|||
private String clientType; |
|||
/** |
|||
* 启动页展示时间,单位秒 |
|||
*/ |
|||
private Integer time; |
|||
/** |
|||
* 【暂时没用】启动页文件类型(图片 - image、 视频 - video) |
|||
*/ |
|||
private String type; |
|||
/** |
|||
* 默认值 |
|||
*/ |
|||
private String defUrl; |
|||
/** |
|||
* 默认值 |
|||
*/ |
|||
private String defClientType; |
|||
/** |
|||
* 默认值 |
|||
*/ |
|||
private Integer defTime; |
|||
/** |
|||
* 默认值 |
|||
*/ |
|||
private String defType; |
|||
} |
@ -0,0 +1,138 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.controller; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.ExcelUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.AssertUtils; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|||
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|||
import com.epmet.dto.CustomerStartPageDTO; |
|||
import com.epmet.dto.form.HomeStartPageFromDTO; |
|||
import com.epmet.dto.form.SaveStartPageFromDTO; |
|||
import com.epmet.dto.form.StartPageFromDTO; |
|||
import com.epmet.dto.result.HomeStartPageResultDTO; |
|||
import com.epmet.dto.result.StartPageResultDTO; |
|||
import com.epmet.excel.CustomerStartPageExcel; |
|||
import com.epmet.service.CustomerStartPageService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 客户小程序启动页配置 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-06-21 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("customerstartpage") |
|||
public class CustomerStartPageController { |
|||
|
|||
@Autowired |
|||
private CustomerStartPageService customerStartPageService; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<CustomerStartPageDTO>> page(@RequestParam Map<String, Object> params) { |
|||
PageData<CustomerStartPageDTO> page = customerStartPageService.page(params); |
|||
return new Result<PageData<CustomerStartPageDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<CustomerStartPageDTO> get(@PathVariable("id") String id) { |
|||
CustomerStartPageDTO data = customerStartPageService.get(id); |
|||
return new Result<CustomerStartPageDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody CustomerStartPageDTO dto) { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
customerStartPageService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
public Result update(@RequestBody CustomerStartPageDTO dto) { |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
customerStartPageService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids) { |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
customerStartPageService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<CustomerStartPageDTO> list = customerStartPageService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, CustomerStartPageExcel.class); |
|||
} |
|||
|
|||
/** |
|||
* @param fromDTO |
|||
* @Author sun |
|||
* @Description 运营端-启动页查询 |
|||
**/ |
|||
@PostMapping("startpage") |
|||
public Result<List<StartPageResultDTO>> startPage(@RequestBody StartPageFromDTO fromDTO) { |
|||
ValidatorUtils.validateEntity(fromDTO, StartPageFromDTO.Start.class); |
|||
return new Result<List<StartPageResultDTO>>().ok(customerStartPageService.startPage(fromDTO)); |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @Author sun |
|||
* @Description 运营端-启动页保存 |
|||
**/ |
|||
@PostMapping("savestartpage") |
|||
public Result saveStartPage(@RequestBody SaveStartPageFromDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, SaveStartPageFromDTO.Save.class); |
|||
if (!"resi".equals(formDTO.getClientType()) && !"work".equals(formDTO.getClientType())) { |
|||
throw new RenException("参数错误,所属端类型值错误"); |
|||
} |
|||
customerStartPageService.saveStartPage(formDTO); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* @param fromDTO |
|||
* @Author sun |
|||
* @Description 小程序-启动页查询 |
|||
**/ |
|||
@PostMapping("homestartpage") |
|||
public Result<HomeStartPageResultDTO> homeStartPage(@RequestBody HomeStartPageFromDTO fromDTO) { |
|||
ValidatorUtils.validateEntity(fromDTO, HomeStartPageFromDTO.Start.class); |
|||
return new Result<HomeStartPageResultDTO>().ok(customerStartPageService.homeStartPage(fromDTO)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,48 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dao; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.result.StartPageResultDTO; |
|||
import com.epmet.entity.CustomerStartPageEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 客户小程序启动页配置 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-06-21 |
|||
*/ |
|||
@Mapper |
|||
public interface CustomerStartPageDao extends BaseDao<CustomerStartPageEntity> { |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 查询客户启动页配置数据 |
|||
**/ |
|||
List<StartPageResultDTO> selectByCustomerId(@Param("customerId") String customerId); |
|||
|
|||
/** |
|||
* @Author sun |
|||
* @Description 根据客户Id删除可能存在的配置数据 |
|||
**/ |
|||
int delByCustomerId(@Param("customerId") String customerId, @Param("clientType") String clientType); |
|||
} |
@ -0,0 +1,66 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 客户小程序启动页配置 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-06-21 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("customer_start_page") |
|||
public class CustomerStartPageEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 小程序所属端类型【居民端: resi 工作端: work】 |
|||
*/ |
|||
private String clientType; |
|||
|
|||
/** |
|||
* 启动页文件url路径 |
|||
*/ |
|||
private String url; |
|||
|
|||
/** |
|||
* 启动页展示时间,单位秒 |
|||
*/ |
|||
private Integer time; |
|||
|
|||
/** |
|||
* 启动页文件类型(图片 - image、 视频 - video) |
|||
*/ |
|||
private String type; |
|||
|
|||
} |
@ -0,0 +1,71 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 客户小程序启动页配置 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-06-21 |
|||
*/ |
|||
@Data |
|||
public class CustomerStartPageExcel { |
|||
|
|||
@Excel(name = "唯一标识") |
|||
private String id; |
|||
|
|||
@Excel(name = "客户ID") |
|||
private String customerId; |
|||
|
|||
@Excel(name = "小程序所属端类型【居民端: resi 工作端: work】") |
|||
private String clientType; |
|||
|
|||
@Excel(name = "启动页文件url路径") |
|||
private String url; |
|||
|
|||
@Excel(name = "启动页展示时间,单位秒") |
|||
private Integer time; |
|||
|
|||
@Excel(name = "启动页文件类型(图片 - image、 视频 - video)") |
|||
private String type; |
|||
|
|||
@Excel(name = "删除标识:0.未删除 1.已删除") |
|||
private Integer delFlag; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime; |
|||
|
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.redis; |
|||
|
|||
import com.epmet.commons.tools.redis.RedisUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* 客户小程序启动页配置 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-06-21 |
|||
*/ |
|||
@Component |
|||
public class CustomerStartPageRedis { |
|||
@Autowired |
|||
private RedisUtils redisUtils; |
|||
|
|||
public void delete(Object[] ids) { |
|||
|
|||
} |
|||
|
|||
public void set(){ |
|||
|
|||
} |
|||
|
|||
public String get(String id){ |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,121 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.CustomerStartPageDTO; |
|||
import com.epmet.dto.form.HomeStartPageFromDTO; |
|||
import com.epmet.dto.form.SaveStartPageFromDTO; |
|||
import com.epmet.dto.form.StartPageFromDTO; |
|||
import com.epmet.dto.result.HomeStartPageResultDTO; |
|||
import com.epmet.dto.result.StartPageResultDTO; |
|||
import com.epmet.entity.CustomerStartPageEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 客户小程序启动页配置 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-06-21 |
|||
*/ |
|||
public interface CustomerStartPageService extends BaseService<CustomerStartPageEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<CustomerStartPageDTO> |
|||
* @author generator |
|||
* @date 2021-06-21 |
|||
*/ |
|||
PageData<CustomerStartPageDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<CustomerStartPageDTO> |
|||
* @author generator |
|||
* @date 2021-06-21 |
|||
*/ |
|||
List<CustomerStartPageDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return CustomerStartPageDTO |
|||
* @author generator |
|||
* @date 2021-06-21 |
|||
*/ |
|||
CustomerStartPageDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2021-06-21 |
|||
*/ |
|||
void save(CustomerStartPageDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2021-06-21 |
|||
*/ |
|||
void update(CustomerStartPageDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2021-06-21 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* @param fromDTO |
|||
* @Author sun |
|||
* @Description 运营端-启动页查询 |
|||
**/ |
|||
List<StartPageResultDTO> startPage(StartPageFromDTO fromDTO); |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @Author sun |
|||
* @Description 运营端-启动页保存 |
|||
**/ |
|||
void saveStartPage(SaveStartPageFromDTO formDTO); |
|||
|
|||
/** |
|||
* @param fromDTO |
|||
* @Author sun |
|||
* @Description 小程序-启动页查询 |
|||
**/ |
|||
HomeStartPageResultDTO homeStartPage(HomeStartPageFromDTO fromDTO); |
|||
} |
@ -0,0 +1,242 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.exception.RenException; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.constant.FieldConstant; |
|||
import com.epmet.commons.tools.utils.HttpClientManager; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dao.CustomerStartPageDao; |
|||
import com.epmet.dto.CustomerStartPageDTO; |
|||
import com.epmet.dto.PaCustomerDTO; |
|||
import com.epmet.dto.form.HomeStartPageFromDTO; |
|||
import com.epmet.dto.form.SaveStartPageFromDTO; |
|||
import com.epmet.dto.form.StartPageFromDTO; |
|||
import com.epmet.dto.result.HomeStartPageResultDTO; |
|||
import com.epmet.dto.result.StartPageResultDTO; |
|||
import com.epmet.entity.CustomerStartPageEntity; |
|||
import com.epmet.redis.CustomerStartPageRedis; |
|||
import com.epmet.service.CustomerStartPageService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 客户小程序启动页配置 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2021-06-21 |
|||
*/ |
|||
@Service |
|||
public class CustomerStartPageServiceImpl extends BaseServiceImpl<CustomerStartPageDao, CustomerStartPageEntity> implements CustomerStartPageService { |
|||
private static final Logger logger = LoggerFactory.getLogger(CustomerStartPageServiceImpl.class); |
|||
@Autowired |
|||
private CustomerStartPageRedis customerStartPageRedis; |
|||
|
|||
@Override |
|||
public PageData<CustomerStartPageDTO> page(Map<String, Object> params) { |
|||
IPage<CustomerStartPageEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, CustomerStartPageDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<CustomerStartPageDTO> list(Map<String, Object> params) { |
|||
List<CustomerStartPageEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, CustomerStartPageDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<CustomerStartPageEntity> getWrapper(Map<String, Object> params) { |
|||
String id = (String) params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<CustomerStartPageEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public CustomerStartPageDTO get(String id) { |
|||
CustomerStartPageEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, CustomerStartPageDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(CustomerStartPageDTO dto) { |
|||
CustomerStartPageEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStartPageEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(CustomerStartPageDTO dto) { |
|||
CustomerStartPageEntity entity = ConvertUtils.sourceToTarget(dto, CustomerStartPageEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
/** |
|||
* @param fromDTO |
|||
* @Author sun |
|||
* @Description 运营端-启动页查询 |
|||
**/ |
|||
@Override |
|||
public List<StartPageResultDTO> startPage(StartPageFromDTO fromDTO) { |
|||
List<StartPageResultDTO> resultList = new ArrayList<>(); |
|||
//1.按客户id查询客户数据
|
|||
resultList = baseDao.selectByCustomerId(fromDTO.getCustomerId()); |
|||
if (null == resultList || resultList.size() < NumConstant.ONE) { |
|||
StartPageResultDTO resi = new StartPageResultDTO(); |
|||
resi.setClientType("resi"); |
|||
resultList.add(resi); |
|||
StartPageResultDTO work = new StartPageResultDTO(); |
|||
work.setClientType("work"); |
|||
resultList.add(work); |
|||
}else {//缺失数据的补齐,保证返回两条
|
|||
Map<String, String> map = resultList.stream().collect(Collectors.toMap(StartPageResultDTO::getClientType,StartPageResultDTO::getClientType,(value1,value2)->{ |
|||
return value2; |
|||
})); |
|||
if(!map.containsKey("resi")){ |
|||
StartPageResultDTO resi = new StartPageResultDTO(); |
|||
resi.setClientType("resi"); |
|||
resultList.add(resi); |
|||
} |
|||
if(!map.containsKey("work")){ |
|||
StartPageResultDTO work = new StartPageResultDTO(); |
|||
work.setClientType("work"); |
|||
resultList.add(work); |
|||
} |
|||
} |
|||
|
|||
//2.查询默认客户数据
|
|||
List<StartPageResultDTO> defList = baseDao.selectByCustomerId("default"); |
|||
|
|||
//3.封装数据并返回
|
|||
resultList.forEach(re -> { |
|||
defList.forEach(d -> { |
|||
if (re.getClientType().equals(d.getClientType())) { |
|||
re.setDefUrl(d.getUrl()); |
|||
re.setDefClientType(d.getClientType()); |
|||
re.setDefTime(d.getTime()); |
|||
re.setDefType(d.getType()); |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
return resultList; |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @Author sun |
|||
* @Description 运营端-启动页保存 |
|||
**/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void saveStartPage(SaveStartPageFromDTO formDTO) { |
|||
//1.按客户Id删除可能存在的历史数据
|
|||
baseDao.delByCustomerId(formDTO.getCustomerId(), formDTO.getClientType()); |
|||
|
|||
//2.新增客户设置数据
|
|||
CustomerStartPageEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerStartPageEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
/** |
|||
* @param fromDTO |
|||
* @Author sun |
|||
* @Description 小程序-启动页查询 |
|||
**/ |
|||
@Override |
|||
public HomeStartPageResultDTO homeStartPage(HomeStartPageFromDTO fromDTO) { |
|||
HomeStartPageResultDTO resultDTO = new HomeStartPageResultDTO(); |
|||
//1.调用third服务,根据appId查询客户Id
|
|||
PaCustomerDTO dto = getCustomerInfo(fromDTO.getAppId()); |
|||
|
|||
//2.根据客户Id查询客户启动页数据
|
|||
List<StartPageResultDTO> defList = baseDao.selectByCustomerId(dto.getId()); |
|||
if(null==defList||defList.size()<NumConstant.ONE){ |
|||
defList = baseDao.selectByCustomerId("default"); |
|||
} |
|||
//3.封装数据并返回
|
|||
defList.forEach(d -> { |
|||
if ("resi".equals(d.getClientType())) { |
|||
resultDTO.setResiUrl(d.getUrl()); |
|||
resultDTO.setResiTime(d.getTime()); |
|||
} |
|||
if ("work".equals(d.getClientType())) { |
|||
resultDTO.setWorkUrl(d.getUrl()); |
|||
resultDTO.setWorkTime(d.getTime()); |
|||
} |
|||
}); |
|||
|
|||
return resultDTO; |
|||
} |
|||
|
|||
/** |
|||
* @param appId |
|||
* @Description 获取客户信息 |
|||
* @author sun |
|||
*/ |
|||
public PaCustomerDTO getCustomerInfo(String appId) { |
|||
String url = "https://epmet-cloud.elinkservice.cn/api/third/customermp/getcustomermsg/"; |
|||
JSONObject jsonObject = new JSONObject(); |
|||
String data = HttpClientManager.getInstance().sendPostByJSON(url + appId, JSON.toJSONString(jsonObject)).getData(); |
|||
logger.info("CustomerStartPageServiceImpl.getCustomerInfo:httpclient->url:" + url + ",结果->" + data); |
|||
JSONObject toResult = JSON.parseObject(data); |
|||
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); |
|||
if (null != toResult.get("code")) { |
|||
mapToResult.setCode(((Integer) toResult.get("code")).intValue()); |
|||
} |
|||
if (!mapToResult.success()) { |
|||
logger.error(String.format("根据appId查询客户Id失败,对应appId->" + appId)); |
|||
throw new RenException(mapToResult.getMsg()); |
|||
} |
|||
Object PublicCustomerResultDTO = mapToResult.getData(); |
|||
JSONObject json = JSON.parseObject(PublicCustomerResultDTO.toString()); |
|||
Map<String, Object> map = (Map) json.get("customer"); |
|||
PaCustomerDTO customer = ConvertUtils.mapToEntity(map, PaCustomerDTO.class); |
|||
logger.info("小程序登陆third服务获取客户用户信息PaCustomerDTO->" + customer); |
|||
return customer; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,18 @@ |
|||
CREATE TABLE `customer_start_page` ( |
|||
`ID` varchar(64) NOT NULL COMMENT '唯一标识', |
|||
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户ID', |
|||
`CLIENT_TYPE` varchar(32) NOT NULL COMMENT '小程序所属端类型【居民端: resi 工作端: work】', |
|||
`URL` varchar(256) NOT NULL COMMENT '启动页文件url路径', |
|||
`TIME` int(11) NOT NULL DEFAULT '0' COMMENT '启动页展示时间,单位秒', |
|||
`TYPE` varchar(32) NOT NULL COMMENT '启动页文件类型(图片 - image、 视频 - video)', |
|||
`DEL_FLAG` int(11) NOT NULL DEFAULT '0' COMMENT '删除标识:0.未删除 1.已删除', |
|||
`REVISION` int(11) NOT NULL COMMENT '乐观锁', |
|||
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', |
|||
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', |
|||
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', |
|||
PRIMARY KEY (`ID`) USING BTREE |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='客户小程序启动页配置'; |
|||
|
|||
INSERT INTO `customer_start_page` VALUES ('3c3a2860d22d11ebbc490050568f8cf7', 'default', 'resi', 'https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20210621/a6e19dd7a39646b58ba29700d7d7dd64.jpg', '5', 'image', '0', '0', 'APP_USER', '2021-06-21 09:07:31', 'APP_USER', '2021-06-21 09:07:31'); |
|||
INSERT INTO `customer_start_page` VALUES ('45fb43a2d22d11ebbc490050568f8cf7', 'default', 'work', 'https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/internal/20210621/a6e19dd7a39646b58ba29700d7d7dd64.jpg', '5', 'image', '0', '0', 'APP_USER', '2021-06-21 09:07:31', 'APP_USER', '2021-06-21 09:07:31'); |
@ -0,0 +1,28 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.dao.CustomerStartPageDao"> |
|||
|
|||
<select id="selectByCustomerId" resultType="com.epmet.dto.result.StartPageResultDTO"> |
|||
SELECT |
|||
url AS url, |
|||
client_type AS clientType, |
|||
time AS time, |
|||
type AS type |
|||
FROM |
|||
customer_start_page |
|||
WHERE |
|||
del_flag = '0' |
|||
AND customer_id = #{customerId} |
|||
</select> |
|||
|
|||
<delete id="delByCustomerId"> |
|||
DELETE |
|||
FROM |
|||
customer_start_page |
|||
WHERE |
|||
customer_id = #{customerId} |
|||
AND client_type = #{clientType} |
|||
</delete> |
|||
|
|||
</mapper> |
Loading…
Reference in new issue