浏览代码

微信开发

chenyongxing 8 年之前
父节点
当前提交
8cdce0d208

+ 3 - 2
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/BaseContants.java

@ -112,10 +112,11 @@ public class BaseContants {
        public static final String message_fail_wechatCode_is_null="wechatCode is null";
        public static final String message_fail_wxMenuName_is_null="wxMenuName is null";
        public static final String message_fail_code_is_null="wechatCode is null";
        public static final String message_fail_wechatcode_is_null="wechatCode is null";
        public static final String message_fail_code_is_null="code is null";
        public static final String message_fail_name_is_null="weChatMenuName is null";
        public static final String message_fail_id_is_null="id is null";
        public static final String message_fail_id_no_exist="id is null";
        public static final String message_fail_code_no_exist="id is null";
        public static final String message_success_update="wxMenu update success";
        public static final String message_success_delete="wxMenu delete success";

+ 5 - 1
common/common-swagger/src/main/java/com/yihu/jw/config/SwaggerConfig.java

@ -30,7 +30,11 @@ public class SwaggerConfig {
                .select()
                .paths(or(
                        regex("/patient/.*")
                     //   , regex("/"+ BaseContants.Function.api_common+"/.*")
                        , regex("/"+ BaseContants.Function.api_common+"/.*")
                        ,regex("/"+BaseContants.Wechat.api_common+"/.*")
                        ,regex("/"+BaseContants.WxAccessToken.api_common+"/.*")
                        ,regex("/"+BaseContants.WxMenu.api_common+"/.*")
                        ,regex("/"+BaseContants.WxTemplate.api_common+"/.*")
                        ))
                .build()
                .apiInfo(publicApiInfo());

+ 3 - 2
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WechatController.java

@ -50,7 +50,7 @@ public class WechatController extends EnvelopRestController {
    }
    @DeleteMapping(value = BaseContants.Wechat.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @DeleteMapping(value = BaseContants.Wechat.api_delete)
    @ApiOperation(value = "删除微信", notes = "删除微信")
    public Envelop deleteWechat(
            @ApiParam(name = "code", value = "code")
@ -63,7 +63,7 @@ public class WechatController extends EnvelopRestController {
        }
    }
    @GetMapping(value = BaseContants.Wechat.api_getByCode, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping(value = BaseContants.Wechat.api_getByCode)
    @ApiOperation(value = "根据code查找微信", notes = "根据code查找微信")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")
@ -75,4 +75,5 @@ public class WechatController extends EnvelopRestController {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
    }
}

+ 8 - 8
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxMenuController.java

@ -51,13 +51,13 @@ public class WxMenuController extends EnvelopRestController {
    }
    @DeleteMapping(value = BaseContants.WxMenu.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @DeleteMapping(value = BaseContants.WxMenu.api_delete)
    @ApiOperation(value = "删除微信菜单", notes = "删除微信菜单")
    public Envelop deleteWxMenu(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) Integer id) {
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code) {
        try {
            wxMenuService.deleteWxMenu(id);
            wxMenuService.deleteWxMenu(code);
            return Envelop.getSuccess(BaseContants.WxMenu.message_success_delete );
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
@ -65,13 +65,13 @@ public class WxMenuController extends EnvelopRestController {
    }
    @GetMapping(value = BaseContants.WxMenu.api_getById, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "根据id查找微信菜单", notes = "根据id查找微信菜单")
    @ApiOperation(value = "根据code查找微信菜单", notes = "根据code查找微信菜单")
    public Envelop findById(
            @ApiParam(name = "id", value = "id")
            @RequestParam(value = "id", required = true) Integer id
            @ApiParam(name = "code", value = "code")
            @RequestParam(value = "code", required = true) String code
    ) {
        try {
            return Envelop.getSuccess(BaseContants.WxMenu.message_success_find, wxMenuService.findById(id));
            return Envelop.getSuccess(BaseContants.WxMenu.message_success_find, wxMenuService.findByCode(code));
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxTemplateController.java

@ -50,7 +50,7 @@ public class WxTemplateController extends EnvelopRestController {
    }
    @DeleteMapping(value = BaseContants.WxTemplate.api_delete, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @DeleteMapping(value = BaseContants.WxTemplate.api_delete)
    @ApiOperation(value = "删除微信模版", notes = "删除微信模版")
    public Envelop deleteWxTemplate(
            @ApiParam(name = "code", value = "code")
@ -63,7 +63,7 @@ public class WxTemplateController extends EnvelopRestController {
        }
    }
    @GetMapping(value = BaseContants.WxTemplate.api_getByCode, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping(value = BaseContants.WxTemplate.api_getByCode)
    @ApiOperation(value = "根据code查找微信模版", notes = "根据code查找微信模版")
    public Envelop findByCode(
            @ApiParam(name = "code", value = "code")

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxMenuDao.java

@ -10,6 +10,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface WxMenuDao  extends PagingAndSortingRepository<WxMenu, Long>, JpaSpecificationExecutor<WxMenu> {
    @Query("from WxMenu m where m.id = ?1")
    WxMenu findById(Integer id);
    @Query("from WxMenu m where m.code = ?1 and m.")
    WxMenu findByCode(String code);
}

+ 37 - 49
svr/svr-base/src/main/java/com/yihu/jw/wx/model/WxWechat.java

@ -1,7 +1,7 @@
package com.yihu.jw.wx.model;// default package
import java.util.Date;
import javax.persistence.*;
import java.util.Date;
/**
 * WxWechat entity. @author MyEclipse Persistence Tools
@ -24,30 +24,41 @@ public class WxWechat implements java.io.Serializable {
	private String createUser;//'创建人'
	private String createUserName;//'创建人名'
	private Date createTime;//'创建时间'
	private String updateUser;//'修改人
	private String updateUserName;//'修改人名'
	private Date updateTime;//'修改时间'
	private String modifyUser;//'修改人
	private String modifyUserName;//'修改人名'{\"id\":\"1\",\"code\":\"1\",\"saas_id\":\"1\",\"weichat_id\":\"1\",\"name\":\"hehe\",\"status\":\"0\",\"app_id\":\"1\",\"app_secret\":\"1\"}
	private Date modifyTime;//'修改时间'
	private String remark;//'备注'
	// Constructors
	/** default constructor */
	public WxWechat() {
	@Column(name = "modify_user", length = 200)
	public String getModifyUser() {
		return modifyUser;
	}
	/** minimal constructor */
	public WxWechat(Integer id, Date createTime, Date updateTime) {
		this.id = id;
		this.createTime = createTime;
		this.updateTime = updateTime;
	public void setModifyUser(String modifyUser) {
		this.modifyUser = modifyUser;
	}
	@Column(name = "modify_user_name", length = 200)
	public String getModifyUserName() {
		return modifyUserName;
	}
	/** full constructor */
	public WxWechat(Integer id, String code, String saasId, String weichatId,
			String name, String status, String type, String appId,
			String appSecret, String baseUrl, String createUser,
			String createUserName, Date createTime, String updateUser,
			String updateUserName, Date updateTime, String remark) {
	public void setModifyUserName(String modifyUserName) {
		this.modifyUserName = modifyUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "modify_time", nullable = false, length = 0)
	public Date getModifyTime() {
		return modifyTime;
	}
	public void setModifyTime(Date modifyTime) {
		this.modifyTime = modifyTime;
	}
	public WxWechat(Integer id, String code, String saasId, String weichatId, String name, String status, String type, String appId, String appSecret, String baseUrl, String createUser, String createUserName, Date createTime, String modifyUser, String modifyUserName, Date modifyTime, String remark) {
		this.id = id;
		this.code = code;
		this.saasId = saasId;
@ -61,11 +72,16 @@ public class WxWechat implements java.io.Serializable {
		this.createUser = createUser;
		this.createUserName = createUserName;
		this.createTime = createTime;
		this.updateUser = updateUser;
		this.updateUserName = updateUserName;
		this.updateTime = updateTime;
		this.modifyUser = modifyUser;
		this.modifyUserName = modifyUserName;
		this.modifyTime = modifyTime;
		this.remark = remark;
	}
	// Constructors
	/** default constructor */
	public WxWechat() {
	}
	// Property accessors
	@Id
@ -187,34 +203,6 @@ public class WxWechat implements java.io.Serializable {
		this.createTime = createTime;
	}
	@Column(name = "update_user", length = 200)
	public String getUpdateUser() {
		return this.updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	@Column(name = "update_user_name", length = 200)
	public String getUpdateUserName() {
		return this.updateUserName;
	}
	public void setUpdateUserName(String updateUserName) {
		this.updateUserName = updateUserName;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", nullable = false, length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return this.remark;

+ 5 - 5
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxMenuService.java

@ -46,16 +46,16 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
    }
    @Transient
    public void deleteWxMenu(Integer id) {
        WxMenu wxMenu = wxMenuDao.findById(id);
    public void deleteWxMenu(String code) {
        WxMenu wxMenu = wxMenuDao.findByCode(code);
        if (wxMenu == null) {
            throw new ApiException(BaseContants.WxMenu.message_fail_id_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(BaseContants.WxMenu.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        wxMenu.setStatus(-1);
        wxMenuDao.save(wxMenu);
    }
    public Object findById(Integer id) {
        return wxMenuDao.findById(id);
    public WxMenu findByCode(String code) {
        return wxMenuDao.findByCode(code);
    }
}