| @@ -153,8 +153,8 @@ public class ShiroConfig { | |||
| //配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | |||
| filterChainDefinitionMap.put("/logout", "authc"); | |||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| // filterChainDefinitionMap.put("/**", "anon"); | |||
| // filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| filterChainDefinitionMap.put("/**", "anon"); | |||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||
| @@ -13,6 +13,7 @@ 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.EnumThemeType; | |||
| import com.iformall.enums.EnumUserAdmin; | |||
| import com.iformall.service.*; | |||
| import com.iformall.shiro.PasswordHelper; | |||
| @@ -56,11 +57,12 @@ public class WxMiniappThemeController extends BaseController { | |||
| 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); | |||
| if(wxMiniappTheme.getType() == null){ | |||
| wxMiniappTheme.setType(EnumThemeType.C.getCode()); | |||
| } | |||
| PageInfo<WxMiniappTheme> page = wxMiniappThemeService.listAsPage(wxMiniappTheme, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| @@ -69,17 +71,22 @@ public class WxMiniappThemeController extends BaseController { | |||
| } | |||
| @ApiOperation("根据id使之生效") | |||
| @GetMapping("/updateEffect") | |||
| @PostMapping("/updateEffect") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "根据id使之生效") | |||
| @TenantIgnore | |||
| public ResultData updateEffect(Long id) { | |||
| public ResultData updateEffect(@RequestBody WxThemeMall wxThemeMall) { | |||
| logger.debug("[" + getIpAddr() + "] WxMiniappThemeController::updateEffect"); | |||
| if(id == null){ | |||
| if(wxThemeMall == null || wxThemeMall.getThemeId() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappThemeService.updateEffect(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| wxThemeMall.setTenantId(getTenantInfo().getTenantId()); | |||
| if(wxThemeMall.getThemeType() == null){ | |||
| wxThemeMall.setThemeType(EnumThemeType.C.getCode()); | |||
| } | |||
| wxMiniappThemeService.updateEffect(wxThemeMall); | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @@ -105,6 +112,9 @@ public class WxMiniappThemeController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| wxMiniappTheme.setTenantId(getTenantInfo().getTenantId()); | |||
| if(wxMiniappTheme.getType() == null){ | |||
| wxMiniappTheme.setType(EnumThemeType.C.getCode()); | |||
| } | |||
| wxMiniappThemeService.saveOrUpdate(wxMiniappTheme); | |||
| return new ResultData(); | |||
| } | |||
| @@ -7,6 +7,8 @@ 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.domain.po.WxThemeMall; | |||
| import com.iformall.enums.EnumThemeType; | |||
| import com.iformall.service.WxMiniappThemeService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -36,22 +38,13 @@ public class WxMiniappThemeController extends BaseController { | |||
| 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); | |||
| WxThemeMall wxThemeMall = new WxThemeMall(); | |||
| wxThemeMall.setTenantId(getTenantInfo().getTenantId()); | |||
| wxThemeMall.setThemeType(EnumThemeType.C.getCode()); | |||
| List<WxMiniappThemeValue> valueList = wxMiniappThemeService.findTheme(wxThemeMall); | |||
| Map<String,WxMiniappThemeValue> map = new HashMap<String,WxMiniappThemeValue>(); | |||
| for (WxMiniappThemeValue v:childList) { | |||
| for (WxMiniappThemeValue v:valueList) { | |||
| map.put(v.getName(),v); | |||
| } | |||
| return new ResultData(map); | |||
| @@ -21,8 +21,8 @@ public class WxMiniappTheme implements Serializable { | |||
| 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="EnumThemeType",name="type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @@ -17,6 +17,9 @@ public class WxMiniappThemeDeploy implements Serializable { | |||
| @io.swagger.annotations.ApiModelProperty(value="说明",name="remarks") | |||
| private String remarks; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumThemeType",name="type") | |||
| private Integer themeType; | |||
| @io.swagger.annotations.ApiModelProperty(value="图标",name="defaultIcon") | |||
| private String defaultIcon; | |||
| @io.swagger.annotations.ApiModelProperty(value="样式",name="defaultStyle") | |||
| @@ -0,0 +1,18 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import lombok.Data; | |||
| import java.io.Serializable; | |||
| @TableName(value = "wx_theme_mall") | |||
| @Data | |||
| public class WxThemeMall implements Serializable { | |||
| private String tenantId; | |||
| private Long themeId; | |||
| private Integer themeType; | |||
| } | |||
| @@ -0,0 +1,39 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumThemeType { | |||
| // 1-B端, 2-C端, 3-服务号, 4-订阅号 | |||
| A(0, "A端"), | |||
| B(1, "B端"), | |||
| C(2, "C端"), | |||
| ; | |||
| public static EnumThemeType getEnum(Integer code) { | |||
| for (EnumThemeType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumThemeType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -4,6 +4,7 @@ import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxMiniappTheme; | |||
| import com.iformall.domain.po.WxMiniappThemeDeploy; | |||
| import com.iformall.domain.po.WxMiniappThemeValue; | |||
| import com.iformall.domain.po.WxThemeMall; | |||
| import java.util.List; | |||
| @@ -16,12 +17,6 @@ public interface WxMiniappThemeMapper extends CommonMapper<WxMiniappTheme, Long> | |||
| List<WxMiniappThemeValue> findChildList(Long id); | |||
| /** | |||
| * 使生效 | |||
| * @param record | |||
| */ | |||
| void updateStatus(WxMiniappTheme record); | |||
| /** | |||
| * 伪删除 | |||
| * @param record | |||
| @@ -32,7 +27,7 @@ public interface WxMiniappThemeMapper extends CommonMapper<WxMiniappTheme, Long> | |||
| * 查配置 | |||
| * @return | |||
| */ | |||
| List<WxMiniappThemeDeploy> findDeployList(); | |||
| List<WxMiniappThemeDeploy> findDeployList(Integer type); | |||
| /** | |||
| * 删value | |||
| @@ -45,4 +40,6 @@ public interface WxMiniappThemeMapper extends CommonMapper<WxMiniappTheme, Long> | |||
| * @param record | |||
| */ | |||
| void insertValue(WxMiniappThemeValue record); | |||
| List<WxMiniappThemeValue> finThemeByThemeMall(WxThemeMall wxThemeMall); | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| 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 com.iformall.domain.po.WxThemeMall; | |||
| import java.util.List; | |||
| /** | |||
| * @author | |||
| */ | |||
| public interface WxThemeMallMapper extends CommonMapper<WxThemeMall, Long> { | |||
| void updateType(WxThemeMall record); | |||
| WxThemeMall findOne(WxThemeMall record); | |||
| } | |||
| @@ -19,7 +19,7 @@ public interface WxMiniappThemeService { | |||
| * @param id | |||
| * @return | |||
| */ | |||
| void updateEffect(Long id); | |||
| void updateEffect(WxThemeMall record); | |||
| /** | |||
| * 伪删除 | |||
| @@ -31,7 +31,7 @@ public interface WxMiniappThemeService { | |||
| * 查配置 | |||
| * @return | |||
| */ | |||
| List<WxMiniappThemeDeploy> findDeployList(); | |||
| List<WxMiniappThemeDeploy> findDeployList(Integer type); | |||
| void saveOrUpdate(WxMiniappTheme record); | |||
| @@ -47,4 +47,5 @@ public interface WxMiniappThemeService { | |||
| */ | |||
| void insertValue(WxMiniappThemeValue record); | |||
| List<WxMiniappThemeValue> findTheme(WxThemeMall wxThemeMall); | |||
| } | |||
| @@ -6,7 +6,9 @@ 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.domain.po.WxThemeMall; | |||
| import com.iformall.mapper.WxMiniappThemeMapper; | |||
| import com.iformall.mapper.WxThemeMallMapper; | |||
| import com.iformall.service.WxMiniappThemeService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -24,6 +26,9 @@ public class WxMiniappThemeServiceImpl implements WxMiniappThemeService { | |||
| @Autowired | |||
| WxMiniappThemeMapper wxMiniappThemeMapper; | |||
| @Autowired | |||
| WxThemeMallMapper wxThemeMallMapper; | |||
| @Override | |||
| public List<WxMiniappTheme> findList(WxMiniappTheme record) { | |||
| return wxMiniappThemeMapper.findList(record); | |||
| @@ -48,9 +53,13 @@ public class WxMiniappThemeServiceImpl implements WxMiniappThemeService { | |||
| } | |||
| @Override | |||
| public void updateEffect(Long id) { | |||
| WxMiniappTheme wxMiniappTheme = wxMiniappThemeMapper.selectById(id); | |||
| wxMiniappThemeMapper.updateStatus(wxMiniappTheme); | |||
| public void updateEffect(WxThemeMall record) { | |||
| WxThemeMall one = wxThemeMallMapper.findOne(record); | |||
| if(one == null){ | |||
| wxThemeMallMapper.insert(record); | |||
| }else{ | |||
| wxThemeMallMapper.updateType(record); | |||
| } | |||
| } | |||
| @Override | |||
| @@ -61,8 +70,8 @@ public class WxMiniappThemeServiceImpl implements WxMiniappThemeService { | |||
| } | |||
| @Override | |||
| public List<WxMiniappThemeDeploy> findDeployList() { | |||
| return wxMiniappThemeMapper.findDeployList(); | |||
| public List<WxMiniappThemeDeploy> findDeployList(Integer type) { | |||
| return wxMiniappThemeMapper.findDeployList(type); | |||
| } | |||
| @Override | |||
| @@ -101,4 +110,9 @@ public class WxMiniappThemeServiceImpl implements WxMiniappThemeService { | |||
| wxMiniappThemeMapper.insertValue(record); | |||
| } | |||
| @Override | |||
| public List<WxMiniappThemeValue> findTheme(WxThemeMall wxThemeMall) { | |||
| return wxMiniappThemeMapper.finThemeByThemeMall(wxThemeMall); | |||
| } | |||
| } | |||
| @@ -8,7 +8,7 @@ | |||
| <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="type" property="type" /> | |||
| <result column="create_date" property="createDate" /> | |||
| <result column="update_date" property="updateDate" /> | |||
| @@ -23,11 +23,11 @@ | |||
| where del_status = 0 | |||
| <if test=" null != id "> and `id` = #{id} </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| and (`tenant_id` = 0 or`tenant_id` = #{tenantId}) | |||
| </if> | |||
| <if test=" null != name and '' != name "> and `name` like concat('%', #{name},'%') </if> | |||
| <if test=" null != status"> | |||
| and `status` = #{status} | |||
| <if test=" null != type"> | |||
| and `type` = #{type} | |||
| </if> | |||
| order by create_date asc | |||
| </sql> | |||
| @@ -46,19 +46,14 @@ | |||
| left join wx_miniapp_theme_value mtv on mtv.miniapp_deploy_id = mtd.id and 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 id="findDeployList" parameterType="Integer" resultType="com.iformall.domain.po.WxMiniappThemeDeploy"> | |||
| SELECT id,`name`,remarks,theme_type themeType,default_icon defaultIcon,default_style defaultStyle | |||
| FROM wx_miniapp_theme_deploy where theme_type = #{themeType}; | |||
| </select> | |||
| @@ -72,4 +67,14 @@ | |||
| </insert> | |||
| <select id="finThemeByThemeMall" parameterType="com.iformall.domain.po.WxThemeMall" 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 | |||
| left join wx_theme_mall tm on tm.theme_id = mtv.miniapp_theme_id and tm.theme_type = mtd.theme_type | |||
| where mtd.theme_type = #{themeType} and tm.tenant_id = #{tenantId} | |||
| </select> | |||
| </mapper> | |||
| @@ -0,0 +1,19 @@ | |||
| <?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.WxThemeMallMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxThemeMall"> | |||
| <result column="tenant_id" property="tenantId" /> | |||
| <result column="theme_id" jdbcType="BIGINT" property="themeId" /> | |||
| <result column="theme_type" jdbcType="INTEGER" property="themeType" /> | |||
| </resultMap> | |||
| <update id="updateType" parameterType="com.iformall.domain.po.WxThemeMall"> | |||
| update wx_theme_mall set theme_id = #{themeId} where tenant_id = #{tenantId} and theme_type = #{themeType}; | |||
| </update> | |||
| <select id="findOne" parameterType="com.iformall.domain.po.WxThemeMall" resultMap="BaseResultMap"> | |||
| select tenant_id,theme_id,theme_type from wx_theme_mall where tenant_id = #{tenantId} and theme_type = #{themeType}; | |||
| </select> | |||
| </mapper> | |||