Просмотр исходного кода

customize

release_toaliyun_real
xhxu 4 лет назад
Родитель
Сommit
b96dff5680
7 измененных файлов: 456 добавлений и 0 удалений
  1. +127
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/basic/WxCustomizeModuleController.java
  2. +50
    -0
      mallinkCApi/src/main/java/com/iformall/controller/WxCustomizeModuleController.java
  3. +45
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCustomizeModule.java
  4. +22
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCustomizeModuleMapper.java
  5. +29
    -0
      mallinkService/src/main/java/com/iformall/service/WxCustomizeModuleService.java
  6. +112
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCustomizeModuleServiceImpl.java
  7. +71
    -0
      mallinkService/src/main/resources/mapper/WxCustomizeModuleMapper.xml

+ 127
- 0
mallinkAdmin/src/main/java/com/iformall/controller/basic/WxCustomizeModuleController.java Просмотреть файл

@@ -0,0 +1,127 @@
package com.iformall.controller.basic;

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxCustomizeModule;
import com.iformall.enums.EnumThemeType;
import com.iformall.service.WxCustomizeModuleService;
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 = "CustomizeModule相关接口")
@RequestMapping("wxCustomizeModule")
public class WxCustomizeModuleController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxCustomizeModuleService wxCustomizeModuleService;

@ApiOperation("查询CustomizeModule列表")
@GetMapping(value = "/list")
@SystemControllerLog(description = "查询CustomizeModule列表")
public ResultData getList(@ModelAttribute WxCustomizeModule wxCustomizeModule, Integer pageNum, Integer pageSize) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getList");
try {
if(wxCustomizeModule == null){
wxCustomizeModule = new WxCustomizeModule();
}
wxCustomizeModule.updateTenantInfo(ifParentUpdateAloneTenantInfo());
if(wxCustomizeModule.getThemeType() == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
PageInfo<WxCustomizeModule> page = wxCustomizeModuleService.listAsPage(wxCustomizeModule, pageNum, pageSize);
return new ResultData(page);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

@ApiOperation("恢复主题默认")
@PostMapping("/updateDefault")
@ApiImplicitParam(name = "themeId", value = "themeId", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "恢复主题默认")
public ResultData updateDefault(@RequestBody WxCustomizeModule wxCustomizeModule) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::updateDefault");
if(wxCustomizeModule == null){
wxCustomizeModule = new WxCustomizeModule();
}
wxCustomizeModule.updateTenantInfo(ifParentUpdateAloneTenantInfo());
if(wxCustomizeModule.getThemeType() == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
return wxCustomizeModuleService.updateDefault(wxCustomizeModule);
}

@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() + "] WxCustomizeModuleController::delete");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCustomizeModule wxCustomizeModule = new WxCustomizeModule();
wxCustomizeModule.updateTenantInfo(ifParentUpdateAloneTenantInfo());
wxCustomizeModule.setId(id);
wxCustomizeModuleService.updateDel(wxCustomizeModule);
return new ResultData(Result.SUCCESS, "删除成功", null);
}

@GetMapping("/isNew")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "-置顶")
public ResultData isNew(Long id) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::delete");
if(id == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCustomizeModule wxCustomizeModule = new WxCustomizeModule();
wxCustomizeModule.updateTenantInfo(ifParentUpdateAloneTenantInfo());
wxCustomizeModule.setId(id);
wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule);
return new ResultData(Result.SUCCESS, "置顶成功", null);
}

@PostMapping("add")
@SystemControllerLog(description = "-添加")
public ResultData add(@RequestBody WxCustomizeModule wxCustomizeModule) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::add");
if(wxCustomizeModule == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
wxCustomizeModule.updateTenantInfo(ifParentUpdateAloneTenantInfo());
if(wxCustomizeModule.getThemeType() == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule);
return new ResultData();
}

@PostMapping("update")
@SystemControllerLog(description = "更新")
public ResultData update(@RequestBody WxCustomizeModule wxCustomizeModule) {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::update");
if(wxCustomizeModule == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
wxCustomizeModule.updateTenantInfo(ifParentUpdateAloneTenantInfo());
wxCustomizeModuleService.saveOrUpdate(wxCustomizeModule);
return new ResultData();
}

}

+ 50
- 0
mallinkCApi/src/main/java/com/iformall/controller/WxCustomizeModuleController.java Просмотреть файл

@@ -0,0 +1,50 @@
package com.iformall.controller;

import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCustomizeModule;
import com.iformall.enums.EnumThemeType;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.service.WxCustomizeModuleService;
import io.swagger.annotations.Api;
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 = "CustomizeModule相关接口")
@RequestMapping("/api/wxCustomizeModule")
public class WxCustomizeModuleController extends BaseController {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxCustomizeModuleService wxCustomizeModuleService;

@ApiOperation("查询CustomizeModule列表")
@GetMapping(value = "/list")
public ResultData getList() {
logger.debug("[" + getIpAddr() + "] WxCustomizeModuleController::getList");
try {
WxCustomizeModule wxCustomizeModule = new WxCustomizeModule();
wxCustomizeModule.updateTenantInfo(getTenantInfo());
if(wxCustomizeModule.getThemeType() == null){
wxCustomizeModule.setThemeType(EnumThemeType.C.getCode());
}
wxCustomizeModule.setIsUsing(EnumYesOrNo.YES.getCode());
List<WxCustomizeModule> list = wxCustomizeModuleService.findList(wxCustomizeModule);
if(list == null || list.size() < 4 || list.size() > 8){
list = wxCustomizeModuleService.findDefault(wxCustomizeModule);
}
return new ResultData(list);
}catch (Exception e){
logger.error(e.getMessage(),e);
return new ResultData(ErrorCode.SYS_SERVER_ERROR);
}
}

}

+ 45
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxCustomizeModule.java Просмотреть файл

@@ -0,0 +1,45 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.TenantEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

@TableName(value = "wx_customize_module")
@Data
@EqualsAndHashCode(callSuper = true)
public class WxCustomizeModule extends TenantEntity {
protected Long id;

@io.swagger.annotations.ApiModelProperty(value="主题",name="themeId")
private Long themeId;
@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="EnumThemeType",name="themeType")
private Integer themeType;
@io.swagger.annotations.ApiModelProperty(value="icon",name="icon")
private String icon;
@io.swagger.annotations.ApiModelProperty(value="style",name="style")
private String style;
@io.swagger.annotations.ApiModelProperty(value="链接类型",name="linkType")
private Integer linkType;
@io.swagger.annotations.ApiModelProperty(value="链接地址",name="linkUrl")
private String linkUrl;
@io.swagger.annotations.ApiModelProperty(value="链接外部小程序ID",name="outLinkAppid")
private String outLinkAppid;
@io.swagger.annotations.ApiModelProperty(value="排序",name="sort")
private Integer sort;
@io.swagger.annotations.ApiModelProperty(value="是否使用",name="isUsing")
private Integer isUsing;

@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
private Date updateDate;

}

+ 22
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCustomizeModuleMapper.java Просмотреть файл

@@ -0,0 +1,22 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.WxCustomizeModule;

import java.util.List;

/**
* @author
*/
public interface WxCustomizeModuleMapper extends CommonMapper<WxCustomizeModule, Long> {

List<WxCustomizeModule> findList(WxCustomizeModule record);

/**
* 伪删除
* @param record
*/
int updateDel(WxCustomizeModule record);

int updateDelByTenantId(WxCustomizeModule record);
}

+ 29
- 0
mallinkService/src/main/java/com/iformall/service/WxCustomizeModuleService.java Просмотреть файл

@@ -0,0 +1,29 @@
package com.iformall.service;

import com.github.pagehelper.PageInfo;
import com.iformall.common.ResultData;
import com.iformall.domain.po.*;

import java.util.List;


public interface WxCustomizeModuleService {

List<WxCustomizeModule> findList(WxCustomizeModule record);

PageInfo<WxCustomizeModule> listAsPage(WxCustomizeModule record, Integer pageIndex, Integer pageSize);

WxCustomizeModule getById(WxCustomizeModule record);

int saveOrUpdate(WxCustomizeModule record);

/**
* 伪删除
* @param record
*/
int updateDel(WxCustomizeModule record);

List<WxCustomizeModule> findDefault(WxCustomizeModule record);

ResultData updateDefault(WxCustomizeModule record);
}

+ 112
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxCustomizeModuleServiceImpl.java Просмотреть файл

@@ -0,0 +1,112 @@
package com.iformall.service.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.*;
import com.iformall.enums.EnumYesOrNo;
import com.iformall.mapper.WxCustomizeModuleMapper;
import com.iformall.service.WxCustomizeModuleService;
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 org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class WxCustomizeModuleServiceImpl implements WxCustomizeModuleService {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
WxCustomizeModuleMapper wxCustomizeModuleMapper;

@Autowired
WxMiniappThemeService wxMiniappThemeService;

@Override
public List<WxCustomizeModule> findList(WxCustomizeModule record) {
return wxCustomizeModuleMapper.findList(record);
}

@Override
public PageInfo<WxCustomizeModule> listAsPage(WxCustomizeModule record, Integer pageIndex, Integer pageSize) {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCustomizeModuleMapper.findList(record));
}

@Override
public WxCustomizeModule getById(WxCustomizeModule record) {
WxCustomizeModule wxCustomizeModule = wxCustomizeModuleMapper.selectById(record.getId());
return wxCustomizeModule;
}


@Override
public int updateDel(WxCustomizeModule record) {
return wxCustomizeModuleMapper.updateDel(record);
}

@Override
public List<WxCustomizeModule> findDefault(WxCustomizeModule record) {
//获取主题
WxThemeMall wxThemeMall = new WxThemeMall();
wxThemeMall.setTenantId(record.getTenantId());
wxThemeMall.setThemeType(record.getThemeType());
WxThemeMall themeMall = wxMiniappThemeService.findThemeMall(wxThemeMall);
Long themeId = 0l;
if(themeMall != null){
themeId = themeMall.getThemeId();
}else{
WxMiniappTheme wxMiniappTheme = new WxMiniappTheme();
wxMiniappTheme.setTenantId(record.getTenantId());
wxMiniappTheme.setType(record.getThemeType());
PageInfo<WxMiniappTheme> page = wxMiniappThemeService.listAsPage(wxMiniappTheme, 1, 1);
themeId = page.getList().get(0).getId();
}
//获取默认
WxCustomizeModule modelQ = new WxCustomizeModule();
modelQ.setTenantId("0");
modelQ.setThemeId(themeId);
modelQ.setThemeType(record.getThemeType());
modelQ.setIsUsing(EnumYesOrNo.YES.getCode());
return wxCustomizeModuleMapper.findList(modelQ);
}

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public ResultData updateDefault(WxCustomizeModule record) {
List<WxCustomizeModule> aDefault = this.findDefault(record);
//删除旧数据
wxCustomizeModuleMapper.updateDelByTenantId(record);
//创建新数据
for (WxCustomizeModule module:aDefault) {
module.setId(null);
module.updateTenantInfo(record);
module.setThemeId(null);
this.saveOrUpdate(module);
}
return new ResultData();
}

@Override
public int saveOrUpdate(WxCustomizeModule record) {
final IdWorker idWorker = IdWorker.get();
Date curr = new Date();
if (record.getId() == null) {
record.setId(idWorker.nextId());
record.setCreateDate(curr);
record.setUpdateDate(curr);
return wxCustomizeModuleMapper.insert(record);
} else {
record.setUpdateDate(curr);
return wxCustomizeModuleMapper.updateById(record);
}
}

}

+ 71
- 0
mallinkService/src/main/resources/mapper/WxCustomizeModuleMapper.xml Просмотреть файл

@@ -0,0 +1,71 @@
<?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.WxCustomizeModuleMapper">

<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCustomizeModule">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
<result column="theme_id" jdbcType="VARCHAR" property="themeId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="remarks" jdbcType="VARCHAR" property="remarks" />
<result column="theme_type" jdbcType="INTEGER" property="themeType"/>
<result column="icon" jdbcType="VARCHAR" property="icon" />
<result column="style" jdbcType="VARCHAR" property="style" />
<result column="link_type" jdbcType="INTEGER" property="linkType"/>
<result column="link_url" jdbcType="VARCHAR" property="linkUrl" />
<result column="out_link_appid" jdbcType="VARCHAR" property="outLinkAppid" />
<result column="sort" jdbcType="INTEGER" property="sort"/>
<result column="is_using" jdbcType="INTEGER" property="isUsing"/>
<result column="create_date" property="createDate" />
<result column="update_date" property="updateDate" />

</resultMap>

<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`theme_id`,`name`,`remarks`,`theme_type`,`icon`,`style`,`link_type`,`link_url`,`out_link_appid`,
`sort`,`is_using`,
`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 != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>
<if test=" null != themeId">
and `theme_id` = #{themeId}
</if>
<if test=" null != name and '' != name "> and `name` like concat('%', #{name},'%') </if>
<if test=" null != themeType">
and `theme_type` = #{themeType}
</if>
<if test=" null != linkType">
and `link_type` = #{linkType}
</if>
<if test=" null != isUsing">
and `is_using` = #{isUsing}
</if>
order by `is_using` desc, `sort` asc, `update_date` desc
</sql>

<select id="findList" parameterType="com.iformall.domain.po.WxCustomizeModule" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from wx_customize_module
<include refid="dynamicWhereConditions"/>
</select>

<update id="updateDel" parameterType="com.iformall.domain.po.WxCustomizeModule">
update wx_customize_module set `del_status` = 1, update_date = now() where id = #{id};
</update>

<update id="updateDelByTenantId" parameterType="com.iformall.domain.po.WxCustomizeModule">
update wx_customize_module set `del_status` = 1, update_date = now() where tenant_id = #{tenantId};
</update>

</mapper>

Загрузка…
Отмена
Сохранить