From 02ce38038dd2b52dc2977934d7714ba876f39b84 Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Tue, 11 Jun 2024 16:05:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E6=8B=93?= =?UTF-8?q?=E5=B1=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/user/expand/UserExpandController.java | 38 ++++ .../expand/UserExpandRouteController.java | 26 +++ .../dao/user/expand/IUserExpandDao.java | 24 +++ .../pojo/dtos/user/expand/UserExpandDTO.java | 68 +++++++ .../pojo/vos/user/expand/UserExpandVO.java | 74 ++++++++ .../user/expand/UserExpandServiceImpl.java | 131 ++++++++++++++ .../mapper/user/expand/user-expand.xml | 64 +++++++ .../templates/user/expand/save-or-update.html | 168 ++++++++++++++++++ 8 files changed, 593 insertions(+) create mode 100644 src/main/java/cn/com/tenlion/operator/controller/api/user/expand/UserExpandController.java create mode 100644 src/main/java/cn/com/tenlion/operator/controller/route/user/expand/UserExpandRouteController.java create mode 100644 src/main/java/cn/com/tenlion/operator/dao/user/expand/IUserExpandDao.java create mode 100644 src/main/java/cn/com/tenlion/operator/pojo/dtos/user/expand/UserExpandDTO.java create mode 100644 src/main/java/cn/com/tenlion/operator/pojo/vos/user/expand/UserExpandVO.java create mode 100644 src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java create mode 100644 src/main/resources/mybatis/mapper/user/expand/user-expand.xml create mode 100644 src/main/resources/templates/user/expand/save-or-update.html diff --git a/src/main/java/cn/com/tenlion/operator/controller/api/user/expand/UserExpandController.java b/src/main/java/cn/com/tenlion/operator/controller/api/user/expand/UserExpandController.java new file mode 100644 index 0000000..1a4d6f7 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/controller/api/user/expand/UserExpandController.java @@ -0,0 +1,38 @@ +package cn.com.tenlion.operator.controller.api.user.expand; + +import cn.com.tenlion.operator.pojo.dtos.user.expand.UserExpandDTO; +import cn.com.tenlion.operator.pojo.vos.user.expand.UserExpandVO; +import cn.com.tenlion.operator.service.user.expand.UserExpandServiceImpl; +import ink.wgink.annotation.CheckRequestBodyAnnotation; +import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.pojo.result.SuccessResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * @ClassName: UserExpandController + * @Description: + * @Author: wanggeng + * @Date: 2024/6/11 上午11:18 + * @Version: 1.0 + */ +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/user/expand") +public class UserExpandController { + + @Autowired + private UserExpandServiceImpl userExpandService; + + @PostMapping("save-or-update/{userId}") + @CheckRequestBodyAnnotation + public synchronized SuccessResult saveOrUpdate(@PathVariable("userId") String userId, @RequestBody UserExpandVO userExpandVO) { + userExpandService.saveOrUpdate(userId, userExpandVO); + return new SuccessResult(); + } + + @GetMapping("get/{userId}") + public UserExpandDTO get(@PathVariable("userId") String userId) { + return userExpandService.get(userId); + } + +} diff --git a/src/main/java/cn/com/tenlion/operator/controller/route/user/expand/UserExpandRouteController.java b/src/main/java/cn/com/tenlion/operator/controller/route/user/expand/UserExpandRouteController.java new file mode 100644 index 0000000..b1dcf9a --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/controller/route/user/expand/UserExpandRouteController.java @@ -0,0 +1,26 @@ +package cn.com.tenlion.operator.controller.route.user.expand; + +import ink.wgink.interfaces.consts.ISystemConstant; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.ModelAndView; + +/** + * @ClassName: UserExpandRouteController + * @Description: + * @Author: wanggeng + * @Date: 2024/6/11 上午11:04 + * @Version: 1.0 + */ +@Controller +@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/user/expand") +public class UserExpandRouteController { + + @GetMapping("save-or-update") + public ModelAndView update() { + ModelAndView modelAndView = new ModelAndView("user/expand/save-or-update"); + return modelAndView; + } + +} diff --git a/src/main/java/cn/com/tenlion/operator/dao/user/expand/IUserExpandDao.java b/src/main/java/cn/com/tenlion/operator/dao/user/expand/IUserExpandDao.java new file mode 100644 index 0000000..3790345 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/dao/user/expand/IUserExpandDao.java @@ -0,0 +1,24 @@ +package cn.com.tenlion.operator.dao.user.expand; + +import cn.com.tenlion.operator.pojo.dtos.user.expand.UserExpandDTO; +import org.springframework.stereotype.Repository; + +import java.util.Map; + +/** + * @ClassName: IUserExpandDao + * @Description: + * @Author: wanggeng + * @Date: 2024/6/11 上午11:07 + * @Version: 1.0 + */ +@Repository +public interface IUserExpandDao { + + void save(Map params); + + void update(Map params); + + UserExpandDTO get(Map params); + +} diff --git a/src/main/java/cn/com/tenlion/operator/pojo/dtos/user/expand/UserExpandDTO.java b/src/main/java/cn/com/tenlion/operator/pojo/dtos/user/expand/UserExpandDTO.java new file mode 100644 index 0000000..dd3a0d5 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/pojo/dtos/user/expand/UserExpandDTO.java @@ -0,0 +1,68 @@ +package cn.com.tenlion.operator.pojo.dtos.user.expand; + +import ink.wgink.pojo.dtos.user.UserDTO; + +/** + * @ClassName: UserExpandDTO + * @Description: + * @Author: wanggeng + * @Date: 2024/6/11 上午10:39 + * @Version: 1.0 + */ +public class UserExpandDTO extends UserDTO { + + private Long priceAdditionalPkg; + private Long priceAdditionalVideoDemo; + private Long priceAll; + private Long priceMaterial; + private Long priceMaterialAgent; + private Long priceMaterialAgentUrgent; + + public Long getPriceAdditionalPkg() { + return priceAdditionalPkg == null ? 0 : priceAdditionalPkg; + } + + public void setPriceAdditionalPkg(Long priceAdditionalPkg) { + this.priceAdditionalPkg = priceAdditionalPkg; + } + + public Long getPriceAdditionalVideoDemo() { + return priceAdditionalVideoDemo == null ? 0 : priceAdditionalVideoDemo; + } + + public void setPriceAdditionalVideoDemo(Long priceAdditionalVideoDemo) { + this.priceAdditionalVideoDemo = priceAdditionalVideoDemo; + } + + public Long getPriceAll() { + return priceAll == null ? 0 : priceAll; + } + + public void setPriceAll(Long priceAll) { + this.priceAll = priceAll; + } + + public Long getPriceMaterial() { + return priceMaterial == null ? 0 : priceMaterial; + } + + public void setPriceMaterial(Long priceMaterial) { + this.priceMaterial = priceMaterial; + } + + public Long getPriceMaterialAgent() { + return priceMaterialAgent == null ? 0 : priceMaterialAgent; + } + + public void setPriceMaterialAgent(Long priceMaterialAgent) { + this.priceMaterialAgent = priceMaterialAgent; + } + + public Long getPriceMaterialAgentUrgent() { + return priceMaterialAgentUrgent == null ? 0 : priceMaterialAgentUrgent; + } + + public void setPriceMaterialAgentUrgent(Long priceMaterialAgentUrgent) { + this.priceMaterialAgentUrgent = priceMaterialAgentUrgent; + } +} diff --git a/src/main/java/cn/com/tenlion/operator/pojo/vos/user/expand/UserExpandVO.java b/src/main/java/cn/com/tenlion/operator/pojo/vos/user/expand/UserExpandVO.java new file mode 100644 index 0000000..adcdb31 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/pojo/vos/user/expand/UserExpandVO.java @@ -0,0 +1,74 @@ +package cn.com.tenlion.operator.pojo.vos.user.expand; + +import ink.wgink.annotation.CheckNumberAnnotation; + +/** + * @ClassName: UserExpandVO + * @Description: + * @Author: wanggeng + * @Date: 2024/6/11 上午10:39 + * @Version: 1.0 + */ +public class UserExpandVO { + + @CheckNumberAnnotation(name = "拓展安装包价格", min = 0) + private Double priceAdditionalPkg; + @CheckNumberAnnotation(name = "视频教程价格", min = 0) + private Double priceAdditionalVideoDemo; + @CheckNumberAnnotation(name = "全托管价格", min = 0) + private Double priceAll; + @CheckNumberAnnotation(name = "写材料价格", min = 0) + private Double priceMaterial; + @CheckNumberAnnotation(name = "写材料+代理价格", min = 0) + private Double priceMaterialAgent; + @CheckNumberAnnotation(name = "写材料+代理(加急)价格", min = 0) + private Double priceMaterialAgentUrgent; + + public Double getPriceAdditionalPkg() { + return priceAdditionalPkg == null ? 0 : priceAdditionalPkg; + } + + public void setPriceAdditionalPkg(Double priceAdditionalPkg) { + this.priceAdditionalPkg = priceAdditionalPkg; + } + + public Double getPriceAdditionalVideoDemo() { + return priceAdditionalVideoDemo == null ? 0 : priceAdditionalVideoDemo; + } + + public void setPriceAdditionalVideoDemo(Double priceAdditionalVideoDemo) { + this.priceAdditionalVideoDemo = priceAdditionalVideoDemo; + } + + public Double getPriceAll() { + return priceAll == null ? 0 : priceAll; + } + + public void setPriceAll(Double priceAll) { + this.priceAll = priceAll; + } + + public Double getPriceMaterial() { + return priceMaterial == null ? 0 : priceMaterial; + } + + public void setPriceMaterial(Double priceMaterial) { + this.priceMaterial = priceMaterial; + } + + public Double getPriceMaterialAgent() { + return priceMaterialAgent == null ? 0 : priceMaterialAgent; + } + + public void setPriceMaterialAgent(Double priceMaterialAgent) { + this.priceMaterialAgent = priceMaterialAgent; + } + + public Double getPriceMaterialAgentUrgent() { + return priceMaterialAgentUrgent == null ? 0 : priceMaterialAgentUrgent; + } + + public void setPriceMaterialAgentUrgent(Double priceMaterialAgentUrgent) { + this.priceMaterialAgentUrgent = priceMaterialAgentUrgent; + } +} diff --git a/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java b/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java new file mode 100644 index 0000000..aa820f3 --- /dev/null +++ b/src/main/java/cn/com/tenlion/operator/service/user/expand/UserExpandServiceImpl.java @@ -0,0 +1,131 @@ +package cn.com.tenlion.operator.service.user.expand; + +import cn.com.tenlion.operator.dao.user.expand.IUserExpandDao; +import cn.com.tenlion.operator.pojo.dtos.user.expand.UserExpandDTO; +import cn.com.tenlion.operator.pojo.vos.user.expand.UserExpandVO; +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.exceptions.SearchException; +import ink.wgink.interfaces.user.IUserExpandBaseService; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.service.user.service.IUserService; +import ink.wgink.util.map.HashMapUtil; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * @ClassName: UserExpandServiceImpl + * @Description: + * @Author: wanggeng + * @Date: 2024/6/11 上午10:39 + * @Version: 1.0 + */ +@Service +public class UserExpandServiceImpl extends DefaultBaseService implements IUserExpandBaseService { + + @Autowired + private IUserExpandDao userExpandDao; + @Autowired + private IUserService userService; + + @Override + public String getRoute() { + return "route/user/expand/save-or-update"; + } + + @Override + public UserExpandDTO get(String userId) { + UserDTO userDTO = userService.get(userId); + return get(userDTO); + } + + @Override + public UserExpandDTO getByUsername(String username) { + UserDTO userDTO = userService.getByUsername(username); + return get(userDTO); + } + + private UserExpandDTO get(UserDTO userDTO) { + if (userDTO == null) { + throw new SearchException("用户不存在"); + } + Map params = getHashMap(2); + params.put("userId", userDTO.getUserId()); + UserExpandDTO userExpandDTO = userExpandDao.get(params); + if (userExpandDTO == null) { + userExpandDTO = new UserExpandDTO(); + } + BeanUtils.copyProperties(userDTO, userExpandDTO); + return userExpandDTO; + } + + @Override + public List listByUserIds(List userIds) { + return Collections.emptyList(); + } + + @Override + public List listByUsernames(List usernames) { + return Collections.emptyList(); + } + + @Override + public List list(Map map) { + return Collections.emptyList(); + } + + @Override + public SuccessResultList> listPage(ListPage listPage) { + return null; + } + + @Override + public SuccessResultList> listPageByIds(List list, ListPage listPage) { + return null; + } + + @Override + public SuccessResultList> listPageByExcludeIds(List list, ListPage listPage) { + return null; + } + + @Override + public int countDateRange(String s, String s1) { + return 0; + } + + @Override + public int count() { + return 0; + } + + @Override + public List listByKeywords(String s) { + return Collections.emptyList(); + } + + public void saveOrUpdate(String userId, UserExpandVO userExpandVO) { + Map params = getHashMap(2); + params.put("userId", userId); + UserExpandDTO userExpandDTO = userExpandDao.get(params); + userExpandVO.setPriceAdditionalPkg(userExpandVO.getPriceAdditionalPkg() * 100); + userExpandVO.setPriceAdditionalVideoDemo(userExpandVO.getPriceAdditionalVideoDemo() * 100); + userExpandVO.setPriceAll(userExpandVO.getPriceAll() * 100); + userExpandVO.setPriceMaterial(userExpandVO.getPriceMaterial() * 100); + userExpandVO.setPriceMaterialAgent(userExpandVO.getPriceMaterialAgent() * 100); + userExpandVO.setPriceMaterialAgentUrgent(userExpandVO.getPriceMaterialAgentUrgent() * 100); + params = HashMapUtil.beanToMap(userExpandVO); + params.put("userId", userId); + if (userExpandDTO == null) { + userExpandDao.save(params); + } else { + userExpandDao.update(params); + } + } +} diff --git a/src/main/resources/mybatis/mapper/user/expand/user-expand.xml b/src/main/resources/mybatis/mapper/user/expand/user-expand.xml new file mode 100644 index 0000000..3a935d7 --- /dev/null +++ b/src/main/resources/mybatis/mapper/user/expand/user-expand.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + INSERT INTO sys_user_expand ( + user_id, + price_additional_pkg, + price_additional_video_demo, + price_all, + price_material, + price_material_agent, + price_material_agent_urgent + ) VALUES ( + #{userId}, + #{priceAdditionalPkg}, + #{priceAdditionalVideoDemo}, + #{priceAll}, + #{priceMaterial}, + #{priceMaterialAgent}, + #{priceMaterialAgentUrgent} + ) + + + + UPDATE + sys_user_expand + SET + price_additional_pkg = #{priceAdditionalPkg}, + price_additional_video_demo = #{priceAdditionalVideoDemo}, + price_all = #{priceAll}, + price_material = #{priceMaterial}, + price_material_agent = #{priceMaterialAgent}, + price_material_agent_urgent = #{priceMaterialAgentUrgent} + WHERE + user_id = #{userId} + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/user/expand/save-or-update.html b/src/main/resources/templates/user/expand/save-or-update.html new file mode 100644 index 0000000..7ee0e3a --- /dev/null +++ b/src/main/resources/templates/user/expand/save-or-update.html @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + +
+
+
+
+
价格设置¥,保留两位小数,使用系统默认金额,设置为0即可
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+ + + + \ No newline at end of file