| @@ -5,31 +5,38 @@ import java.text.ParseException; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import com.simple.domain.po.MallUserInfo; | |||
| import com.simple.shiro.UserSession; | |||
| import org.apache.shiro.SecurityUtils; | |||
| import org.springframework.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| @RestController | |||
| public class BaseController { | |||
| @InitBinder | |||
| public void InitBinder(WebDataBinder dataBinder) { | |||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||
| public void setAsText(String value) { | |||
| try { | |||
| setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | |||
| } catch(ParseException e) { | |||
| try { | |||
| setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||
| } catch (ParseException e1) { | |||
| setValue(null); | |||
| } | |||
| } | |||
| } | |||
| public String getAsText() { | |||
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); | |||
| } | |||
| }); | |||
| } | |||
| @InitBinder | |||
| public void InitBinder(WebDataBinder dataBinder) { | |||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||
| public void setAsText(String value) { | |||
| try { | |||
| setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | |||
| } catch(ParseException e) { | |||
| try { | |||
| setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||
| } catch (ParseException e1) { | |||
| setValue(null); | |||
| } | |||
| } | |||
| } | |||
| public String getAsText() { | |||
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); | |||
| } | |||
| }); | |||
| } | |||
| public MallUserInfo getUser(){ | |||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| return user; | |||
| } | |||
| } | |||
| @@ -1,8 +1,9 @@ | |||
| package com.simple.controller; | |||
| import com.simple.domain.dto.WxCouponChannelDto; | |||
| import com.simple.domain.po.MallUserInfo; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.util.Assert; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| @@ -15,6 +16,9 @@ import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxCouponChannel") | |||
| public class WxCouponChannelController extends BaseController | |||
| @@ -22,6 +26,7 @@ public class WxCouponChannelController extends BaseController | |||
| @Autowired | |||
| private WxCouponChannelService wxCouponChannelService; | |||
| private Logger logger = Logger.getLogger(WxCouponChannelController.class); | |||
| @ApiOperation("分页列表接口") | |||
| @@ -66,12 +71,17 @@ public class WxCouponChannelController extends BaseController | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCouponChannelService.getById(id)); | |||
| } | |||
| /*@ApiOperation("根据") | |||
| @GetMapping("/add") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCouponChannelService.getById(id)); | |||
| }*/ | |||
| @ApiOperation("批量新增") | |||
| @PostMapping("/addbatch") | |||
| public ResultData findById(@RequestBody WxCouponChannelDto wxCouponChannelDto) { | |||
| String[] ids = wxCouponChannelDto.getCouponIds().split(","); | |||
| String[] channelId = wxCouponChannelDto.getChannelId().split(","); | |||
| List<WxCouponChannel> list = new ArrayList<>(); | |||
| MallUserInfo user = getUser(); | |||
| wxCouponChannelService.addBatch(ids,channelId,user.getTenantId()); | |||
| return new ResultData(); | |||
| } | |||
| @@ -60,8 +60,8 @@ public class WxCouponController extends BaseController | |||
| String[] arys = wxCoupon.getBusiness().split(","); | |||
| wxCoupon.setBusiness(JSON.toJSONString(arys)); | |||
| } | |||
| wxCouponService.saveOrUpdate(wxCoupon); | |||
| return new ResultData(); | |||
| Long id = wxCouponService.saveOrUpdate(wxCoupon); | |||
| return new ResultData(id); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @@ -74,8 +74,8 @@ public class WxCouponController extends BaseController | |||
| String[] arys = wxCoupon.getBusiness().split(","); | |||
| wxCoupon.setBusiness(JSON.toJSONString(arys)); | |||
| } | |||
| wxCouponService.saveOrUpdate(wxCoupon); | |||
| return new ResultData(); | |||
| Long id = wxCouponService.saveOrUpdate(wxCoupon); | |||
| return new ResultData(id); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @@ -0,0 +1,62 @@ | |||
| package com.simple.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxGroup; | |||
| import com.simple.service.WxGroupService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxGroup") | |||
| public class WxGroupController extends BaseController | |||
| { | |||
| @Autowired | |||
| private WxGroupService wxGroupService; | |||
| private Logger logger = Logger.getLogger(WxGroupController.class); | |||
| @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 WxGroup wxGroup,Integer pageNum, Integer pageSize) { | |||
| if (null == wxGroup) wxGroup = new WxGroup(); | |||
| final PageInfo<WxGroup> page = wxGroupService.listAsPage(wxGroup, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxGroup wxGroup) { | |||
| //Assert.notNull(wxGroup.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxGroupService.saveOrUpdate(wxGroup); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxGroup wxGroup) { | |||
| wxGroupService.saveOrUpdate(wxGroup); | |||
| return new ResultData(); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true) | |||
| public ResultData delete(String id) { | |||
| wxGroupService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="String", paramType = "query",required=true) | |||
| public ResultData findById(String id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxGroupService.getById(id)); | |||
| } | |||
| } | |||
| @@ -62,6 +62,12 @@ public class WxMsgModelController extends BaseController | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxMsgModelService.getById(id)); | |||
| } | |||
| @ApiOperation("获取所有数据") | |||
| @GetMapping("getmodellist") | |||
| public ResultData getmodellist() { | |||
| return wxMsgModelService.getmodellist(); | |||
| } | |||
| } | |||
| @@ -1,19 +1,16 @@ | |||
| package com.simple.controller; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.util.Assert; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.Result; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMsgSignature; | |||
| import com.simple.service.WxMsgSignatureService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.log4j.Logger; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxMsgSignature") | |||
| @@ -65,7 +62,12 @@ public class WxMsgSignatureController extends BaseController | |||
| public ResultData findById(Long id) { | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxMsgSignatureService.getById(id)); | |||
| } | |||
| @ApiOperation("获取所有数据") | |||
| @GetMapping("getsignaturelist") | |||
| public ResultData getmodellist() { | |||
| return wxMsgSignatureService.getsignaturelist(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| package com.simple.domain.dto; | |||
| import java.io.Serializable; | |||
| public class WxCouponChannelDto implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| private Long couponId; | |||
| private String couponIds; | |||
| private String channelId; | |||
| public String getChannelId() { | |||
| return channelId; | |||
| } | |||
| public void setChannelId(String channelId) { | |||
| this.channelId = channelId; | |||
| } | |||
| public Long getCouponId() { | |||
| return couponId; | |||
| } | |||
| public void setCouponId(Long couponId) { | |||
| this.couponId = couponId; | |||
| } | |||
| public String getCouponIds() { | |||
| return couponIds; | |||
| } | |||
| public void setCouponIds(String couponIds) { | |||
| this.couponIds = couponIds; | |||
| } | |||
| } | |||
| @@ -1,12 +1,12 @@ | |||
| package com.simple.domain.po; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.*; | |||
| import java.util.*; | |||
| import java.math.*; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import javax.persistence.Id; | |||
| import java.io.Serializable; | |||
| @Table(name = "wx_coupon_channel") | |||
| public class WxCouponChannel implements Serializable { | |||
| @@ -19,6 +19,7 @@ public class WxCouponChannel implements Serializable { | |||
| protected List<String> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public Long getId() { | |||
| return id; | |||
| @@ -124,7 +125,6 @@ public class WxCouponChannel implements Serializable { | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| @@ -154,7 +154,7 @@ public class WxCouponChannel implements Serializable { | |||
| } | |||
| } | |||
| public void setSortColumns(WxCouponChannel.Field... fields) | |||
| public void setSortColumns(Field... fields) | |||
| { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| @@ -169,9 +169,9 @@ public class WxCouponChannel implements Serializable { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| } | |||
| public void setSortColumns(String sortColumns) | |||
| { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| @@ -0,0 +1,189 @@ | |||
| package com.simple.domain.po; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "wx_group") | |||
| public class WxGroup implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected String id; | |||
| @Transient | |||
| protected List<String> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| public String getId() { | |||
| return id; | |||
| } | |||
| public void setId(String id) { | |||
| this.id = id; | |||
| } | |||
| public String getSortColumns() { | |||
| return sortColumns; | |||
| } | |||
| public List<String> getIds() { | |||
| return ids; | |||
| } | |||
| public void setIds(List<String> ids) { | |||
| this.ids = ids; | |||
| } | |||
| /*商场名**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商场名",name="name") | |||
| private String name; | |||
| /*国家**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="国家",name="country") | |||
| private String country; | |||
| /*省**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="省",name="province") | |||
| private String province; | |||
| /*城市**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="城市",name="city") | |||
| private String city; | |||
| /*地址**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="地址",name="addr") | |||
| private String addr; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="longitude") | |||
| private String longitude; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="latitude") | |||
| private String latitude; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="createtime") | |||
| private Date createtime; | |||
| /***/ | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="logurl") | |||
| private String logurl; | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String _name) { | |||
| name = _name; | |||
| } | |||
| public String getCountry() { | |||
| return country; | |||
| } | |||
| public void setCountry(String _country) { | |||
| country = _country; | |||
| } | |||
| public String getProvince() { | |||
| return province; | |||
| } | |||
| public void setProvince(String _province) { | |||
| province = _province; | |||
| } | |||
| public String getCity() { | |||
| return city; | |||
| } | |||
| public void setCity(String _city) { | |||
| city = _city; | |||
| } | |||
| public String getAddr() { | |||
| return addr; | |||
| } | |||
| public void setAddr(String _addr) { | |||
| addr = _addr; | |||
| } | |||
| public String getLongitude() { | |||
| return longitude; | |||
| } | |||
| public void setLongitude(String _longitude) { | |||
| longitude = _longitude; | |||
| } | |||
| public String getLatitude() { | |||
| return latitude; | |||
| } | |||
| public void setLatitude(String _latitude) { | |||
| latitude = _latitude; | |||
| } | |||
| public Date getCreatetime() { | |||
| return createtime; | |||
| } | |||
| public void setCreatetime(Date _createtime) { | |||
| createtime = _createtime; | |||
| } | |||
| public String getLogurl() { | |||
| return logurl; | |||
| } | |||
| public void setLogurl(String _logurl) { | |||
| logurl = _logurl; | |||
| } | |||
| public static enum Field | |||
| { | |||
| Id_ASC("`id` ASC"),Id_DESC("`id` DESC") | |||
| ,Name_ASC("`name` ASC"),Name_DESC("`name` DESC") | |||
| ,Country_ASC("`country` ASC"),Country_DESC("`country` DESC") | |||
| ,Province_ASC("`province` ASC"),Province_DESC("`province` DESC") | |||
| ,City_ASC("`city` ASC"),City_DESC("`city` DESC") | |||
| ,Addr_ASC("`addr` ASC"),Addr_DESC("`addr` DESC") | |||
| ,Longitude_ASC("`longitude` ASC"),Longitude_DESC("`longitude` DESC") | |||
| ,Latitude_ASC("`latitude` ASC"),Latitude_DESC("`latitude` DESC") | |||
| ,Createtime_ASC("`createtime` ASC"),Createtime_DESC("`createtime` DESC") | |||
| ,Logurl_ASC("`logurl` ASC"),Logurl_DESC("`logurl` 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(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(","); | |||
| List<Field> fList = new 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)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,17 @@ | |||
| package com.simple.mapper; | |||
| import com.simple.common.CommonMapper; | |||
| import com.simple.domain.po.WxGroup; | |||
| import java.util.List; | |||
| public interface WxGroupMapper extends CommonMapper<WxGroup, String> { | |||
| List<WxGroup> findList(WxGroup wxGroup); | |||
| } | |||
| @@ -37,6 +37,8 @@ public interface WxCouponChannelService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| void addBatch(String[] ids,String[] channelId,String tanantId); | |||
| @@ -30,7 +30,7 @@ public interface WxCouponService { | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxCoupon record); | |||
| Long saveOrUpdate(WxCoupon record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| @@ -0,0 +1,48 @@ | |||
| package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxGroup; | |||
| public interface WxGroupService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param offset | |||
| * @param limit | |||
| * @return | |||
| */ | |||
| PageInfo<WxGroup> listAsPage(WxGroup record, Integer pageIndex, Integer pageSize); | |||
| /** | |||
| * 根据Id获得实体 | |||
| * | |||
| * @param id | |||
| * @return | |||
| */ | |||
| WxGroup getById(String id); | |||
| /** | |||
| * 保存或更新实体 | |||
| * | |||
| * @param record | |||
| */ | |||
| void saveOrUpdate(WxGroup record); | |||
| /** | |||
| * 根据Id删除实体 | |||
| * | |||
| * @param id | |||
| */ | |||
| void deleteById(String id); | |||
| } | |||
| @@ -38,12 +38,12 @@ public interface WxMsgModelService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| ResultData getmodellist(); | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.simple.service; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMsgSignature; | |||
| public interface WxMsgSignatureService { | |||
| @@ -37,12 +38,8 @@ public interface WxMsgSignatureService { | |||
| * @param id | |||
| */ | |||
| void deleteById(Long id); | |||
| ResultData getsignaturelist(); | |||
| } | |||
| @@ -3,18 +3,23 @@ package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxCoupon; | |||
| import com.simple.domain.po.WxCouponChannel; | |||
| import com.simple.mapper.WxCouponChannelMapper; | |||
| import com.simple.service.WxCouponChannelService; | |||
| import com.simple.service.WxCouponService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.simple.common.IdWorker; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| @Service | |||
| public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| @Autowired | |||
| WxCouponChannelMapper wxCouponChannelMapper; | |||
| @Autowired | |||
| WxCouponService wxCouponService; | |||
| @Override | |||
| @@ -43,12 +48,34 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| public void deleteById(Long id) { | |||
| wxCouponChannelMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| @Transactional | |||
| public void addBatch(String[] ids,String[] channelId,String tanantId) { | |||
| for (String targetIdstr:channelId) { | |||
| Integer targetId = Integer.parseInt(targetIdstr); | |||
| for (String couponidstr:ids) { | |||
| Long couponid = Long.parseLong(couponidstr); | |||
| addCuponChannel(couponid,targetId,tanantId); | |||
| } | |||
| } | |||
| } | |||
| public void addCuponChannel(Long couponid,Integer channelId,String tanantId){ | |||
| WxCoupon wxCouponUP = new WxCoupon(); | |||
| wxCouponUP.setId(couponid); | |||
| wxCouponUP.setStatus(1); | |||
| wxCouponService.saveOrUpdate(wxCouponUP); | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.setCouponId(couponid); | |||
| wxCouponChannel.setCouponStatus(1); | |||
| wxCouponChannel.setTargetAd(channelId); | |||
| wxCouponChannel.setTenantId(tanantId); | |||
| saveOrUpdate(wxCouponChannel); | |||
| } | |||
| } | |||
| @@ -29,7 +29,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxCoupon record) { | |||
| public Long saveOrUpdate(WxCoupon record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| @@ -38,6 +38,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| } else { | |||
| wxCouponMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| return record.getId(); | |||
| } | |||
| @Override | |||
| @@ -0,0 +1,51 @@ | |||
| package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.domain.po.WxGroup; | |||
| import com.simple.mapper.WxGroupMapper; | |||
| import com.simple.service.WxGroupService; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @Service | |||
| public class WxGroupServiceImpl implements WxGroupService { | |||
| @Autowired | |||
| WxGroupMapper wxGroupMapper; | |||
| @Override | |||
| public PageInfo<WxGroup> listAsPage(WxGroup record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxGroupMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxGroup getById(String id) { | |||
| return wxGroupMapper.selectByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxGroup record) { | |||
| if (record.getId() == null) { | |||
| record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| wxGroupMapper.insertSelective(record); | |||
| } else { | |||
| wxGroupMapper.updateByPrimaryKeySelective(record); | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteById(String id) { | |||
| wxGroupMapper.deleteByPrimaryKey(id); | |||
| } | |||
| } | |||
| @@ -58,16 +58,18 @@ public class WxMsgCallbackServiceImpl implements WxMsgCallbackService { | |||
| wxMsgConfig.setBid(bid); | |||
| String tenantid=null; | |||
| List<WxMsgConfig> list = wxMsgConfigMapper.findList(wxMsgConfig); | |||
| if(list.size()==1){ | |||
| tenantid=list.get(0).getTenantId(); | |||
| } | |||
| List<WxMsgCallback> wxMsgCallbacks = JSONArray.parseArray(item, WxMsgCallback.class); | |||
| if(list.size()==1) { | |||
| List<WxMsgCallback> wxMsgCallbacks = JSONArray.parseArray(item, WxMsgCallback.class); | |||
| wxMsgConfig = list.get(0); | |||
| wxMsgConfig.setRemains(wxMsgConfig.getRemains() - wxMsgCallbacks.size()); | |||
| wxMsgConfigMapper.updateByPrimaryKeySelective(wxMsgConfig); | |||
| for(WxMsgCallback wxMsgCallback:wxMsgCallbacks){ | |||
| wxMsgCallback.setTenantId(tenantid); | |||
| wxMsgCallback.setSign(sign); | |||
| wxMsgCallback.setCreatetime(new Date()); | |||
| wxMsgCallbackMapper.insertSelective(wxMsgCallback); | |||
| for (WxMsgCallback wxMsgCallback : wxMsgCallbacks) { | |||
| wxMsgCallback.setTenantId(tenantid); | |||
| wxMsgCallback.setSign(sign); | |||
| wxMsgCallback.setCreatetime(new Date()); | |||
| wxMsgCallbackMapper.insertSelective(wxMsgCallback); | |||
| } | |||
| } | |||
| } | |||
| @@ -122,12 +122,14 @@ public class WxMsgModelServiceImpl implements WxMsgModelService { | |||
| public void deleteById(Long id) { | |||
| wxMsgModelMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public ResultData getmodellist() { | |||
| WxMsgModel wxMsgModel = new WxMsgModel(); | |||
| wxMsgModel.setTenantId("1"); | |||
| List<WxMsgModel> list = wxMsgModelMapper.findList(wxMsgModel); | |||
| return new ResultData(list); | |||
| } | |||
| } | |||
| @@ -47,18 +47,24 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| //2手机多条以逗号分隔,直接通过实体得到wxmsg.getphones | |||
| //3通过标签 | |||
| String phones=wxMsg.getPhones(); | |||
| if(!phones.equals("")){ | |||
| if(!wxMsg.getExcelpath().equals("")) | |||
| if(phones.equals("")){ | |||
| if(null!=wxMsg.getExcelpath() && !wxMsg.getExcelpath().equals("")) | |||
| phones=parseexcle(wxMsg.getExcelpath()); | |||
| else | |||
| phones=parselabel(wxMsg.getLabel()); | |||
| } | |||
| if(phones.equals("")){ | |||
| return new ResultData(Result.SUCCESS, "您需要添加要发送的手机号"); | |||
| } | |||
| if (wxMsg.getId() == null) { | |||
| //草稿 | |||
| if (wxMsg.getSendstatus() == 2) { | |||
| if (wxMsg.getStatus() == 2) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsg.setId(idWorker.nextId()); | |||
| wxMsg.setTenantId("1"); | |||
| wxMsg.setCreatetime(new Date()); | |||
| wxMsgMapper.insertSelective(wxMsg); | |||
| return new ResultData(Result.SUCCESS, "已保存到草稿箱"); | |||
| @@ -72,13 +78,15 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| wxMsg.setStatus(0); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsg.setId(idWorker.nextId()); | |||
| wxMsg.setTenantId("1"); | |||
| wxMsg.setCreatetime(new Date()); | |||
| wxMsgMapper.insertSelective(wxMsg); | |||
| return new ResultData(Result.SUCCESS, "短信会在预设时间发送"); | |||
| } | |||
| } else { | |||
| //草稿 | |||
| if (wxMsg.getSendstatus() == 2) { | |||
| if (wxMsg.getStatus() == 2) { | |||
| wxMsgMapper.updateByPrimaryKeySelective(wxMsg); | |||
| return new ResultData(Result.SUCCESS, "已保存到草稿箱"); | |||
| } | |||
| @@ -179,6 +187,8 @@ public class WxMsgServiceImpl implements WxMsgService { | |||
| if (wxMsg.getId() == null) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMsg.setId(idWorker.nextId()); | |||
| wxMsg.setTenantId("1"); | |||
| wxMsg.setCreatetime(new Date()); | |||
| wxMsgMapper.insertSelective(wxMsg); | |||
| } else { | |||
| wxMsgMapper.updateByPrimaryKeySelective(wxMsg); | |||
| @@ -3,6 +3,8 @@ package com.simple.service.impl; | |||
| import java.util.*; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.simple.common.ResultData; | |||
| import com.simple.domain.po.WxMsgModel; | |||
| import com.simple.domain.po.WxMsgSignature; | |||
| import com.simple.mapper.WxMsgSignatureMapper; | |||
| import com.simple.service.WxMsgSignatureService; | |||
| @@ -45,12 +47,14 @@ public class WxMsgSignatureServiceImpl implements WxMsgSignatureService { | |||
| public void deleteById(Long id) { | |||
| wxMsgSignatureMapper.deleteByPrimaryKey(id); | |||
| } | |||
| @Override | |||
| public ResultData getsignaturelist() { | |||
| WxMsgSignature wxMsgSignature = new WxMsgSignature(); | |||
| wxMsgSignature.setTenantId("1"); | |||
| List<WxMsgSignature> list = wxMsgSignatureMapper.findList(wxMsgSignature); | |||
| return new ResultData(list); | |||
| } | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| <?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.simple.mapper.WxGroupMapper"> | |||
| <resultMap id="BaseResultMap" type="com.simple.domain.po.WxGroup"> | |||
| <id column="id" jdbcType="INTEGER" property="id" /> | |||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||
| <result column="country" jdbcType="VARCHAR" property="country" /> | |||
| <result column="province" jdbcType="VARCHAR" property="province" /> | |||
| <result column="city" jdbcType="VARCHAR" property="city" /> | |||
| <result column="addr" jdbcType="VARCHAR" property="addr" /> | |||
| <result column="longitude" jdbcType="VARCHAR" property="longitude" /> | |||
| <result column="latitude" jdbcType="VARCHAR" property="latitude" /> | |||
| <result column="createtime" jdbcType="TIMESTAMP" property="createtime" /> | |||
| <result column="logurl" jdbcType="VARCHAR" property="logurl" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`name`,`country`,`province`,`city`,`addr`,`longitude`,`latitude`,`createtime`,`logurl` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> and `id` = #{id} </if> | |||
| <if test=" null != name "> and `name` = #{name} </if> | |||
| <if test=" null != country "> and `country` = #{country} </if> | |||
| <if test=" null != province "> and `province` = #{province} </if> | |||
| <if test=" null != city "> and `city` = #{city} </if> | |||
| <if test=" null != addr "> and `addr` = #{addr} </if> | |||
| <if test=" null != longitude "> and `longitude` = #{longitude} </if> | |||
| <if test=" null != latitude "> and `latitude` = #{latitude} </if> | |||
| <if test=" null != createtime "> and `createtime` = #{createtime} </if> | |||
| <if test=" null != logurl "> and `logurl` = #{logurl} </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.simple.domain.po.WxGroup" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> from wx_group | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||