diff --git a/mallinkAdmin/src/main/java/com/simple/controller/PushLimitController.java b/mallinkAdmin/src/main/java/com/simple/controller/PushLimitController.java index 1aaeeb325..d784dda15 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/PushLimitController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/PushLimitController.java @@ -32,13 +32,10 @@ public class PushLimitController extends BaseController @ApiOperation("分页列表接口") @GetMapping("list") - @ApiImplicitParams({ - @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), - @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) - public ResultData list(@ModelAttribute PushLimit pushLimit, Integer pageNum, Integer pageSize) { + public ResultData list(@ModelAttribute PushLimit pushLimit) { if (null == pushLimit) pushLimit = new PushLimit(); pushLimit.setTenantId(getTenantId()); - final PageInfo page = pushLimitService.listAsPage(pushLimit, pageNum, pageSize); + final PageInfo page = pushLimitService.listAsPage(pushLimit, 1, 10); return new ResultData(page); } diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxMallConfigController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxMallConfigController.java new file mode 100644 index 000000000..498ebddc1 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxMallConfigController.java @@ -0,0 +1,125 @@ +package com.simple.controller; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.github.pagehelper.PageInfo; +import com.simple.common.ResultData; +import com.simple.domain.po.WxMallConfig; +import com.simple.service.WxMallConfigService; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping("wxMallConfig") +@Api(description="停车发券和精准发劵接口") +public class WxMallConfigController extends BaseController +{ + @Autowired + private WxMallConfigService wxMallConfigService; + + private Logger logger = Logger.getLogger(WxMallConfigController.class); + + @ApiOperation("获取停车劵开关") + @GetMapping("getStopCarConpon") + public ResultData getStopCarConpon() { + WxMallConfig wxMallConfig = new WxMallConfig(); + wxMallConfig.setKey("stopCarCouponSwitch"); + wxMallConfig.setTenantId(getTenantId()); + PageInfo page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1); + if(page.getSize()>0) { + WxMallConfig config = page.getList().get(0); + return new ResultData(config); + } + return new ResultData(); + } + + @ApiOperation("获取核销劵开关") + @GetMapping("getVerifyConpon") + public ResultData getVerifyConpon() { + WxMallConfig wxMallConfig = new WxMallConfig(); + wxMallConfig.setKey("verifyConponSwitch"); + wxMallConfig.setTenantId(getTenantId()); + PageInfo page = wxMallConfigService.listAsPage(wxMallConfig, 1, 1); + if(page.getSize()>0) { + WxMallConfig config = page.getList().get(0); + return new ResultData(config); + } + return new ResultData(); + } + + @PostMapping("updateStopCarConpon") + @ApiOperation("修改核销开关") + public ResultData updateStopCarConpon(@RequestBody WxMallConfig wxMallConfig) { + WxMallConfig temp = new WxMallConfig(); + temp.setKey("stopCarCouponSwitch"); + temp.setTenantId(getTenantId()); + temp.setValue(wxMallConfig.getValue()); + temp.setId(wxMallConfig.getId()); + wxMallConfigService.saveOrUpdate(temp); + return new ResultData(); + } + + @PostMapping("updateVerifyConpon") + @ApiOperation("修改核销开关") + public ResultData updateVerifyConpon(@RequestBody WxMallConfig wxMallConfig) { + WxMallConfig temp = new WxMallConfig(); + temp.setKey("verifyConponSwitch"); + temp.setTenantId(getTenantId()); + temp.setValue(wxMallConfig.getValue()); + temp.setId(wxMallConfig.getId()); + wxMallConfigService.saveOrUpdate(temp); + return new ResultData(); + } + +// @ApiOperation("分页列表接口") +// @GetMapping("list") +// @ApiImplicitParams({ +// @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), +// @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) +// public ResultData list(@ModelAttribute WxMallConfig wxMallConfig,Integer pageNum, Integer pageSize) { +// if (null == wxMallConfig) wxMallConfig = new WxMallConfig(); +// final PageInfo page = wxMallConfigService.listAsPage(wxMallConfig, pageNum, pageSize); +// return new ResultData(page); +// } +// +// @ApiOperation("新增接口") +// @PostMapping("add") +// public ResultData add(@RequestBody WxMallConfig wxMallConfig) { +// //Assert.notNull(wxMallConfig.getName(), "角色名不能为空"); +// //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); +// wxMallConfigService.saveOrUpdate(wxMallConfig); +// return new ResultData(); +// } +// +// @ApiOperation("根据id更新接口") +// @PostMapping("update") +// public ResultData update(@RequestBody WxMallConfig wxMallConfig) { +// wxMallConfigService.saveOrUpdate(wxMallConfig); +// return new ResultData(); +// } +// +// @ApiOperation("根据id删除接口") +// @GetMapping("/del") +// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) +// public ResultData delete(Long id) { +// wxMallConfigService.deleteById(id); +// return new ResultData(Result.SUCCESS, "删除成功", null); +// } +// +// @ApiOperation("根据id查询接口") +// @GetMapping("/findById") +// @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) +// public ResultData findById(Long id) { +// return new ResultData(Result.SUCCESS,"查询成功",wxMallConfigService.getById(id)); +// } + + + +} diff --git a/mallinkService/src/main/java/com/simple/domain/po/WxMallConfig.java b/mallinkService/src/main/java/com/simple/domain/po/WxMallConfig.java new file mode 100644 index 000000000..9a2e9f982 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/po/WxMallConfig.java @@ -0,0 +1,162 @@ +package com.simple.domain.po; + +import javax.persistence.*; +import java.util.*; +import java.math.*; +import javax.persistence.Transient; +import java.util.List; +import javax.persistence.Id; +import java.io.Serializable; + +@Table(name = "wx_mall_config") +public class WxMallConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + protected Long id; + + @Transient + protected List ids; + @Transient + protected String sortColumns; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSortColumns() { + return sortColumns; + } + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } + + + + /*租户id**/ + @io.swagger.annotations.ApiModelProperty(value="租户id",name="tenantId") + private String tenantId; + /*配置**/ + @io.swagger.annotations.ApiModelProperty(value="配置",name="key") + private String key; + /*0:启用 1:停用**/ + @io.swagger.annotations.ApiModelProperty(value="0:启用 1:停用",name="value") + private Integer value; + /*备注**/ + @io.swagger.annotations.ApiModelProperty(value="备注",name="remark") + private String remark; + /*创建时间**/ + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") + private Date createTime; + /*修改时间**/ + @io.swagger.annotations.ApiModelProperty(value="修改时间",name="updateTime") + private Date updateTime; + public String getTenantId() { + return tenantId; + } + public void setTenantId(String _tenantId) { + tenantId = _tenantId; + } + public String getKey() { + return key; + } + public void setKey(String _key) { + key = _key; + } + public Integer getValue() { + return value; + } + public void setValue(Integer _value) { + value = _value; + } + public String getRemark() { + return remark; + } + public void setRemark(String _remark) { + remark = _remark; + } + public Date getCreateTime() { + return createTime; + } + public void setCreateTime(Date _createTime) { + createTime = _createTime; + } + public Date getUpdateTime() { + return updateTime; + } + public void setUpdateTime(Date _updateTime) { + updateTime = _updateTime; + } + + + + public static enum Field + { + Id_ASC("`id` ASC"),Id_DESC("`id` DESC") + ,TenantId_ASC("`tenantId` ASC"),TenantId_DESC("`tenantId` DESC") + ,Key_ASC("`key` ASC"),Key_DESC("`key` DESC") + ,Value_ASC("`value` ASC"),Value_DESC("`value` DESC") + ,Remark_ASC("`remark` ASC"),Remark_DESC("`remark` DESC") + ,CreateTime_ASC("`createTime` ASC"),CreateTime_DESC("`createTime` DESC") + ,UpdateTime_ASC("`updateTime` ASC"),UpdateTime_DESC("`updateTime` DESC") + ; + private String value; + Field(String value){ + this.value = value; + } + public String getValue() { + return value; + } + public void setCol(String value) { + this.value = value; + } + @Override + public String toString() { + return this.getValue(); + } + } + + public void setSortColumns(WxMallConfig.Field... fields) + { + if (fields == null || fields.length == 0) { + return; + } + for (int k = 0; k < fields.length; k++) { + if (fields[k] == null) { + return; + } + } + StringBuilder sb = new StringBuilder(fields[0].toString()); + for (int k = 1; k < fields.length; k++) { + sb.append(","); + sb.append(fields[k].toString()); + } + + } + + public void setSortColumns(String sortColumns) + { + if (sortColumns == null || "".equals(sortColumns.trim())) { + return; + } + if (sortColumns.contains(",")) { + String[] cols = sortColumns.split(","); + java.util.List fList = new java.util.ArrayList(); + for (int k = 0; k < cols.length; k++) { + fList.add(Field.valueOf(cols[k])); + } + this.setSortColumns(fList.toArray(new Field[fList.size()])); + } else { + this.setSortColumns(Field.valueOf(sortColumns)); + } + } +} diff --git a/mallinkService/src/main/java/com/simple/mapper/WxMallConfigMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxMallConfigMapper.java new file mode 100644 index 000000000..2f9e5f41d --- /dev/null +++ b/mallinkService/src/main/java/com/simple/mapper/WxMallConfigMapper.java @@ -0,0 +1,17 @@ +package com.simple.mapper; + +import java.util.*; +import com.simple.common.CommonMapper; +import org.apache.ibatis.annotations.Param; +import com.simple.domain.po.WxMallConfig; + +public interface WxMallConfigMapper extends CommonMapper { + + List findList(WxMallConfig wxMallConfig); + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/WxMallConfigService.java b/mallinkService/src/main/java/com/simple/service/WxMallConfigService.java new file mode 100644 index 000000000..25d9832c5 --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/WxMallConfigService.java @@ -0,0 +1,48 @@ +package com.simple.service; + +import java.util.*; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxMallConfig; + +public interface WxMallConfigService { + + /** + * 根据实体查询分页列表 + * + * @param record + * @param offset + * @param limit + * @return + */ + PageInfo listAsPage(WxMallConfig record, Integer pageIndex, Integer pageSize); + + /** + * 根据Id获得实体 + * + * @param id + * @return + */ + WxMallConfig getById(Long id); + + /** + * 保存或更新实体 + * + * @param record + */ + void saveOrUpdate(WxMallConfig record); + + /** + * 根据Id删除实体 + * + * @param id + */ + void deleteById(Long id); + + + + + + + + +} diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxMallConfigServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxMallConfigServiceImpl.java new file mode 100644 index 000000000..c1efbaa0d --- /dev/null +++ b/mallinkService/src/main/java/com/simple/service/impl/WxMallConfigServiceImpl.java @@ -0,0 +1,54 @@ +package com.simple.service.impl; + +import java.util.*; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.simple.domain.po.WxMallConfig; +import com.simple.mapper.WxMallConfigMapper; +import com.simple.service.WxMallConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.simple.common.IdWorker; + +@Service +public class WxMallConfigServiceImpl implements WxMallConfigService { + + @Autowired + WxMallConfigMapper wxMallConfigMapper; + + + @Override + public PageInfo listAsPage(WxMallConfig record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMallConfigMapper.findList(record)); + } + + @Override + public WxMallConfig getById(Long id) { + return wxMallConfigMapper.selectByPrimaryKey(id); + } + + @Override + public void saveOrUpdate(WxMallConfig record) { + if (record.getId() == null) { + //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); + IdWorker idWorker = new IdWorker(0, 0); + record.setId(idWorker.nextId()); + wxMallConfigMapper.insertSelective(record); + } else { + wxMallConfigMapper.updateByPrimaryKeySelective(record); + } + } + + @Override + public void deleteById(Long id) { + wxMallConfigMapper.deleteByPrimaryKey(id); + } + + + + + + + + +} diff --git a/mallinkService/src/main/resources/mapper/WxMallConfigMapper.xml b/mallinkService/src/main/resources/mapper/WxMallConfigMapper.xml new file mode 100644 index 000000000..0546a4bd7 --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxMallConfigMapper.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + `id`,`tenant_id`,`key`,`value`,`remark`,`create_time`,`update_time` + + + + where 1 = 1 + + + and `id` = #{id} + + + + + and `tenant_id` like concat('%', #{tenantId},'%') + + + + + and `key` like concat('%', #{key},'%') + + + + + and `value` = #{value} + + + + + and `remark` like concat('%', #{remark},'%') + + + + + and `create_time` = #{createTime} + + + + + and `update_time` = #{updateTime} + + + + and id in + + #{idItem} + + + order by ${sortColumns} + + + + + + + + + +