| @@ -33,6 +33,9 @@ public class WxWeappExtSet implements Serializable { | |||
| /**提交审核列表*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="提交审核列表",name="releaseJson") | |||
| private String releaseJson; | |||
| /**提交审核列表*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="停车(0:不支持,1:etcp)",name="carSupport") | |||
| private Integer carSupport; | |||
| /**创建时间*/ | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @@ -49,6 +52,7 @@ public class WxWeappExtSet implements Serializable { | |||
| ,Type_ASC("`type` ASC"),Type_DESC("`type` DESC") | |||
| ,ExtJson_ASC("`ext_json` ASC"),ExtJson_DESC("`ext_json` DESC") | |||
| ,ReleaseJson_ASC("`release_json` ASC"),ReleaseJson_DESC("`release_json` DESC") | |||
| ,CarSupport_ASC("`car_support` ASC"),CarSupport_DESC("`car_support` DESC") | |||
| ,CreateDate_ASC("`create_date` ASC"),CreateDate_DESC("`create_date` DESC") | |||
| ,UpdateDate_ASC("`update_date` ASC"),UpdateDate_DESC("`update_date` DESC") | |||
| ; | |||
| @@ -0,0 +1,38 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumCarSupport { | |||
| // 0-不支持 1-ETCP | |||
| NOCAR(0, "暂未支持"), | |||
| ETCP(1, "ETCP"), | |||
| ; | |||
| public static EnumCarSupport getEnum(Integer code) { | |||
| for (EnumCarSupport value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCarSupport(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -3,6 +3,8 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxWeappExtSet; | |||
| import java.util.List; | |||
| public interface WxWeappExtSetService { | |||
| /** | |||
| @@ -14,6 +16,14 @@ public interface WxWeappExtSetService { | |||
| * @return | |||
| */ | |||
| PageInfo<WxWeappExtSet> listAsPage(WxWeappExtSet record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据实体查询列表 | |||
| * | |||
| * @param record | |||
| * @return | |||
| */ | |||
| List<WxWeappExtSet> getList(WxWeappExtSet record); | |||
| /** | |||
| * 根据Id获得实体 | |||
| @@ -6,6 +6,8 @@ import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxAuthorizerInfo; | |||
| import com.iformall.domain.po.WxWeappExtSet; | |||
| import com.iformall.domain.vo.WxWeappInfo; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumCarSupport; | |||
| import com.iformall.mapper.WxAppinfoMapper; | |||
| import com.iformall.mapper.WxAuthorizerInfoMapper; | |||
| import com.iformall.mapper.WxWeappExtSetMapper; | |||
| @@ -109,16 +111,22 @@ public class WxAuthorizerInfoServiceImpl implements WxAuthorizerInfoService { | |||
| record.setUpdateTime(curDate); | |||
| // 授权表 添加 | |||
| authorizerInfoMapper.insertSelective(record); | |||
| // 扩展配置表添加 | |||
| WxWeappExtSet weappExtSet = new WxWeappExtSet(); | |||
| weappExtSet.setId(record.getId()); | |||
| weappExtSet.setAppId(record.getAuthorizerAppid()); | |||
| if(appinfo != null) { | |||
| weappExtSet.setType(appinfo.getType()); | |||
| if(appinfo.getType().equals(EnumAppType.C.getCode()) || | |||
| appinfo.getType().equals(EnumAppType.B.getCode())) { | |||
| // C/B 扩展配置表添加 | |||
| WxWeappExtSet weappExtSet = new WxWeappExtSet(); | |||
| weappExtSet.setId(record.getId()); | |||
| weappExtSet.setAppId(record.getAuthorizerAppid()); | |||
| if (appinfo.getType().equals(EnumAppType.C.getCode())) { | |||
| weappExtSet.setCarSupport(EnumCarSupport.NOCAR.getCode()); | |||
| } | |||
| if (appinfo != null) { | |||
| weappExtSet.setType(appinfo.getType()); | |||
| } | |||
| weappExtSet.setCreateDate(curDate); | |||
| weappExtSet.setUpdateDate(curDate); | |||
| weappExtSetMapper.insertSelective(weappExtSet); | |||
| } | |||
| weappExtSet.setCreateDate(curDate); | |||
| weappExtSet.setUpdateDate(curDate); | |||
| weappExtSetMapper.insertSelective(weappExtSet); | |||
| } else { | |||
| record.setId(authorizerInfo.getId()); | |||
| record.setUpdateTime(curDate); | |||
| @@ -9,6 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.iformall.common.IdWorker; | |||
| import java.util.List; | |||
| @Service | |||
| public class WxWeappExtSetServiceImpl implements WxWeappExtSetService { | |||
| @@ -21,6 +23,11 @@ public class WxWeappExtSetServiceImpl implements WxWeappExtSetService { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxWeappExtSetMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public List<WxWeappExtSet> getList(WxWeappExtSet record) { | |||
| return wxWeappExtSetMapper.findList(record); | |||
| } | |||
| @Override | |||
| public WxWeappExtSet getById(Long id) { | |||
| return wxWeappExtSetMapper.selectByPrimaryKey(id); | |||
| @@ -7,12 +7,13 @@ | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="ext_json" jdbcType="VARCHAR" property="extJson"/> | |||
| <result column="release_json" jdbcType="VARCHAR" property="releaseJson"/> | |||
| <result column="car_support" jdbcType="TINYINT" property="carSupport"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`app_id`,`type`,`ext_json`,`release_json`,`create_date`,`update_date` | |||
| `id`,`app_id`,`type`,`ext_json`,`release_json`,`car_support`,`create_date`,`update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -26,6 +27,9 @@ | |||
| <if test=" null != type "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != carSupport "> | |||
| and `car_support` = #{carSupport} | |||
| </if> | |||
| <if test=" null != createDate "> | |||
| and `create_date` = #{createDate} | |||
| </if> | |||
| @@ -1,20 +1,28 @@ | |||
| package com.iformall.controller; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxWeappExtSet; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxWeappExtSetService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| 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.Controller; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| /** | |||
| * Stormeye Wu | |||
| */ | |||
| @@ -24,6 +32,9 @@ import org.springframework.web.bind.annotation.*; | |||
| public class WxWeappExtSetController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(getClass()); | |||
| @Autowired | |||
| private WxAppinfoService appinfoService; | |||
| @Autowired | |||
| private WxWeappExtSetService weappExtSetService; | |||
| @@ -55,4 +66,57 @@ public class WxWeappExtSetController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("batchUpdate") | |||
| public ResultData batchAdd(@RequestBody WxWeappExtSet weappExtSet) { | |||
| logger.debug("[" + getIpAddr() + "] WxWeappExtSetController::batchAdd"); | |||
| if (null == weappExtSet) return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| if(StringUtils.isBlank(weappExtSet.getExtJson())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| String extJson = weappExtSet.getExtJson(); | |||
| JSONObject obj = JSON.parseObject(extJson); | |||
| if(obj == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| JSONObject extObj = obj.getJSONObject("ext"); | |||
| if(extObj == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| JSONObject attrObj = extObj.getJSONObject("attr"); | |||
| if(attrObj == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxWeappExtSet extSetQ = new WxWeappExtSet(); | |||
| extSetQ.setType(weappExtSet.getType()); | |||
| List<WxWeappExtSet> weappExtSetList = weappExtSetService.getList(extSetQ); | |||
| for(WxWeappExtSet info: weappExtSetList) { | |||
| WxAppinfo appinfo = appinfoService.getByAppId(info.getAppId()); | |||
| if(appinfo == null) { | |||
| continue; | |||
| } | |||
| obj.put("extAppid", info.getAppId()); | |||
| if(weappExtSet.getType().equals(EnumAppType.C.getCode())) { | |||
| if (attrObj != null) { | |||
| attrObj.put("ifHaveCarModular", String.valueOf(info.getCarSupport())); | |||
| } | |||
| } | |||
| if(extObj != null) { | |||
| extObj.put("weappId", info.getAppId()); | |||
| extObj.put("name", appinfo.getName()); | |||
| if(weappExtSet.getType().equals(EnumAppType.C.getCode())) { | |||
| extObj.put("attr", attrObj); | |||
| } | |||
| obj.put("ext", extObj); | |||
| } | |||
| info.setExtJson(JSON.toJSONString(obj)); | |||
| try { | |||
| weappExtSetService.saveOrUpdate(info); | |||
| } catch (Exception e) { | |||
| logger.error("APPID " + info.getAppId() + ", 保存失败 " + e.getMessage()); | |||
| } | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||