| @@ -0,0 +1,127 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.config.WechatWebProperties; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxWeappInfo; | |||
| import com.iformall.enums.EnumGroupSupport; | |||
| import com.iformall.enums.EnumInvestUserType; | |||
| import com.iformall.enums.EnumUserAdmin; | |||
| import com.iformall.service.*; | |||
| import com.iformall.shiro.PasswordHelper; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| 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.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.util.Assert; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| @RestController | |||
| @Api(description = "MiniappTheme相关接口") | |||
| @RequestMapping("wxMiniappTheme") | |||
| public class WxMiniappThemeController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxMiniappThemeService wxMiniappThemeService; | |||
| @ApiOperation("查询MiniappTheme列表") | |||
| @GetMapping(value = "/list") | |||
| @SystemControllerLog(description = "查询MiniappTheme列表") | |||
| @TenantIgnore | |||
| public ResultData getList(@ModelAttribute WxMiniappTheme wxMiniappTheme, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::getList"); | |||
| try { | |||
| if(wxMiniappTheme == null){ | |||
| wxMiniappTheme = new WxMiniappTheme(); | |||
| } | |||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| PageInfo<WxMiniappTheme> page = wxMiniappThemeService.listAsPage(wxMiniappTheme, pageNum, pageSize); | |||
| if(page.getTotal() == 0){ | |||
| wxMiniappTheme.setTenantId("1"); | |||
| page = wxMiniappThemeService.listAsPage(wxMiniappTheme, pageNum, pageSize); | |||
| } | |||
| return new ResultData(page); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| @ApiOperation("根据id使之生效") | |||
| @GetMapping("/updateEffect") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "根据id使之生效") | |||
| @TenantIgnore | |||
| public ResultData updateEffect(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::updateEffect"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappThemeService.updateEffect(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "-删除") | |||
| @TenantIgnore | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::delete"); | |||
| if(id == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappThemeService.updateDel(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "-添加") | |||
| @TenantIgnore | |||
| public ResultData add(@RequestBody WxMiniappTheme wxMiniappTheme) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::add"); | |||
| if(wxMiniappTheme == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| wxMiniappThemeService.saveOrUpdate(wxMiniappTheme); | |||
| return new ResultData(); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "集团-更新") | |||
| public ResultData update(@RequestBody WxMiniappTheme wxMiniappTheme) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::update"); | |||
| if(wxMiniappTheme == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| wxMiniappThemeService.saveOrUpdate(wxMiniappTheme); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,58 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMiniappTheme; | |||
| import com.iformall.domain.po.WxMiniappThemeValue; | |||
| import com.iformall.service.WxMiniappThemeService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiOperation; | |||
| 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 | |||
| @Api(description = "/api/MiniappTheme相关接口") | |||
| @RequestMapping("wxMiniappTheme") | |||
| public class WxMiniappThemeController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxMiniappThemeService wxMiniappThemeService; | |||
| @ApiOperation("查询MiniappTheme列表") | |||
| @GetMapping(value = "/getOne") | |||
| @TenantIgnore | |||
| public ResultData getOne() { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::getOne"); | |||
| try { | |||
| WxMiniappTheme wxMiniappTheme = new WxMiniappTheme(); | |||
| wxMiniappTheme.setStatus(0); | |||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| List<WxMiniappTheme> list = wxMiniappThemeService.findList(wxMiniappTheme); | |||
| if(list == null || list.size() == 0){ | |||
| wxMiniappTheme.setTenantId("1"); | |||
| list = wxMiniappThemeService.findList(wxMiniappTheme); | |||
| } | |||
| if(list == null || list.size() == 0){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| WxMiniappTheme wxMiniappTheme1 = list.get(0); | |||
| List<WxMiniappThemeValue> childList = wxMiniappThemeService.findChildList(wxMiniappTheme1.getId()); | |||
| wxMiniappTheme1.setWxMiniappThemeValue(childList); | |||
| return new ResultData(wxMiniappTheme1); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import lombok.Data; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @TableName(value = "wx_miniapp_theme") | |||
| @Data | |||
| public class WxMiniappTheme implements Serializable { | |||
| protected Long id; | |||
| protected String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="名称",name="name") | |||
| private String name; | |||
| @io.swagger.annotations.ApiModelProperty(value="说明",name="remarks") | |||
| private String remarks; | |||
| @io.swagger.annotations.ApiModelProperty(value="预览图片",name="previewUrl") | |||
| private String previewUrl; | |||
| @io.swagger.annotations.ApiModelProperty(value="0:生效中,1:失效",name="status") | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @TableField(exist = false) | |||
| private List<WxMiniappThemeValue> wxMiniappThemeValue; | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import lombok.Data; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_miniapp_theme_deploy") | |||
| @Data | |||
| public class WxMiniappThemeDeploy implements Serializable { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="名称",name="name") | |||
| private String name; | |||
| @io.swagger.annotations.ApiModelProperty(value="说明",name="remarks") | |||
| private String remarks; | |||
| @io.swagger.annotations.ApiModelProperty(value="图标",name="defaultIcon") | |||
| private String defaultIcon; | |||
| @io.swagger.annotations.ApiModelProperty(value="样式",name="defaultStyle") | |||
| private String defaultStyle; | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import lombok.Data; | |||
| import java.io.Serializable; | |||
| @TableName(value = "wx_miniapp_theme_value") | |||
| @Data | |||
| public class WxMiniappThemeValue implements Serializable { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="主题ID",name="miniappThemeId") | |||
| private Long miniappThemeId; | |||
| @io.swagger.annotations.ApiModelProperty(value="配置ID",name="miniappDeployId") | |||
| private Long miniappDeployId; | |||
| @io.swagger.annotations.ApiModelProperty(value="图标",name="icon") | |||
| private String icon; | |||
| @io.swagger.annotations.ApiModelProperty(value="样式",name="styleClass") | |||
| private String styleClass; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="名称",name="name") | |||
| private String name; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="说明",name="remarks") | |||
| private String remarks; | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxMiniappTheme; | |||
| import com.iformall.domain.po.WxMiniappThemeDeploy; | |||
| import com.iformall.domain.po.WxMiniappThemeValue; | |||
| import java.util.List; | |||
| /** | |||
| * @author | |||
| */ | |||
| public interface WxMiniappThemeMapper extends CommonMapper<WxMiniappTheme, Long> { | |||
| List<WxMiniappTheme> findList(WxMiniappTheme record); | |||
| List<WxMiniappThemeValue> findChildList(Long id); | |||
| /** | |||
| * 使生效 | |||
| * @param record | |||
| */ | |||
| void updateStatus(WxMiniappTheme record); | |||
| /** | |||
| * 伪删除 | |||
| * @param record | |||
| */ | |||
| void updateDel(WxMiniappTheme record); | |||
| /** | |||
| * 查配置 | |||
| * @return | |||
| */ | |||
| List<WxMiniappThemeDeploy> findDeployList(); | |||
| /** | |||
| * 删value | |||
| * @param record | |||
| */ | |||
| void deleteValue(WxMiniappTheme record); | |||
| /** | |||
| * 加value | |||
| * @param record | |||
| */ | |||
| void insertValue(WxMiniappThemeValue record); | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.*; | |||
| import java.util.List; | |||
| public interface WxMiniappThemeService { | |||
| List<WxMiniappTheme> findList(WxMiniappTheme record); | |||
| PageInfo<WxMiniappTheme> listAsPage(WxMiniappTheme record, Integer pageIndex, Integer pageSize); | |||
| WxMiniappTheme getById(WxMiniappTheme record); | |||
| List<WxMiniappThemeValue> findChildList(Long id); | |||
| /** | |||
| * 使生效 | |||
| * @param id | |||
| * @return | |||
| */ | |||
| void updateEffect(Long id); | |||
| /** | |||
| * 伪删除 | |||
| * @param id | |||
| */ | |||
| void updateDel(Long id); | |||
| /** | |||
| * 查配置 | |||
| * @return | |||
| */ | |||
| List<WxMiniappThemeDeploy> findDeployList(); | |||
| void saveOrUpdate(WxMiniappTheme record); | |||
| /** | |||
| * 根据Theme删value | |||
| * @param id | |||
| */ | |||
| void deleteValue(Long id); | |||
| /** | |||
| * 加value | |||
| * @param record | |||
| */ | |||
| void insertValue(WxMiniappThemeValue record); | |||
| } | |||
| @@ -0,0 +1,103 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.WxMiniappTheme; | |||
| import com.iformall.domain.po.WxMiniappThemeDeploy; | |||
| import com.iformall.domain.po.WxMiniappThemeValue; | |||
| import com.iformall.mapper.WxMiniappThemeMapper; | |||
| import com.iformall.service.WxMiniappThemeService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Service | |||
| public class WxMiniappThemeServiceImpl implements WxMiniappThemeService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxMiniappThemeMapper wxMiniappThemeMapper; | |||
| @Override | |||
| public List<WxMiniappTheme> findList(WxMiniappTheme record) { | |||
| return wxMiniappThemeMapper.findList(record); | |||
| } | |||
| @Override | |||
| public PageInfo<WxMiniappTheme> listAsPage(WxMiniappTheme record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMiniappThemeMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxMiniappTheme getById(WxMiniappTheme record) { | |||
| WxMiniappTheme wxMiniappTheme = wxMiniappThemeMapper.selectById(record.getId()); | |||
| List<WxMiniappThemeValue> childList = wxMiniappThemeMapper.findChildList(record.getId()); | |||
| wxMiniappTheme.setWxMiniappThemeValue(childList); | |||
| return wxMiniappTheme; | |||
| } | |||
| @Override | |||
| public List<WxMiniappThemeValue> findChildList(Long id) { | |||
| return wxMiniappThemeMapper.findChildList(id); | |||
| } | |||
| @Override | |||
| public void updateEffect(Long id) { | |||
| WxMiniappTheme wxMiniappTheme = wxMiniappThemeMapper.selectById(id); | |||
| wxMiniappThemeMapper.updateStatus(wxMiniappTheme); | |||
| } | |||
| @Override | |||
| public void updateDel(Long id) { | |||
| WxMiniappTheme record = new WxMiniappTheme(); | |||
| record.setId(id); | |||
| wxMiniappThemeMapper.updateDel(record); | |||
| } | |||
| @Override | |||
| public List<WxMiniappThemeDeploy> findDeployList() { | |||
| return wxMiniappThemeMapper.findDeployList(); | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxMiniappTheme record) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| Date curr = new Date(); | |||
| if (record.getId() == null) { | |||
| record.setId(idWorker.nextId()); | |||
| record.setCreateDate(curr); | |||
| record.setUpdateDate(curr); | |||
| wxMiniappThemeMapper.insert(record); | |||
| } else { | |||
| record.setUpdateDate(curr); | |||
| wxMiniappThemeMapper.updateById(record); | |||
| wxMiniappThemeMapper.deleteValue(record); | |||
| } | |||
| if(record.getWxMiniappThemeValue() != null && record.getWxMiniappThemeValue().size() > 0){ | |||
| for (WxMiniappThemeValue value:record.getWxMiniappThemeValue()) { | |||
| value.setId(idWorker.nextId()); | |||
| wxMiniappThemeMapper.insertValue(value); | |||
| } | |||
| } | |||
| } | |||
| @Override | |||
| public void deleteValue(Long id) { | |||
| WxMiniappTheme record = new WxMiniappTheme(); | |||
| record.setId(id); | |||
| wxMiniappThemeMapper.deleteValue(record); | |||
| } | |||
| @Override | |||
| public void insertValue(WxMiniappThemeValue record) { | |||
| wxMiniappThemeMapper.insertValue(record); | |||
| } | |||
| } | |||
| @@ -0,0 +1,76 @@ | |||
| <?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.iformall.mapper.WxMiniappThemeMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMiniappTheme"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" property="tenantId" /> | |||
| <result column="name" jdbcType="VARCHAR" property="name" /> | |||
| <result column="remarks" property="remarks" /> | |||
| <result column="preview_url" property="previewUrl" /> | |||
| <result column="status" property="status" /> | |||
| <result column="create_date" property="createDate" /> | |||
| <result column="update_date" property="updateDate" /> | |||
| <!--<collection fetchType="eager" property="wxMiniappThemeValue" ofType="com.iformall.domain.po.WxMiniappThemeValue" column="id" select="findChildList"/>--> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`name`,`remarks`,`preview_url`,`status`,`create_date`,`update_date` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where del_status = 0 | |||
| <if test=" null != id "> and `id` = #{id} </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != name and '' != name "> and `name` like concat('%', #{name},'%') </if> | |||
| <if test=" null != status"> | |||
| and `status` = #{status} | |||
| </if> | |||
| <if test=" null == sortColumns"> order by create_date asc </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxMiniappTheme" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_miniapp_theme | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findChildList" resultType="com.iformall.domain.po.WxMiniappThemeValue"> | |||
| SELECT mtv.id id,mtv.miniapp_theme_id miniappThemeId,mtv.miniapp_deploy_id miniappDeployId, | |||
| mtd.name name,mtd.remarks remarks,ifnull(mtv.icon,mtd.default_icon) icon,ifnull(mtv.style_class,mtd.default_style) styleClass | |||
| FROM wx_miniapp_theme_deploy mtd | |||
| left join wx_miniapp_theme_value mtv on mtv.miniapp_deploy_id = mtd.id | |||
| WHERE mtv.miniapp_theme_id = #{id}; | |||
| </select> | |||
| <update id="updateStatus" parameterType="com.iformall.domain.po.WxMiniappTheme"> | |||
| update wx_miniapp_theme set `status` = 0, update_date = now() where id = #{id} and del_status = 0; | |||
| update wx_miniapp_theme set `status` = 1, update_date = now() where tenant_id = #{tenantId} and id != #{id} and `status` = 0 and del_status = 0 ; | |||
| </update> | |||
| <update id="updateDel" parameterType="com.iformall.domain.po.WxMiniappTheme"> | |||
| update wx_miniapp_theme set `del_status` = 1, update_date = now() where id = #{id}; | |||
| </update> | |||
| <select id="findDeployList" resultType="com.iformall.domain.po.WxMiniappThemeDeploy"> | |||
| SELECT id,`name`,remarks,default_icon defaultIcon,default_style defaultStyle | |||
| FROM wx_miniapp_theme_deploy; | |||
| </select> | |||
| <delete id="deleteValue" parameterType="com.iformall.domain.po.WxMiniappTheme"> | |||
| delete from wx_miniapp_theme_value where miniapp_theme_id = #{id}; | |||
| </delete> | |||
| <insert id="insertValue" parameterType="com.iformall.domain.po.WxMiniappThemeValue"> | |||
| INSERT INTO wx_miniapp_theme_value (id,miniapp_theme_id,miniapp_deploy_id,icon,style_class) | |||
| VALUES (#{id},#{miniappThemeId},#{miniappDeployId},#{icon},#{styleClass}); | |||
| </insert> | |||
| </mapper> | |||