| @@ -0,0 +1,71 @@ | |||||
| package com.iformall.controller.sm; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.sm.MouldPatch; | |||||
| import com.iformall.domain.po.sm.MouldPatchSign; | |||||
| import com.iformall.domain.po.sm.UserMouldVideo; | |||||
| import com.iformall.service.sm.MouldPatchService; | |||||
| import com.iformall.service.sm.MouldPatchSignService; | |||||
| import com.iformall.service.sm.UserMouldVideoService; | |||||
| 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.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("userVideo") | |||||
| @Api(description = "模板接口") | |||||
| public class UserMouldVideoController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private UserMouldVideoService userMouldVideoService; | |||||
| @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 UserMouldVideo record, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] UserMouldVideoController::list"); | |||||
| if (record == null) record = new UserMouldVideo(); | |||||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
| final PageInfo<UserMouldVideo> page = userMouldVideoService.listAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("根据id删除接口") | |||||
| @GetMapping("/del") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "删除") | |||||
| public ResultData delete(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] UserMouldVideoController::delete"); | |||||
| userMouldVideoService.deleteById(id); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "查询") | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] UserMouldVideoController::findById"); | |||||
| UserMouldVideo userMouldVideo = userMouldVideoService.getById(id); | |||||
| return new ResultData(userMouldVideo); | |||||
| } | |||||
| } | |||||
| @@ -102,27 +102,10 @@ public class BaseController { | |||||
| }); | }); | ||||
| } | } | ||||
| @Deprecated | |||||
| public String getTenantId() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String tenantId = (String) request.getAttribute(Constant.TENANT_ID); | |||||
| return tenantId; | |||||
| } | |||||
| public TenantEntity getTenantInfo() { | public TenantEntity getTenantInfo() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String tenantId = (String) request.getAttribute(Constant.TENANT_ID); | |||||
| String parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID); | |||||
| TenantEntity tenantEntity = new TenantEntity() ; | |||||
| tenantEntity.setTenantId(tenantId); | |||||
| tenantEntity.setParentTenantId(parentTenantId); | |||||
| return tenantEntity; | |||||
| return new TenantEntity(); | |||||
| } | } | ||||
| public String getFinalTenantId() { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| return tenantEntity.getFinalTenantId(); | |||||
| } | |||||
| public Long getMemberId() { | public Long getMemberId() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| @@ -132,140 +115,6 @@ public class BaseController { | |||||
| } | } | ||||
| return memberId; | return memberId; | ||||
| } | } | ||||
| public WxAppinfo getCurrentApp() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| WxAppinfo appInfo = (WxAppinfo) request.getAttribute(Constant.APP_INFO); | |||||
| if(appInfo == null){ | |||||
| throw new MallinkException(ErrorCode.USER_APPINFO_NOT_EXIST); | |||||
| } | |||||
| return appInfo; | |||||
| } | |||||
| public EnumPayVersion getPayVersion() { | |||||
| WxAppinfo appinfo = getCurrentApp(); | |||||
| if ( null == appinfo) { | |||||
| throw new MallinkException(ErrorCode.USER_APPINFO_NOT_EXIST); | |||||
| } | |||||
| WxPayAccount payAccount = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, Constant.payaccountPrev+appinfo.getPayId(), WxPayAccount.class); | |||||
| if (null == payAccount) { | |||||
| payAccount = wxPayAccountService.getById(appinfo.getPayId()); | |||||
| if (null != payAccount) { | |||||
| RedisCacheUtils.cache(objectCommonRedisTemplate, Constant.payaccountPrev+appinfo.getPayId(), payAccount, 24*60*60); | |||||
| } | |||||
| } | |||||
| if (null == payAccount) { | |||||
| throw new MallinkException(ErrorCode.USER_APPINFO_NOFUND_PAYACCOUNT); | |||||
| } | |||||
| return EnumPayVersion.getEnum(payAccount.getPayVersion()); | |||||
| } | |||||
| /** | |||||
| * 微信端获取当前用户 wx_c_user,非会员 | |||||
| * 请尽量多用getTenantId, getUserId | |||||
| */ | |||||
| public CUser getCUser() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY); | |||||
| if (baseuser == null) { | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| if (baseuser.getRealUser() == null) { | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| CUser user = null; | |||||
| if(EnumAppPlat.WX.equals(baseuser.getAppPlat())){ | |||||
| user = RedisCacheUtils.getFieldObject(baseuser, "realUser", WxCUser.class); | |||||
| }else if(EnumAppPlat.TOUTIAO.equals(baseuser.getAppPlat())){ | |||||
| user = RedisCacheUtils.getFieldObject(baseuser, "realUser", TtCUser.class); | |||||
| }else{ | |||||
| user = RedisCacheUtils.getFieldObject(baseuser, "realUser", CUser.class); | |||||
| } | |||||
| if(user == null){ | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| // TenantEntity tenantEntity = getTenantInfo(); | |||||
| // if (user.getTenantId() == null) { | |||||
| // user.setTenantId(tenantEntity.getTenantId()); | |||||
| // } | |||||
| // if (user.getParentTenantId() == null) { | |||||
| // user.setParentTenantId(tenantEntity.getParentTenantId()); | |||||
| // } | |||||
| return user; | |||||
| } | |||||
| public EnumPayWay getPayWay(){ | |||||
| EnumAppPlat appPlat = getCUser().getAppPlat(); | |||||
| if(EnumAppPlat.WX.equals(appPlat)){ | |||||
| return EnumPayWay.PAY_WAY_WECHAT; | |||||
| }else if (EnumAppPlat.TOUTIAO.equals(appPlat)){ | |||||
| return EnumPayWay.PAY_WAY_TT; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| public void removeCacheCUser() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY); | |||||
| cUserTokenService.removeTokenCache(baseuser.getToken()); | |||||
| } | |||||
| private WxCUserBasicInfo getCacheMember(Long memberId,String finalTenantId,String key,long seconds) throws MallinkException { | |||||
| // 缓存 | |||||
| WxCUserBasicInfo member = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, key, WxCUserBasicInfo.class); | |||||
| if(null == member) { | |||||
| member = wxCUserBasicInfoService.getById(memberId,finalTenantId); | |||||
| if (member == null) { | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| RedisCacheUtils.cache(objectCommonRedisTemplate, key, member, seconds); | |||||
| } | |||||
| return member; | |||||
| } | |||||
| public WxCUserBasicInfo getCacheMember() throws MallinkException { | |||||
| Long memberId = getMemberId(); | |||||
| String key = "webapp:member:"+memberId; | |||||
| return getCacheMember(memberId,getFinalTenantId(), key, 3600*24*3); | |||||
| } | |||||
| /*此处缓存短暂时间,因为积分、成长值记录*/ | |||||
| public WxCUserBasicInfo getShortCacheMember(Long memberId,String finalTenantId) throws Exception { | |||||
| String key = "webapp:short:member:"+memberId; | |||||
| return getCacheMember(memberId,finalTenantId, key, 100); | |||||
| } | |||||
| public void removeCacheMember(Long memberId) { | |||||
| String key = "webapp:member:"+memberId; | |||||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, key); | |||||
| String shortKey = "webapp:short:member:"+memberId; | |||||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, shortKey); | |||||
| } | |||||
| public WxMaService getWeappService(String appId) { | |||||
| if(isFmOpen) { | |||||
| return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| } else { | |||||
| WxAppinfo appinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); | |||||
| if (appinfo == null) { | |||||
| return null; | |||||
| } | |||||
| WxMaService service = maUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| } | |||||
| public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | |||||
| if(!isFmOpen) { | |||||
| WxMaService service = maUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| public String getIpAddr() { | public String getIpAddr() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| @@ -273,23 +122,4 @@ public class BaseController { | |||||
| return ipaddress; | return ipaddress; | ||||
| } | } | ||||
| /** | |||||
| * 根据扩展字段获取tenantId | |||||
| */ | |||||
| public String getTenantId(String attach){ | |||||
| if(StringUtils.isNotBlank(attach)){ | |||||
| try{ | |||||
| Map<String,Object> map = JSONObject.parseObject(attach, Map.class); | |||||
| String tenantId = map.get("tenantId").toString(); | |||||
| if(StringUtils.isNotBlank(tenantId)){ | |||||
| return tenantId; | |||||
| } | |||||
| }catch (Exception e){ | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -45,7 +45,7 @@ public class MouldPatchController extends BaseController { | |||||
| record.setSendType(EnumMouldSendType.auto.getCode()); | record.setSendType(EnumMouldSendType.auto.getCode()); | ||||
| record.setStatus(EnumaMouldPatchStatus.put_on.getCode()); | record.setStatus(EnumaMouldPatchStatus.put_on.getCode()); | ||||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | ||||
| final PageInfo<MouldPatch> page = mouldPatchService.listAsPage(record, pageNum, pageSize); | |||||
| final PageInfo<MouldPatch> page = mouldPatchService.cListAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | return new ResultData(page); | ||||
| } | } | ||||
| @@ -0,0 +1,89 @@ | |||||
| package com.iformall.controller; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.sm.MouldPatch; | |||||
| import com.iformall.domain.po.sm.MouldPatchSign; | |||||
| import com.iformall.domain.po.sm.UserMouldVideo; | |||||
| import com.iformall.enums.EnumMouldSendType; | |||||
| import com.iformall.enums.EnumaMouldPatchStatus; | |||||
| import com.iformall.service.sm.MouldPatchService; | |||||
| import com.iformall.service.sm.MouldPatchSignService; | |||||
| import com.iformall.service.sm.UserMouldVideoService; | |||||
| 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.web.bind.annotation.*; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("/api/userVideo") | |||||
| @Api(description = "模板接口") | |||||
| public class UserMouldVideoController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private UserMouldVideoService userMouldVideoService; | |||||
| @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 UserMouldVideo record, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] UserMouldVideoController::list"); | |||||
| if (record == null) record = new UserMouldVideo(); | |||||
| record.setUserId(getMemberId()); | |||||
| record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
| final PageInfo<UserMouldVideo> page = userMouldVideoService.cListAsPage(record, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("根据id查询接口") | |||||
| @GetMapping("/findById") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData findById(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] MouldPatchController::findById"); | |||||
| UserMouldVideo userMouldVideo = userMouldVideoService.getById(id); | |||||
| return new ResultData(userMouldVideo); | |||||
| } | |||||
| @ApiOperation("新增接口") | |||||
| @PostMapping("saveOrUpdate") | |||||
| public ResultData saveOrUpdate(@RequestBody UserMouldVideo record) { | |||||
| logger.debug("[" + getIpAddr() + "] MouldPatchController::saveOrUpdate"); | |||||
| record.setUserId(getMemberId()); | |||||
| return userMouldVideoService.saveOrUpdate(record); | |||||
| } | |||||
| @ApiOperation("生成视频") | |||||
| @PostMapping("createVideo") | |||||
| public ResultData create(@RequestBody UserMouldVideo record) { | |||||
| logger.debug("[" + getIpAddr() + "] MouldPatchController::saveOrUpdate"); | |||||
| if(record.getId() == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| } | |||||
| UserMouldVideo mouldVideo = userMouldVideoService.getById(record.getId()); | |||||
| if(mouldVideo == null || !mouldVideo.getUserId().equals(getMemberId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到用户数据"); | |||||
| } | |||||
| UserMouldVideo mouldVideoUpd = new UserMouldVideo(); | |||||
| mouldVideoUpd.setId(record.getId()); | |||||
| // mouldVideoUpd.setVideoId(); | |||||
| // mouldVideoUpd.setVideoPath(); | |||||
| // mouldVideoUpd.setVideoTime(); | |||||
| return userMouldVideoService.saveOrUpdate(mouldVideoUpd); | |||||
| } | |||||
| } | |||||
| @@ -1,27 +1,15 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; | |||||
| import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.google.code.kaptcha.Producer; | import com.google.code.kaptcha.Producer; | ||||
| import com.iformall.annotation.AuthIgnore; | import com.iformall.annotation.AuthIgnore; | ||||
| import com.iformall.annotation.TenantIgnore; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.vo.MallUserInfoVo; | |||||
| import com.iformall.domain.vo.WxCUserVo; | |||||
| import com.iformall.domain.vo.WxLevelMerchantCVo; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.cuser.CUserServiceFactory; | import com.iformall.service.cuser.CUserServiceFactory; | ||||
| import com.iformall.service.wechat.FmOpenService; | |||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.IPUtil; | |||||
| import com.iformall.utils.PasswordHelper; | import com.iformall.utils.PasswordHelper; | ||||
| import com.iformall.utils.RedisCacheUtils; | import com.iformall.utils.RedisCacheUtils; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| @@ -30,31 +18,19 @@ import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.apache.commons.io.IOUtils; | import org.apache.commons.io.IOUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.apache.shiro.SecurityUtils; | |||||
| import org.apache.shiro.subject.Subject; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Qualifier; | import org.springframework.beans.factory.annotation.Qualifier; | ||||
| import org.springframework.data.redis.core.RedisTemplate; | import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.context.request.RequestContextHolder; | |||||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||||
| import javax.imageio.ImageIO; | import javax.imageio.ImageIO; | ||||
| import javax.servlet.ServletException; | |||||
| import javax.servlet.ServletOutputStream; | import javax.servlet.ServletOutputStream; | ||||
| import javax.servlet.http.Cookie; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.awt.image.BufferedImage; | import java.awt.image.BufferedImage; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.io.PrintWriter; | |||||
| import java.math.BigDecimal; | |||||
| import java.net.URLEncoder; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.List; | |||||
| import java.util.Map; | import java.util.Map; | ||||
| @RestController | @RestController | ||||
| @@ -250,455 +226,4 @@ public class WxUserGrantController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| @PostMapping("/updateScene") | |||||
| @ApiOperation(value = "用户更新scene", notes = "{\"scene\":\"string\"}") | |||||
| public ResultData updateScene(@RequestBody Map<String, String> map) { | |||||
| logger.info(map.toString()); | |||||
| String scene = map.get("scene"); | |||||
| CUser user = getCUser(); | |||||
| if (StringUtils.isBlank(user.getScene()) || | |||||
| user.getScene().equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| if(StringUtils.isNotBlank(scene) && scene.equalsIgnoreCase(Constant.UNDEFINED)) { | |||||
| user.setScene(scene); | |||||
| cuserFactory.getCUserService(user.getAppPlat()).updateScene(user); | |||||
| removeCacheCUser(); | |||||
| } | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("/updateLBS") | |||||
| @ApiOperation(value = "用户更新位置信息", notes = "{\"latitude\":\"string\",\"longitude\":\"string\"}") | |||||
| public ResultData updateLBS(@RequestBody Map<String, String> map) { | |||||
| logger.info(map.toString()); | |||||
| String longitude = map.get("longitude"); | |||||
| String latitude = map.get("latitude"); | |||||
| CUser user = getCUser(); | |||||
| if (!StringUtils.isBlank(longitude)) | |||||
| user.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); | |||||
| if (!StringUtils.isBlank(latitude)) | |||||
| user.setLatitude(BigDecimal.valueOf(Double.valueOf(latitude))); | |||||
| cuserFactory.getCUserService(user.getAppPlat()).updateLBS(user); | |||||
| return new ResultData(); | |||||
| } | |||||
| @PostMapping("/updateExtInfo") | |||||
| @ApiOperation(value = "用户更新扩展信息(手机)", notes = "{\"systemInfo\":\"string\"}") | |||||
| public ResultData updateExtInfo(@RequestBody Map<String, String> map) { | |||||
| logger.debug(map.toString()); | |||||
| String systemInfo = map.get("systemInfo"); | |||||
| CUser user = getCUser(); | |||||
| if (StringUtils.isNotBlank(systemInfo)) { | |||||
| JSONObject extraInfo = new JSONObject(); | |||||
| extraInfo.put("systemInfo", JSONObject.parseObject(systemInfo)); | |||||
| user.setExtraInfo(extraInfo.toJSONString()); | |||||
| } | |||||
| cuserFactory.getCUserService(user.getAppPlat()).updateExtInfo(user); | |||||
| return new ResultData(); | |||||
| } | |||||
| /** | |||||
| * 获取用户的昵称等信息 | |||||
| * | |||||
| * @param map | |||||
| * @return | |||||
| */ | |||||
| @PostMapping("/getUserInfo") | |||||
| @ApiOperation(value = "授权后获取用户的昵称,unionId等信息", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | |||||
| public ResultData getUserInfo(@RequestBody Map<String, String> map) { | |||||
| logger.info(map.toString()); | |||||
| Map resultMap = new HashMap(); | |||||
| String encryptedData = map.get("encryptedData"); | |||||
| String iv = map.get("iv"); | |||||
| if (StringUtils.isBlank(encryptedData)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "encryptedData不能为空"); | |||||
| } | |||||
| if (StringUtils.isBlank(iv)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "iv不能为空"); | |||||
| } | |||||
| CUser user = getCUser(); | |||||
| if (user != null) { | |||||
| WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(user.getAppId()); | |||||
| if(wxAppinfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
| } | |||||
| try { | |||||
| // 解密用户信息 | |||||
| cuserFactory.getCUserService(user.getAppPlat()).decryptUserInfo(encryptedData, iv,user,wxAppinfo,isFmOpen); | |||||
| resultMap.put("openId", user.getOpenId()); | |||||
| resultMap.put("unionId", user.getUnionId()); | |||||
| resultMap.put("msg", "获取用户信息成功!"); | |||||
| return new ResultData(resultMap); | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage(), e); | |||||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "解密并保存出错", resultMap); | |||||
| } | |||||
| } else { | |||||
| return new ResultData(ErrorCode.USER_LOGIN_FAILED); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 授权后获取用户的手机号等信息 | |||||
| * | |||||
| * @param map | |||||
| * @return | |||||
| */ | |||||
| @PostMapping("/getUserPhone") | |||||
| @ApiOperation(value = "授权后获取用户的手机号", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | |||||
| public ResultData getUserPhone(@RequestBody Map<String, String> map) { | |||||
| logger.info(map.toString()); | |||||
| String encryptedData = map.get("encryptedData"); | |||||
| String iv = map.get("iv"); | |||||
| //登录凭证不能为空 | |||||
| if (StringUtils.isBlank(encryptedData)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "encryptedData 不能为空"); | |||||
| } | |||||
| if (StringUtils.isBlank(iv)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "iv 不能为空"); | |||||
| } | |||||
| Map resultMap = new HashMap(); | |||||
| CUser user = getCUser(); | |||||
| if (user == null) { | |||||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(user.getAppId()); | |||||
| if(wxAppinfo == null){ | |||||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
| } | |||||
| try { | |||||
| // 解密 | |||||
| String phone = cuserFactory.getCUserService(user.getAppPlat()).decryptPhoneNoInfo(encryptedData, iv, user, wxAppinfo, isFmOpen); | |||||
| resultMap.put("msg", "授权手机成功!"); | |||||
| resultMap.put("phone", phone); | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| }catch (Exception e) { | |||||
| this.logger.error(e.getMessage(), e); | |||||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "解密并保存出错", resultMap); | |||||
| } | |||||
| return new ResultData(resultMap); | |||||
| } | |||||
| /** | |||||
| * 检查微信用户状态 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @RequestMapping("/checkWechatStatus") | |||||
| @ApiOperation(value = "判断用户是否完成授权", notes = "") | |||||
| public ResultData checkWechatStatus() { | |||||
| Map resultMap = new HashMap(); | |||||
| CUser user = getCUser(); | |||||
| if (StringUtils.isNoneEmpty(user.getNickName())) { | |||||
| resultMap.put("nickName", user.getNickName()); | |||||
| } else { | |||||
| logger.warn("用户昵称未授权,跳转到用户授权页!"); | |||||
| return new ResultData(ErrorCode.NICK_NAME_NOT_FOUND.getCode(), "用户昵称未授权,请跳转到用户昵称授权页!", resultMap); | |||||
| } | |||||
| if (StringUtils.isNotBlank(user.getPhone())) { | |||||
| resultMap.put("phone", user.getPhone()); | |||||
| } else { | |||||
| if (StringUtils.isBlank(user.getPhone())) { | |||||
| logger.warn("用户手机号未授权,跳转到授权手机号页!"); | |||||
| return new ResultData(ErrorCode.PHONE_NOT_FOUND.getCode(), "用户手机号未授权,请跳转到授权手机号页!", resultMap); | |||||
| } | |||||
| if (user.getPhone().contains("*")) { | |||||
| logger.warn("用户手机号已加密,跳转到手工输入手机号页!"); | |||||
| return new ResultData(ErrorCode.PHONE_IS_ENCRYPTED.getCode(), "用户手机号已加密,手工输入手机号页!", resultMap); | |||||
| } | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "是老用户,已完成用户昵称/手机号授权", resultMap); | |||||
| } | |||||
| /** | |||||
| * 检查用户状态 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @RequestMapping("/checkUserStatus") | |||||
| @ApiOperation(value = "判断用户是否完成昵称授权", notes = "") | |||||
| public ResultData checkUserStatus() { | |||||
| Map resultMap = new HashMap(); | |||||
| CUser user = getCUser(); | |||||
| if (StringUtils.isNoneEmpty(user.getNickName())) { | |||||
| resultMap.put("nickName", user.getNickName()); | |||||
| } else { | |||||
| logger.warn("用户昵称未授权,跳转到用户授权页!"); | |||||
| return new ResultData(ErrorCode.NICK_NAME_NOT_FOUND.getCode(), "用户昵称未授权,请跳转到用户昵称授权页!", resultMap); | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "是老用户,已完成用户昵称授权", resultMap); | |||||
| } | |||||
| /** | |||||
| * 检查用户状态 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @RequestMapping("/checkPhoneStatus") | |||||
| @ApiOperation(value = "判断用户是否完成手机授权", notes = "") | |||||
| public ResultData checkPhoneStatus() { | |||||
| Map resultMap = new HashMap(); | |||||
| CUser user = getCUser(); | |||||
| if (StringUtils.isNotBlank(user.getPhone())) { | |||||
| resultMap.put("phone", user.getPhone()); | |||||
| } else { | |||||
| if (StringUtils.isBlank(user.getPhone())) { | |||||
| logger.warn("用户手机号未授权,跳转到授权手机号页!"); | |||||
| return new ResultData(ErrorCode.PHONE_NOT_FOUND.getCode(), "用户手机号未授权,请跳转到授权手机号页!", resultMap); | |||||
| } | |||||
| if (user.getPhone().contains("*")) { | |||||
| logger.warn("用户手机号已加密,跳转到手工输入手机号页!"); | |||||
| return new ResultData(ErrorCode.PHONE_IS_ENCRYPTED.getCode(), "用户手机号已加密,手工输入手机号页!", resultMap); | |||||
| } | |||||
| } | |||||
| return new ResultData(Result.SUCCESS, "是老用户,已完成手机号授权", resultMap); | |||||
| } | |||||
| // @RedisCache //导致更改手机号后数据更新不及时 | |||||
| @ApiOperation("获取当前用户信息") | |||||
| @GetMapping("/userinfo") | |||||
| public ResultData getUserInfo() { | |||||
| CUser user = getCUser(); | |||||
| WxCUserVo userVo = new WxCUserVo(); | |||||
| org.springframework.beans.BeanUtils.copyProperties(user, userVo); | |||||
| userVo.setScore(0); | |||||
| userVo.setCredit(0); | |||||
| if(user.basicInfoIs()){ | |||||
| WxCUserBasicInfo wxCUserBasicInfo; | |||||
| try { | |||||
| wxCUserBasicInfo = getShortCacheMember(user.getUserId(),getFinalTenantId()); | |||||
| //WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(user.getUserId()); | |||||
| if (wxCUserBasicInfo != null) { | |||||
| userVo.setAvatarUrl(wxCUserBasicInfo.getAvatarUrl()); | |||||
| userVo.setNickName(wxCUserBasicInfo.getNickName()); | |||||
| userVo.setScore(wxCUserBasicInfo.getPoins()); | |||||
| userVo.setCredit(wxCUserBasicInfo.getCredit()); | |||||
| userVo.setName(wxCUserBasicInfo.getName()); | |||||
| userVo.setBirthdate(wxCUserBasicInfo.getBirthdate()); | |||||
| userVo.setSex(wxCUserBasicInfo.getSex()); | |||||
| userVo.setHeight(wxCUserBasicInfo.getHeight()); | |||||
| userVo.setWeight(wxCUserBasicInfo.getWeight()); | |||||
| userVo.setAddress(wxCUserBasicInfo.getAddress()); | |||||
| userVo.setStatus(wxCUserBasicInfo.getStatus()); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error("userinfo error.",e); | |||||
| } | |||||
| } | |||||
| if (userVo.getScore() == null) | |||||
| userVo.setScore(0); | |||||
| Integer levelScore = 0; | |||||
| Integer levelTarget= 0; | |||||
| userVo.setLevelName(WxLevelConfigService.DEFAULT_LEVEL); | |||||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(getTenantInfo()); | |||||
| if (levelList.size() > 0) | |||||
| levelTarget = levelList.get(0).getPoints(); | |||||
| for (int i = 0; i<levelList.size(); i++) { | |||||
| WxLevelConfig levelConfig = levelList.get(i); | |||||
| if (userVo.getScore() >= levelConfig.getPoints()) { | |||||
| userVo.setLevelId(levelConfig.getId()); | |||||
| userVo.setLevelName(levelConfig.getLevel()); | |||||
| levelScore = levelConfig.getPoints(); | |||||
| if (i+1 < levelList.size()) | |||||
| levelTarget = levelList.get(i+1).getPoints(); | |||||
| } | |||||
| } | |||||
| if (levelTarget == 0) { | |||||
| userVo.setUpgradePercent(0); | |||||
| userVo.setUpgradeScore(0); | |||||
| } else if(levelScore == levelTarget) { | |||||
| userVo.setUpgradePercent(100); | |||||
| userVo.setUpgradeScore(0); | |||||
| } else { | |||||
| userVo.setUpgradePercent((userVo.getScore()-levelScore)*100/(levelTarget-levelScore)); | |||||
| userVo.setUpgradeScore(levelTarget-userVo.getScore()); | |||||
| } | |||||
| return new ResultData(userVo); | |||||
| } | |||||
| /** | |||||
| * 授权后获取用户的手机号等信息 | |||||
| * | |||||
| * @param map | |||||
| * @return | |||||
| */ | |||||
| @PostMapping("/getWeRunData") | |||||
| @ApiOperation(value = "获取用户过去三十天微信运动步数", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | |||||
| public ResultData getWeRunData(@RequestBody Map<String, String> map) { | |||||
| logger.debug(map.toString()); | |||||
| String encryptedData = map.get("encryptedData"); | |||||
| String iv = map.get("iv"); | |||||
| //登录凭证不能为空 | |||||
| if (StringUtils.isBlank(encryptedData)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "encryptedData 不能为空"); | |||||
| } | |||||
| if (StringUtils.isBlank(iv)) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "iv 不能为空"); | |||||
| } | |||||
| CUser user = getCUser(); | |||||
| String session_key = user.getSessionKey(); | |||||
| try { | |||||
| // 解密 | |||||
| String weRunDataStr = WxMaCryptUtils.decrypt(session_key, encryptedData, iv); | |||||
| if (null != weRunDataStr) { | |||||
| Object obj = JSON.parse(weRunDataStr); | |||||
| return new ResultData(obj); | |||||
| } else { | |||||
| return new ResultData(ErrorCode.WE_RUN_DATA_DECODE_ERR); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| this.logger.error(e.getMessage(), e); | |||||
| return new ResultData(ErrorCode.WE_RUN_DATA_DECODE_ERR); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 用户更新信息 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @PostMapping("/updateUserInfo") | |||||
| @ApiOperation(value = "用户更新信息", notes = "") | |||||
| public ResultData updateUserInfo(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) { | |||||
| if (wxCUserBasicInfo == null) | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| Long memberId; | |||||
| try { | |||||
| memberId = getMemberId(); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(Result.ERROR,e.getMessage()); | |||||
| } | |||||
| if (StringUtils.isNotBlank(wxCUserBasicInfo.getNickName()) | |||||
| || StringUtils.isNotBlank(wxCUserBasicInfo.getAvatarUrl()) | |||||
| || StringUtils.isNotBlank(wxCUserBasicInfo.getName()) | |||||
| || wxCUserBasicInfo.getBirthdate() != null | |||||
| || wxCUserBasicInfo.getSex() != null | |||||
| || StringUtils.isNotBlank(wxCUserBasicInfo.getAddress())) { | |||||
| WxCUserBasicInfo record = new WxCUserBasicInfo(); | |||||
| record.setId(memberId); | |||||
| record.setNickName(wxCUserBasicInfo.getNickName()); | |||||
| record.setAvatarUrl(wxCUserBasicInfo.getAvatarUrl()); | |||||
| record.setName(wxCUserBasicInfo.getName()); | |||||
| record.setBirthdate(wxCUserBasicInfo.getBirthdate()); | |||||
| record.setSex(wxCUserBasicInfo.getSex()); | |||||
| record.setWeight(wxCUserBasicInfo.getWeight()); | |||||
| record.setHeight(wxCUserBasicInfo.getHeight()); | |||||
| record.setAddress(wxCUserBasicInfo.getAddress()); | |||||
| record.setUpdateDate(new Date()); | |||||
| record.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||||
| wxCUserBasicInfoService.update(record); | |||||
| removeCacheMember(memberId); | |||||
| try{ | |||||
| //推送猫酷 | |||||
| mallCooUserInfoService.pullByMobileMsg(tenantEntity, record.getId()); | |||||
| }catch(Exception e){ | |||||
| logger.error("发送同步会员消息异常"); | |||||
| } | |||||
| wxScoreRulesService.addScore(tenantEntity,EnumScoreType.COMPLETE_INFO, record); | |||||
| //增加积分 | |||||
| WxCreditHistory wxCreditHistory = new WxCreditHistory(); | |||||
| wxCreditHistory.setCUserId(record.getId()); | |||||
| // wxCreditHistory.updateTenantInfo(tenantEntity); | |||||
| wxCreditHistory.setTenantId(tenantEntity.getFinalTenantId()); | |||||
| wxCreditHistory.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||||
| wxCreditHistory.setCreateDate(new Date()); | |||||
| wxCreditHistory.setCreditType(EnumScoreType.COMPLETE_INFO.getCode()); | |||||
| wxCreditHistory.setChangePurpose(EnumScoreType.COMPLETE_INFO.getMessage()); | |||||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||||
| wxCreditHistory.setOperatorId(memberId); | |||||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory,tenantEntity.getTenantId()); | |||||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT, record,tenantEntity,null); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| /** | |||||
| * 获取用户折扣率 | |||||
| * | |||||
| * @return | |||||
| */ | |||||
| @RequestMapping("/getDiscountInfo") | |||||
| @ApiOperation(value = "获取用户折扣率", notes = "") | |||||
| public ResultData getDiscountInfo() { | |||||
| WxCUserBasicInfo member; | |||||
| try { | |||||
| Long memberId = getMemberId(); | |||||
| member = wxCUserBasicInfoService.getById(memberId,getFinalTenantId()); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(Result.ERROR,e.getMessage()); | |||||
| } | |||||
| List<WxLevelConfig> levelList = wxLevelConfigService.getByTenantInfo(getTenantInfo()); | |||||
| String level = WxLevelConfigService.DEFAULT_LEVEL; | |||||
| Long levelId = 0L; | |||||
| for (WxLevelConfig levelConfig : levelList) { | |||||
| if (member.getPoins() >= levelConfig.getPoints()) { | |||||
| if (levelConfig.getDiscountEnable().equals(EnumLevelConfigDiscountStatus.ENABLE.getCode())) | |||||
| levelId = levelConfig.getId(); | |||||
| level = levelConfig.getLevel(); | |||||
| } | |||||
| } | |||||
| WxLevelMerchant levelMerchant = new WxLevelMerchant(); | |||||
| levelMerchant.updateTenantInfo(getTenantInfo()); | |||||
| levelMerchant.setLevelId(levelId); | |||||
| List<WxLevelMerchantCVo> levelMerchantList = wxLevelConfigService.findListCVo(levelMerchant); | |||||
| Map<String, Object> result = new HashMap(); | |||||
| result.put("id", member.getId()); | |||||
| result.put("level", level); | |||||
| result.put("levelMerchantList", levelMerchantList); | |||||
| return new ResultData(result); | |||||
| } | |||||
| @PostMapping("/updateMsg") | |||||
| @ApiOperation(value = "updateMsg", notes = "{\"id\":\"string\"}") | |||||
| public ResultData updateMsg() { | |||||
| CUser user = getCUser(); | |||||
| cuserFactory.getCUserService(user.getAppPlat()).updateMsgCount(user); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("获取当前用户二维码") | |||||
| @GetMapping("/userinfoQrCode") | |||||
| public ResultData getUserinfoQrCode() { | |||||
| CUser user = getCUser(); | |||||
| if(user.basicInfoIs()){ | |||||
| String qrCode = ""; | |||||
| if(StringUtils.isBlank(user.getQrCode())){ | |||||
| qrCode = cuserFactory.getCUserService(user.getAppPlat()).updateQrCode(user); | |||||
| }else{ | |||||
| qrCode = user.getQrCode(); | |||||
| } | |||||
| return new ResultData(qrCode); | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.USER_IS_NOT_MEMBER); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -73,6 +73,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| if(basicInfo == null){ | if(basicInfo == null){ | ||||
| throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | throw new MallinkException(ErrorCode.NET_TOKEN_INVALID.getCode(), "URL:" + request.getRequestURL() + " token失效,请重新登录"); | ||||
| } | } | ||||
| request.setAttribute(Constant.LOGIN_MEMBER_KEY,basicInfo.getId()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -96,7 +96,7 @@ public class MouldPatch extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") | @io.swagger.annotations.ApiModelProperty(value="购买须知",name="remark") | ||||
| private String remark; | private String remark; | ||||
| @io.swagger.annotations.ApiModelProperty(value="模板文件",name="mould_path") | |||||
| @io.swagger.annotations.ApiModelProperty(value="模板文件",name="mouldPath") | |||||
| private String mouldPath; | private String mouldPath; | ||||
| @io.swagger.annotations.ApiModelProperty(value="EnumaMouldPatchStatus 状态(-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废)",name="status") | @io.swagger.annotations.ApiModelProperty(value="EnumaMouldPatchStatus 状态(-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废)",name="status") | ||||
| @@ -26,6 +26,7 @@ public interface MouldPatchService { | |||||
| * @return | * @return | ||||
| */ | */ | ||||
| PageInfo<MouldPatch> listAsPage(MouldPatch record, Integer pageIndex, Integer pageSize); | PageInfo<MouldPatch> listAsPage(MouldPatch record, Integer pageIndex, Integer pageSize); | ||||
| PageInfo<MouldPatch> cListAsPage(MouldPatch record, Integer pageIndex, Integer pageSize); | |||||
| /** | /** | ||||
| * 根据Id获得实体 | * 根据Id获得实体 | ||||
| @@ -0,0 +1,42 @@ | |||||
| package com.iformall.service.sm; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.sm.MouldPatch; | |||||
| import com.iformall.domain.po.sm.UserMouldVideo; | |||||
| public interface UserMouldVideoService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<UserMouldVideo> listAsPage(UserMouldVideo record, Integer pageIndex, Integer pageSize); | |||||
| PageInfo<UserMouldVideo> cListAsPage(UserMouldVideo record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据Id获得实体 | |||||
| * | |||||
| * @param id | |||||
| * @return | |||||
| */ | |||||
| UserMouldVideo getById(Long id); | |||||
| /** | |||||
| * 保存或更新实体 | |||||
| * | |||||
| * @param record | |||||
| */ | |||||
| ResultData saveOrUpdate(UserMouldVideo record); | |||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| */ | |||||
| void deleteById(Long id); | |||||
| } | |||||
| @@ -34,6 +34,11 @@ public class MouldPatchServiceImpl implements MouldPatchService { | |||||
| public PageInfo<MouldPatch> listAsPage(MouldPatch record, Integer pageIndex, Integer pageSize) { | public PageInfo<MouldPatch> listAsPage(MouldPatch record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> mouldPatchMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> mouldPatchMapper.findList(record)); | ||||
| } | } | ||||
| @Override | |||||
| public PageInfo<MouldPatch> cListAsPage(MouldPatch record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> mouldPatchMapper.findCList(record)); | |||||
| } | |||||
| @Override | @Override | ||||
| public MouldPatch getById(Long id) { | public MouldPatch getById(Long id) { | ||||
| @@ -0,0 +1,64 @@ | |||||
| package com.iformall.service.sm.impl; | |||||
| import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.sm.UserMouldVideo; | |||||
| import com.iformall.mapper.UserMouldVideoMapper; | |||||
| import com.iformall.service.sm.UserMouldVideoService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.Date; | |||||
| @Service | |||||
| public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| UserMouldVideoMapper userMouldVideoMapper; | |||||
| @Override | |||||
| public PageInfo<UserMouldVideo> listAsPage(UserMouldVideo record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userMouldVideoMapper.findList(record)); | |||||
| } | |||||
| @Override | |||||
| public PageInfo<UserMouldVideo> cListAsPage(UserMouldVideo record, Integer pageIndex, Integer pageSize) { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> userMouldVideoMapper.findCList(record)); | |||||
| } | |||||
| @Override | |||||
| public UserMouldVideo getById(Long id) { | |||||
| return userMouldVideoMapper.selectById(id); | |||||
| } | |||||
| @Override | |||||
| public ResultData saveOrUpdate(UserMouldVideo record) { | |||||
| Date now = new Date(); | |||||
| if (record.getId() == null) { | |||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setCreateDate(now); | |||||
| record.setUpdateDate(now); | |||||
| userMouldVideoMapper.insert(record); | |||||
| } else { | |||||
| record.setUpdateDate(now); | |||||
| userMouldVideoMapper.updateById(record); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| @Override | |||||
| public void deleteById(Long id) { | |||||
| userMouldVideoMapper.deleteById(id); | |||||
| } | |||||
| } | |||||